53 while ((is) && ch !=
'\n');
87 const scalar scaleFactor
107 maxId =
max(maxId, starVertexId);
115 <<
"No points in file " << inputName <<
nl 124 mapToFoamPointId_.setSize(maxId+1);
131 mapToFoamPointId_ = -1;
145 is >> points_[pointi].x()
146 >> points_[pointi].y()
147 >> points_[pointi].z();
151 mapToFoamPointId_[starVertexId] = pointi;
166 && (scaleFactor > 1.0 + SMALL || scaleFactor < 1.0 - SMALL)
169 points_ *= scaleFactor;
219 label nFluids = 0, nSolids = 0, nBaffles = 0, nShells = 0;
223 bool unknownVertices =
false;
233 label shapeId, nLabels, cellTableId, typeId;
257 maxId =
max(maxId, starCellId);
259 if (!cellTable_.found(cellTableId))
261 cellTable_.setName(cellTableId);
262 cellTable_.setMaterial(cellTableId,
"fluid");
270 maxId =
max(maxId, starCellId);
273 if (!cellTable_.found(cellTableId))
275 cellTable_.setName(cellTableId);
276 cellTable_.setMaterial(cellTableId,
"solid");
283 maxId =
max(maxId, starCellId);
288 if (!cellTable_.found(cellTableId))
290 cellTable_.setName(cellTableId);
291 cellTable_.setMaterial(cellTableId,
"shell");
297 const label nCells = nFluids + (keepSolids_ ? nSolids : 0);
299 Info<<
"Number of fluids = " << nFluids <<
nl 300 <<
"Number of baffles = " << nBaffles <<
nl 301 <<
"Number of solids = " << nSolids
302 << (keepSolids_ ?
" (treat as fluid)" :
" (ignored)") <<
nl 303 <<
"Number of shells = " << nShells <<
" (ignored)" <<
nl;
309 err <<
"No cells in file " << inputName <<
nl;
313 err <<
"Consists of shells only (typeId=4)." <<
nl;
320 cellFaces_.setSize(nCells);
321 cellShapes_.setSize(nCells);
322 cellTableId_.setSize(nCells);
325 baffleFaces_.setSize(nBaffles);
328 origCellId_.setSize(nCells + nBaffles);
329 mapToFoamCellId_.setSize(maxId+1);
330 mapToFoamCellId_ = -1;
346 label ignoredLabel, shapeId, nLabels, cellTableId, typeId;
348 label celli = 0, bafflei = 0;
359 if (nLabels > starLabels.
size())
366 for (label i = 0; i < nLabels; ++i)
411 for (label i=0; i < nLabels; ++i)
413 label pointId = mapToFoamPointId_[starLabels[i]];
416 Info<<
"Cells inconsistent with vertex file. " 417 <<
"Star vertex " << starLabels[i]
418 <<
" does not exist" <<
endl;
420 unknownVertices =
true;
422 starLabels[i] = pointId;
431 origCellId_[celli] = starCellId;
432 mapToFoamCellId_[starCellId] = celli;
434 cellTableId_[celli] = cellTableId;
441 cellFaces_[celli] = cellShapes_[celli].faces();
447 label nFaces = starLabels[0] - 1;
452 for (label i=starLabels[0]; i < nLabels; ++i)
454 label pointId = mapToFoamPointId_[starLabels[i]];
457 Info<<
"Cells inconsistent with vertex file. " 458 <<
"Star vertex " << starLabels[i]
459 <<
" does not exist" <<
endl;
461 unknownVertices =
true;
463 starLabels[i] = pointId;
474 for (label i=0; i < nFaces; ++i)
476 label beg = starLabels[i];
477 label
n = starLabels[i+1] - beg;
495 Info<<
"star cell " << starCellId <<
" has " 497 <<
" empty faces - could cause boundary " 498 <<
"addressing problems" 508 <<
"star cell " << starCellId <<
" has " << nFaces
513 origCellId_[celli] = starCellId;
514 mapToFoamCellId_[starCellId] = celli;
516 cellTableId_[celli] = cellTableId;
517 cellShapes_[celli] = genericShape;
518 cellFaces_[celli] = faces;
527 for (label i=0; i < nLabels; ++i)
529 label pointId = mapToFoamPointId_[starLabels[i]];
532 Info<<
"Baffles inconsistent with vertex file. " 533 <<
"Star vertex " << starLabels[i]
534 <<
" does not exist" <<
endl;
536 unknownVertices =
true;
538 starLabels[i] = pointId;
557 baffleFaces_[bafflei] =
f;
559 mapToFoamCellId_[starCellId] = nCells + bafflei;
560 origCellId_[nCells + bafflei] = starCellId;
566 baffleFaces_.setSize(bafflei);
572 <<
"cells with unknown vertices" 583 mapToFoamPointId_.clear();
612 label
nPatches = 0, nFaces = 0, nBafflePatches = 0, maxId = 0;
613 label starCellId, cellFaceId, starRegion, configNumber;
617 labelList mapToFoamPatchId(1000, label(-1));
620 patchTypes_.setSize(1000);
665 label patchLabel = mapToFoamPatchId[starRegion];
666 if (patchLabel == -1)
669 mapToFoamPatchId[starRegion] = patchLabel;
670 origRegion[patchLabel] = starRegion;
671 patchTypes_[patchLabel] = patchType;
673 maxId =
max(maxId, starRegion);
676 if (patchType ==
"BAFF")
683 ++nPatchFaces[patchLabel];
688 Info<<
"No boundary faces in file " << inputName <<
endl;
693 Info<<
"Could not read boundary file " << inputName <<
endl;
700 <<
" (including extra for missing) with " 701 << nFaces <<
" faces" <<
endl;
716 forAll(patchTypes_, patchi)
718 bool fndName =
false, fndType =
false;
720 auto iter = boundaryRegion_.cfind(origRegion[patchi]);
726 fndType =
dict.readIfPresent(
"BoundaryType", patchTypes_[patchi]);
727 fndName =
dict.readIfPresent(
"Label", patchNames_[patchi]);
735 if (patchTypes_[patchi] ==
"symp")
737 patchTypes_[patchi] =
"symplane";
739 else if (patchTypes_[patchi] ==
"cycl")
741 patchTypes_[patchi] =
"cyclic";
743 else if (patchTypes_[patchi] ==
"baff")
745 patchTypes_[patchi] =
"baffle";
747 else if (patchTypes_[patchi] ==
"moni")
749 patchTypes_[patchi] =
"monitoring";
756 patchNames_[patchi] =
757 patchTypes_[patchi] +
"_" +
name(origRegion[patchi]);
762 patchNames_[
nPatches-1] = defaultBoundaryName;
775 oldToNew[sortedIndices[i]] = i;
790 label baffleIndex = (
nPatches-1 - nBafflePatches);
792 for (label i=0; i < oldToNew.
size()-1; ++i)
794 if (patchTypes_[i] ==
"baffle")
796 oldToNew[i] = baffleIndex++;
800 oldToNew[i] = newIndex++;
810 mapToFoamPatchId.
setSize(maxId+1, -1);
811 forAll(origRegion, patchi)
813 mapToFoamPatchId[origRegion[patchi]] = patchi;
817 forAll(boundaryIds_, patchi)
819 boundaryIds_[patchi].setSize(nPatchFaces[patchi]);
820 nPatchFaces[patchi] = 0;
826 if (
nPatches > 1 && mapToFoamCellId_.size() > 1)
842 label patchi = mapToFoamPatchId[starRegion];
850 if (starCellId < mapToFoamCellId_.size())
852 cellId = mapToFoamCellId_[starCellId];
858 <<
"Boundaries inconsistent with cell file. " 859 <<
"Star cell " << starCellId <<
" does not exist" 865 if (
cellId < cellShapes_.size())
867 label mapIndex = cellShapes_[
cellId].model().index();
868 if (shapeLookup.
found(mapIndex))
870 mapIndex = shapeLookup[mapIndex];
873 [mapIndex][cellFaceId];
883 boundaryIds_[patchi][nPatchFaces[patchi]] =
886 #ifdef DEBUG_BOUNDARY 890 ++nPatchFaces[patchi];
896 patchPhysicalTypes_.setSize(patchTypes_.size());
899 forAll(boundaryIds_, patchi)
902 if (nPatchFaces[patchi] < boundaryIds_[patchi].size())
904 boundaryIds_[patchi].setSize(nPatchFaces[patchi]);
907 word origType = patchTypes_[patchi];
908 patchPhysicalTypes_[patchi] = origType;
910 if (origType ==
"symplane")
912 patchTypes_[patchi] = symmetryPolyPatch::typeName;
913 patchPhysicalTypes_[patchi] = patchTypes_[patchi];
915 else if (origType ==
"wall")
917 patchTypes_[patchi] = wallPolyPatch::typeName;
918 patchPhysicalTypes_[patchi] = patchTypes_[patchi];
920 else if (origType ==
"cyclic")
924 patchTypes_[patchi] = oldCyclicPolyPatch::typeName;
925 patchPhysicalTypes_[patchi] = patchTypes_[patchi];
927 else if (origType ==
"baffle")
931 patchTypes_[patchi] = emptyPolyPatch::typeName;
932 patchPhysicalTypes_[patchi] =
"baffle";
936 patchTypes_[patchi] = polyPatch::typeName;
939 Info<<
"patch " << patchi
940 <<
" (region " << origRegion[patchi]
941 <<
": " << origType <<
") type: '" << patchTypes_[patchi]
942 <<
"' name: " << patchNames_[patchi] <<
endl;
946 mapToFoamCellId_.clear();
956 label
nPoints = points_.size();
962 const faceList& faces = cellFaces_[celli];
968 oldToNew[labels[j]]++;
977 if (oldToNew[i] >= 0)
979 oldToNew[i] = pointi++;
996 for (
face&
f : faces)
1003 for (
face&
f : baffleFaces_)
1040 const scalar scaleFactor,
1041 const bool keepSolids
1045 keepSolids_(keepSolids),
1047 mapToFoamPointId_(0),
Generic output stream using a standard (STL) stream.
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
A face is a list of labels corresponding to mesh vertices.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool found(const Key &key) const
Same as contains()
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
static void readToNewline(ISstream &is)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
An analytical geometric cellShape.
constexpr char nl
The newline '\n' character (0x0a)
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
A token holds an item read from Istream.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Identify cell faces in terms of cell Id and face Id.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
A List obtained as a section of another List.
void readDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant")
Read constant/cellTable.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
A class for handling words, derived from Foam::string.
static const cellModel * ptr(const modelType model)
Look up pointer to cellModel by enumeration, or nullptr on failure.
errorManip< error > abort(error &err)
Input from file stream as an ISstream, normally using std::ifstream for the actual input...
virtual Istream & read(token &t) override
Return next token from stream.
cellTable cellTable_
Cell table persistent data saved as a dictionary.
void readDict(const objectRegistry &obr, const word &name="boundaryRegion", const fileName &instance="constant")
Read constant/boundaryRegion.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
Generic input stream using a standard (STL) stream.
label index() const noexcept
Return index of model in the model list.
void inplaceLower(std::string &s)
Inplace transform string with std::tolower on each character.
bool good() const noexcept
True if next operation might succeed.
label labelToken() const
Return label value.
Maps a geometry to a set of cell primitives.
bool isLabel() const noexcept
Token is LABEL.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
Registry of regIOobjects.
ISstream & get(char &c)
Raw, low-level get character function.
This class supports creating polyMeshes with baffles.
static constexpr const zero Zero
Global zero (0)