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
58 const bool& boundsOpt,
59 const bool& rotatingZonesOpt
63 label boxCells = nCells_.x();
64 label radialCells = nCells_.y();
71 nCells_ = Vector<label>
75 2.0*radialCells*bb_.span().z()/bb_.span().x()
85 if(!boundsOpt || rotatingZonesOpt)
88 const vector scaling(expansion, expansion, 1);
92 bbInflate(bb_, scaling);
93 roundBoundingBox(bb_, roundFactor);
97 bbInflate(rzbb_, scaling);
98 roundBoundingBox(rzbb_, roundFactor);
102 radBox_ = ceil(0.3*rzbb_.max().x()/roundFactor)*roundFactor;
103 nCells_ *= refineFactor_;
107 void Foam::blockMeshCylindricalConfiguration::writeBackgroundMesh()
109 const scalar radOut = bb_.max().x();
110 const scalar radIn = rzbb_.max().x();
111 const scalar boxToRadOut = radOut - radBox_;
112 const scalar boxToRadIn = radIn - radBox_;
114 const label inCells = ceil(boxToRadIn*nCells_.y()/boxToRadOut);
115 const label outCells = nCells_.y() - inCells;
117 beginDict(os_,
"backgroundMesh");
119 os_ <<
indent <<
"radOut " << radOut <<
";" <<
endl;
120 os_ <<
indent <<
"radIn " << radIn <<
";" <<
endl;
121 os_ <<
indent <<
"radBox " << radBox_ <<
";" <<
nl <<
endl;
122 os_ <<
indent <<
"zMin " << bb_.min().z() <<
";" <<
endl;
123 os_ <<
indent <<
"zMax " << bb_.max().z() <<
";" <<
nl <<
endl;
124 os_ <<
indent <<
"boxCells " << nCells_.x() <<
";" <<
endl;
125 os_ <<
indent <<
"inCells " << inCells <<
";" <<
endl;
126 os_ <<
indent <<
"outCells " << outCells <<
";" <<
endl;
127 os_ <<
indent <<
"zCells " << nCells_.z() <<
";" <<
nl <<
endl;
129 os_ <<
indent <<
"radOutN #neg $radOut;" <<
endl;
130 os_ <<
indent <<
"radInN #neg $radIn;" <<
endl;
131 os_ <<
indent <<
"radBoxN #neg $radBox;" <<
endl;
135 os_ <<
"convertToMeters 1;" <<
nl <<
endl;
139 void Foam::blockMeshCylindricalConfiguration::writeDefaultPatch()
141 Pair<word> defaultPatch;
143 word opt =
"defaultPatch";
144 if (patchOpts_.found(opt))
146 defaultPatch = readPatchOption(opt);
150 defaultPatch = {
"background",
"internal"};
153 beginDict(os_,
"defaultPatch");
155 os_ <<
indent <<
"name " << defaultPatch.first() <<
";" <<
nl
156 <<
indent <<
"type " << defaultPatch.second() <<
";" <<
endl;
160 Info<<
"\nAdding defaultPatch '" << defaultPatch.first()
161 <<
"' of type '" << defaultPatch.second() <<
"'" <<
endl;
165 void Foam::blockMeshCylindricalConfiguration::writePatch
173 <<
" { type " <<
type
174 <<
"; faces ( " <<
face.c_str()
178 <<
"' of type '" <<
type <<
"'" <<
endl;
182 void Foam::blockMeshCylindricalConfiguration::writeBoundary()
185 bool enableBoundary = clearBoundary_;
193 enableBoundary = patchOpts_.found(
patches[i] +
"Patch");
198 os_ <<
"// delete \"-disabled\" to enable boundary settings" <<
endl;
200 Info<<
"\nNote: The boundary list in blockMeshDict is disabled" <<
nl
201 <<
"To enable, open the file and edit line number "
202 << os_.lineNumber() <<
nl <<
endl;
208 enableBoundary ?
"boundary" :
"boundary-disabled"
213 const bool optFound(patchOpts_.found(
patches[i] +
"Patch"));
217 if (clearBoundary_ && !optFound)
222 Pair<word> patch(
patches[i],
"patch");
226 patch = readPatchOption(patch.first() +
"Patch");
229 beginDict(os_, patch.first());
230 os_ <<
indent <<
"type " << patch.second() <<
";" <<
endl;
231 beginList(os_,
"faces");
251 os_ <<
indent <<
"(12 13 14 15)" <<
nl
265 endDict(os_, i != 1);
272 void Foam::blockMeshCylindricalConfiguration::writeGeometry()
274 beginDict(os_,
"geometry");
276 List<word> geometries {
"rotatingZone",
"outer"};
277 List<word> dims {
"radIn",
"radOut"};
279 scalar zMin =
roundDown(bb_.min().z(), 10);
280 scalar zMax =
roundUp(bb_.max().z(), 10);
283 const scalar span = zMax - zMin;
289 beginDict(os_, geometries[i]);
291 os_ <<
indent <<
"type cylinder;" <<
nl
292 <<
indent <<
"point1 (0 0 " << zMin <<
");" <<
nl
293 <<
indent <<
"point2 (0 0 " << zMax <<
");" <<
nl
294 <<
indent <<
"radius $!backgroundMesh/" << dims[i] <<
";" <<
endl;
303 void Foam::blockMeshCylindricalConfiguration::writeProjectedVertex
312 writeVertex(
x,
y, z);
317 void Foam::blockMeshCylindricalConfiguration::writeVertices()
319 beginList(os_,
"vertices");
325 writeVertex(
"radBoxN",
"radBoxN", dir);
326 writeVertex(
"radBox",
"radBoxN", dir);
327 writeVertex(
"radBox",
"radBox", dir);
328 writeVertex(
"radBoxN",
"radBox", dir);
332 writeProjectedVertex(
"radInN",
"radInN", dir,
"rotatingZone");
333 writeProjectedVertex(
"radIn",
"radInN", dir,
"rotatingZone");
334 writeProjectedVertex(
"radIn",
"radIn", dir,
"rotatingZone");
335 writeProjectedVertex(
"radInN",
"radIn", dir,
"rotatingZone");
337 writeProjectedVertex(
"radOutN",
"radOutN", dir,
"outer");
338 writeProjectedVertex(
"radOut",
"radOutN", dir,
"outer");
339 writeProjectedVertex(
"radOut",
"radOut", dir,
"outer");
340 writeProjectedVertex(
"radOutN",
"radOut", dir,
"outer");
347 void Foam::blockMeshCylindricalConfiguration::writeBlocks()
349 os_ <<
"boxMesh" <<
endl;
350 writeVertex(
"boxCells",
"boxCells",
"zCells");
351 os_ <<
"simpleGrading (1 1 1);" <<
nl <<
endl;
353 os_ <<
"inMesh" <<
endl;
354 writeVertex(
"boxCells",
"inCells",
"zCells");
355 os_ <<
"simpleGrading (1 1 1);" <<
nl <<
endl;
357 os_ <<
"outMesh" <<
endl;
358 writeVertex(
"boxCells",
"outCells",
"zCells");
359 os_ <<
"simpleGrading (1 $!backgroundMesh/outGrading 1);" <<
nl <<
endl;
361 beginList(os_,
"blocks");
363 os_ <<
indent <<
"hex (0 1 2 3 12 13 14 15) $boxMesh" <<
nl <<
nl
364 <<
indent <<
"hex (1 0 4 5 13 12 16 17) $inMesh" <<
nl
365 <<
indent <<
"hex (0 3 7 4 12 15 19 16) $inMesh" <<
nl
366 <<
indent <<
"hex (2 1 5 6 14 13 17 18) $inMesh" <<
nl
367 <<
indent <<
"hex (3 2 6 7 15 14 18 19) $inMesh" <<
nl <<
nl
368 <<
indent <<
"hex (5 4 8 9 17 16 20 21) $outMesh" <<
nl
369 <<
indent <<
"hex (4 7 11 8 16 19 23 20) $outMesh" <<
nl
370 <<
indent <<
"hex (6 5 9 10 18 17 21 22) $outMesh" <<
nl
371 <<
indent <<
"hex (7 6 10 11 19 18 22 23) $outMesh" <<
endl;
377 void Foam::blockMeshCylindricalConfiguration::writeEdges()
379 beginList(os_,
"edges");
381 os_ <<
indent <<
"project 4 5 (rotatingZone)" <<
nl
382 <<
indent <<
"project 5 6 (rotatingZone)" <<
nl
383 <<
indent <<
"project 6 7 (rotatingZone)" <<
nl
384 <<
indent <<
"project 7 4 (rotatingZone)" <<
nl
385 <<
indent <<
"project 16 17 (rotatingZone)" <<
nl
386 <<
indent <<
"project 17 18 (rotatingZone)" <<
nl
387 <<
indent <<
"project 18 19 (rotatingZone)" <<
nl
388 <<
indent <<
"project 19 16 (rotatingZone)" <<
nl <<
nl
389 <<
indent <<
"project 8 9 (outer)" <<
nl
390 <<
indent <<
"project 9 10 (outer)" <<
nl
391 <<
indent <<
"project 10 11 (outer)" <<
nl
392 <<
indent <<
"project 11 8 (outer)" <<
nl
393 <<
indent <<
"project 20 21 (outer)" <<
nl
394 <<
indent <<
"project 21 22 (outer)" <<
nl
395 <<
indent <<
"project 22 23 (outer)" <<
nl
402 void Foam::blockMeshCylindricalConfiguration::writeMergePatchPairs()
404 os_ <<
"mergePatchPairs" <<
nl
414 const fileName&
name,
417 const meshingSurfaceList& surfaces,
418 const bool& boundsOpt,
419 const Vector<label>& nCells,
420 const label refineFactor,
421 const HashTable<Pair<word>>& patchOpts,
422 const bool clearBoundary
425 blockMeshConfigurationBase(
name, dir, time, surfaces, patchOpts),
426 rzbb_(surfaces.rzbb()),
428 refineFactor_(refineFactor),
429 clearBoundary_(clearBoundary)
431 if (!isBoundBoxOnZaxis())
434 <<
"Attempting to create a cylindrical background mesh"
435 <<
nl <<
"but the geometry bounds are not aligned with the z-axis."
439 bool rotatingZonesOpt(
true);
441 if (rzbb_.volume() == 0)
443 rotatingZonesOpt =
false;
446 <<
"Creating a cylindrical background mesh without a "
447 <<
"rotatingZone specified by the '-rotatingZones' option."
454 rzbb_.min() = factor*bb_.min();
455 rzbb_.max() = factor*bb_.max();
458 calcBlockMeshDict(boundsOpt, rotatingZonesOpt);
472 dict_.writeHeader(os_, word(
"dictionary"));
474 writeBackgroundMesh();
481 writeMergePatchPairs();
483 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...
static const List< word > patches
Default patch names for the background mesh.
blockMeshCylindricalConfiguration(const fileName &name, const fileName &dir, const Time &time, const meshingSurfaceList &surfaces, const bool &boundsOpt, const Vector< label > &nCells, const label refineFactor, const HashTable< Pair< word >> &patchOpts, const bool clearBoundary)
Construct from components.
~blockMeshCylindricalConfiguration()
Destructor.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::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)
void cmptMultiply(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1, const LagrangianPatchField< Type > &f2)
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.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
Vector< scalar > vector
A scalar version of the templated Vector.
scalar roundUp(const scalar x, const scalar s)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
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.