6 <<
"Cannot open file " << kivaFileName
10 Info <<
"Reading kiva grid from file " << kivaFileName <<
endl;
31 if (kivaVersion == kiva3v)
50 scalar
ff, fbcl, fbcf, fbcb;
53 >> i1 >> i3 >>
i4 >> i8
54 >>
ff >> fbcl >> fbcf >> fbcb
80 <<
"mTable == 0. This is not supported." 81 " kivaToFoam needs complete neighbour information" 99 Info <<
"Finished reading KIVA file" <<
endl;
107 label activeCells = 0;
118 for (label i=0; i<
nPoints; i++)
123 hexLabels[1] =
i1tab[i];
125 hexLabels[3] =
i3tab[i];
126 hexLabels[4] =
i8tab[i];
139 label start = pointMap[edges[ei].start()];
140 while (start != pointMap[start])
142 start = pointMap[start];
145 label
end = pointMap[edges[ei].end()];
146 while (
end != pointMap[
end])
151 label minLabel =
min(start,
end);
153 pointMap[start] = pointMap[
end] = minLabel;
158 cellZoning[activeCells] =
idreg[i];
166 cellZoning.setSize(activeCells);
176 cs[i] = pointMap[cs[i]];
182 label bcIDs[11] = {-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};
184 const label nBCs = 12;
186 const word* kivaPatchTypes[nBCs] =
188 &wallPolyPatch::typeName,
189 &wallPolyPatch::typeName,
190 &wallPolyPatch::typeName,
191 &wallPolyPatch::typeName,
192 &symmetryPolyPatch::typeName,
193 &wedgePolyPatch::typeName,
194 &polyPatch::typeName,
195 &polyPatch::typeName,
196 &polyPatch::typeName,
197 &polyPatch::typeName,
198 &symmetryPolyPatch::typeName,
199 &oldCyclicPolyPatch::typeName
218 const char* kivaPatchNames[nBCs] =
240 for (label i=0; i<
nPoints; i++)
323 &&
pFaces[LINER][0].size()
324 &&
pFaces[CYLINDERHEAD].size()
325 &&
pFaces[CYLINDERHEAD][0].size()
330 for (
const face& pf :
pFaces[CYLINDERHEAD][0])
340 SLList<face> newLinerFaces;
342 for (
const face& pf :
pFaces[LINER][0])
344 scalar minfz = GREAT;
352 pFaces[CYLINDERHEAD][0].append(pf);
356 newLinerFaces.append(pf);
360 if (
pFaces[LINER][0].size() != newLinerFaces.size())
362 Info<<
"Transferred " <<
pFaces[LINER][0].size() - newLinerFaces.size()
363 <<
" faces from liner region to cylinder head" <<
endl;
364 pFaces[LINER][0] = newLinerFaces;
367 SLList<face> newCylinderHeadFaces;
369 for (
const face& pf :
pFaces[CYLINDERHEAD][0])
371 scalar minfz = GREAT;
377 if (minfz < zHeadMin)
379 pFaces[LINER][0].append(pf);
383 newCylinderHeadFaces.append(pf);
387 if (
pFaces[CYLINDERHEAD][0].size() != newCylinderHeadFaces.size())
389 Info<<
"Transferred faces from cylinder-head region to linder" <<
endl;
390 pFaces[CYLINDERHEAD][0] = newCylinderHeadFaces;
397 for (
int bci=0; bci<nBCs; bci++)
401 if (
pFaces[bci][rgi].size())
418 auto iterf =
pFaces[WEDGE][0].begin();
419 auto iterb =
pFaces[WEDGE][1].begin();
424 iterf.good() && iterb.good();
430 points[iterf()[d]].y() = -tanTheta*
points[iterf()[d]].x();
431 points[iterb()[d]].y() = tanTheta*
points[iterb()[d]].x();
437 pFaces[CYCLIC].setSize(1);
439 for (
const face& pf :
pFaces[WEDGE][1])
441 pFaces[CYCLIC][0].append(pf);
460 for (
int bci=0; bci<nBCs; bci++)
464 if (
pFaces[bci][rgi].size())
470 if (
pFaces[bci].size() > 1)
537 polyMesh::meshSubDir,
559 polyMesh::defaultRegion,
573 IOstream::minPrecision(10);
581 runTime.path()/
runTime.constant()/polyMesh::defaultRegion/
"cellZoning" 583 Info <<
"Writing cell zoning info to file: " << czPath <<
endl;
586 cz << cellZoning <<
endl;
List< faceList > faceListList
List of faceList.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
labelList pointLabels(nPoints, -1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
IOstream & hex(IOstream &io)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
wordList patchTypes(nPatches)
labelList idface(nPoints)
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< cellShape > cellShapeList
List of cellShape.
preservePatchTypes(runTime, runTime.constant(), polyMesh::meshSubDir, patchNames, patchDicts, defaultFacesName, defaultFacesType)
polyMesh pShapeMesh(IOobject(polyMesh::defaultRegion, runTime.constant(), runTime), std::move(points), cellShapes, boundary, patchNames, patchDicts, defaultFacesName, defaultFacesType)
std::ifstream kivaFile(kivaFileName)
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
wordList patchNames(nPatches)
faceListList boundary(nPatches)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
forAll(cellShapes, celli)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
List< word > wordList
List of word.
pointField points(nPoints)
Info<< "Reading kiva grid from file "<< kivaFileName<< endl;char title[120];kivaFile.getline(title, 120, '\n');label nPoints, nCells, nRegs;kivaFile > nCells nPoints nRegs
messageStream Info
Information stream (stdout output on master, null elsewhere)
PtrList< dictionary > patchDicts
List< label > labelList
A List of labels.
dimensionedScalar tan(const dimensionedScalar &ds)
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)