35 {
"xMin",
"xMax",
"yMin",
"yMax",
"zMin",
"zMax"};
40 void Foam::blockMeshCartesianConfiguration::calcBlockMeshDict
57 nCells_ = Vector<label>(
bb_.
span()/roundFactor);
62 nCells_ = Vector<label>(
bb_.
span()/roundFactor);
78 nCells_ *= refineFactor_;
80 Info<<
"Using background mesh nCells " << nCells_ <<
endl;
84 void Foam::blockMeshCartesianConfiguration::writeBackgroundMesh()
86 dictionary
dict(
"backgroundMesh");
88 dict.
add(
"xMin", bb_.min().x(),
true);
89 dict.
add(
"xMax", bb_.max().x(),
true);
90 dict.
add(
"yMin", bb_.min().y(),
true);
91 dict.
add(
"yMax", bb_.max().y(),
true);
92 dict.
add(
"zMin", bb_.min().z(),
true);
93 dict.
add(
"zMax", bb_.max().z(),
true);
94 dict.
add(
"xCells", nCells_.x(),
true);
95 dict.
add(
"yCells", nCells_.y(),
true);
96 dict.
add(
"zCells", nCells_.z(),
true);
100 <<
"convertToMeters 1;" <<
nl
105 void Foam::blockMeshCartesianConfiguration::writeDefaultPatch()
107 Pair<word> defaultPatch;
109 word opt =
"defaultPatch";
110 if (patchOpts_.found(opt))
112 defaultPatch = readPatchOption(opt);
116 defaultPatch = {
"background",
"internal"};
119 beginDict(os_,
"defaultPatch");
121 os_ <<
indent <<
"name " << defaultPatch.first() <<
";" <<
nl
122 <<
indent <<
"type " << defaultPatch.second() <<
";" <<
endl;
126 Info<<
"\nAdding defaultPatch '" << defaultPatch.first()
127 <<
"' of type '" << defaultPatch.second() <<
"'" <<
endl;
131 void Foam::blockMeshCartesianConfiguration::writePatch
139 <<
" { type " <<
type
140 <<
"; faces ( " << face.c_str()
144 <<
"' of type '" <<
type <<
"'" <<
endl;
148 void Foam::blockMeshCartesianConfiguration::writeBoundary()
151 bool enableBoundary = clearBoundary_;
159 enableBoundary = patchOpts_.found(
patches[i] +
"Patch");
164 os_ <<
"// delete \"-disabled\" to enable boundary settings" <<
endl;
166 Info<<
"\nNote: The boundary list in blockMeshDict is disabled" <<
nl
167 <<
"To enable, open the file and edit line number "
168 << os_.lineNumber() <<
nl <<
endl;
174 enableBoundary ?
"boundary" :
"boundary-disabled"
177 const List<word> faces
189 const bool optFound(patchOpts_.found(
patches[i] +
"Patch"));
193 if (clearBoundary_ && !optFound)
198 Pair<word> patch(
patches[i],
"patch");
202 patch = readPatchOption(patch.first() +
"Patch");
205 writePatch(patch.first(), patch.second(), faces[i]);
212 void Foam::blockMeshCartesianConfiguration::writeVertices()
214 beginList(os_,
"vertices");
216 writeVertex(
"xMin",
"yMin",
"zMin");
217 writeVertex(
"xMax",
"yMin",
"zMin");
218 writeVertex(
"xMax",
"yMax",
"zMin");
219 writeVertex(
"xMin",
"yMax",
"zMin");
220 writeVertex(
"xMin",
"yMin",
"zMax");
221 writeVertex(
"xMax",
"yMin",
"zMax");
222 writeVertex(
"xMax",
"yMax",
"zMax");
223 writeVertex(
"xMin",
"yMax",
"zMax");
229 void Foam::blockMeshCartesianConfiguration::writeBlocks()
231 beginList(os_,
"blocks");
233 os_ <<
indent <<
"hex (0 1 2 3 4 5 6 7)" <<
nl
235 <<
indent <<
"$!backgroundMesh/xCells" <<
nl
236 <<
indent <<
"$!backgroundMesh/yCells" <<
nl
245 void Foam::blockMeshCartesianConfiguration::writeEdges()
247 beginList(os_,
"edges");
252 void Foam::blockMeshCartesianConfiguration::writeMergePatchPairs()
254 beginList(os_,
"mergePatchPairs");
263 const fileName&
name,
266 const meshingSurfaceList& surfaces,
267 const bool& boundsOpt,
268 const Vector<label>& nCells,
269 const label refineFactor,
270 const HashTable<Pair<word>>& patchOpts,
271 const bool clearBoundary
274 blockMeshConfigurationBase(
name, dir, time, surfaces, patchOpts),
276 refineFactor_(refineFactor),
277 clearBoundary_(clearBoundary)
279 calcBlockMeshDict(boundsOpt);
293 dict_.writeHeader(os_, word(
"dictionary"));
295 writeBackgroundMesh();
301 writeMergePatchPairs();
303 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...
~blockMeshCartesianConfiguration()
Destructor.
blockMeshCartesianConfiguration(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.
static const List< word > patches
Default patch names for the background mesh.
void write()
Write the blockMeshDict.
void roundBoundingBox(boundBox &bb, const scalar s)
Round a bounding box by the rounding scale.
boundBox bb_
Bounding box for the background mesh block.
scalar minDim() const
Smallest length/height/width dimension.
vector span() const
The bounding box span (from minimum to maximum)
const fileName & name() const
Return the dictionary name.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
const fvPatchList & patches
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
bool isEven(const label l)
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.
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
scalar roundingScale(const scalar s)
Ostream & indent(Ostream &os)
Indent stream.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.