41 void Foam::blockMeshCylindricalConfiguration::bbInflate
52 void Foam::blockMeshCylindricalConfiguration::calcBlockMeshDict()
55 label boxCells = nCells_.x();
56 label radialCells = nCells_.y();
63 nCells_ = Vector<label>
67 2.0*radialCells*bb_.span().z()/bb_.span().x()
75 const vector scaling(expansion, expansion, 1);
78 bbInflate(bb_, scaling);
79 bbInflate(rzbb_, scaling);
82 roundBoundingBox(bb_, roundFactor);
83 roundBoundingBox(rzbb_, roundFactor);
85 radBox_ = ceil(0.3*rzbb_.max().x()/roundFactor)*roundFactor;
87 nCells_ *= refineFactor_;
91 void Foam::blockMeshCylindricalConfiguration::writeBackgroundMesh()
93 const scalar radOut = bb_.max().x();
94 const scalar radIn = rzbb_.max().x();
95 const scalar boxToRadOut = radOut - radBox_;
96 const scalar boxToRadIn = radIn - radBox_;
98 const label inCells = ceil(boxToRadIn*nCells_.y()/boxToRadOut);
99 const label outCells = nCells_.y() - inCells;
101 beginDict(os_,
"backgroundMesh");
103 os_ <<
indent <<
"radOut " << radOut <<
";" <<
endl;
104 os_ <<
indent <<
"radIn " << radIn <<
";" <<
endl;
105 os_ <<
indent <<
"radBox " << radBox_ <<
";" <<
nl <<
endl;
106 os_ <<
indent <<
"zMin " << bb_.min().z() <<
";" <<
endl;
107 os_ <<
indent <<
"zMax " << bb_.max().z() <<
";" <<
nl <<
endl;
108 os_ <<
indent <<
"boxCells " << nCells_.x() <<
";" <<
endl;
109 os_ <<
indent <<
"inCells " << inCells <<
";" <<
endl;
110 os_ <<
indent <<
"outCells " << outCells <<
";" <<
endl;
111 os_ <<
indent <<
"zCells " << nCells_.z() <<
";" <<
nl <<
endl;
113 os_ <<
indent <<
"radOutN #neg $radOut;" <<
endl;
114 os_ <<
indent <<
"radInN #neg $radIn;" <<
endl;
115 os_ <<
indent <<
"radBoxN #neg $radBox;" <<
endl;
119 os_ <<
"convertToMeters 1;" <<
nl <<
endl;
123 void Foam::blockMeshCylindricalConfiguration::writeDefaultPatch()
125 Pair<word> defaultPatch;
127 word opt =
"defaultPatch";
128 if (patchOpts_.found(opt))
130 defaultPatch = readPatchOption(opt);
134 defaultPatch = {
"sides",
"patch"};
137 beginDict(os_,
"defaultPatch");
139 os_ <<
indent <<
"name " << defaultPatch.first() <<
";" <<
nl
140 <<
indent <<
"type " << defaultPatch.second() <<
";" <<
endl;
144 Info<<
"\nAdding defaultPatch '" << defaultPatch.first()
145 <<
"' of type '" << defaultPatch.second() <<
"'" <<
endl;
149 void Foam::blockMeshCylindricalConfiguration::writePatch
157 <<
" { type " <<
type
158 <<
"; faces ( " << face.c_str()
162 <<
"' of type '" <<
type <<
"'" <<
endl;
166 void Foam::blockMeshCylindricalConfiguration::writeBoundary()
169 bool enableBoundary = clearBoundary_;
177 enableBoundary = patchOpts_.found(
patches[i] +
"Patch");
182 os_ <<
"// delete \"-disabled\" to enable boundary settings" <<
endl;
184 Info<<
"\nNote: The boundary list in blockMeshDict is disabled" <<
nl
185 <<
"To enable, open the file and edit line number "
186 << os_.lineNumber() <<
nl <<
endl;
192 enableBoundary ?
"boundary" :
"boundary-disabled"
197 const bool optFound(patchOpts_.found(
patches[i] +
"Patch"));
201 if (clearBoundary_ && !optFound)
206 Pair<word> patch(
patches[i],
"patch");
210 patch = readPatchOption(patch.first() +
"Patch");
213 beginDict(os_, patch.first());
214 os_ <<
indent <<
"type " << patch.second() <<
";" <<
endl;
215 beginList(os_,
"faces");
235 os_ <<
indent <<
"(12 13 14 15)" <<
nl
249 endDict(os_, i != 1);
256 void Foam::blockMeshCylindricalConfiguration::writeGeometry()
258 beginDict(os_,
"geometry");
260 List<word> geometries {
"rotatingZone",
"outer"};
261 List<word> dims {
"radIn",
"radOut"};
263 const scalar zMin =
roundDown(bb_.min().z(), 10);
264 const scalar zMax =
roundUp(bb_.max().z(), 10);
268 beginDict(os_, geometries[i]);
270 os_ <<
indent <<
"type searchableCylinder;" <<
nl
271 <<
indent <<
"point1 (0 0 " << zMin <<
");" <<
nl
272 <<
indent <<
"point2 (0 0 " << zMax <<
");" <<
nl
273 <<
indent <<
"radius $!backgroundMesh/" << dims[i] <<
";" <<
endl;
282 void Foam::blockMeshCylindricalConfiguration::writeProjectedVertex
291 writeVertex(
x,
y, z);
296 void Foam::blockMeshCylindricalConfiguration::writeVertices()
298 beginList(os_,
"vertices");
304 writeVertex(
"radBoxN",
"radBoxN", dir);
305 writeVertex(
"radBox",
"radBoxN", dir);
306 writeVertex(
"radBox",
"radBox", dir);
307 writeVertex(
"radBoxN",
"radBox", dir);
311 writeProjectedVertex(
"radInN",
"radInN", dir,
"rotatingZone");
312 writeProjectedVertex(
"radIn",
"radInN", dir,
"rotatingZone");
313 writeProjectedVertex(
"radIn",
"radIn", dir,
"rotatingZone");
314 writeProjectedVertex(
"radInN",
"radIn", dir,
"rotatingZone");
316 writeProjectedVertex(
"radOutN",
"radOutN", dir,
"outer");
317 writeProjectedVertex(
"radOut",
"radOutN", dir,
"outer");
318 writeProjectedVertex(
"radOut",
"radOut", dir,
"outer");
319 writeProjectedVertex(
"radOutN",
"radOut", dir,
"outer");
326 void Foam::blockMeshCylindricalConfiguration::writeBlocks()
328 os_ <<
"boxMesh" <<
endl;
329 writeVertex(
"boxCells",
"boxCells",
"zCells");
330 os_ <<
"simpleGrading (1 1 1);" <<
nl <<
endl;
332 os_ <<
"inMesh" <<
endl;
333 writeVertex(
"boxCells",
"inCells",
"zCells");
334 os_ <<
"simpleGrading (1 1 1);" <<
nl <<
endl;
336 os_ <<
"outMesh" <<
endl;
337 writeVertex(
"boxCells",
"outCells",
"zCells");
338 os_ <<
"simpleGrading (1 $!backgroundMesh/outGrading 1);" <<
nl <<
endl;
340 beginList(os_,
"blocks");
342 os_ <<
indent <<
"hex (0 1 2 3 12 13 14 15) $boxMesh" <<
nl <<
nl
343 <<
indent <<
"hex (1 0 4 5 13 12 16 17) $inMesh" <<
nl
344 <<
indent <<
"hex (0 3 7 4 12 15 19 16) $inMesh" <<
nl
345 <<
indent <<
"hex (2 1 5 6 14 13 17 18) $inMesh" <<
nl
346 <<
indent <<
"hex (3 2 6 7 15 14 18 19) $inMesh" <<
nl <<
nl
347 <<
indent <<
"hex (5 4 8 9 17 16 20 21) $outMesh" <<
nl
348 <<
indent <<
"hex (4 7 11 8 16 19 23 20) $outMesh" <<
nl
349 <<
indent <<
"hex (6 5 9 10 18 17 21 22) $outMesh" <<
nl
350 <<
indent <<
"hex (7 6 10 11 19 18 22 23) $outMesh" <<
endl;
356 void Foam::blockMeshCylindricalConfiguration::writeEdges()
358 beginList(os_,
"edges");
360 os_ <<
indent <<
"project 4 5 (rotatingZone)" <<
nl
361 <<
indent <<
"project 5 6 (rotatingZone)" <<
nl
362 <<
indent <<
"project 6 7 (rotatingZone)" <<
nl
363 <<
indent <<
"project 7 4 (rotatingZone)" <<
nl
364 <<
indent <<
"project 16 17 (rotatingZone)" <<
nl
365 <<
indent <<
"project 17 18 (rotatingZone)" <<
nl
366 <<
indent <<
"project 18 19 (rotatingZone)" <<
nl
367 <<
indent <<
"project 19 16 (rotatingZone)" <<
nl <<
nl
368 <<
indent <<
"project 8 9 (outer)" <<
nl
369 <<
indent <<
"project 9 10 (outer)" <<
nl
370 <<
indent <<
"project 10 11 (outer)" <<
nl
371 <<
indent <<
"project 11 8 (outer)" <<
nl
372 <<
indent <<
"project 20 21 (outer)" <<
nl
373 <<
indent <<
"project 21 22 (outer)" <<
nl
374 <<
indent <<
"project 22 23 (outer)" <<
nl
381 void Foam::blockMeshCylindricalConfiguration::writeMergePatchPairs()
383 os_ <<
"mergePatchPairs" <<
nl
393 const fileName&
name,
396 const meshingSurfaceList& surfaces,
397 const Vector<label>& nCells,
398 const label refineFactor,
399 const HashTable<Pair<word>>& patchOpts,
400 const bool clearBoundary
403 blockMeshConfigurationBase(
name, dir, time, surfaces, patchOpts),
404 rzbb_(surfaces.rzbb()),
406 refineFactor_(refineFactor),
407 clearBoundary_(clearBoundary)
409 if (rzbb_.volume() == 0)
412 <<
"Attempting to create a cylindrical background mesh"
413 <<
nl <<
"but the rotatingZone surface has zero volume."
431 dict_.writeHeader(os_, word(
"dictionary"));
433 writeBackgroundMesh();
440 writeMergePatchPairs();
442 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
errorManipArg< error, int > exit(error &err, const int errNo=1)
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< 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.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Unit conversion functions.