34 Foam::label Foam::ccm::writer::prostarCellFaceId
44 label cellFaceId = cFaces.
find(faceI);
45 label mapIndex = shape.model().index();
49 Info<<
" face[" << faceI <<
"]: " << faces[faceI] <<
nl 51 <<
" cellFace: " << cellFaceId
52 <<
" cellFaces: " << cFaces
53 <<
" shape [index " << mapIndex <<
"] " << shape
59 Info<<
" face [" << cFaces[cFaceI] <<
"] = " 60 << faces[cFaces[cFaceI]] <<
nl;
63 Info <<
"shapeFaces" <<
nl;
65 const faceList sFaces = shape.faces();
68 Info<<
" sFace[" << sFaceI <<
"] = " 69 << sFaces[sFaceI] <<
nl;
79 if (prostarShapeLookup_.
found(mapIndex))
81 const faceList sFaces = shape.faces();
84 if (faces[faceI] == sFaces[sFaceI])
90 Info <<
" FoamCellFace: " << sFaceI;
97 mapIndex = prostarShapeLookup_[mapIndex];
98 cellFaceId = STARCDCore::foamToStarFaceAddr[mapIndex][cellFaceId];
102 Info<<
" ProstarShape: " << mapIndex
103 <<
" ProstarFaceId: " << cellFaceId + 1
109 return cellFaceId + 1;
114 void Foam::ccm::writer::writeFaces
123 if (globalState_->hasError() || size <= 0)
128 CCMIOEntity nodeType;
131 nodeType = kCCMIOBoundaryFaces;
135 nodeType = kCCMIOInternalFaces;
138 const faceList& faces = mesh_.faces();
139 const labelList& owner = mesh_.faceOwner();
140 const labelList& neigh = mesh_.faceNeighbour();
145 label streamSize = size;
146 for (label faceI = 0; faceI < size; ++faceI)
148 streamSize += faces[faceI + start].
size();
152 List<int> ccmStream(streamSize);
154 for (label faceI = 0; faceI < size; ++faceI)
156 const labelList& vrtList = faces[faceI + start];
158 ccmStream[streamSize++] = vrtList.
size();
161 ccmStream[streamSize++] = vrtList[i] + 1;
167 Info<<
"CCMIOWriteFaces() size:" << size <<
" streamSize:" 168 << streamSize <<
endl;
173 &(globalState_->error),
183 if (globalState_->hasError())
192 if (ccmStream.size() < streamSize)
194 ccmStream.setSize(streamSize);
197 for (
int faceI = 0; faceI < size; ++faceI)
199 ccmStream[faceI] = owner[faceI + start] + 1;
205 streamSize = 2 * size;
206 if (ccmStream.size() < streamSize)
208 ccmStream.setSize(streamSize);
211 for (
int faceI = 0; faceI < size; ++faceI)
213 ccmStream[faceI*2] = owner[faceI + start] + 1;
214 ccmStream[faceI*2+1] = neigh[faceI + start] + 1;
220 Info<<
"CCMIOWriteFaceCells() size:" << size;
234 &(globalState_->error),
247 if (ccmStream.size() < streamSize)
249 ccmStream.setSize(streamSize);
252 for (
int faceIdx = 0; faceIdx < size; ++faceIdx)
254 label faceI = faceIdx + start;
256 ccmStream[faceIdx] = prostarCellFaceId(owner[faceI], faceI);
261 &(globalState_->error),
273 streamSize = 2 * size;
274 if (ccmStream.size() < streamSize)
276 ccmStream.setSize(streamSize);
279 for (
int faceIdx = 0; faceIdx < size; ++faceIdx)
281 label faceI = faceIdx + start;
282 ccmStream[faceIdx*2] = prostarCellFaceId(owner[faceI], faceI);
283 ccmStream[faceIdx*2+1] = prostarCellFaceId(neigh[faceI], faceI);
288 &(globalState_->error),
305 void Foam::ccm::writer::writeVertices
307 const ccmID& verticesNode
325 const float scaling(0.001);
326 List<float> vrts(3*
pts.size());
329 vrts[3*i] = 1000.0 *
pts[i].x();
330 vrts[3*i+1] = 1000.0 *
pts[i].y();
331 vrts[3*i+2] = 1000.0 *
pts[i].z();
336 &(globalState_->error),
344 assertNoError(
"writing 'Vertices' node");
352 void Foam::ccm::writer::writeInternalFaces
354 const ccmID& topoNode
357 label nFaces = mesh_.nInternalFaces();
359 Info<<
"writing internalFaces: " << nFaces <<
endl;
365 &(globalState_->error),
371 assertNoError(
"creating internalFaces node");
376 maps_->internalFaces,
380 assertNoError(
"writing internalFaces");
387 void Foam::ccm::writer::writeBoundaryFaces
389 const ccmID& topoNode
392 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
395 Info<<
"writing boundaryFaces:" <<
flush;
397 label defaultId = findDefaultBoundary();
405 CCMIONewIndexedEntity
407 &(globalState_->error),
416 "creating boundaryFaces node patch: " +
patches[defaultId].
name()
422 maps_->boundary[defaultId],
429 "writing boundaryFaces patch: " +
patches[defaultId].
name()
438 label regionId = patchI;
439 if (regionId == defaultId)
443 else if (defaultId == -1 || regionId < defaultId)
450 if (
patches[patchI].size() > 0)
453 CCMIONewIndexedEntity
455 &(globalState_->error),
464 "creating boundaryFaces node patch: " +
patches[patchI].
name()
470 maps_->boundary[patchI],
477 "writing boundaryFaces patch: " +
patches[patchI].
name()
489 void Foam::ccm::writer::writeCells
491 const ccmID& topoNode
494 Info<<
"writing cells: " << mesh_.nCells() <<
endl;
499 List<int> mapData(mesh_.nCells(), -1);
500 bool useCellZones =
false;
517 if (ioList.headerOk())
519 if (ioList.size() == mesh_.nCells())
521 mapData.transfer(ioList);
526 << ioList.objectPath() <<
endl 527 <<
" Has incorrect number of cells: " 528 << ioList.size() <<
" instead of " << mesh_.nCells()
529 <<
" - use cellZone information instead" 544 if (!cellTable_.size())
546 Info<<
"created cellTable from cellZones" <<
endl;
551 label nUnzoned = mesh_.nCells();
554 Info<<
"matching cellZones to cellTable" <<
endl;
556 forAll(mesh_.cellZones(), zoneI)
558 const cellZone& cZone = mesh_.cellZones()[zoneI];
561 nUnzoned -= cZone.size();
563 label tableId = cellTable_.findIndex(cZone.name());
568 dict.add(
"Label", cZone.name());
569 dict.add(
"MaterialType",
"fluid");
570 tableId = cellTable_.append(
dict);
573 for (
auto id : cZone)
575 mapData[id] = tableId;
584 dict.add(
"Label",
"__unzonedCells__");
585 dict.add(
"MaterialType",
"fluid");
586 label tableId = cellTable_.append(
dict);
588 for (
auto&
id : mapData)
602 &(globalState_->error),
608 assertNoError(
"creating 'Cells' node");
612 &(globalState_->error),
616 kCCMIOStart, kCCMIOEnd
618 assertNoError(
"writing 'Cells' node");
624 label mapIndex = shapes[cellI].model().index();
627 if (prostarShapeLookup_.found(mapIndex))
629 mapData[cellI] = prostarShapeLookup_[mapIndex];
633 mapData[cellI] = STARCDCore::starcdPoly;
639 &(globalState_->error),
644 kCCMIOStart, kCCMIOEnd
648 writeInterfaces(cellsNode);
655 void Foam::ccm::writer::writeInterfaces
657 const ccmID& cellsNode
660 IOList<labelList> interfaces
674 if (interfaces.headerOk() && interfaces.size() > 0)
676 List<int> mapData(2 * interfaces.size());
680 mapData[i*2] = interfaces[i][0];
681 mapData[i*2+1] = interfaces[i][1];
689 &(globalState_->error),
699 &(globalState_->error),
704 mapData.cdata(), kCCMIOStart, kCCMIOEnd
709 assertNoError(
"writing interfaces 'FaceIds'");
726 &(globalState_->error),
727 (globalState_->root),
733 assertNoError(
"could not create default state");
754 &(globalState_->error),
760 assertNoError(
"could not create processor node");
766 nullptr, stateNode, processorNode,
787 ccmID verticesNode, topoNode;
792 &(globalState_->error),
793 (globalState_->root),
802 &(globalState_->error),
803 (globalState_->root),
811 writeVertices(verticesNode);
812 writeInternalFaces(topoNode);
813 writeBoundaryFaces(topoNode);
814 writeCells(topoNode);
815 writeProblem(stateNode);
822 &(globalState_->error),
824 nullptr, &verticesNode,
829 assertNoError(
"Error after writing geometry processor");
void size(const label n)
Older name for setAddressableSize.
bool found(const Key &key) const
Same as contains()
constexpr char nl
The newline '\n' character (0x0a)
const cellShapeList & cellShapes() const
Return cell shapes.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< cellShape > cellShapeList
List of cellShape.
const cellList & cells() const
Ignore writing from objectRegistry::writeObject()
#define forAll(list, i)
Loop across all elements in list.
List< face > faceList
List of faces.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void writeGeometry()
Write the mesh.
Reading is optional [identical to LAZY_READ].
virtual const faceList & faces() const
Return raw faces.
label find(const T &val) const
Find index of the first occurrence of the value.
int debug
Static debugging option.
Internal bits for wrapping libccmio - do not use directly.
Ostream & flush(Ostream &os)
Flush stream.
#define WarningInFunction
Report a warning using Foam::Warning.
const polyBoundaryMesh & patches
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
Do not request registration (bool: false)