Go to the documentation of this file. 1 ifstream
kivaFile(kivaFileName.c_str());
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;
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])
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] =
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<<
"Transfered " <<
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<<
"Transfered 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())
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);
446 pFaces[CYCLIC][0].append(iterb());
465 for (
int bci=0; bci<nBCs; bci++)
469 if (
pFaces[bci][rgi].size())
475 if (
pFaces[bci].size() > 1)
542 polyMesh::meshSubDir,
564 polyMesh::defaultRegion,
582 runTime.path()/runTime.constant()/polyMesh::defaultRegion/
"cellZoning"
584 Info <<
"Writing cell zoning info to file: " << czPath <<
endl;
587 cz << cellZoning <<
endl;
const cellShapeList & cellShapes
vectorField pointField
pointField is a vectorField.
preservePatchTypes(runTime, runTime.constant(), polyMesh::meshSubDir, patchNames, patchDicts, defaultFacesName, defaultFacesType)
dimensionedScalar tan(const dimensionedScalar &ds)
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
List< label > labelList
A List of labels.
faceListList boundary(nPatches)
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
PtrList< dictionary > patchDicts
wordList patchTypes(nPatches)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
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, &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
A List of words.
List< faceList > faceListList
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
labelList idface(nPoints)
polyMesh pShapeMesh(IOobject(polyMesh::defaultRegion, runTime.constant(), runTime), xferMove(points), cellShapes, boundary, patchNames, patchDicts, defaultFacesName, defaultFacesType)
wordList patchNames(nPatches)
errorManipArg< error, int > exit(error &err, const int errNo=1)
IOstream & hex(IOstream &io)
pointField points(nPoints)
forAll(cellShapes, celli)
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
ifstream kivaFile(kivaFileName.c_str())
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< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
labelList pointLabels(nPoints, -1)
word name(const complex &)
Return a string representation of a complex.
stressControl lookup("compactNormalStress") >> compactNormalStress
scalar degToRad(const scalar deg)
Conversion from degrees to radians.