Go to the documentation of this file.
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;
475 boundaryFaceIndices.
shrink();
476 cellCorrespondence.
shrink();
478 Info<<
"Read " << cellVerts.size() <<
" cells"
479 <<
" and " << boundaryFaces.size() <<
" boundary faces." <<
endl;
490 Info<<
"Starting reading patches at line " << is.
lineNumber() <<
'.'
498 if (isSeparator(
line))
504 label group, constraintSet, restraintSet, loadSet, dofSet,
505 tempSet, contactSet, nFaces;
507 >>
group >> constraintSet >> restraintSet >> loadSet
508 >> dofSet >> tempSet >> contactSet >> nFaces;
511 word groupName = string::validate<word>(
line);
514 <<
" named " << groupName
515 <<
" trying to read " << nFaces <<
" patch face indices."
519 label groupType = -1;
522 while (nFaces < groupIndices.size())
529 if (nFaces == groupIndices.size()-1)
534 for (
label i = 0; i < nRead; i++)
538 lineStr >> groupType >> tag >> nodeLeaf >>
component;
540 groupIndices[nFaces++] = tag;
549 patchFaceIndices.
append(groupIndices);
554 <<
"When reading patches expect entity type code 8"
555 <<
nl <<
" Skipping group code " << groupType
561 patchFaceIndices.
shrink();
574 Info<<
"Starting reading contraints at line " << is.
lineNumber() <<
'.'
593 <<
" trying to read vertex indices."
602 if (isSeparator(
line))
616 <<
" read " << vertices.size() <<
" vertex indices." <<
endl;
630 if (dofGroups[patchI].
found(
f[0]))
632 bool allInGroup =
true;
637 if (!dofGroups[patchI].
found(
f[fp]))
655 int main(
int argc,
char *argv[])
662 "dump boundary faces as boundaryFaces.obj (for debugging)"
674 <<
"Cannot open file " << ideasName
680 const bool verbose =
false;
683 scalar lengthScale = 1;
684 scalar forceScale = 1;
685 scalar tempScale = 1;
686 scalar tempOffset = 0;
708 while (inFile.good())
710 label tag = readTag(inFile);
717 Info<<
"Processing tag:" << tag <<
endl;
737 readPoints(inFile,
points, unvPointID);
773 Info<<
"Skipping tag " << tag <<
" on line "
774 << inFile.lineNumber() <<
endl;
783 label maxUnvPoint = 0;
784 forAll(unvPointID, pointI)
786 maxUnvPoint =
max(maxUnvPoint, unvPointID[pointI]);
800 static_cast<labelList&
>(cellVerts[cellI])
808 <<
" unv vertices " << cellVerts[cellI]
809 <<
" has some undefined vertices " << foamVerts
814 cellVerts[cellI].
transfer(foamVerts);
819 forAll(boundaryFaces, bFaceI)
826 <<
"Boundary face " << bFaceI
827 <<
" unv vertices " << boundaryFaces[bFaceI]
828 <<
" has some undefined vertices " << foamVerts
833 boundaryFaces[bFaceI].
transfer(foamVerts);
853 forAll(boundaryFaces, faceI)
856 faceToFaceID.insert(
face(sortedVerts), faceI);
861 faceList faces = cellVerts[cellI].faces();
866 faceToFaceID.
find(
face(sortedVerts));
868 if (fnd != faceToFaceID.end())
890 if (own[faceI] == -1 && nei[faceI] != -1)
893 boundaryFaces[faceI] = boundaryFaces[faceI].reverseFace();
894 Swap(own[faceI], nei[faceI]);
900 Info <<
"Found " << nReverse <<
" reversed boundary faces out of "
901 << boundaryFaces.size() <<
endl;
908 if (own[faceI] != -1 && nei[faceI] != -1)
918 Info <<
"Of " << boundaryFaces.size() <<
" so-called"
919 <<
" boundary faces " << cnt <<
" belong to two cells "
920 <<
"and are therefore internal" <<
endl;
928 if (dofVertIndices.size())
936 Info<<
"Using " << dofVertIndices.size()
937 <<
" DOF sets to detect boundary faces."<<
endl;
940 forAll(dofVertIndices, patchI)
949 forAll(dofVertIndices, patchI)
951 const labelList& foamVerts = dofVertIndices[patchI];
955 dofGroups[patchI].insert(foamVerts[i]);
963 const cellShape& shape = cellVerts[cellI];
969 label patchI = findPatch(dofGroups, shapeFaces[i]);
973 dynPatchFaces[patchI].append(shapeFaces[i]);
979 patchFaceVerts.
setSize(dynPatchFaces.size());
981 forAll(dynPatchFaces, patchI)
983 patchFaceVerts[patchI].
transfer(dynPatchFaces[patchI]);
992 patchFaceVerts.
setSize(patchFaceIndices.size());
994 Info<<
"Sorting boundary faces according to group (patch)" <<
endl;
1001 Map<label> boundaryFaceToIndex(boundaryFaceIndices.size());
1003 forAll(boundaryFaceIndices, i)
1005 boundaryFaceToIndex.insert(boundaryFaceIndices[i], i);
1008 forAll(patchFaceVerts, patchI)
1013 const labelList& faceIndices = patchFaceIndices[patchI];
1017 bool duplicateFaces =
false;
1022 if (boundaryFaceToIndex.found(faceIndices[i]))
1024 label bFaceI = boundaryFaceToIndex[faceIndices[i]];
1026 if (own[bFaceI] != -1 && nei[bFaceI] == -1)
1030 if (alreadyOnBoundary.
found(bFaceI))
1032 duplicateFaces =
true;
1040 isAPatch[patchI] =
false;
1047 <<
"For patch " << patchI <<
" there were "
1049 <<
" faces not used because they seem"
1050 <<
" to be internal. "
1051 <<
"This seems to be a face or a cell-zone"
1058 << patchI <<
" has faces that are already "
1059 <<
" in use on other boundary-patches,"
1060 <<
" Assuming faceZoneset." <<
endl;
1066 if (cellCorrespondence[faceIndices[0]] >= 0)
1072 if (cellCorrespondence[faceIndices[0]] < 0)
1075 <<
"The face index " << faceIndices[i]
1076 <<
" was not found amongst the cells."
1077 <<
" This kills the theory that "
1082 theCells[i] = cellCorrespondence[faceIndices[i]];
1092 theFaces[i] = boundaryFaceToIndex[faceIndices[i]];
1103 label bFaceI = boundaryFaceToIndex[faceIndices[i]];
1104 alreadyOnBoundary.
insert(bFaceI);
1111 polyPoints.transfer(
points);
1114 polyPoints /= lengthScale;
1120 Info<<
"Writing boundary faces to OBJ file boundaryFaces.obj"
1127 xferCopyTo< faceList >(boundaryFaces)
1133 xferCopy(rawSurface.localPoints()),
1135 ).
write(runTime.path()/
"boundaryFaces.obj");
1139 Info<<
"\nConstructing mesh with non-default patches of size:" <<
nl;
1145 if (isAPatch[patchI])
1148 << patchFaceVerts[patchI].
size() <<
nl;
1150 usedPatchFaceVerts.
append(patchFaceVerts[patchI]);
1154 usedPatchFaceVerts.
shrink();
1175 polyPatch::typeName,
1180 if (faceZones.
size() > 0 || cellZones.
size() > 0)
1182 Info <<
"Adding cell and face zones" <<
endl;
1188 if (cellZones.
size() > 0)
1205 if (faceZones.
size() > 0)
1223 const label old = oldIndizes[i];
1247 const face&
f = boundaryFaces[old];
1248 if (
mag(centers[j]-
f.centre(
points)) < SMALL)
1262 (
c1 == own[j] &&
c2 == nei[j])
1263 || (
c2 == own[j] &&
c1 == nei[j])
1271 assert(noveau > -1);
1272 indizes[i] = noveau;
1276 faceZones.
toc()[cnt],
static SLList< string > validArgs
A list of valid (mandatory) arguments.
virtual const pointField & points() const
Return raw points.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
A class for handling words, derived from string.
A class for handling file names.
List< Key > toc() const
Return the table of contents.
static word defaultRegion
Return the default region name.
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3)
IOporosityModelList pZones(mesh)
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
const cellZoneMesh & cellZones() const
Return cell zone mesh.
A topoSetSource to select cells based on usage in faces.
const char *const group
Group name for atomic constants.
Ostream & endl(Ostream &os)
Add newline and flush stream.
faceList faces() const
Faces of this cell.
dimensioned< scalar > mag(const dimensioned< Type > &)
labelList patchFaces(const polyBoundaryMesh &patches, const wordList &names)
Mesh consisting of general polyhedral cells.
const faceZoneMesh & faceZones() const
Return face zone mesh.
List< word > wordList
A List of words.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
virtual bool write() const
Write mesh using IO settings from time.
static void write(const fileName &, const MeshedSurface< Face > &)
Write to file.
Ostream & flush(Ostream &os)
Flush stream.
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
A subset of mesh faces organised as a primitive patch.
void append(const T &)
Append an element at the end of the list.
ISstream & getLine(string &)
Raw, low-level getline into a string function.
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or NULL.
virtual const labelList & faceOwner() const
Return face owner.
unsigned operator()(const PrimitiveType &p, unsigned seed) const
int main(int argc, char *argv[])
wordList patchNames(nPatches)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
label size() const
Return number of elements in table.
A list that is sorted upon construction or when explicitly requested with the sort() method.
bool found(const Key &) const
Return true if hashedEntry is found in table.
An analytical geometric cellShape.
Input from memory buffer stream.
errorManip< error > abort(error &err)
const dimensionedScalar c2
Second radiation constant: default SI units: [m.K].
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))
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
IOstream & hex(IOstream &io)
An STL-conforming hash table.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void setSize(const label)
Reset size of List.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
MeshedSurface< face > meshedSurface
Xfer< T > xferCopy(const T &)
Construct by copying the contents of the arg.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const vectorField & faceCentres() const
void transfer(List< T > &)
Transfer contents of the argument List into this.
bool insert(const Key &key)
Insert a new entry.
label readLabel(Istream &is)
bool optionFound(const word &opt) const
Return true if the named option is found.
label lineNumber() const
Return current stream line number.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
A face is a list of labels corresponding to mesh vertices.
static int compare(const face &, const face &)
Compare faces.
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
void size(const label)
Override size to be inconsistent with allocated storage.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
static void noParallel()
Remove the parallel options.
bool good() const
Return true if next operation might succeed.
Foam::argList args(argc, argv)
void setSize(const label)
Alter the addressed list size.
#define WarningInFunction
Report a warning using Foam::Warning.
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
word name(const complex &)
Return a string representation of a complex.
virtual const labelList & faceNeighbour() const
Return face neighbour.