68 const string SEPARATOR(
" -1");
70 bool isSeparator(
const string& line)
72 return line.substr(0, 6) == SEPARATOR;
96 tag = line.substr(0, 6);
98 }
while (tag == SEPARATOR);
113 if (isSeparator(line))
136 if (isSeparator(line))
144 scalar readUnvScalar(
const string& unvString)
148 s.replaceAll(
"d",
"E");
149 s.replaceAll(
"D",
"E");
173 string units(line.substr(10, 20));
177 Info<<
"unitType:" << unitType <<
endl;
182 lengthScale = readUnvScalar(line.substr(0, 25));
183 forceScale = readUnvScalar(line.substr(25, 25));
184 tempScale = readUnvScalar(line.substr(50, 25));
187 tempOffset = readUnvScalar(line.substr(0, 25));
189 Info<<
"Unit factors:" << nl
190 <<
" Length scale : " << lengthScale << nl
191 <<
" Force scale : " << forceScale << nl
192 <<
" Temperature scale : " << tempScale << nl
193 <<
" Temperature offset : " << tempOffset << nl
208 static bool hasWarned =
false;
221 else if (pointi != points.
size()+1 && !hasWarned)
228 ) <<
"Points not in order starting at point " << pointi
236 pt[0] = readUnvScalar(line.substr(0, 25));
237 pt[1] = readUnvScalar(line.substr(25, 25));
238 pt[2] = readUnvScalar(line.substr(50, 25));
240 unvPointID.
append(pointi);
257 if (indizes.
size() < (celli+1))
261 indizes[celli] = val;
281 label maxUnvPoint = 0;
282 forAll(unvPointID, pointi)
284 maxUnvPoint =
max(maxUnvPoint, unvPointID[pointi]);
302 if (isSeparator(line))
307 label celli, feID, physProp, matProp, colour, nNodes;
311 >> celli >> feID >> physProp >> matProp >> colour >> nNodes;
313 if (foundFeType.
insert(feID))
315 Info<<
"First occurrence of element type " << feID
316 <<
" for cell " << celli <<
" at line " 326 else if (feID == 171)
331 else if (feID == 41 || feID == 91)
339 >> cVerts[0] >> cVerts[1] >> cVerts[2];
340 boundaryFaces.
append(cVerts);
341 boundaryFaceIndices.
append(celli);
343 else if (feID == 44 || feID == 94)
351 >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3];
352 boundaryFaces.
append(cVerts);
353 boundaryFaceIndices.
append(celli);
355 else if (feID == 111)
363 >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3];
366 cellMaterial.
append(physProp);
367 addAndExtend(cellCorrespondence,celli,cellMaterial.
size()-1);
369 if (cellVerts.
last().
size() != cVerts.size())
372 <<
" element:" << celli
374 <<
" collapsed from " << cVerts << nl
375 <<
" to:" << cellVerts.
last()
379 else if (feID == 112)
387 >> cVerts[0] >> cVerts[1] >> cVerts[2]
388 >> cVerts[3] >> cVerts[4] >> cVerts[5];
391 cellMaterial.
append(physProp);
392 addAndExtend(cellCorrespondence,celli,cellMaterial.
size()-1);
394 if (cellVerts.
last().
size() != cVerts.size())
397 <<
" element:" << celli
399 <<
" collapsed from " << cVerts << nl
400 <<
" to:" << cellVerts.
last()
404 else if (feID == 115)
412 >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3]
413 >> cVerts[4] >> cVerts[5] >> cVerts[6] >> cVerts[7];
416 cellMaterial.
append(physProp);
417 addAndExtend(cellCorrespondence,celli,cellMaterial.
size()-1);
419 if (cellVerts.
last().
size() != cVerts.size())
422 <<
" element:" << celli
424 <<
" collapsed from " << cVerts << nl
425 <<
" to:" << cellVerts.
last()
429 else if (feID == 118)
439 >> cVerts[0] >> dummy >> cVerts[1] >> dummy >> cVerts[2];
444 lineStr >> dummy>> cVerts[3];
448 cellMaterial.
append(physProp);
449 addAndExtend(cellCorrespondence,celli,cellMaterial.
size()-1);
451 if (cellVerts.
last().
size() != cVerts.size())
454 <<
" element:" << celli
456 <<
" collapsed from " << cVerts << nl
457 <<
" to:" << cellVerts.
last()
463 if (skippedElements.
insert(feID))
466 <<
"Cell type " << feID <<
" not supported" <<
endl;
476 boundaryFaceIndices.
shrink();
477 cellCorrespondence.
shrink();
479 Info<<
"Read " << cellVerts.
size() <<
" cells" 480 <<
" and " << boundaryFaces.
size() <<
" boundary faces." <<
endl;
491 Info<<
"Starting reading patches at line " << is.
lineNumber() <<
'.' 499 if (isSeparator(line))
505 label group, constraintSet, restraintSet, loadSet, dofSet,
506 tempSet, contactSet, nFaces;
508 >> group >> constraintSet >> restraintSet >> loadSet
509 >> dofSet >> tempSet >> contactSet >> nFaces;
512 word groupName = string::validate<word>(line);
514 Info<<
"For group " << group
515 <<
" named " << groupName
516 <<
" trying to read " << nFaces <<
" patch face indices." 520 label groupType = -1;
523 while (nFaces < groupIndices.size())
530 if (nFaces == groupIndices.size()-1)
535 for (
label i = 0; i < nRead; i++)
539 lineStr >> groupType >> tag >> nodeLeaf >>
component;
541 groupIndices[nFaces++] = tag;
549 patchNames.
append(groupName);
550 patchFaceIndices.
append(groupIndices);
555 <<
"When reading patches expect entity type code 8" 556 << nl <<
" Skipping group code " << groupType
562 patchFaceIndices.
shrink();
575 Info<<
"Starting reading contraints at line " << is.
lineNumber() <<
'.' 589 patchNames.
append(lineStr);
592 Info<<
"For DOF set " << group
593 <<
" named " << patchNames.
last()
594 <<
" trying to read vertex indices." 603 if (isSeparator(line))
615 Info<<
"For DOF set " << group
616 <<
" named " << patchNames.
last()
617 <<
" read " << vertices.
size() <<
" vertex indices." <<
endl;
631 if (dofGroups[patchi].
found(f[0]))
633 bool allInGroup =
true;
638 if (!dofGroups[patchi].
found(f[fp]))
656 int main(
int argc,
char *argv[])
663 "dump boundary faces as boundaryFaces.obj (for debugging)" 675 <<
"Cannot open file " << ideasName
681 const bool verbose =
false;
684 scalar lengthScale = 1;
685 scalar forceScale = 1;
686 scalar tempScale = 1;
687 scalar tempOffset = 0;
709 while (inFile.good())
711 label tag = readTag(inFile);
718 Info<<
"Processing tag:" << tag <<
endl;
738 readPoints(inFile, points, unvPointID);
774 Info<<
"Skipping tag " << tag <<
" on line " 775 << inFile.lineNumber() <<
endl;
784 label maxUnvPoint = 0;
785 forAll(unvPointID, pointi)
787 maxUnvPoint =
max(maxUnvPoint, unvPointID[pointi]);
801 static_cast<labelList&>(cellVerts[celli])
809 <<
" unv vertices " << cellVerts[celli]
810 <<
" has some undefined vertices " << foamVerts
815 cellVerts[celli].
transfer(foamVerts);
820 forAll(boundaryFaces, bFacei)
827 <<
"Boundary face " << bFacei
828 <<
" unv vertices " << boundaryFaces[bFacei]
829 <<
" has some undefined vertices " << foamVerts
834 boundaryFaces[bFacei].
transfer(foamVerts);
854 forAll(boundaryFaces, facei)
857 faceToFaceID.insert(
face(sortedVerts), facei);
862 faceList faces = cellVerts[celli].faces();
867 faceToFaceID.
find(
face(sortedVerts));
869 if (fnd != faceToFaceID.
end())
891 if (own[facei] == -1 && nei[facei] != -1)
894 boundaryFaces[facei] = boundaryFaces[facei].reverseFace();
895 Swap(own[facei], nei[facei]);
901 Info <<
"Found " << nReverse <<
" reversed boundary faces out of " 909 if (own[facei] != -1 && nei[facei] != -1)
911 faceToCell[1].insert(facei, own[facei]);
912 faceToCell[0].insert(facei, nei[facei]);
919 Info <<
"Of " << boundaryFaces.
size() <<
" so-called" 920 <<
" boundary faces " << cnt <<
" belong to two cells " 921 <<
"and are therefore internal" <<
endl;
929 if (dofVertIndices.
size())
937 Info<<
"Using " << dofVertIndices.
size()
938 <<
" DOF sets to detect boundary faces."<<
endl;
941 forAll(dofVertIndices, patchi)
950 forAll(dofVertIndices, patchi)
956 dofGroups[
patchi].insert(foamVerts[i]);
964 const cellShape& shape = cellVerts[celli];
970 label patchi = findPatch(dofGroups, shapeFaces[i]);
974 dynPatchFaces[
patchi].append(shapeFaces[i]);
980 patchFaceVerts.
setSize(dynPatchFaces.size());
982 forAll(dynPatchFaces, patchi)
995 Info<<
"Sorting boundary faces according to group (patch)" <<
endl;
1004 forAll(boundaryFaceIndices, i)
1006 boundaryFaceToIndex.insert(boundaryFaceIndices[i], i);
1009 forAll(patchFaceVerts, patchi)
1018 bool duplicateFaces =
false;
1023 if (boundaryFaceToIndex.found(faceIndices[i]))
1025 label bFacei = boundaryFaceToIndex[faceIndices[i]];
1027 if (own[bFacei] != -1 && nei[bFacei] == -1)
1029 patchFaces[cnt] = boundaryFaces[bFacei];
1031 if (alreadyOnBoundary.
found(bFacei))
1033 duplicateFaces =
true;
1039 if (cnt != patchFaces.
size() || duplicateFaces)
1041 isAPatch[
patchi] =
false;
1045 if (cnt != patchFaces.
size())
1048 <<
"For patch " << patchi <<
" there were " 1049 << patchFaces.
size()-cnt
1050 <<
" faces not used because they seem" 1051 <<
" to be internal. " 1052 <<
"This seems to be a face or a cell-zone" 1059 << patchi <<
" has faces that are already " 1060 <<
" in use on other boundary-patches," 1061 <<
" Assuming faceZoneset." <<
endl;
1067 if (cellCorrespondence[faceIndices[0]] >= 0)
1073 if (cellCorrespondence[faceIndices[0]] < 0)
1076 <<
"The face index " << faceIndices[i]
1077 <<
" was not found amongst the cells." 1078 <<
" This kills the theory that " 1079 << patchNames[
patchi] <<
" is a cell zone" 1083 theCells[i] = cellCorrespondence[faceIndices[i]];
1085 cellZones.
insert(patchNames[patchi], theCells);
1093 theFaces[i] = boundaryFaceToIndex[faceIndices[i]];
1095 faceZones.
insert(patchNames[patchi],theFaces);
1104 label bFacei = boundaryFaceToIndex[faceIndices[i]];
1105 alreadyOnBoundary.
insert(bFacei);
1115 polyPoints /= lengthScale;
1121 Info<<
"Writing boundary faces to OBJ file boundaryFaces.obj" 1128 xferCopyTo<faceList>(boundaryFaces)
1134 xferCopy(rawSurface.localPoints()),
1136 ).
write(runTime.path()/
"boundaryFaces.obj");
1140 Info<<
"\nConstructing mesh with non-default patches of size:" <<
nl;
1144 forAll(patchNames, patchi)
1146 if (isAPatch[patchi])
1150 usedPatchNames.
append(patchNames[patchi]);
1151 usedPatchFaceVerts.
append(patchFaceVerts[patchi]);
1155 usedPatchFaceVerts.
shrink();
1176 polyPatch::typeName,
1181 if (faceZones.
size() > 0 || cellZones.
size() > 0)
1183 Info <<
"Adding cell and face zones" <<
endl;
1189 if (cellZones.
size() > 0)
1193 word name = cellZones.
toc()[cnt];
1194 Info<<
" Cell Zone " << name <<
" " <<
tab 1206 if (faceZones.
size() > 0)
1215 word name = faceZones.
toc()[cnt];
1219 Info<<
" Face Zone " << name <<
" " <<
tab 1224 const label old = oldIndizes[i];
1227 if (faceToCell[0].
found(old))
1229 c1 = faceToCell[0][old];
1231 if (faceToCell[1].
found(old))
1233 c2 = faceToCell[1][old];
1248 const face& f = boundaryFaces[old];
1249 if (
mag(centers[j]- f.
centre(points)) < SMALL)
1263 (c1 == own[j] &&
c2 == nei[j])
1264 || (
c2 == own[j] && c1 == nei[j])
1272 assert(noveau > -1);
1273 indizes[i] = noveau;
1277 faceZones.
toc()[cnt],
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
const char *const group
Group name for atomic constants.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or nullptr.
A class for handling file names.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
const faceZoneMesh & faceZones() const
Return face zone mesh.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
A face is a list of labels corresponding to mesh vertices.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A list that is sorted upon construction or when explicitly requested with the sort() method...
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
const T * cdata() const
Return a const pointer to the first data element,.
An analytical geometric cellShape.
void size(const label)
Override size to be inconsistent with allocated storage.
const dimensionedScalar c2
Second radiation constant: default SI units: [m.K].
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
point centre(const pointField &) const
Centre point of face.
static void noParallel()
Remove the parallel options.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Xfer< T > xferCopy(const T &)
Construct by copying the contents of the arg.
label lineNumber() const
Return current stream line number.
unsigned operator()(const PrimitiveType &p, unsigned seed) const
bool insert(const Key &key)
Insert a new entry.
bool good() const
Return true if next operation might succeed.
label size() const
Return number of elements in table.
virtual const pointField & points() const
Return raw points.
List< bool > boolList
Bool container classes.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
pointField vertices(const blockVertexList &bvl)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
faceList faces() const
Faces of this cell.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
void setSize(const label)
Alter the addressed list size.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
bool found(const Key &) const
Return true if hashedEntry is found in table.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
A class for handling words, derived from string.
const cellZoneMesh & cellZones() const
Return cell zone mesh.
MeshedSurface< face > meshedSurface
static int compare(const face &, const face &)
Compare faces.
wordList patchNames(nPatches)
virtual const labelList & faceOwner() const
Return face owner.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
An STL-conforming hash table.
void addZones(const List< pointZone *> &pz, const List< faceZone *> &fz, const List< cellZone *> &cz)
Add mesh zones.
errorManip< error > abort(error &err)
label readLabel(Istream &is)
static void write(const fileName &, const MeshedSurface< Face > &)
Write to file.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
const vectorField & faceCentres() const
List< word > wordList
A List of words.
void setSize(const label)
Reset size of List.
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3)
Ostream & flush(Ostream &os)
Flush stream.
#define WarningInFunction
Report a warning using Foam::Warning.
Input from memory buffer stream.
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
dimensioned< scalar > mag(const dimensioned< Type > &)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Mesh consisting of general polyhedral cells.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
A subset of mesh faces organised as a primitive patch.
List< Key > toc() const
Return the table of contents.
A class for managing temporary objects.
T & last()
Return the last element of the list.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void transfer(List< T > &)
Transfer contents of the argument List into this.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
IOporosityModelList pZones(mesh)
ISstream & getLine(string &)
Raw, low-level getline into a string function.