39 "Default_Boundary_Region";
42 "Default_Boundary_Solid";
49 { 0, 1, 4, -1, 2, 3 },
50 { 3, -1, 2, -1, 1, 0 },
64 while ((is) && ch !=
'\n');
86 if (header != fileSignature)
88 Info<<
"header mismatch " << fileSignature <<
" " << is.
name()
98 boundaryRegion_.readDict(registry);
99 cellTable_.readDict(registry);
119 const scalar scaleFactor
122 const word fileSignature =
"PROSTAR_VERTEX";
129 readHeader(is, fileSignature);
134 while ((is >> lineLabel).good())
137 maxId =
max(maxId, lineLabel);
147 mapToFoamPointId_.setSize(maxId+1);
154 mapToFoamPointId_ = -1;
162 readHeader(is, fileSignature);
167 while ((is >> lineLabel).good())
169 is >> points_[pointi].x()
170 >> points_[pointi].y()
171 >> points_[pointi].z();
175 mapToFoamPointId_[lineLabel] = pointi;
187 if (scaleFactor > 1.0 + small || scaleFactor < 1.0 - small)
189 points_ *= scaleFactor;
195 <<
"no points in file " << inputName
244 const word fileSignature =
"PROSTAR_CELL";
245 label nFluids = 0, nSolids = 0, nBaffles = 0, nShells = 0;
248 bool unknownVertices =
false;
256 readHeader(is, fileSignature);
258 label lineLabel, shapeId, nLabels, cellTableId, typeId;
260 while ((is >> lineLabel).good())
262 label starCellId = lineLabel;
278 if (typeId == starcdFluidType)
281 maxId =
max(maxId, starCellId);
283 if (!cellTable_.found(cellTableId))
285 cellTable_.setName(cellTableId);
286 cellTable_.setMaterial(cellTableId,
"fluid");
289 else if (typeId == starcdSolidType)
294 maxId =
max(maxId, starCellId);
297 if (!cellTable_.found(cellTableId))
299 cellTable_.setName(cellTableId);
300 cellTable_.setMaterial(cellTableId,
"solid");
304 else if (typeId == starcdBaffleType)
308 maxId =
max(maxId, starCellId);
310 else if (typeId == starcdShellType)
313 if (!cellTable_.found(cellTableId))
315 cellTable_.setName(cellTableId);
316 cellTable_.setMaterial(cellTableId,
"shell");
323 Info<<
"Number of fluids = " << nFluids <<
nl
324 <<
"Number of baffles = " << nBaffles <<
nl;
327 Info<<
"Number of solids = " << nSolids <<
nl;
331 Info<<
"Ignored solids = " << nSolids <<
nl;
333 Info<<
"Ignored shells = " << nShells <<
endl;
339 nCells = nFluids + nSolids;
346 cellFaces_.setSize(nCells);
347 cellShapes_.setSize(nCells);
348 cellTableId_.setSize(nCells);
351 baffleFaces_.setSize(nBaffles);
354 origCellId_.setSize(nCells + nBaffles);
355 mapToFoamCellId_.setSize(maxId+1);
356 mapToFoamCellId_ = -1;
367 <<
"no cells in file " << inputName
373 readHeader(is, fileSignature);
376 label lineLabel, shapeId, nLabels, cellTableId, typeId;
381 while ((is >> lineLabel).good())
383 label starCellId = lineLabel;
389 if (nLabels > starLabels.
size())
396 for (
label i = 0; i < nLabels; ++i)
406 if (typeId == starcdSolidType && !keepSolids)
418 curModelPtr = hexModel;
421 curModelPtr = prismModel;
424 curModelPtr = tetModel;
427 curModelPtr = pyrModel;
437 for (
label i=0; i < nLabels; ++i)
439 label pointId = mapToFoamPointId_[starLabels[i]];
442 Info<<
"Cells inconsistent with vertex file. "
443 <<
"Star vertex " << starLabels[i]
444 <<
" does not exist" <<
endl;
446 unknownVertices =
true;
448 starLabels[i] = pointId;
457 origCellId_[celli] = starCellId;
458 mapToFoamCellId_[starCellId] = celli;
460 cellTableId_[celli] = cellTableId;
467 cellFaces_[celli] = cellShapes_[celli].faces();
470 else if (shapeId == starcdPoly)
473 label nFaces = starLabels[0] - 1;
478 for (
label i=starLabels[0]; i < nLabels; ++i)
480 label pointId = mapToFoamPointId_[starLabels[i]];
483 Info<<
"Cells inconsistent with vertex file. "
484 <<
"Star vertex " << starLabels[i]
485 <<
" does not exist" <<
endl;
487 unknownVertices =
true;
489 starLabels[i] = pointId;
500 for (
label i=0; i < nFaces; ++i)
502 label beg = starLabels[i];
503 label n = starLabels[i+1] - beg;
521 Info<<
"star cell " << starCellId <<
" has "
523 <<
" empty faces - could cause boundary "
524 <<
"addressing problems"
534 <<
"star cell " << starCellId <<
" has " << nFaces
539 origCellId_[celli] = starCellId;
540 mapToFoamCellId_[starCellId] = celli;
542 cellTableId_[celli] = cellTableId;
543 cellShapes_[celli] = genericShape;
544 cellFaces_[celli] = faces;
547 else if (typeId == starcdBaffleType)
553 for (
label i=0; i < nLabels; ++i)
555 label pointId = mapToFoamPointId_[starLabels[i]];
558 Info<<
"Baffles inconsistent with vertex file. "
559 <<
"Star vertex " << starLabels[i]
560 <<
" does not exist" <<
endl;
562 unknownVertices =
true;
564 starLabels[i] = pointId;
583 baffleFaces_[baffleI] =
f;
585 mapToFoamCellId_[starCellId] = nCells + baffleI;
586 origCellId_[nCells + baffleI] = starCellId;
592 baffleFaces_.setSize(baffleI);
598 <<
"cells with unknown vertices"
609 mapToFoamPointId_.clear();
635 const word fileSignature =
"PROSTAR_BOUNDARY";
637 label lineLabel, starCellId, cellFaceId, starRegion, configNumber;
643 patchTypes_.setSize(1000);
650 faceLookupIndex.
insert(hexModel->index(), 0);
651 faceLookupIndex.
insert(prismModel->index(), 1);
652 faceLookupIndex.
insert(tetModel->index(), 2);
653 faceLookupIndex.
insert(pyrModel->index(), 3);
671 readHeader(is, fileSignature);
673 while ((is >> lineLabel).good())
682 label patchLabel = mapToFoamPatchId[starRegion];
683 if (patchLabel == -1)
686 mapToFoamPatchId[starRegion] = patchLabel;
687 origRegion[patchLabel] = starRegion;
688 patchTypes_[patchLabel] = patchType;
690 maxId =
max(maxId, starRegion);
693 if (patchType ==
"BAFF")
700 nPatchFaces[patchLabel]++;
705 Info<<
"No boundary faces in file " << inputName <<
endl;
710 Info<<
"Could not read boundary file " << inputName <<
endl;
717 <<
" (including extra for missing)" <<
endl;
734 bool foundName =
false, foundType =
false;
737 iter = boundaryRegion_.
find(origRegion[
patchi]);
741 iter != boundaryRegion_.
end()
744 foundType = iter().readIfPresent
750 foundName = iter().readIfPresent
766 if (patchTypes_[
patchi] ==
"symp")
768 patchTypes_[
patchi] =
"symplane";
770 else if (patchTypes_[
patchi] ==
"cycl")
772 patchTypes_[
patchi] =
"cyclic";
774 else if (patchTypes_[
patchi] ==
"baff")
776 patchTypes_[
patchi] =
"baffle";
778 else if (patchTypes_[
patchi] ==
"moni")
780 patchTypes_[
patchi] =
"monitoring";
793 patchNames_[
nPatches-1] = defaultBoundaryName;
804 oldToNew[sortedIndices[i]] = i;
821 for (
label i=0; i < oldToNew.
size()-1; ++i)
823 if (patchTypes_[i] ==
"baffle")
825 oldToNew[i] = baffleIndex++;
829 oldToNew[i] = newIndex++;
839 mapToFoamPatchId.
setSize(maxId+1, -1);
855 if (
nPatches > 1 && mapToFoamCellId_.size() > 1)
858 readHeader(is, fileSignature);
860 while ((is >> lineLabel).good())
877 if (starCellId < mapToFoamCellId_.size())
879 cellId = mapToFoamCellId_[starCellId];
885 <<
"Boundaries inconsistent with cell file. "
886 <<
"Star cell " << starCellId <<
" does not exist"
892 if (
cellId < cellShapes_.size())
895 if (faceLookupIndex.
found(index))
897 index = faceLookupIndex[index];
898 cellFaceId = starToFoamFaceAddr[index][cellFaceId];
911 #ifdef DEBUG_BOUNDARY
921 patchPhysicalTypes_.setSize(patchTypes_.size());
933 patchPhysicalTypes_[
patchi] = origType;
935 if (origType ==
"symplane")
937 patchTypes_[
patchi] = symmetryPolyPatch::typeName;
940 else if (origType ==
"wall")
942 patchTypes_[
patchi] = wallPolyPatch::typeName;
945 else if (origType ==
"cyclic")
947 patchTypes_[
patchi] = mergedCyclicPolyPatch::typeName;
950 else if (origType ==
"baffle")
952 patchTypes_[
patchi] = mergedCyclicPolyPatch::typeName;
953 patchPhysicalTypes_[
patchi] =
"baffle";
957 patchTypes_[
patchi] = polyPatch::typeName;
961 <<
" (region " << origRegion[
patchi]
962 <<
": " << origType <<
") type: '" << patchTypes_[
patchi]
967 mapToFoamCellId_.clear();
983 const faceList& faces = cellFaces_[celli];
989 oldToNew[labels[j]]++;
998 if (oldToNew[i] >= 0)
1000 oldToNew[i] = pointi++;
1015 forAll(cellFaces_, celli)
1017 faceList& faces = cellFaces_[celli];
1025 forAll(baffleFaces_, facei)
1037 readPoints(geometryFile_ +
".vrt", scaleFactor);
1038 readCells(geometryFile_ +
".cel");
1040 readBoundary(geometryFile_ +
".bnd");
1052 const scalar scaleFactor
1057 mapToFoamPointId_(0),
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
bool found(const Key &) const
Return true if hashedEntry is found in table.
const fileName & name() const
Return the name of the stream.
bool good() const
Return true if next operation might succeed.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
A List obtained as a section of another List.
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
An analytical geometric cellShape.
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.
static const int starToFoamFaceAddr[4][6]
Face addressing from pro-STAR faces -> OpenFOAM faces.
STARCD(const fileName &prefix, const objectRegistry &, const scalar scaleFactor=1.0)
Construct from case name.
virtual ~STARCD()
Destructor.
static bool readHeader(IFstream &, word fileSignature)
Read header.
static bool keepSolids
Keep solids (default false)
virtual bool readGeometry(const scalar scaleFactor=1.0)
Read the mesh from the file(s)
void cullPoints()
Remove unused points.
static const char *const defaultBoundaryName
void readBoundary(const fileName &)
Read boundary (cell/face) definitions.
void readPoints(const fileName &, const scalar scaleFactor)
Read points from file.
virtual void readCells(const fileName &)
Read cell connectivities from file.
static const char *const defaultSolidBoundaryName
static void readToNewline(IFstream &)
Read and discard to newline.
void readAux(const objectRegistry &)
Read auxiliary data from constant/{boundaryRegion,cellTable}.
Registry of regIOobjects.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< label > labelList
A List of labels.
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.
errorManip< error > abort(error &err)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable