1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Utility class used to provide length-scale estimates at various
30 mesh locations. These estimates are based on specified boundary
31 conditions provided through dictionary entries.
35 University of Massachusetts Amherst
39 lengthScaleEstimator.C
40 lengthScaleEstimatorI.H
42 \*---------------------------------------------------------------------------*/
44 #ifndef lengthScaleEstimator_H
45 #define lengthScaleEstimator_H
48 #include "dictionary.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 /*---------------------------------------------------------------------------*\
56 Class lengthScaleEstimator Declaration
57 \*---------------------------------------------------------------------------*/
59 class lengthScaleEstimator
63 //- Const reference to polyMesh
64 const polyMesh& mesh_;
66 //- Edge bisection/collapse criteria
70 scalar minLengthScale_;
71 scalar maxLengthScale_;
72 scalar curvatureDeviation_;
74 //- Specific to proximity-based refinement
76 boundBox proxBoundBox_;
77 labelListList proximityBins_;
79 //- Specific to mesh-slicing operations
80 scalar sliceThreshold_;
82 List<boundBox> sliceBoxes_;
84 // Buffers for parallel length-scale calculations
85 labelListList sendLblBuffer_;
86 labelListList recvLblBuffer_;
87 labelListList sendLvlBuffer_;
88 labelListList recvLvlBuffer_;
89 scalarListList sendSclBuffer_;
90 scalarListList recvSclBuffer_;
92 //- Sub-dictionary which specifies
93 // fixed length-scales for patches
94 dictionary fixedPatches_;
96 //- Sub-dictionary which specifies
97 // floating length-scales for patches
98 dictionary freePatches_;
100 //- Sub-dictionary which specifies
101 // patches with curvature-based length-scale
102 dictionary curvaturePatches_;
104 //- Sub-dictionary which specifies
105 // patches with proximity-based length-scale
106 dictionary proximityPatches_;
108 //- Patches for which edge-refinements
110 labelList noModPatchIDs_;
112 //- Field-based refinement
115 scalar lowerRefineLevel_;
116 scalar upperRefineLevel_;
118 //- Specify limits for refinement criteria
120 label maxRefineLevel_;
122 // Private Member Functions
124 // Check for legitimacy of patches
125 void checkPatches(const wordList& patchList) const;
127 // Prepare for proximity-based refinement, if necessary
128 void prepareProximityPatches();
130 // Perform spatial hashing on a set of points
131 static void spatialHash
133 const pointField& pointLocations,
134 const labelList& pointIndices,
136 const label resolution,
140 // Send length-scale info across processors
141 void writeLengthScaleInfo
143 const labelList& cellLevels,
144 const scalarList& lengthScale
147 // Receive length-scale info across processors
148 void readLengthScaleInfo
152 labelList& cellLevels,
153 UList<scalar>& lengthScale,
154 labelHashSet& levelCells
159 // Declare the name of the class and its debug switch
160 TypeName("lengthScaleEstimator");
164 //- Construct from polyMesh and dictionary
165 explicit lengthScaleEstimator
172 virtual ~lengthScaleEstimator();
176 //- Read edge refinement options from the dictionary
177 void readRefinementOptions
179 const dictionary& refineDict,
181 bool mandatory = false
184 //- Set explicitly coupled patch information
185 void setCoupledPatches
187 const dictionary& coupledPatches
190 //- Calculate the length scale field
191 void calculateLengthScale(UList<scalar>& lengthScale);
193 //- Return refinement criteria
194 inline scalar ratioMin() const;
195 inline scalar ratioMax() const;
196 inline scalar growthFactor() const;
198 //- Limit length scale for surface-edges
199 inline void limitScale(scalar& scale) const;
201 //- Check if a particular patch is free-floating
202 // (i.e., gets its length-scale from the interior)
203 inline bool isFreePatch(const label pIndex) const;
205 //- Check if a particular patch is flagged
206 // for proximity-based refinement
207 inline bool isProximityPatch(const label pIndex) const;
209 //- Check if a particular patch is flagged
210 // for curvature-based refinement
211 inline bool isCurvaturePatch(const label pIndex) const;
213 //- Return reference curvature deviation
214 inline scalar curvatureDeviation() const
216 return curvatureDeviation_;
219 //- Check whether a particular point is too close
220 // to a previous mesh slice location
221 inline bool checkOldSlices(const vector& gCentre) const;
223 //- Add a boundBox to the existing set of sliceBoxes
224 inline void appendBox(const boundBox& bBox);
226 //- Clear the list of sliceBoxes
227 inline void clearBoxes();
229 //- Set an initial hold-off value
230 inline void setHoldOff(const label hVal)
232 sliceHoldOff_ = hVal;
235 //- Return the current holdOff value
236 inline label holdOff() const
238 return sliceHoldOff_;
241 //- Decrement the current holdOff value
242 inline void decrementHoldOff()
247 //- Check whether a particular patch permits refinement
248 inline bool checkRefinementPatch
253 //- Return the appropriate length-scale for boundary face
254 inline scalar fixedLengthScale
258 bool usePolyMesh = false
261 //- Test for proximity to patch faces
262 inline bool testProximity
264 const vector& gCentre,
265 const vector& gNormal,
266 const scalar testStep,
272 } // End namespace Foam
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 #include "lengthScaleEstimatorI.H"
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //