40 void Foam::blockMeshCylindricalConfiguration::bbInflate
50 bool Foam::blockMeshCylindricalConfiguration::isBoundBoxOnZaxis()
52 const vector bbMidNorm = bb_.midpoint()/bb_.mag();
53 return mag(bbMidNorm.x()) < rootSmall &&
mag(bbMidNorm.y()) < rootSmall;
56 void Foam::blockMeshCylindricalConfiguration::calcBlockMeshDict()
59 label boxCells = nCells_.x();
60 label radialCells = nCells_.y();
67 nCells_ = Vector<label>
71 2.0*radialCells*bb_.span().z()/bb_.span().x()
79 const vector scaling(expansion, expansion, 1);
82 bbInflate(bb_, scaling);
83 bbInflate(rzbb_, scaling);
86 roundBoundingBox(bb_, roundFactor);
87 roundBoundingBox(rzbb_, roundFactor);
89 radBox_ = ceil(0.3*rzbb_.max().x()/roundFactor)*roundFactor;
91 nCells_ *= refineFactor_;
95 void Foam::blockMeshCylindricalConfiguration::writeBackgroundMesh()
97 const scalar radOut = bb_.max().x();
98 const scalar radIn = rzbb_.max().x();
99 const scalar boxToRadOut = radOut - radBox_;
100 const scalar boxToRadIn = radIn - radBox_;
102 const label inCells = ceil(boxToRadIn*nCells_.y()/boxToRadOut);
103 const label outCells = nCells_.y() - inCells;
105 beginDict(os_,
"backgroundMesh");
107 os_ <<
indent <<
"radOut " << radOut <<
";" <<
endl;
108 os_ <<
indent <<
"radIn " << radIn <<
";" <<
endl;
109 os_ <<
indent <<
"radBox " << radBox_ <<
";" <<
nl <<
endl;
110 os_ <<
indent <<
"zMin " << bb_.min().z() <<
";" <<
endl;
111 os_ <<
indent <<
"zMax " << bb_.max().z() <<
";" <<
nl <<
endl;
112 os_ <<
indent <<
"boxCells " << nCells_.x() <<
";" <<
endl;
113 os_ <<
indent <<
"inCells " << inCells <<
";" <<
endl;
114 os_ <<
indent <<
"outCells " << outCells <<
";" <<
endl;
115 os_ <<
indent <<
"zCells " << nCells_.z() <<
";" <<
nl <<
endl;
117 os_ <<
indent <<
"radOutN #neg $radOut;" <<
endl;
118 os_ <<
indent <<
"radInN #neg $radIn;" <<
endl;
119 os_ <<
indent <<
"radBoxN #neg $radBox;" <<
endl;
123 os_ <<
"convertToMeters 1;" <<
nl <<
endl;
127 void Foam::blockMeshCylindricalConfiguration::writeDefaultPatch()
129 Pair<word> defaultPatch;
131 word opt =
"defaultPatch";
132 if (patchOpts_.found(opt))
134 defaultPatch = readPatchOption(opt);
138 defaultPatch = {
"background",
"internal"};
141 beginDict(os_,
"defaultPatch");
143 os_ <<
indent <<
"name " << defaultPatch.first() <<
";" <<
nl
144 <<
indent <<
"type " << defaultPatch.second() <<
";" <<
endl;
148 Info<<
"\nAdding defaultPatch '" << defaultPatch.first()
149 <<
"' of type '" << defaultPatch.second() <<
"'" <<
endl;
153 void Foam::blockMeshCylindricalConfiguration::writePatch
161 <<
" { type " <<
type
162 <<
"; faces ( " << face.c_str()
166 <<
"' of type '" <<
type <<
"'" <<
endl;
170 void Foam::blockMeshCylindricalConfiguration::writeBoundary()
173 bool enableBoundary = clearBoundary_;
181 enableBoundary = patchOpts_.found(
patches[i] +
"Patch");
186 os_ <<
"// delete \"-disabled\" to enable boundary settings" <<
endl;
188 Info<<
"\nNote: The boundary list in blockMeshDict is disabled" <<
nl
189 <<
"To enable, open the file and edit line number "
190 << os_.lineNumber() <<
nl <<
endl;
196 enableBoundary ?
"boundary" :
"boundary-disabled"
201 const bool optFound(patchOpts_.found(
patches[i] +
"Patch"));
205 if (clearBoundary_ && !optFound)
210 Pair<word> patch(
patches[i],
"patch");
214 patch = readPatchOption(patch.first() +
"Patch");
217 beginDict(os_, patch.first());
218 os_ <<
indent <<
"type " << patch.second() <<
";" <<
endl;
219 beginList(os_,
"faces");
239 os_ <<
indent <<
"(12 13 14 15)" <<
nl
253 endDict(os_, i != 1);
260 void Foam::blockMeshCylindricalConfiguration::writeGeometry()
262 beginDict(os_,
"geometry");
264 List<word> geometries {
"rotatingZone",
"outer"};
265 List<word> dims {
"radIn",
"radOut"};
267 const scalar zMin =
roundDown(bb_.min().z(), 10);
268 const scalar zMax =
roundUp(bb_.max().z(), 10);
272 beginDict(os_, geometries[i]);
274 os_ <<
indent <<
"type searchableCylinder;" <<
nl
275 <<
indent <<
"point1 (0 0 " << zMin <<
");" <<
nl
276 <<
indent <<
"point2 (0 0 " << zMax <<
");" <<
nl
277 <<
indent <<
"radius $!backgroundMesh/" << dims[i] <<
";" <<
endl;
286 void Foam::blockMeshCylindricalConfiguration::writeProjectedVertex
295 writeVertex(
x,
y, z);
300 void Foam::blockMeshCylindricalConfiguration::writeVertices()
302 beginList(os_,
"vertices");
308 writeVertex(
"radBoxN",
"radBoxN", dir);
309 writeVertex(
"radBox",
"radBoxN", dir);
310 writeVertex(
"radBox",
"radBox", dir);
311 writeVertex(
"radBoxN",
"radBox", dir);
315 writeProjectedVertex(
"radInN",
"radInN", dir,
"rotatingZone");
316 writeProjectedVertex(
"radIn",
"radInN", dir,
"rotatingZone");
317 writeProjectedVertex(
"radIn",
"radIn", dir,
"rotatingZone");
318 writeProjectedVertex(
"radInN",
"radIn", dir,
"rotatingZone");
320 writeProjectedVertex(
"radOutN",
"radOutN", dir,
"outer");
321 writeProjectedVertex(
"radOut",
"radOutN", dir,
"outer");
322 writeProjectedVertex(
"radOut",
"radOut", dir,
"outer");
323 writeProjectedVertex(
"radOutN",
"radOut", dir,
"outer");
330 void Foam::blockMeshCylindricalConfiguration::writeBlocks()
332 os_ <<
"boxMesh" <<
endl;
333 writeVertex(
"boxCells",
"boxCells",
"zCells");
334 os_ <<
"simpleGrading (1 1 1);" <<
nl <<
endl;
336 os_ <<
"inMesh" <<
endl;
337 writeVertex(
"boxCells",
"inCells",
"zCells");
338 os_ <<
"simpleGrading (1 1 1);" <<
nl <<
endl;
340 os_ <<
"outMesh" <<
endl;
341 writeVertex(
"boxCells",
"outCells",
"zCells");
342 os_ <<
"simpleGrading (1 $!backgroundMesh/outGrading 1);" <<
nl <<
endl;
344 beginList(os_,
"blocks");
346 os_ <<
indent <<
"hex (0 1 2 3 12 13 14 15) $boxMesh" <<
nl <<
nl
347 <<
indent <<
"hex (1 0 4 5 13 12 16 17) $inMesh" <<
nl
348 <<
indent <<
"hex (0 3 7 4 12 15 19 16) $inMesh" <<
nl
349 <<
indent <<
"hex (2 1 5 6 14 13 17 18) $inMesh" <<
nl
350 <<
indent <<
"hex (3 2 6 7 15 14 18 19) $inMesh" <<
nl <<
nl
351 <<
indent <<
"hex (5 4 8 9 17 16 20 21) $outMesh" <<
nl
352 <<
indent <<
"hex (4 7 11 8 16 19 23 20) $outMesh" <<
nl
353 <<
indent <<
"hex (6 5 9 10 18 17 21 22) $outMesh" <<
nl
354 <<
indent <<
"hex (7 6 10 11 19 18 22 23) $outMesh" <<
endl;
360 void Foam::blockMeshCylindricalConfiguration::writeEdges()
362 beginList(os_,
"edges");
364 os_ <<
indent <<
"project 4 5 (rotatingZone)" <<
nl
365 <<
indent <<
"project 5 6 (rotatingZone)" <<
nl
366 <<
indent <<
"project 6 7 (rotatingZone)" <<
nl
367 <<
indent <<
"project 7 4 (rotatingZone)" <<
nl
368 <<
indent <<
"project 16 17 (rotatingZone)" <<
nl
369 <<
indent <<
"project 17 18 (rotatingZone)" <<
nl
370 <<
indent <<
"project 18 19 (rotatingZone)" <<
nl
371 <<
indent <<
"project 19 16 (rotatingZone)" <<
nl <<
nl
372 <<
indent <<
"project 8 9 (outer)" <<
nl
373 <<
indent <<
"project 9 10 (outer)" <<
nl
374 <<
indent <<
"project 10 11 (outer)" <<
nl
375 <<
indent <<
"project 11 8 (outer)" <<
nl
376 <<
indent <<
"project 20 21 (outer)" <<
nl
377 <<
indent <<
"project 21 22 (outer)" <<
nl
378 <<
indent <<
"project 22 23 (outer)" <<
nl
385 void Foam::blockMeshCylindricalConfiguration::writeMergePatchPairs()
387 os_ <<
"mergePatchPairs" <<
nl
397 const fileName&
name,
400 const meshingSurfaceList& surfaces,
401 const Vector<label>& nCells,
402 const label refineFactor,
403 const HashTable<Pair<word>>& patchOpts,
404 const bool clearBoundary
407 blockMeshConfigurationBase(
name, dir, time, surfaces, patchOpts),
408 rzbb_(surfaces.rzbb()),
410 refineFactor_(refineFactor),
411 clearBoundary_(clearBoundary)
413 if (!isBoundBoxOnZaxis())
416 <<
"Attempting to create a cylindrical background mesh"
417 <<
nl <<
"but the geometry bounds are not aligned with the z-axis."
421 if (rzbb_.volume() == 0)
424 <<
"Creating a cylindrical background mesh without a "
425 <<
"rotatingZone specified by the '-rotatingZones' option."
432 rzbb_.min() = factor*bb_.min();
433 rzbb_.max() = factor*bb_.max();
450 dict_.writeHeader(os_, word(
"dictionary"));
452 writeBackgroundMesh();
459 writeMergePatchPairs();
461 dict_.writeEndDivider(os_);
#define forAll(list, i)
Loop across all elements in list.
Functions for calculating the bounds and number of cells of a background mesh configured within a blo...
blockMeshCylindricalConfiguration(const fileName &name, const fileName &dir, const Time &time, const meshingSurfaceList &surfaces, const Vector< label > &nCells, const label refineFactor, const HashTable< Pair< word >> &patchOpts, const bool clearBoundary)
Construct from components.
static const List< word > patches
Default patch names for the background mesh.
~blockMeshCylindricalConfiguration()
Destructor.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
errorManipArg< error, int > exit(error &err, const int errNo=1)
scalar degToRad(const scalar deg)
Convert degrees to radians.
scalar roundDown(const scalar x, const scalar s)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
Vector< scalar > vector
A scalar version of the templated Vector.
scalar roundUp(const scalar x, const scalar s)
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
scalar roundingScale(const scalar s)
Ostream & indent(Ostream &os)
Indent stream.
dimensionedScalar cos(const dimensionedScalar &ds)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.