6 <<
"Cannot open file " << kivaFileName
10 Info <<
"Reading kiva grid from file " << kivaFileName <<
endl;
31 if (kivaVersion == kiva3v)
48 scalar
ff, fbcl, fbcf, fbcb;
51 >> i1 >> i3 >>
i4 >> i8
52 >>
ff >> fbcl >> fbcf >> fbcb
74 <<
"mTable == 0. This is not supported."
75 " kivaToFoam needs complete neighbour information"
93 Info <<
"Finished reading KIVA file" <<
endl;
99 const cellModel&
hex = *(cellModeller::lookup(
"hex"));
101 label activeCells = 0;
117 hexLabels[1] =
i1tab[i];
119 hexLabels[3] =
i3tab[i];
120 hexLabels[4] =
i8tab[i];
133 label start = pointMap[edges[ei].start()];
134 while (start != pointMap[start])
136 start = pointMap[start];
139 label end = pointMap[edges[ei].end()];
140 while (end != pointMap[end])
147 pointMap[start] = pointMap[end] = minLabel;
152 cellZoning[activeCells] =
idreg[i];
160 cellZoning.setSize(activeCells);
170 cs[i] = pointMap[cs[i]];
176 label bcIDs[11] = {-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};
178 const label nBCs = 12;
180 const word* kivaPatchTypes[nBCs] =
182 &wallPolyPatch::typeName,
183 &wallPolyPatch::typeName,
184 &wallPolyPatch::typeName,
185 &wallPolyPatch::typeName,
186 &symmetryPolyPatch::typeName,
187 &wedgePolyPatch::typeName,
188 &polyPatch::typeName,
189 &polyPatch::typeName,
190 &polyPatch::typeName,
191 &polyPatch::typeName,
192 &symmetryPolyPatch::typeName,
193 &mergedCyclicPolyPatch::typeName
212 const char* kivaPatchNames[nBCs] =
317 &&
pFaces[LINER][0].size()
318 &&
pFaces[CYLINDERHEAD].size()
319 &&
pFaces[CYLINDERHEAD][0].size()
326 const face& pf = iter();
336 SLList<face> newLinerFaces;
340 const face& pf = iter();
342 scalar minfz = great;
350 pFaces[CYLINDERHEAD][0].append(pf);
354 newLinerFaces.append(pf);
358 if (
pFaces[LINER][0].size() != newLinerFaces.size())
360 Info<<
"Transferred " <<
pFaces[LINER][0].size() - newLinerFaces.size()
361 <<
" faces from liner region to cylinder head" <<
endl;
362 pFaces[LINER][0] = newLinerFaces;
365 SLList<face> newCylinderHeadFaces;
369 const face& pf = iter();
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 SLList<face>::iterator iterf =
pFaces[WEDGE][0].begin();
419 SLList<face>::iterator iterb =
pFaces[WEDGE][1].begin();
423 iterf !=
pFaces[WEDGE][0].end() && iterb !=
pFaces[WEDGE][1].end();
429 points[iterf()[d]].y() = -tanTheta*
points[iterf()[d]].x();
430 points[iterb()[d]].y() = tanTheta*
points[iterb()[d]].x();
436 pFaces[CYCLIC].setSize(1);
440 pFaces[CYCLIC][0].append(iterb());
459 for (
int bci=0; bci<nBCs; bci++)
463 if (
pFaces[bci][rgi].size())
469 if (
pFaces[bci].size() > 1)
536 polyMesh::meshSubDir,
558 polyMesh::defaultRegion,
579 runTime.path()/runTime.constant()/polyMesh::defaultRegion/
"cellZoning"
581 Info <<
"Writing cell zoning info to file: " << czPath <<
endl;
584 cz << cellZoning <<
endl;
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const cellShapeList & cellShapes
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
List< word > wordList
A List of words.
dimensionedScalar tan(const dimensionedScalar &ds)
scalar degToRad(const scalar deg)
Convert degrees to radians.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
IOstream & hex(IOstream &io)
vectorField pointField
pointField is a vectorField.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< faceList > faceListList
dimensioned< scalar > mag(const dimensioned< Type > &)
wordList patchTypes(nPatches)
wordList patchNames(nPatches)
ifstream kivaFile(kivaFileName.c_str())
PtrList< dictionary > patchDicts
pointField points(nPoints)
polyMeshUnMergeCyclics(pShapeMesh)
faceListList boundary(nPatches)
forAll(cellShapes, celli)
labelList idface(nPoints)
labelList pointLabels(nPoints, -1)
Info<< "Reading kiva grid from file "<< kivaFileName<< endl;char title[120];kivaFile.getline(title, 120, '\n');label nPoints, nCells, nRegs;kivaFile > nCells nPoints nRegs
polyMesh pShapeMesh(IOobject(polyMesh::defaultRegion, runTime.constant(), runTime), move(points), cellShapes, boundary, patchNames, patchDicts, defaultFacesName, defaultFacesType)
preservePatchTypes(runTime, runTime.constant(), polyMesh::meshSubDir, patchNames, patchDicts, defaultFacesName, defaultFacesType)
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("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]=cellShape(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, &mergedCyclicPolyPatch::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]