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;
137 void Foam::blockMeshCylindricalConfiguration::writeDefaultPatch()
139 Pair<word> defaultPatch;
141 word opt =
"defaultPatch";
142 if (patchOpts_.found(opt))
144 defaultPatch = readPatchOption(opt);
148 defaultPatch = {
"background",
"internal"};
151 beginDict(os_,
"defaultPatch");
153 os_ <<
indent <<
"name " << defaultPatch.first() <<
";" <<
nl
154 <<
indent <<
"type " << defaultPatch.second() <<
";" <<
endl;
158 Info<<
"\nAdding defaultPatch '" << defaultPatch.first()
159 <<
"' of type '" << defaultPatch.second() <<
"'" <<
endl;
163 void Foam::blockMeshCylindricalConfiguration::writePatch
171 <<
" { type " <<
type
172 <<
"; faces ( " <<
face.c_str()
176 <<
"' of type '" <<
type <<
"'" <<
endl;
180 void Foam::blockMeshCylindricalConfiguration::writeBoundary()
183 bool enableBoundary = clearBoundary_;
191 enableBoundary = patchOpts_.found(
patches[i] +
"Patch");
196 os_ <<
"// delete \"-disabled\" to enable boundary settings" <<
endl;
198 Info<<
"\nNote: The boundary list in blockMeshDict is disabled" <<
nl
199 <<
"To enable, open the file and edit line number "
200 << os_.lineNumber() <<
nl <<
endl;
206 enableBoundary ?
"boundary" :
"boundary-disabled"
211 const bool optFound(patchOpts_.found(
patches[i] +
"Patch"));
215 if (clearBoundary_ && !optFound)
220 Pair<word> patch(
patches[i],
"patch");
224 patch = readPatchOption(patch.first() +
"Patch");
227 beginDict(os_, patch.first());
228 os_ <<
indent <<
"type " << patch.second() <<
";" <<
endl;
229 beginList(os_,
"faces");
249 os_ <<
indent <<
"(12 13 14 15)" <<
nl
263 endDict(os_, i != 1);
270 void Foam::blockMeshCylindricalConfiguration::writeGeometry()
272 beginDict(os_,
"geometry");
274 List<word> geometries {
"rotatingZone",
"outer"};
277 scalar zMin =
roundDown(bb_.min().z(), 10);
278 scalar zMax =
roundUp(bb_.max().z(), 10);
281 const scalar span = zMax - zMin;
287 beginDict(os_, geometries[i]);
289 os_ <<
indent <<
"type cylinder;" <<
nl
290 <<
indent <<
"point1 (0 0 " << zMin <<
");" <<
nl
291 <<
indent <<
"point2 (0 0 " << zMax <<
");" <<
nl
292 <<
indent <<
"radius $!backgroundMesh/" << dims[i] <<
";" <<
endl;
301 void Foam::blockMeshCylindricalConfiguration::writeProjectedVertex
310 writeVertex(
x,
y, z);
315 void Foam::blockMeshCylindricalConfiguration::writeVertices()
317 beginList(os_,
"vertices");
323 writeVertex(
"radBoxN",
"radBoxN", dir);
324 writeVertex(
"radBox",
"radBoxN", dir);
325 writeVertex(
"radBox",
"radBox", dir);
326 writeVertex(
"radBoxN",
"radBox", dir);
330 writeProjectedVertex(
"radInN",
"radInN", dir,
"rotatingZone");
331 writeProjectedVertex(
"radIn",
"radInN", dir,
"rotatingZone");
332 writeProjectedVertex(
"radIn",
"radIn", dir,
"rotatingZone");
333 writeProjectedVertex(
"radInN",
"radIn", dir,
"rotatingZone");
335 writeProjectedVertex(
"radOutN",
"radOutN", dir,
"outer");
336 writeProjectedVertex(
"radOut",
"radOutN", dir,
"outer");
337 writeProjectedVertex(
"radOut",
"radOut", dir,
"outer");
338 writeProjectedVertex(
"radOutN",
"radOut", dir,
"outer");
345 void Foam::blockMeshCylindricalConfiguration::writeBlocks()
347 os_ <<
"boxMesh" <<
endl;
348 writeVertex(
"boxCells",
"boxCells",
"zCells");
349 os_ <<
"simpleGrading (1 1 1);" <<
nl <<
endl;
351 os_ <<
"inMesh" <<
endl;
352 writeVertex(
"boxCells",
"inCells",
"zCells");
353 os_ <<
"simpleGrading (1 1 1);" <<
nl <<
endl;
355 os_ <<
"outMesh" <<
endl;
356 writeVertex(
"boxCells",
"outCells",
"zCells");
357 os_ <<
"simpleGrading (1 $!backgroundMesh/outGrading 1);" <<
nl <<
endl;
359 beginList(os_,
"blocks");
361 os_ <<
indent <<
"hex (0 1 2 3 12 13 14 15) $boxMesh" <<
nl <<
nl
362 <<
indent <<
"hex (1 0 4 5 13 12 16 17) $inMesh" <<
nl
363 <<
indent <<
"hex (0 3 7 4 12 15 19 16) $inMesh" <<
nl
364 <<
indent <<
"hex (2 1 5 6 14 13 17 18) $inMesh" <<
nl
365 <<
indent <<
"hex (3 2 6 7 15 14 18 19) $inMesh" <<
nl <<
nl
366 <<
indent <<
"hex (5 4 8 9 17 16 20 21) $outMesh" <<
nl
367 <<
indent <<
"hex (4 7 11 8 16 19 23 20) $outMesh" <<
nl
368 <<
indent <<
"hex (6 5 9 10 18 17 21 22) $outMesh" <<
nl
369 <<
indent <<
"hex (7 6 10 11 19 18 22 23) $outMesh" <<
endl;
375 void Foam::blockMeshCylindricalConfiguration::writeEdges()
377 beginList(os_,
"edges");
379 os_ <<
indent <<
"project 4 5 (rotatingZone)" <<
nl
380 <<
indent <<
"project 5 6 (rotatingZone)" <<
nl
381 <<
indent <<
"project 6 7 (rotatingZone)" <<
nl
382 <<
indent <<
"project 7 4 (rotatingZone)" <<
nl
383 <<
indent <<
"project 16 17 (rotatingZone)" <<
nl
384 <<
indent <<
"project 17 18 (rotatingZone)" <<
nl
385 <<
indent <<
"project 18 19 (rotatingZone)" <<
nl
386 <<
indent <<
"project 19 16 (rotatingZone)" <<
nl <<
nl
387 <<
indent <<
"project 8 9 (outer)" <<
nl
388 <<
indent <<
"project 9 10 (outer)" <<
nl
389 <<
indent <<
"project 10 11 (outer)" <<
nl
390 <<
indent <<
"project 11 8 (outer)" <<
nl
391 <<
indent <<
"project 20 21 (outer)" <<
nl
392 <<
indent <<
"project 21 22 (outer)" <<
nl
393 <<
indent <<
"project 22 23 (outer)" <<
nl
400 void Foam::blockMeshCylindricalConfiguration::writeMergePatchPairs()
402 os_ <<
"mergePatchPairs" <<
nl
412 const fileName&
name,
415 const meshingSurfaceList& surfaces,
416 const bool& boundsOpt,
417 const Vector<label>& nCells,
418 const label refineFactor,
419 const HashTable<Pair<word>>& patchOpts,
420 const bool clearBoundary
423 blockMeshConfigurationBase(
name, dir,
time, surfaces, patchOpts),
424 rzbb_(surfaces.rzbb()),
426 refineFactor_(refineFactor),
427 clearBoundary_(clearBoundary)
429 if (!isBoundBoxOnZaxis())
432 <<
"Attempting to create a cylindrical background mesh"
433 <<
nl <<
"but the geometry bounds are not aligned with the z-axis."
437 bool rotatingZonesOpt(
true);
439 if (rzbb_.volume() == 0)
441 rotatingZonesOpt =
false;
444 <<
"Creating a cylindrical background mesh without a "
445 <<
"rotatingZone specified by the '-rotatingZones' option."
452 rzbb_.min() = factor*bb_.min();
453 rzbb_.max() = factor*bb_.max();
456 calcBlockMeshDict(boundsOpt, rotatingZonesOpt);
470 dict_.writeHeader(os_, word(
"dictionary"));
472 writeBackgroundMesh();
479 writeMergePatchPairs();
481 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.
Motion of the mesh specified as a list of pointMeshMovers.
#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)
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.
tmp< DimensionedField< Type, GeoMesh, Field > > cmptMultiply(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type, GeoMesh, PrimitiveField2 > &df2)
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.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
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.