OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "refinementParameters.H"
00028 #include "mathematicalConstants.H"
00029 #include "polyMesh.H"
00030 #include "globalIndex.H"
00031 
00032 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00033 
00034 // Construct from dictionary
00035 Foam::refinementParameters::refinementParameters
00036 (
00037     const dictionary& dict,
00038     const label dummy
00039 )
00040 :
00041     maxGlobalCells_(readLabel(dict.lookup("cellLimit"))),
00042     maxLocalCells_(readLabel(dict.lookup("procCellLimit"))),
00043     minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
00044     curvature_(readScalar(dict.lookup("curvature"))),
00045     nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
00046     keepPoints_(dict.lookup("keepPoints"))
00047 {}
00048 
00049 
00050 Foam::refinementParameters::refinementParameters(const dictionary& dict)
00051 :
00052     maxGlobalCells_(readLabel(dict.lookup("maxGlobalCells"))),
00053     maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
00054     minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
00055     nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
00056     keepPoints_(pointField(1, dict.lookup("locationInMesh")))
00057 {
00058     scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
00059 
00060     if (featAngle < 0 || featAngle > 180)
00061     {
00062         curvature_ = -GREAT;
00063     }
00064     else
00065     {
00066         curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0);
00067     }
00068 }
00069 
00070 
00071 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00072 
00073 Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
00074  const
00075 {
00076     // Global calculation engine
00077     globalIndex globalCells(mesh.nCells());
00078 
00079     // Cell label per point
00080     labelList cellLabels(keepPoints_.size());
00081 
00082     forAll(keepPoints_, i)
00083     {
00084         const point& keepPoint = keepPoints_[i];
00085 
00086         label localCellI = mesh.findCell(keepPoint);
00087 
00088         label globalCellI = -1;
00089 
00090         if (localCellI != -1)
00091         {
00092             Pout<< "Found point " << keepPoint << " in cell " << localCellI
00093                 << " on processor " << Pstream::myProcNo() << endl;
00094             globalCellI = globalCells.toGlobal(localCellI);
00095         }
00096 
00097         reduce(globalCellI, maxOp<label>());
00098 
00099         if (globalCellI == -1)
00100         {
00101             FatalErrorIn
00102             (
00103                 "refinementParameters::findCells(const polyMesh&) const"
00104             )   << "Point " << keepPoint
00105                 << " is not inside the mesh or on a face or edge." << nl
00106                 << "Bounding box of the mesh:" << mesh.bounds()
00107                 << exit(FatalError);
00108         }
00109 
00110         if (globalCells.isLocal(globalCellI))
00111         {
00112             cellLabels[i] = localCellI;
00113         }
00114         else
00115         {
00116             cellLabels[i] = -1;
00117         }
00118     }
00119     return cellLabels;
00120 }
00121 
00122 
00123 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd