33 const char* Foam::meshWriters::STARCD::defaultBoundaryName =
34 "Default_Boundary_Region";
39 { 0, 1, 4, 5, 2, -1 },
40 { 5, 4, 2, 0, -1, -1 },
47 Foam::label Foam::meshWriters::STARCD::findDefaultBoundary()
const 56 if (defaultBoundaryName == patches[
patchi].
name())
66 void Foam::meshWriters::STARCD::getCellTable()
83 bool useCellZones =
false;
87 if (ioList.headerOk())
95 Info<<
"no cellTable information available" <<
endl;
101 << ioList.objectPath() <<
" has incorrect number of cells " 102 <<
" - use cellZone information" 119 Info<<
"created cellTable from cellZones" <<
endl;
127 Info<<
"matching cellZones to cellTable" <<
endl;
134 nUnzoned -= cZone.
size();
141 dict.add(
"Label", cZone.name());
142 dict.add(
"MaterialType",
"fluid");
157 dict.add(
"Label",
"__unZonedCells__");
158 dict.add(
"MaterialType",
"fluid");
173 void Foam::meshWriters::STARCD::writeHeader(Ostream& os,
const char* filetype)
175 os <<
"PROSTAR_" << filetype <<
nl 188 void Foam::meshWriters::STARCD::writePoints(
const fileName& prefix)
const 190 OFstream os(prefix +
".vrt");
191 writeHeader(os,
"VERTEX");
197 os.setf(std::ios::showpoint);
201 Info<<
"Writing " << os.name() <<
" : " 202 << points.size() <<
" points" <<
endl;
218 void Foam::meshWriters::STARCD::writeCells(
const fileName& prefix)
const 220 OFstream os(prefix +
".cel");
221 writeHeader(os,
"CELL");
225 Map<label> shapeLookupIndex;
236 Info<<
"Writing " << os.name() <<
" : " 237 << cells.size() <<
" cells" <<
endl;
242 label materialType = 1;
246 if (dict.found(
"MaterialType"))
249 dict.lookup(
"MaterialType") >> matType;
250 if (matType ==
"solid")
258 const cellShape& shape = shapes[
cellId];
259 label mapIndex = shape.model().index();
262 if (shapeLookupIndex.found(mapIndex))
264 label shapeId = shapeLookupIndex[mapIndex];
269 <<
" " << vrtList.
size()
271 <<
" " << materialType;
278 if ((count % 8) == 0)
281 <<
" " << cellId + 1;
283 os <<
" " << vrtList[i] + 1;
295 List<label> indices(cFaces.size() + 1);
296 indices[0] = indices.
size();
298 label count = indices.size();
302 count += faces[cFaces[facei]].size();
303 indices[facei+1] =
count;
310 <<
" " << materialType;
317 if ((count % 8) == 0)
320 <<
" " << cellId + 1;
322 os <<
" " << indices[i];
329 label meshFace = cFaces[facei];
332 if (owner[meshFace] == cellId)
338 f = faces[meshFace].reverseFace();
343 if ((count % 8) == 0)
346 <<
" " << cellId + 1;
349 os <<
" " << f[i] + 1;
360 void Foam::meshWriters::STARCD::writeBoundary(
const fileName& prefix)
const 362 OFstream os(prefix +
".bnd");
363 writeHeader(os,
"BOUNDARY");
374 Map<label> faceLookupIndex;
380 Info<<
"Writing " << os.name() <<
" : " 381 << (
mesh_.
nFaces() - patches[0].start()) <<
" boundaries" << endl;
384 label defaultId = findDefaultBoundary();
393 if (regionId == defaultId)
397 else if (defaultId == -1 || regionId < defaultId)
408 label facei = patchStart;
409 facei < (patchStart + patchSize);
413 label cellId = owner[facei];
415 const cellShape& shape = shapes[
cellId];
429 label mapIndex = shape.model().index();
432 if (faceLookupIndex.found(mapIndex))
434 const faceList sFaces = shape.faces();
437 if (faces[facei] == sFaces[sFacei])
444 mapIndex = faceLookupIndex[mapIndex];
454 <<
" " << cellFaceId + 1
457 <<
" " << bndType.c_str()
469 const scalar scaleFactor
490 rm(baseName +
".vrt");
491 rm(baseName +
".cel");
492 rm(baseName +
".bnd");
493 rm(baseName +
".inp");
501 if (baseName.empty())
516 writePoints(baseName);
517 writeCells(baseName);
521 writeBoundary(baseName);
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
label append(const dictionary &)
Append to the end, return index.
static string defaultMeshName
Specify a default mesh name.
static const label foamToStarFaceAddr[4][6]
Face addressing from OpenFOAM faces -> pro-STAR faces.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
virtual bool write(const fileName &meshName=fileName::null) const
Write volume mesh.
const meshCellZones & cellZones() const
Return cell zones.
static const cellModel * tetModel
static const cellModel * prismModel
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
bool writeBoundary_
Write bnd file.
void size(const label)
Override size to be inconsistent with allocated storage.
const cellShapeList & cellShapes() const
Return cell shapes.
boundaryRegion boundaryRegion_
boundaryRegion persistent data saved as a dictionary
bool empty() const
Return true if the hash table is empty.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
const cellList & cells() const
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
virtual const pointField & points() const
Return raw points.
STARCD(const polyMesh &, const scalar scaleFactor=1.0)
Open a file for writing.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
void readDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant")
Read constant/cellTable.
vectorField pointField
pointField is a vectorField.
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
static const cellModel * pyrModel
bool found(const Key &) const
Return true if hashedEntry is found in table.
const word & constant() const
Return constant name.
virtual const labelList & faceOwner() const
Return face owner.
List< label > labelList
A List of labels.
virtual const faceList & faces() const
Return raw faces.
scalar scaleFactor_
Scaling factor for points (eg, [m] -> [mm])
labelList cellTableId_
cellTable IDs for each cell
word boundaryType(const word &name) const
Return BoundaryType corresponding to patch 'name'.
const Time & time() const
Return time.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
label index() const
Return index of model in the model list.
void readDict(const objectRegistry &, const word &name="boundaryRegion", const fileName &instance="constant")
Read constant/boundaryRegion.
label size() const
Return the number of elements in the UPtrList.
void rmFiles(const fileName &baseName) const
Remove STAR-CD files for the baseName.
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual ~STARCD()
Destructor.
static const cellModel * hexModel
Mesh consisting of general polyhedral cells.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
meshWriter(const polyMesh &, const scalar scaleFactor=1.0)
Create a writer object.
label findIndex(const word &name) const
Return index corresponding to name.
cellTable cellTable_
cellTable persistent data saved as a dictionary
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
List< cell > cellList
list of cells
const polyMesh & mesh_
Mesh reference.