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();
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)" <<
endl;
715 forAll(patchTypes_, patchi)
717 bool fndName =
false, fndType =
false;
719 auto iter = boundaryRegion_.cfind(origRegion[patchi]);
725 fndType =
dict.readIfPresent(
"BoundaryType", patchTypes_[patchi]);
726 fndName =
dict.readIfPresent(
"Label", patchNames_[patchi]);
734 if (patchTypes_[patchi] ==
"symp")
736 patchTypes_[patchi] =
"symplane";
738 else if (patchTypes_[patchi] ==
"cycl")
740 patchTypes_[patchi] =
"cyclic";
742 else if (patchTypes_[patchi] ==
"baff")
744 patchTypes_[patchi] =
"baffle";
746 else if (patchTypes_[patchi] ==
"moni")
748 patchTypes_[patchi] =
"monitoring";
755 patchNames_[patchi] =
756 patchTypes_[patchi] +
"_" +
name(origRegion[patchi]);
761 patchNames_[
nPatches-1] = defaultBoundaryName;
774 oldToNew[sortedIndices[i]] = i;
789 label baffleIndex = (
nPatches-1 - nBafflePatches);
791 for (label i=0; i < oldToNew.
size()-1; ++i)
793 if (patchTypes_[i] ==
"baffle")
795 oldToNew[i] = baffleIndex++;
799 oldToNew[i] = newIndex++;
809 mapToFoamPatchId.
setSize(maxId+1, -1);
810 forAll(origRegion, patchi)
812 mapToFoamPatchId[origRegion[patchi]] = patchi;
816 forAll(boundaryIds_, patchi)
818 boundaryIds_[patchi].setSize(nPatchFaces[patchi]);
819 nPatchFaces[patchi] = 0;
825 if (
nPatches > 1 && mapToFoamCellId_.size() > 1)
841 label patchi = mapToFoamPatchId[starRegion];
849 if (starCellId < mapToFoamCellId_.size())
851 cellId = mapToFoamCellId_[starCellId];
857 <<
"Boundaries inconsistent with cell file. "
858 <<
"Star cell " << starCellId <<
" does not exist"
864 if (
cellId < cellShapes_.size())
866 label mapIndex = cellShapes_[
cellId].model().index();
867 if (shapeLookup.
found(mapIndex))
869 mapIndex = shapeLookup[mapIndex];
872 [mapIndex][cellFaceId];
882 boundaryIds_[patchi][nPatchFaces[patchi]] =
889 ++nPatchFaces[patchi];
895 patchPhysicalTypes_.setSize(patchTypes_.size());
898 forAll(boundaryIds_, patchi)
901 if (nPatchFaces[patchi] < boundaryIds_[patchi].size())
903 boundaryIds_[patchi].setSize(nPatchFaces[patchi]);
906 word origType = patchTypes_[patchi];
907 patchPhysicalTypes_[patchi] = origType;
909 if (origType ==
"symplane")
912 patchPhysicalTypes_[patchi] = patchTypes_[patchi];
914 else if (origType ==
"wall")
917 patchPhysicalTypes_[patchi] = patchTypes_[patchi];
919 else if (origType ==
"cyclic")
924 patchPhysicalTypes_[patchi] = patchTypes_[patchi];
926 else if (origType ==
"baffle")
931 patchPhysicalTypes_[patchi] =
"baffle";
938 Info<<
"patch " << patchi
939 <<
" (region " << origRegion[patchi]
940 <<
": " << origType <<
") type: '" << patchTypes_[patchi]
941 <<
"' name: " << patchNames_[patchi] <<
endl;
945 mapToFoamCellId_.clear();
955 label
nPoints = points_.size();
961 const faceList& faces = cellFaces_[celli];
967 oldToNew[labels[j]]++;
976 if (oldToNew[i] >= 0)
978 oldToNew[i] = pointi++;
995 for (
face&
f : faces)
1002 for (
face&
f : baffleFaces_)
1039 const scalar scaleFactor,
1040 const bool keepSolids
1044 keepSolids_(keepSolids),
1046 mapToFoamPointId_(0),
Various functions to operate on Lists.
bool found(const Key &key) const
Return true if hashed entry is found in table.
Input from file stream, using an ISstream.
bool good() const noexcept
True if next operation might succeed.
Generic input stream using a standard (STL) stream.
ISstream & get(char &c)
Raw, low-level get character function.
virtual Istream & read(token &t)
Return next token from stream.
void setSize(const label n)
Alias for resize()
A HashTable to objects of type <T> with a label key.
Generic output stream using a standard (STL) stream.
A List obtained as a section of another List.
void size(const label n)
Older name for setAddressableSize.
void readDict(const objectRegistry &, const word &name="boundaryRegion", const fileName &instance="constant")
Read constant/boundaryRegion.
Maps a geometry to a set of cell primitives.
An analytical geometric cellShape.
void readDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant")
Read constant/cellTable.
reference ref() const
A reference to the entry (Error if not found)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
Identify cell faces in terms of cell Id and face Id.
This class supports creating polyMeshes with baffles.
cellTable cellTable_
Cell table persistent data saved as a dictionary.
Registry of regIOobjects.
A token holds an item read from Istream.
bool isLabel() const noexcept
Token is LABEL.
label labelToken() const
Return label value.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
void inplaceLower(std::string &s)
Inplace transform string with std::tolower on each character.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
List< label > labelList
A List of labels.
static void readToNewline(ISstream &is)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
static const char *const typeName
The type name used in ensight case files.