35 {
"xMin",
"xMax",
"yMin",
"yMax",
"zMin",
"zMax"};
40 void Foam::blockMeshCartesianConfiguration::calcBlockMeshDict()
51 nCells_ = Vector<label>(
bb_.
span()/roundFactor);
56 nCells_ = Vector<label>(
bb_.
span()/roundFactor);
72 nCells_ *= refineFactor_;
74 Info<<
"Using background mesh nCells " << nCells_ <<
endl;
78 void Foam::blockMeshCartesianConfiguration::writeBackgroundMesh()
80 dictionary
dict(
"backgroundMesh");
82 dict.
add(
"xMin", bb_.min().x(),
true);
83 dict.
add(
"xMax", bb_.max().x(),
true);
84 dict.
add(
"yMin", bb_.min().y(),
true);
85 dict.
add(
"yMax", bb_.max().y(),
true);
86 dict.
add(
"zMin", bb_.min().z(),
true);
87 dict.
add(
"zMax", bb_.max().z(),
true);
88 dict.
add(
"xCells", nCells_.x(),
true);
89 dict.
add(
"yCells", nCells_.y(),
true);
90 dict.
add(
"zCells", nCells_.z(),
true);
94 <<
"convertToMeters 1;" <<
nl
99 void Foam::blockMeshCartesianConfiguration::writeDefaultPatch()
101 Pair<word> defaultPatch;
103 word opt =
"defaultPatch";
104 if (patchOpts_.found(opt))
106 defaultPatch = readPatchOption(opt);
110 defaultPatch = {
"background",
"internal"};
113 beginDict(os_,
"defaultPatch");
115 os_ <<
indent <<
"name " << defaultPatch.first() <<
";" <<
nl
116 <<
indent <<
"type " << defaultPatch.second() <<
";" <<
endl;
120 Info<<
"\nAdding defaultPatch '" << defaultPatch.first()
121 <<
"' of type '" << defaultPatch.second() <<
"'" <<
endl;
125 void Foam::blockMeshCartesianConfiguration::writePatch
133 <<
" { type " <<
type
134 <<
"; faces ( " << face.c_str()
138 <<
"' of type '" <<
type <<
"'" <<
endl;
142 void Foam::blockMeshCartesianConfiguration::writeBoundary()
145 bool enableBoundary = clearBoundary_;
153 enableBoundary = patchOpts_.found(
patches[i] +
"Patch");
158 os_ <<
"// delete \"-disabled\" to enable boundary settings" <<
endl;
160 Info<<
"\nNote: The boundary list in blockMeshDict is disabled" <<
nl
161 <<
"To enable, open the file and edit line number "
162 << os_.lineNumber() <<
nl <<
endl;
168 enableBoundary ?
"boundary" :
"boundary-disabled"
171 const List<word> faces
183 const bool optFound(patchOpts_.found(
patches[i] +
"Patch"));
187 if (clearBoundary_ && !optFound)
192 Pair<word> patch(
patches[i],
"patch");
196 patch = readPatchOption(patch.first() +
"Patch");
199 writePatch(patch.first(), patch.second(), faces[i]);
206 void Foam::blockMeshCartesianConfiguration::writeVertices()
208 beginList(os_,
"vertices");
210 writeVertex(
"xMin",
"yMin",
"zMin");
211 writeVertex(
"xMax",
"yMin",
"zMin");
212 writeVertex(
"xMax",
"yMax",
"zMin");
213 writeVertex(
"xMin",
"yMax",
"zMin");
214 writeVertex(
"xMin",
"yMin",
"zMax");
215 writeVertex(
"xMax",
"yMin",
"zMax");
216 writeVertex(
"xMax",
"yMax",
"zMax");
217 writeVertex(
"xMin",
"yMax",
"zMax");
223 void Foam::blockMeshCartesianConfiguration::writeBlocks()
225 beginList(os_,
"blocks");
227 os_ <<
indent <<
"hex (0 1 2 3 4 5 6 7)" <<
nl
229 <<
indent <<
"$!backgroundMesh/xCells" <<
nl
230 <<
indent <<
"$!backgroundMesh/yCells" <<
nl
239 void Foam::blockMeshCartesianConfiguration::writeEdges()
241 beginList(os_,
"edges");
246 void Foam::blockMeshCartesianConfiguration::writeMergePatchPairs()
248 beginList(os_,
"mergePatchPairs");
257 const fileName&
name,
260 const meshingSurfaceList& surfaces,
261 const Vector<label>& nCells,
262 const label refineFactor,
263 const HashTable<Pair<word>>& patchOpts,
264 const bool clearBoundary
267 blockMeshConfigurationBase(
name, dir, time, surfaces, patchOpts),
269 refineFactor_(refineFactor),
270 clearBoundary_(clearBoundary)
286 dict_.writeHeader(os_, word(
"dictionary"));
288 writeBackgroundMesh();
294 writeMergePatchPairs();
296 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.
static const List< word > patches
Default patch names for the background mesh.
blockMeshCartesianConfiguration(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.
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.