Go to the documentation of this file.
105 int main(
int argc,
char *argv[])
109 "Convert tetgen .ele and .node and .face files to an OpenFOAM mesh"
116 "Skip reading .face file for boundary information"
123 const bool readFaceFile = !
args.
found(
"noFaceFile");
125 const fileName nodeFile(prefix +
".node");
126 const fileName eleFile(prefix +
".ele");
127 const fileName faceFile(prefix +
".face");
132 <<
" nodes : " << nodeFile <<
endl
133 <<
" elems : " << eleFile <<
endl
139 <<
" nodes : " << nodeFile <<
endl
140 <<
" elems : " << eleFile <<
endl
141 <<
" faces : " << faceFile <<
endl
144 Info<<
"Reading .face file for boundary information" <<
nl <<
endl;
150 <<
"Cannot read " << nodeFile <<
" or " << eleFile
154 if (readFaceFile && !
isFile(faceFile))
157 <<
"Cannot read " << faceFile <<
endl
158 <<
"Did you run tetgen with -f option?" <<
endl
159 <<
"If you don't want to read the .face file and thus not have"
160 <<
" patches please\nrerun with the -noFaceFile option"
176 nodeStream.getLine(
line);
178 while (
line.starts_with(
'#'));
182 label nNodes, nDims, nNodeAttr;
185 nodeLine >> nNodes >> nDims >> nNodeAttr >> hasRegion;
189 <<
" nodes : " << nNodes <<
endl
190 <<
" nDims : " << nDims <<
endl
191 <<
" nAttr : " << nNodeAttr <<
endl
192 <<
" hasRegion : " << hasRegion <<
endl
207 while (nodeStream.good())
209 nodeStream.getLine(
line);
219 nodeLine >> nodeI >>
x >>
y >> z;
221 for (label i = 0; i < nNodeAttr; i++)
233 nodeToPoint.insert(nodeI, pointi);
237 if (pointi != nNodes)
240 <<
"Only " << pointi <<
" nodes present instead of " << nNodes
253 eleStream.getLine(
line);
255 while (
line.starts_with(
'#'));
259 label nTets, nPtsPerTet, nElemAttr;
261 eleLine >> nTets >> nPtsPerTet >> nElemAttr;
265 <<
" tets : " << nTets <<
endl
266 <<
" pointsPerTet : " << nPtsPerTet <<
endl
267 <<
" nAttr : " << nElemAttr <<
endl
273 <<
"Cannot handle tets with "
274 << nPtsPerTet <<
" points per tetrahedron in .ele file" <<
endl
275 <<
"Can only handle tetrahedra with four points"
282 <<
"Element attributes (third elemenent in .ele header)"
283 <<
" not used" <<
endl;
294 while (eleStream.good())
296 eleStream.getLine(
line);
305 for (label i = 0; i < 4; i++)
315 for (label i = 0; i < nElemAttr; i++)
369 faceStream.getLine(
line);
371 while (
line.starts_with(
'#'));
375 label nFaces, nFaceAttr;
377 faceLine >> nFaces >> nFaceAttr;
381 <<
" faces : " << nFaces <<
endl
382 <<
" nAttr : " << nFaceAttr <<
endl
389 <<
"Expect boundary markers to be"
390 <<
" present in .face file." <<
endl
391 <<
"This is the second number in the header which is now:"
409 while (faceStream.good())
411 faceStream.getLine(
line);
417 label tetGenFacei, dummy, region;
419 faceLine >> tetGenFacei;
423 for (label i = 0; i < 3; i++)
427 f[2-i] = nodeToPoint[nodeI];
433 boundaryFaces[facei] =
f;
444 const auto patchFind = regionToPatch.cfind(region);
446 if (patchFind.found())
454 Info<<
"Mapping tetgen region " << region
458 regionToPatch.insert(region,
nPatches++);
464 for (label i = 1; i < nFaceAttr; i++)
486 Info<<
" region:" << iter.key()
487 <<
'\t' <<
"patch:" << iter.val() <<
nl;
514 allPatchFaces[patchi].append(boundaryFaces[facei]);
519 forAll(allPatchFaces, patchi)
522 << allPatchFaces[patchi].size() <<
endl;
524 patchFaces[patchi].transfer(allPatchFaces[patchi]);
static autoPtr< T > New(Args &&... args)
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A class for handling words, derived from Foam::string.
A class for handling file names.
static word defaultRegion
Input from file stream, using an ISstream.
const labelListList & pointFaces() const
static void addNote(const string ¬e)
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Ostream & endl(Ostream &os)
T get(const label index) const
Mesh consisting of general polyhedral cells.
wordList patchTypes(nPatches)
Like polyPatch but without reference to mesh. Used in boundaryMesh to hold data on patches....
List< word > wordList
A List of words.
static void addArgument(const string &argName, const string &usage="")
Generic templated field type.
void setSize(const label n)
wordList patchNames(nPatches)
static const cellModel & ref(const modelType model)
label max(const labelHashSet &set, label maxValue=labelMin)
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Tet storage. Null constructable (unfortunately tetrahedron<point, point> is not)
void reset(autoPtr< T > &&other) noexcept
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
static unsigned int defaultPrecision() noexcept
virtual const faceList & faces() const
#define FatalErrorInFunction
List< faceList > faceListList
A List of faceList.
forAllConstIters(mixture.phases(), phase)
label nInternalFaces() const noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A face is a list of labels corresponding to mesh vertices.
#define FatalIOErrorInFunction(ios)
Maps a geometry to a set of cell primitives.
vector point
Point is a vector.
static word defaultName(const label n=-1)
const word & constant() const
Foam::argList args(argc, argv)
#define WarningInFunction
Foam::autoPtr< Foam::fvMesh > meshPtr(nullptr)
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]
bool found(const word &optName) const
Cell-face mesh analysis engine.