85 if (mesh.
faces()[facei] ==
f)
99 int main(
int argc,
char *argv[])
105 "skip reading .face file for boundary information"
114 const fileName nodeFile(prefix +
".node");
115 const fileName eleFile(prefix +
".ele");
116 const fileName faceFile(prefix +
".face");
121 <<
" nodes : " << nodeFile <<
endl
122 <<
" elems : " << eleFile <<
endl
128 <<
" nodes : " << nodeFile <<
endl
129 <<
" elems : " << eleFile <<
endl
130 <<
" faces : " << faceFile <<
endl
133 Info<<
"Reading .face file for boundary information" <<
nl <<
endl;
139 <<
"Cannot read " << nodeFile <<
" or " << eleFile
143 if (readFaceFile && !
isFile(faceFile))
146 <<
"Cannot read " << faceFile <<
endl
147 <<
"Did you run tetgen with -f option?" <<
endl
148 <<
"If you don't want to read the .face file and thus not have"
149 <<
" patches please\nrerun with the -noFaceFile option"
165 nodeStream.getLine(
line);
167 while (
line.size() &&
line[0] ==
'#');
171 label nNodes, nDims, nNodeAttr;
174 nodeLine >> nNodes >> nDims >> nNodeAttr >> hasRegion;
178 <<
" nodes : " << nNodes <<
endl
179 <<
" nDims : " << nDims <<
endl
180 <<
" nAttr : " << nNodeAttr <<
endl
181 <<
" hasRegion : " << hasRegion <<
endl
196 while (nodeStream.good())
198 nodeStream.getLine(
line);
208 nodeLine >> nodeI >>
x >>
y >> z;
210 for (
label i = 0; i < nNodeAttr; i++)
222 nodeToPoint.insert(nodeI, pointi);
226 if (pointi != nNodes)
229 <<
"Only " << pointi <<
" nodes present instead of " << nNodes
242 eleStream.getLine(
line);
244 while (
line.size() &&
line[0] ==
'#');
248 label nTets, nPtsPerTet, nElemAttr;
250 eleLine >> nTets >> nPtsPerTet >> nElemAttr;
254 <<
" tets : " << nTets <<
endl
255 <<
" pointsPerTet : " << nPtsPerTet <<
endl
256 <<
" nAttr : " << nElemAttr <<
endl
262 <<
"Cannot handle tets with "
263 << nPtsPerTet <<
" points per tetrahedron in .ele file" <<
endl
264 <<
"Can only handle tetrahedra with four points"
271 <<
"Element attributes (third element in .ele header)"
272 <<
" not used" <<
endl;
284 while (eleStream.good())
286 eleStream.getLine(
line);
295 for (
label i = 0; i < 4; i++)
299 tetPoints[i] = nodeToPoint[nodeI];
305 for (
label i = 0; i < nElemAttr; i++)
361 faceStream.getLine(
line);
363 while (
line.size() &&
line[0] ==
'#');
367 label nFaces, nFaceAttr;
369 faceLine >> nFaces >> nFaceAttr;
373 <<
" faces : " << nFaces <<
endl
374 <<
" nAttr : " << nFaceAttr <<
endl
381 <<
"Expect boundary markers to be"
382 <<
" present in .face file." <<
endl
383 <<
"This is the second number in the header which is now:"
401 while (faceStream.good())
403 faceStream.getLine(
line);
409 label tetGenFacei, dummy, region;
411 faceLine >> tetGenFacei;
415 for (
label i = 0; i < 3; i++)
419 f[2-i] = nodeToPoint[nodeI];
425 boundaryFaces[facei] =
f;
437 regionToPatch.
find(region);
439 if (patchFind == regionToPatch.
end())
443 Info<<
"Mapping tetgen region " << region
454 boundaryPatch[facei] =
patchi;
457 for (
label i = 1; i < nFaceAttr; i++)
479 Info<<
" region:" << iter.key() <<
'\t' <<
"patch:"
503 forAll(boundaryPatch, facei)
546 Info<<
"Writing mesh to " << runTime.constant() <<
endl <<
endl;
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Input from memory buffer stream.
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
const word & executable() const
Name of executable without the path.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or nullptr.
An analytical geometric cellShape.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
Mesh consisting of general polyhedral cells.
static word defaultRegion
Return the default region name.
Cell-face mesh analysis engine.
virtual const faceList & faces() const =0
Return faces.
label nInternalFaces() const
void reset(const label nPoints, const label nInternalFaces, const label nFaces, const label nCells)
Reset this primitiveMesh given the primitive array sizes.
const labelListList & pointFaces() const
A class for handling words, derived from string.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
#define WarningInFunction
Report a warning using Foam::Warning.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
A List of words.
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.
errorManip< error > abort(error &err)
vector point
Point is a vector.
List< faceList > faceListList
wordList patchTypes(nPatches)
wordList patchNames(nPatches)
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]
Foam::argList args(argc, argv)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable