Skip to content
Snippets Groups Projects
Commit 7d9b0b10 authored by Mattijs Janssens's avatar Mattijs Janssens
Browse files

handle marked internal faces

parent c647881d
Branches
Tags
No related merge requests found
...@@ -54,8 +54,9 @@ Description ...@@ -54,8 +54,9 @@ Description
NOTE: NOTE:
- for some reason boundary faces point inwards. I just reverse them - for some reason boundary faces point inwards. I just reverse them
always. Might use some geometric check instead. always. Might use some geometric check instead.
- marked faces might not actually be boundary faces of mesh. This is not handled - marked faces might not actually be boundary faces of mesh.
and you'll have to run without face file (-noFaceFile option) This is hopefully handled now by first constructing without boundaries
and then reconstructing with boundary faces.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
...@@ -69,20 +70,40 @@ using namespace Foam; ...@@ -69,20 +70,40 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Find label of face.
label findFace(const primitiveMesh& mesh, const face& f)
{
const labelList& pFaces = mesh.pointFaces()[f[0]];
forAll(pFaces, i)
{
label faceI = pFaces[i];
if (mesh.faces()[faceI] == f)
{
return faceI;
}
}
FatalErrorIn("findFace(const primitiveMesh&, const face&)")
<< "Cannot find face " << f << " in mesh." << abort(FatalError);
return -1;
}
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validArgs.append("file prefix"); argList::validArgs.append("file prefix");
argList::validOptions.insert("noFaceFile", ""); argList::validOptions.insert("noFaceFile", "");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
bool readFaceFile = !args.options().found("noFaceFile"); bool readFaceFile = !args.options().found("noFaceFile");
bool overwrite = args.options().found("overwrite");
fileName prefix(args.additionalArgs()[0]); fileName prefix(args.additionalArgs()[0]);
...@@ -287,16 +308,44 @@ int main(int argc, char *argv[]) ...@@ -287,16 +308,44 @@ int main(int argc, char *argv[])
} }
label nPatches = 0; //
// Construct mesh with default boundary only
//
autoPtr<polyMesh> meshPtr
(
new polyMesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.constant(),
runTime
),
points,
cells,
faceListList(0),
wordList(0), //boundaryPatchNames
wordList(0), //boundaryPatchTypes
"defaultFaces",
polyPatch::typeName,
wordList(0)
)
);
const polyMesh& mesh = meshPtr;
// List of Foam vertices per boundary face
faceList boundaryFaces;
// For each boundary faces the Foam patchID
labelList boundaryPatch;
if (readFaceFile) if (readFaceFile)
{ {
label nPatches = 0;
// List of Foam vertices per boundary face
faceList boundaryFaces;
// For each boundary faces the Foam patchID
labelList boundaryPatch;
// //
// read boundary faces // read boundary faces
// //
...@@ -366,48 +415,59 @@ int main(int argc, char *argv[]) ...@@ -366,48 +415,59 @@ int main(int argc, char *argv[])
f[2-i] = nodeToPoint[nodeI]; f[2-i] = nodeToPoint[nodeI];
} }
boundaryFaces[faceI] = f;
if (nFaceAttr > 0) if (findFace(mesh, f) >= mesh.nInternalFaces())
{ {
// First attribute is the region number boundaryFaces[faceI] = f;
faceLine >> region;
if (nFaceAttr > 0)
{
// First attribute is the region number
faceLine >> region;
// Get Foam patchID and update region->patch table.
label patchI = 0;
Map<label>::iterator patchFind = regionToPatch.find(region); // Get Foam patchID and update region->patch table.
label patchI = 0;
if (patchFind == regionToPatch.end()) Map<label>::iterator patchFind =
{ regionToPatch.find(region);
patchI = nPatches;
Info<< "Mapping tetgen region " << region if (patchFind == regionToPatch.end())
<< " to Foam patch " {
<< patchI << endl; patchI = nPatches;
regionToPatch.insert(region, nPatches++); Info<< "Mapping tetgen region " << region
} << " to Foam patch "
else << patchI << endl;
{
patchI = patchFind();
}
boundaryPatch[faceI] = patchI; regionToPatch.insert(region, nPatches++);
}
else
{
patchI = patchFind();
}
// Skip remaining attributes boundaryPatch[faceI] = patchI;
for (label i = 1; i < nFaceAttr; i++)
{ // Skip remaining attributes
faceLine >> dummy; for (label i = 1; i < nFaceAttr; i++)
{
faceLine >> dummy;
}
} }
}
faceI++; faceI++;
}
} }
} }
// Print region to patch mapping
// Trim
boundaryFaces.setSize(faceI);
boundaryPatch.setSize(faceI);
// Print region to patch mapping
Info<< "Regions:" << endl; Info<< "Regions:" << endl;
for for
...@@ -421,28 +481,23 @@ int main(int argc, char *argv[]) ...@@ -421,28 +481,23 @@ int main(int argc, char *argv[])
<< iter() << endl; << iter() << endl;
} }
Info<< endl; Info<< endl;
}
// Storage for boundary faces // Storage for boundary faces
faceListList patchFaces(nPatches);
wordList patchNames(nPatches);
faceListList patchFaces(nPatches); forAll(patchNames, patchI)
{
wordList patchNames(nPatches); patchNames[patchI] = word("patch") + name(patchI);
}
forAll(patchNames, patchI)
{
patchNames[patchI] = word("patch") + name(patchI);
}
wordList patchTypes(nPatches, polyPatch::typeName); wordList patchTypes(nPatches, polyPatch::typeName);
word defaultFacesName = "defaultFaces"; word defaultFacesName = "defaultFaces";
word defaultFacesType = polyPatch::typeName; word defaultFacesType = polyPatch::typeName;
wordList patchPhysicalTypes(nPatches, polyPatch::typeName); wordList patchPhysicalTypes(nPatches, polyPatch::typeName);
if (readFaceFile)
{
// Sort boundaryFaces by patch using boundaryPatch. // Sort boundaryFaces by patch using boundaryPatch.
List<DynamicList<face> > allPatchFaces(nPatches); List<DynamicList<face> > allPatchFaces(nPatches);
...@@ -464,34 +519,34 @@ int main(int argc, char *argv[]) ...@@ -464,34 +519,34 @@ int main(int argc, char *argv[])
} }
Info<< endl; Info<< endl;
}
if (!overwrite)
{
runTime++;
}
polyMesh mesh meshPtr.reset
(
IOobject
( (
polyMesh::defaultRegion, new polyMesh
runTime.constant(), (
runTime IOobject
), (
points, polyMesh::defaultRegion,
cells, runTime.constant(),
patchFaces, runTime
patchNames, ),
patchTypes, points,
defaultFacesName, cells,
defaultFacesType, patchFaces,
patchPhysicalTypes patchNames,
); patchTypes,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
)
);
}
Info<< "Writing mesh to " << runTime.constant() << endl << endl; Info<< "Writing mesh to " << runTime.constant() << endl << endl;
mesh.write(); meshPtr().write();
Info<< "End\n" << endl; Info<< "End\n" << endl;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment