88 const string SEPARATOR(
" -1");
90 bool isSeparator(
const string&
line)
92 return line.substr(0, 6) == SEPARATOR;
116 tag = line.substr(0, 6);
118 }
while (tag == SEPARATOR);
133 if (isSeparator(line))
156 if (isSeparator(line))
164 scalar readUnvScalar(
const string& unvString)
168 s.replaceAll(
"d",
"E");
169 s.replaceAll(
"D",
"E");
193 string units(line.substr(10, 20));
196 label unitType = readLabel(
IStringStream(line.substr(30, 10))());
197 Sout<<
"unitType:" << unitType <<
endl;
202 lengthScale = readUnvScalar(line.substr(0, 25));
203 forceScale = readUnvScalar(line.substr(25, 25));
204 tempScale = readUnvScalar(line.substr(50, 25));
207 tempOffset = readUnvScalar(line.substr(0, 25));
209 Sout<<
"Unit factors:" <<
nl
210 <<
" Length scale : " << lengthScale <<
nl
211 <<
" Force scale : " << forceScale <<
nl
212 <<
" Temperature scale : " << tempScale <<
nl
213 <<
" Temperature offset : " << tempOffset <<
nl
228 static bool hasWarned =
false;
235 label pointI = readLabel(
IStringStream(line.substr(0, 10))());
241 else if (pointI != points.
size()+1 && !hasWarned)
247 "readPoints(IFstream&, label&, DynamicList<point>"
248 ", DynamicList<label>&)",
250 ) <<
"Points not in order starting at point " << pointI
258 pt[0] = readUnvScalar(line.substr(0, 25));
259 pt[1] = readUnvScalar(line.substr(25, 25));
260 pt[2] = readUnvScalar(line.substr(50, 25));
262 unvPointID.
append(pointI);
279 if (indizes.
size() < (cellI+1))
283 indizes[cellI] = val;
303 label maxUnvPoint = 0;
304 forAll(unvPointID, pointI)
306 maxUnvPoint =
max(maxUnvPoint, unvPointID[pointI]);
324 if (isSeparator(line))
330 label cellI, feID, physProp, matProp, colour, nNodes;
331 lineStr >> cellI >> feID >> physProp >> matProp >> colour >> nNodes;
333 if (foundFeType.
insert(feID))
335 Info<<
"First occurrence of element type " << feID
336 <<
" for cell " << cellI <<
" at line "
346 else if (feID == 171)
351 else if (feID == 41 || feID == 91)
358 lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2];
359 boundaryFaces.
append(cVerts);
360 boundaryFaceIndices.
append(cellI);
362 else if (feID == 44 || feID == 94)
369 lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3];
370 boundaryFaces.
append(cVerts);
371 boundaryFaceIndices.
append(cellI);
373 else if (feID == 111)
380 lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3];
383 cellMaterial.
append(physProp);
384 addAndExtend(cellCorrespondence,cellI,cellMaterial.
size()-1);
386 if (cellVerts[cellVerts.
size()-1].
size() != cVerts.size())
389 <<
" element:" << cellI
391 <<
" collapsed from " << cVerts <<
nl
392 <<
" to:" << cellVerts[cellVerts.
size()-1]
396 else if (feID == 112)
403 lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3]
404 >> cVerts[4] >> cVerts[5];
407 cellMaterial.
append(physProp);
408 addAndExtend(cellCorrespondence,cellI,cellMaterial.
size()-1);
410 if (cellVerts[cellVerts.
size()-1].
size() != cVerts.size())
413 <<
" element:" << cellI
415 <<
" collapsed from " << cVerts <<
nl
416 <<
" to:" << cellVerts[cellVerts.
size()-1]
420 else if (feID == 115)
428 >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3]
429 >> cVerts[4] >> cVerts[5] >> cVerts[6] >> cVerts[7];
432 cellMaterial.
append(physProp);
433 addAndExtend(cellCorrespondence,cellI,cellMaterial.
size()-1);
435 if (cellVerts[cellVerts.
size()-1].
size() != cVerts.size())
438 <<
" element:" << cellI
440 <<
" collapsed from " << cVerts <<
nl
441 <<
" to:" << cellVerts[cellVerts.
size()-1]
445 else if (feID == 118)
456 >> cVerts[0] >> dummy >> cVerts[1] >> dummy
462 lineStr >> dummy>> cVerts[3];
466 cellMaterial.
append(physProp);
467 addAndExtend(cellCorrespondence,cellI,cellMaterial.
size()-1);
469 if (cellVerts[cellVerts.
size()-1].
size() != cVerts.size())
472 <<
" element:" << cellI
474 <<
" collapsed from " << cVerts <<
nl
475 <<
" to:" << cellVerts[cellVerts.
size()-1]
481 if (skippedElements.
insert(feID))
484 <<
"Cell type " << feID <<
" not supported" <<
endl;
493 boundaryFaceIndices.
shrink();
494 cellCorrespondence.
shrink();
496 Sout<<
"Read " << cellVerts.
size() <<
" cells"
497 <<
" and " << boundaryFaces.
size() <<
" boundary faces." <<
endl;
508 Sout<<
"Starting reading patches at line " << is.
lineNumber() <<
'.'
516 if (isSeparator(line))
522 label group, constraintSet, restraintSet, loadSet, dofSet,
523 tempSet, contactSet, nFaces;
525 >> group >> constraintSet >> restraintSet >> loadSet
526 >> dofSet >> tempSet >> contactSet >> nFaces;
529 word groupName = string::validate<word>(line);
531 Info<<
"For group " << group
532 <<
" named " << groupName
533 <<
" trying to read " << nFaces <<
" patch face indices."
537 label groupType = -1;
540 while (nFaces < groupIndices.size())
547 if (nFaces == groupIndices.size()-1)
552 for (label i = 0; i < nRead; i++)
556 lineStr >> groupType >> tag >> nodeLeaf >>
component;
558 groupIndices[nFaces++] = tag;
566 patchNames.
append(groupName);
567 patchFaceIndices.
append(groupIndices);
572 <<
"When reading patches expect entity type code 8"
573 <<
nl <<
" Skipping group code " << groupType
579 patchFaceIndices.
shrink();
592 Sout<<
"Starting reading constraints at line " << is.
lineNumber() <<
'.'
606 patchNames.
append(lineStr);
609 Info<<
"For DOF set " << group
610 <<
" named " << patchNames[patchNames.
size()-1]
611 <<
" trying to read vertex indices."
620 if (isSeparator(line))
632 Info<<
"For DOF set " << group
633 <<
" named " << patchNames[patchNames.
size()-1]
634 <<
" read " << vertices.
size() <<
" vertex indices." <<
endl;
648 if (dofGroups[patchI].found(f[0]))
650 bool allInGroup =
true;
653 for (label fp = 1; fp < f.
size(); fp++)
655 if (!dofGroups[patchI].found(f[fp]))
672 const bool verbose=
false;
676 int main(
int argc,
char *argv[])
692 <<
"Cannot open file " << ideasName
698 scalar lengthScale = 1;
699 scalar forceScale = 1;
700 scalar tempScale = 1;
701 scalar tempOffset = 0;
723 while (inFile.good())
725 label tag = readTag(inFile);
732 Sout<<
"Processing tag:" << tag <<
endl;
752 readPoints(inFile, points, unvPointID);
788 Sout<<
"Skipping tag " << tag <<
" on line "
798 label maxUnvPoint = 0;
799 forAll(unvPointID, pointI)
801 maxUnvPoint =
max(maxUnvPoint, unvPointID[pointI]);
815 static_cast<labelList&>(cellVerts[cellI])
823 <<
" unv vertices " << cellVerts[cellI]
824 <<
" has some undefined vertices " << foamVerts
829 cellVerts[cellI].
transfer(foamVerts);
834 forAll(boundaryFaces, bFaceI)
841 <<
"Boundary face " << bFaceI
842 <<
" unv vertices " << boundaryFaces[bFaceI]
843 <<
" has some undefined vertices " << foamVerts
848 boundaryFaces[bFaceI].
transfer(foamVerts);
867 forAll(boundaryFaces,faceI)
871 faceToFaceID.insert(theFace,faceI);
876 faceList faces = cellVerts[cellI].faces();
881 if (faceToFaceID.found(theFace))
883 label faceI = faceToFaceID[theFace];
884 if (nrFaceCells[faceI] < 2)
886 faceToCell[nrFaceCells[faceI]].insert(faceI,cellI);
888 nrFaceCells[faceI]++;
894 forAll(nrFaceCells, faceI)
896 assert(nrFaceCells[faceI] == 1 || nrFaceCells[faceI] == 2);
897 if (nrFaceCells[faceI]>1)
905 Info <<
"Of " << boundaryFaces.
size() <<
" so-called"
906 <<
" boundary faces " << cnt <<
" belong to two cells "
907 <<
"and are therefore internal" <<
endl;
915 if (dofVertIndices.
size())
923 Info<<
"Using " << dofVertIndices.
size()
924 <<
" DOF sets to detect boundary faces."<<
endl;
927 forAll(dofVertIndices, patchI)
936 forAll(dofVertIndices, patchI)
938 const labelList& foamVerts = dofVertIndices[patchI];
942 dofGroups[patchI].insert(foamVerts[i]);
950 const cellShape& shape = cellVerts[cellI];
956 label patchI = findPatch(dofGroups, shapeFaces[i]);
960 dynPatchFaces[patchI].append(shapeFaces[i]);
966 patchFaceVerts.
setSize(dynPatchFaces.size());
968 forAll(dynPatchFaces, patchI)
970 patchFaceVerts[patchI].
transfer(dynPatchFaces[patchI]);
981 Info<<
"Sorting boundary faces according to group (patch)" <<
endl;
990 forAll(boundaryFaceIndices, i)
992 boundaryFaceToIndex.insert(boundaryFaceIndices[i], i);
995 forAll(patchFaceVerts, patchI)
997 Info << patchI <<
": " << patchNames[patchI] <<
" is " <<
flush;
999 faceList& patchFaces = patchFaceVerts[patchI];
1000 const labelList& faceIndices = patchFaceIndices[patchI];
1004 bool duplicateFaces =
false;
1009 if (boundaryFaceToIndex.found(faceIndices[i]))
1011 label bFaceI = boundaryFaceToIndex[faceIndices[i]];
1012 if (nrFaceCells[bFaceI] == 1)
1014 patchFaces[cnt] = boundaryFaces[bFaceI];
1016 if (alreadyOnBoundary.
found(bFaceI))
1018 duplicateFaces =
true;
1024 if (cnt!=patchFaces.
size() || duplicateFaces)
1026 isAPatch[patchI] =
false;
1030 if (cnt != patchFaces.
size())
1033 <<
"For patch " << patchI <<
" there were "
1034 << patchFaces.
size()-cnt
1035 <<
" faces not used because they seem"
1036 <<
" to be internal. "
1037 <<
"This seems to be a face or a cell-zone"
1044 << patchI <<
" has faces that are already "
1045 <<
" in use on other boundary-patches,"
1046 <<
" Assuming faceZoneset." << endl;
1052 if (cellCorrespondence[faceIndices[0]] >= 0)
1058 if (cellCorrespondence[faceIndices[0]] < 0)
1061 <<
"The face index " << faceIndices[i]
1062 <<
" was not found amongst the cells."
1063 <<
" This kills the theory that "
1064 << patchNames[patchI] <<
" is a cell zone"
1068 theCells[i] = cellCorrespondence[faceIndices[i]];
1070 cellZones.
insert(patchNames[patchI], theCells);
1078 theFaces[i] = boundaryFaceToIndex[faceIndices[i]];
1080 faceZones.
insert(patchNames[patchI],theFaces);
1089 label bFaceI = boundaryFaceToIndex[faceIndices[i]];
1090 alreadyOnBoundary.
insert(bFaceI);
1100 polyPoints /= lengthScale;
1110 const face& f = boundaryFaces[i];
1114 f.
triangles(polyPoints, nTri, triFaces);
1116 forAll(triFaces, triFaceI)
1118 const face& f = triFaces[triFaceI];
1124 triSurface rawSurface(triangles.shrink(), polyPoints);
1129 rawSurface.localFaces(),
1130 rawSurface.localPoints()
1133 Info<<
"Writing boundary faces to STL file boundaryFaces.stl"
1136 surface.
write(runTime.path()/
"boundaryFaces.stl");
1140 Info<<
"\nConstructing mesh with non-default patches of size:" <<
nl;
1144 forAll(patchNames, patchI)
1146 if (isAPatch[patchI]) {
1147 Info<<
" " << patchNames[patchI] <<
'\t'
1148 << patchFaceVerts[patchI].
size() <<
nl;
1149 usedPatchNames.
append(patchNames[patchI]);
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)
1193 Info<<
" Cell Zone " << name <<
" " <<
tab
1205 if (faceZones.
size() > 0)
1214 word name = faceZones.
toc()[cnt];
1218 Info<<
" Face Zone " << name <<
" " <<
tab
1223 const label old = oldIndizes[i];
1225 label c1 = -1, c2 = -1;
1226 if (faceToCell[0].found(old))
1228 c1 = faceToCell[0][old];
1230 if (faceToCell[1].found(old))
1232 c2 = faceToCell[1][old];
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])
1272 indizes[i] = noveau;
1276 faceZones.
toc()[cnt],