34 const char* Foam::meshWriters::STARCD::defaultBoundaryName =
35 "Default_Boundary_Region";
40 { 0, 1, 4, 5, 2, -1 },
41 { 5, 4, 2, 0, -1, -1 },
48 Foam::label Foam::meshWriters::STARCD::findDefaultBoundary()
const 57 if (defaultBoundaryName == patches[
patchi].
name())
67 void Foam::meshWriters::STARCD::getCellTable()
84 bool useCellZones =
false;
88 if (ioList.headerOk())
96 Info<<
"no cellTable information available" <<
endl;
102 << ioList.objectPath() <<
" has incorrect number of cells " 103 <<
" - use cellZone information" 120 Info<<
"created cellTable from cellZones" <<
endl;
128 Info<<
"matching cellZones to cellTable" <<
endl;
135 nUnzoned -= cZone.
size();
142 dict.add(
"Label", cZone.name());
143 dict.add(
"MaterialType",
"fluid");
158 dict.add(
"Label",
"__unZonedCells__");
159 dict.add(
"MaterialType",
"fluid");
174 void Foam::meshWriters::STARCD::writeHeader(Ostream& os,
const char* filetype)
176 os <<
"PROSTAR_" << filetype <<
nl 189 void Foam::meshWriters::STARCD::writePoints(
const fileName& prefix)
const 191 OFstream os(prefix +
".vrt");
192 writeHeader(os,
"VERTEX");
198 os.setf(std::ios::showpoint);
202 Info<<
"Writing " << os.name() <<
" : " 203 << points.size() <<
" points" <<
endl;
219 void Foam::meshWriters::STARCD::writeCells(
const fileName& prefix)
const 221 OFstream os(prefix +
".cel");
222 writeHeader(os,
"CELL");
226 Map<label> shapeLookupIndex;
237 Info<<
"Writing " << os.name() <<
" : " 238 << cells.size() <<
" cells" <<
endl;
243 label materialType = 1;
247 if (dict.found(
"MaterialType"))
250 dict.lookup(
"MaterialType") >> matType;
251 if (matType ==
"solid")
259 const cellShape& shape = shapes[
cellId];
260 label mapIndex = shape.model().index();
263 if (shapeLookupIndex.found(mapIndex))
265 label shapeId = shapeLookupIndex[mapIndex];
270 <<
" " << vrtList.
size()
272 <<
" " << materialType;
279 if ((count % 8) == 0)
282 <<
" " << cellId + 1;
284 os <<
" " << vrtList[i] + 1;
296 List<label> indices(cFaces.size() + 1);
297 indices[0] = indices.
size();
299 label count = indices.size();
303 count += faces[cFaces[facei]].size();
304 indices[facei+1] = count;
311 <<
" " << materialType;
318 if ((count % 8) == 0)
321 <<
" " << cellId + 1;
323 os <<
" " << indices[i];
330 label meshFace = cFaces[facei];
333 if (owner[meshFace] == cellId)
339 f = faces[meshFace].reverseFace();
344 if ((count % 8) == 0)
347 <<
" " << cellId + 1;
350 os <<
" " << f[i] + 1;
361 void Foam::meshWriters::STARCD::writeBoundary(
const fileName& prefix)
const 363 OFstream os(prefix +
".bnd");
364 writeHeader(os,
"BOUNDARY");
375 Map<label> faceLookupIndex;
381 Info<<
"Writing " << os.name() <<
" : " 382 << (
mesh_.
nFaces() - patches[0].start()) <<
" boundaries" << endl;
385 label defaultId = findDefaultBoundary();
394 if (regionId == defaultId)
398 else if (defaultId == -1 || regionId < defaultId)
409 label facei = patchStart;
410 facei < (patchStart + patchSize);
414 label cellId = owner[facei];
416 const cellShape& shape = shapes[
cellId];
430 label mapIndex = shape.model().index();
433 if (faceLookupIndex.found(mapIndex))
435 const faceList sFaces = shape.faces();
438 if (faces[facei] == sFaces[sFacei])
445 mapIndex = faceLookupIndex[mapIndex];
455 <<
" " << cellFaceId + 1
458 <<
" " << bndType.c_str()
467 Foam::meshWriters::STARCD::STARCD
470 const scalar scaleFactor
491 rm(baseName +
".vrt");
492 rm(baseName +
".cel");
493 rm(baseName +
".bnd");
494 rm(baseName +
".inp");
502 if (baseName.empty())
517 writePoints(baseName);
518 writeCells(baseName);
522 writeBoundary(baseName);
const Time & time() const
Return time.
label append(const dictionary &)
Append to the end, return index.
write OpenFOAM meshes and/or results to another CFD format
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.
static const cellModel * tetModel
void rmFiles(const fileName &baseName) const
Remove STAR-CD files for the baseName.
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.
boundaryRegion boundaryRegion_
boundaryRegion persistent data saved as a dictionary
Ostream & endl(Ostream &os)
Add newline and flush stream.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
const cellList & cells() const
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
const cellShapeList & cellShapes() const
Return cell shapes.
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
word boundaryType(const word &name) const
Return BoundaryType corresponding to patch 'name'.
const word & constant() const
Return constant name.
List< label > labelList
A List of labels.
scalar scaleFactor_
Scaling factor for points (eg, [m] -> [mm])
bool empty() const
Return true if the hash table is empty.
bool found(const Key &) const
Return true if hashedEntry is found in table.
labelList cellTableId_
cellTable IDs for each cell
label findIndex(const word &name) const
Return index corresponding to name.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
void readDict(const objectRegistry &, const word &name="boundaryRegion", const fileName &instance="constant")
Read constant/boundaryRegion.
void setSize(const label)
Reset size of List.
const cellZoneMesh & cellZones() const
Return cell zone mesh.
#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.
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
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
label index() const
Return index of model in the model list.
const polyMesh & mesh_
Mesh reference.
label size() const
Return the number of elements in the UPtrList.
virtual bool write(const fileName &meshName=fileName::null) const
Write volume mesh.