FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

refinementParameters.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "refinementParameters.H"
00027 #include <OpenFOAM/mathematicalConstants.H>
00028 #include <OpenFOAM/polyMesh.H>
00029 #include <OpenFOAM/globalIndex.H>
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 // Construct from dictionary
00034 Foam::refinementParameters::refinementParameters
00035 (
00036     const dictionary& dict,
00037     const label dummy
00038 )
00039 :
00040     maxGlobalCells_(readLabel(dict.lookup("cellLimit"))),
00041     maxLocalCells_(readLabel(dict.lookup("procCellLimit"))),
00042     minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
00043     curvature_(readScalar(dict.lookup("curvature"))),
00044     nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
00045     keepPoints_(dict.lookup("keepPoints")),
00046     allowFreeStandingZoneFaces_
00047     (
00048         dict.lookupOrDefault<Switch>
00049         (
00050             "allowFreeStandingZoneFaces",
00051             true
00052         )
00053     ),
00054     maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
00055 {}
00056 
00057 
00058 Foam::refinementParameters::refinementParameters(const dictionary& dict)
00059 :
00060     maxGlobalCells_(readLabel(dict.lookup("maxGlobalCells"))),
00061     maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
00062     minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
00063     nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
00064     keepPoints_(pointField(1, dict.lookup("locationInMesh"))),
00065     allowFreeStandingZoneFaces_
00066     (
00067         dict.lookupOrDefault<Switch>
00068         (
00069             "allowFreeStandingZoneFaces",
00070             true
00071         )
00072     ),
00073     maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
00074 {
00075     scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
00076 
00077     if (featAngle < 0 || featAngle > 180)
00078     {
00079         curvature_ = -GREAT;
00080     }
00081     else
00082     {
00083         curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0);
00084     }
00085 }
00086 
00087 
00088 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00089 
00090 Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
00091  const
00092 {
00093     // Global calculation engine
00094     globalIndex globalCells(mesh.nCells());
00095 
00096     // Cell label per point
00097     labelList cellLabels(keepPoints_.size());
00098 
00099     forAll(keepPoints_, i)
00100     {
00101         const point& keepPoint = keepPoints_[i];
00102 
00103         label localCellI = mesh.findCell(keepPoint);
00104 
00105         label globalCellI = -1;
00106 
00107         if (localCellI != -1)
00108         {
00109             Pout<< "Found point " << keepPoint << " in cell " << localCellI
00110                 << " on processor " << Pstream::myProcNo() << endl;
00111             globalCellI = globalCells.toGlobal(localCellI);
00112         }
00113 
00114         reduce(globalCellI, maxOp<label>());
00115 
00116         if (globalCellI == -1)
00117         {
00118             FatalErrorIn
00119             (
00120                 "refinementParameters::findCells(const polyMesh&) const"
00121             )   << "Point " << keepPoint
00122                 << " is not inside the mesh or on a face or edge." << nl
00123                 << "Bounding box of the mesh:" << mesh.bounds()
00124                 << exit(FatalError);
00125         }
00126 
00127         if (globalCells.isLocal(globalCellI))
00128         {
00129             cellLabels[i] = localCellI;
00130         }
00131         else
00132         {
00133             cellLabels[i] = -1;
00134         }
00135     }
00136     return cellLabels;
00137 }
00138 
00139 
00140 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines