1 ifstream
kivaFile(kivaFileName.c_str());
6 <<
"Cannot open file " << kivaFileName
10 Info <<
"Reading kiva grid from file " << kivaFileName <<
endl;
31 if (kivaVersion == kiva3v)
43 f(nPoints),
bcl(nPoints),
bcf(nPoints),
bcb(nPoints);
50 scalar
ff, fbcl, fbcf, fbcb;
53 >> i1 >> i3 >> i4 >> i8
54 >> ff >> fbcl >> fbcf >> fbcb
68 if (
bcl[i] > 0 &&
bcl[i] != 4) nBfaces++;
69 if (
bcf[i] > 0 &&
bcf[i] != 4) nBfaces++;
70 if (bcb[i] > 0 && bcb[i] != 4) nBfaces++;
80 <<
"mTable == 0. This is not supported." 81 " kivaToFoam needs complete neighbour information" 99 Info <<
"Finished reading KIVA file" <<
endl;
107 label activeCells = 0;
123 hexLabels[1] = i1tab[i];
124 hexLabels[2] = i3tab[i1tab[i]];
125 hexLabels[3] = i3tab[i];
126 hexLabels[4] =
i8tab[i];
127 hexLabels[5] = i1tab[
i8tab[i]];
128 hexLabels[6] = i3tab[i1tab[i8tab[i]]];
129 hexLabels[7] = i3tab[i8tab[i]];
131 cellShapes[activeCells] = cellShape(hex, hexLabels);
133 edgeList edges = cellShapes[activeCells].edges();
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])
153 pointMap[start] = pointMap[end] = minLabel;
158 cellZoning[activeCells] =
idreg[i];
165 cellShapes.setSize(activeCells);
166 cellZoning.setSize(activeCells);
172 cellShape& cs = cellShapes[celli];
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 &mergedCyclicPolyPatch::typeName
218 const char* kivaPatchNames[nBCs] =
235 List<SLList<face>> pFaces[nBCs];
310 quadFace[2] = i3tab[i1tab[i8tab[i]]];
323 && pFaces[LINER][0].size()
324 && pFaces[CYLINDERHEAD].size()
325 && pFaces[CYLINDERHEAD][0].size()
332 const face& pf = iter();
342 SLList<face> newLinerFaces;
346 const face& pf = iter();
348 scalar minfz = great;
356 pFaces[CYLINDERHEAD][0].append(pf);
360 newLinerFaces.append(pf);
364 if (pFaces[LINER][0].size() != newLinerFaces.size())
366 Info<<
"Transferred " << pFaces[LINER][0].size() - newLinerFaces.size()
367 <<
" faces from liner region to cylinder head" <<
endl;
368 pFaces[LINER][0] = newLinerFaces;
371 SLList<face> newCylinderHeadFaces;
375 const face& pf = iter();
377 scalar minfz = great;
383 if (minfz < zHeadMin)
385 pFaces[LINER][0].append(pf);
389 newCylinderHeadFaces.append(pf);
393 if (pFaces[CYLINDERHEAD][0].size() != newCylinderHeadFaces.size())
395 Info<<
"Transferred faces from cylinder-head region to linder" <<
endl;
396 pFaces[CYLINDERHEAD][0] = newCylinderHeadFaces;
403 for (
int bci=0; bci<nBCs; bci++)
407 if (pFaces[bci][rgi].size())
416 if (pFaces[WEDGE].size() && pFaces[WEDGE][0].size())
418 if (pFaces[WEDGE][0].size() == cellShapes.size())
424 SLList<face>::iterator iterf = pFaces[WEDGE][0].begin();
425 SLList<face>::iterator iterb = pFaces[WEDGE][1].begin();
429 iterf != pFaces[WEDGE][0].end() && iterb != pFaces[WEDGE][1].end();
435 points[iterf()[d]].y() = -tanTheta*
points[iterf()[d]].x();
436 points[iterb()[d]].y() = tanTheta*
points[iterb()[d]].x();
442 pFaces[CYCLIC].setSize(1);
443 pFaces[CYCLIC][0] = pFaces[WEDGE][0];
444 forAllIter(SLList<face>, pFaces[WEDGE][1], iterb)
446 pFaces[CYCLIC][0].append(iterb());
449 pFaces[WEDGE].clear();
460 word defaultFacesName =
"defaultFaces";
461 word defaultFacesType = emptyPolyPatch::typeName;
465 for (
int bci=0; bci<nBCs; bci++)
469 if (pFaces[bci][rgi].size())
475 if (pFaces[bci].size() > 1)
494 forAll(cellShapes[celli], i)
496 pointLabels[cellShapes[celli][i]] = 1;
504 if (pointLabels[pointi] != -1)
510 points.setSize(newPointi);
515 cellShape& cs = cellShapes[celli];
519 cs[i] = pointLabels[cs[i]];
528 face&
f = boundary[
patchi][facei];
532 f[i] = pointLabels[f[i]];
542 polyMesh::meshSubDir,
551 if (!patchDicts.set(
patchi))
553 patchDicts.set(
patchi,
new dictionary());
556 patchDicts[
patchi].add(
"type", patchTypes[
patchi],
false);
564 polyMesh::defaultRegion,
585 runTime.path()/runTime.constant()/polyMesh::defaultRegion/
"cellZoning" 587 Info <<
"Writing cell zoning info to file: " << czPath <<
endl;
590 cz << cellZoning <<
endl;
List< faceList > faceListList
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
labelList pointLabels(nPoints, -1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
wordList patchTypes(nPatches)
labelList idface(nPoints)
Ostream & endl(Ostream &os)
Add newline and flush stream.
preservePatchTypes(runTime, runTime.constant(), polyMesh::meshSubDir, patchNames, patchDicts, defaultFacesName, defaultFacesType)
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
ifstream kivaFile(kivaFileName.c_str())
polyMesh pShapeMesh(IOobject(polyMesh::defaultRegion, runTime.constant(), runTime), move(points), cellShapes, boundary, patchNames, patchDicts, defaultFacesName, defaultFacesType)
vectorField pointField
pointField is a vectorField.
stressControl lookup("compactNormalStress") >> compactNormalStress
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
const cellShapeList & cellShapes
wordList patchNames(nPatches)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< label > labelList
A List of labels.
faceListList boundary(nPatches)
forAll(cellShapes, celli)
word name(const complex &)
Return a string representation of a complex.
List< word > wordList
A List of words.
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
dimensioned< scalar > mag(const dimensioned< Type > &)
PtrList< dictionary > patchDicts
polyMeshUnMergeCyclics(pShapeMesh)
dimensionedScalar tan(const dimensionedScalar &ds)
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)