35 Foam::label Foam::fileFormats::STARCDMeshWriter::findDefaultBoundary()
const
53 void Foam::fileFormats::STARCDMeshWriter::getCellTable()
61 mesh_.time().constant(),
70 bool useCellZones =
false;
71 cellTableId_.setSize(mesh_.nCells(), -1);
74 if (ioList.headerOk())
76 if (ioList.size() == mesh_.nCells())
78 cellTableId_.transfer(ioList);
80 if (cellTable_.empty())
82 Info<<
"no cellTable information available" <<
endl;
88 << ioList.objectPath() <<
" has incorrect number of cells "
89 <<
" - use cellZone information"
104 if (cellTable_.empty())
106 Info<<
"created cellTable from cellZones" <<
endl;
111 label nUnzoned = mesh_.nCells();
114 Info<<
"matching cellZones to cellTable" <<
endl;
116 for (
const cellZone& cZone : mesh_.cellZones())
120 nUnzoned -= cZone.size();
122 label tableId = cellTable_.findIndex(cZone.name());
127 dict.add(
"Label", cZone.name());
128 dict.add(
"MaterialType",
"fluid");
129 tableId = cellTable_.append(
dict);
132 for (
const label celli : cZone)
134 cellTableId_[celli] = tableId;
143 dict.add(
"Label",
"__unZonedCells__");
144 dict.add(
"MaterialType",
"fluid");
145 const label tableId = cellTable_.append(
dict);
149 if (cellTableId_[i] < 0)
151 cellTableId_[i] = tableId;
159 void Foam::fileFormats::STARCDMeshWriter::writeCells
161 const fileName& prefix
170 const Map<label> shapeLookupIndex
180 const faceList& faces = mesh_.faces();
181 const labelList& owner = mesh_.faceOwner();
183 Info<<
"Writing " <<
os.name() <<
" : "
188 const label tableId = cellTableId_[
cellId];
190 if (cellTable_.found(tableId))
192 const dictionary&
dict = cellTable_[tableId];
197 dict.readIfPresent(
"MaterialType", matType)
198 && matType ==
"solid"
205 const cellShape& shape = shapes[
cellId];
206 const label mapIndex = shape.model().index();
209 if (shapeLookupIndex.found(mapIndex))
211 const label shapeId = shapeLookupIndex[mapIndex];
216 <<
' ' << vrtList.size()
218 <<
' ' << materialType;
223 for (
const label pointi : vrtList)
225 if ((
count % 8) == 0)
230 os <<
' ' << pointi + 1;
242 List<label> indices(cFaces.size() + 1);
243 indices[0] = indices.size();
245 label
count = indices.size();
249 count += faces[cFaces[facei]].size();
250 indices[facei+1] =
count;
257 <<
' ' << materialType;
262 for (
const label pointi : indices)
264 if ((
count % 8) == 0)
274 for (
const label meshFace : cFaces)
278 if (owner[meshFace] ==
cellId)
284 f = faces[meshFace].reverseFace();
287 for (
const label pointi :
f)
289 if ((
count % 8) == 0)
295 os <<
' ' << pointi + 1;
306 void Foam::fileFormats::STARCDMeshWriter::writeBoundary
308 const fileName& prefix
316 const faceList& faces = mesh_.faces();
317 const labelList& owner = mesh_.faceOwner();
318 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
324 const Map<label> shapeLookupIndex =
332 Info<<
"Writing " <<
os.name() <<
" : "
333 << (mesh_.nFaces() -
patches[0].start()) <<
" boundaries" <<
endl;
336 const label defaultId = findDefaultBoundary();
344 label regionId = patchi;
345 if (regionId == defaultId)
349 else if (defaultId == -1 || regionId < defaultId)
354 label patchStart =
patches[patchi].start();
355 label patchSize =
patches[patchi].size();
356 word bndType = boundaryRegion_.boundaryType(
patches[patchi].
name());
360 label facei = patchStart;
361 facei < (patchStart + patchSize);
365 label
cellId = owner[facei];
367 const cellShape& shape = shapes[
cellId];
368 label cellFaceId = cFaces.find(facei);
381 label mapIndex = shape.model().index();
384 if (shapeLookupIndex.found(mapIndex))
386 const faceList sFaces = shape.faces();
389 if (faces[facei] == sFaces[sFacei])
396 mapIndex = shapeLookupIndex[mapIndex];
407 <<
' ' << cellFaceId + 1
410 <<
' ' << bndType.c_str()
419 Foam::fileFormats::STARCDMeshWriter::STARCDMeshWriter
422 const scalar scaleFactor,
423 const bool writeBndFile
427 writeBoundary_(writeBndFile)
441 if (baseName.empty())
447 mesh_.time().timeName() !=
"0"
448 && mesh_.time().timeName() != mesh_.time().constant()
451 baseName +=
"_" + mesh_.time().timeName();
464 Info<<
"Writing " <<
os.name() <<
" : "
465 << mesh_.nPoints() <<
" points" <<
endl;
467 writePoints(
os, mesh_.points(), scaleFactor_);
471 writeCells(baseName);
476 writeBoundary(baseName);