handle marked internal faces
This commit is contained in:
parent
c647881d7b
commit
7d9b0b103d
@ -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;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// 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[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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[])
|
|||||||
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)
|
||||||
// Get Foam patchID and update region->patch table.
|
|
||||||
label patchI = 0;
|
|
||||||
|
|
||||||
Map<label>::iterator patchFind = regionToPatch.find(region);
|
|
||||||
|
|
||||||
if (patchFind == regionToPatch.end())
|
|
||||||
{
|
{
|
||||||
patchI = nPatches;
|
// First attribute is the region number
|
||||||
|
faceLine >> region;
|
||||||
|
|
||||||
Info<< "Mapping tetgen region " << region
|
|
||||||
<< " to Foam patch "
|
|
||||||
<< patchI << endl;
|
|
||||||
|
|
||||||
regionToPatch.insert(region, nPatches++);
|
// Get Foam patchID and update region->patch table.
|
||||||
}
|
label patchI = 0;
|
||||||
else
|
|
||||||
{
|
Map<label>::iterator patchFind =
|
||||||
patchI = patchFind();
|
regionToPatch.find(region);
|
||||||
|
|
||||||
|
if (patchFind == regionToPatch.end())
|
||||||
|
{
|
||||||
|
patchI = nPatches;
|
||||||
|
|
||||||
|
Info<< "Mapping tetgen region " << region
|
||||||
|
<< " to Foam patch "
|
||||||
|
<< patchI << endl;
|
||||||
|
|
||||||
|
regionToPatch.insert(region, nPatches++);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
patchI = patchFind();
|
||||||
|
}
|
||||||
|
|
||||||
|
boundaryPatch[faceI] = patchI;
|
||||||
|
|
||||||
|
// Skip remaining attributes
|
||||||
|
for (label i = 1; i < nFaceAttr; i++)
|
||||||
|
{
|
||||||
|
faceLine >> dummy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boundaryPatch[faceI] = patchI;
|
faceI++;
|
||||||
|
|
||||||
// Skip remaining attributes
|
|
||||||
for (label i = 1; i < nFaceAttr; i++)
|
|
||||||
{
|
|
||||||
faceLine >> dummy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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[])
|
|||||||
<< 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)
|
||||||
|
{
|
||||||
|
patchNames[patchI] = word("patch") + name(patchI);
|
||||||
|
}
|
||||||
|
|
||||||
wordList patchNames(nPatches);
|
wordList patchTypes(nPatches, polyPatch::typeName);
|
||||||
|
word defaultFacesName = "defaultFaces";
|
||||||
forAll(patchNames, patchI)
|
word defaultFacesType = polyPatch::typeName;
|
||||||
{
|
wordList patchPhysicalTypes(nPatches, polyPatch::typeName);
|
||||||
patchNames[patchI] = word("patch") + name(patchI);
|
|
||||||
}
|
|
||||||
|
|
||||||
wordList patchTypes(nPatches, polyPatch::typeName);
|
|
||||||
word defaultFacesName = "defaultFaces";
|
|
||||||
word defaultFacesType = 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[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user