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,6 +308,36 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (readFaceFile)
|
||||||
|
{
|
||||||
label nPatches = 0;
|
label nPatches = 0;
|
||||||
|
|
||||||
// List of Foam vertices per boundary face
|
// List of Foam vertices per boundary face
|
||||||
@ -295,8 +346,6 @@ int main(int argc, char *argv[])
|
|||||||
// For each boundary faces the Foam patchID
|
// For each boundary faces the Foam patchID
|
||||||
labelList boundaryPatch;
|
labelList boundaryPatch;
|
||||||
|
|
||||||
if (readFaceFile)
|
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// read boundary faces
|
// read boundary faces
|
||||||
//
|
//
|
||||||
@ -366,6 +415,9 @@ int main(int argc, char *argv[])
|
|||||||
f[2-i] = nodeToPoint[nodeI];
|
f[2-i] = nodeToPoint[nodeI];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (findFace(mesh, f) >= mesh.nInternalFaces())
|
||||||
|
{
|
||||||
boundaryFaces[faceI] = f;
|
boundaryFaces[faceI] = f;
|
||||||
|
|
||||||
if (nFaceAttr > 0)
|
if (nFaceAttr > 0)
|
||||||
@ -377,7 +429,8 @@ int main(int argc, char *argv[])
|
|||||||
// Get Foam patchID and update region->patch table.
|
// Get Foam patchID and update region->patch table.
|
||||||
label patchI = 0;
|
label patchI = 0;
|
||||||
|
|
||||||
Map<label>::iterator patchFind = regionToPatch.find(region);
|
Map<label>::iterator patchFind =
|
||||||
|
regionToPatch.find(region);
|
||||||
|
|
||||||
if (patchFind == regionToPatch.end())
|
if (patchFind == regionToPatch.end())
|
||||||
{
|
{
|
||||||
@ -406,6 +459,13 @@ int main(int argc, char *argv[])
|
|||||||
faceI++;
|
faceI++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Trim
|
||||||
|
boundaryFaces.setSize(faceI);
|
||||||
|
boundaryPatch.setSize(faceI);
|
||||||
|
|
||||||
|
|
||||||
// Print region to patch mapping
|
// Print region to patch mapping
|
||||||
Info<< "Regions:" << endl;
|
Info<< "Regions:" << endl;
|
||||||
@ -421,13 +481,10 @@ 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);
|
faceListList patchFaces(nPatches);
|
||||||
|
|
||||||
wordList patchNames(nPatches);
|
wordList patchNames(nPatches);
|
||||||
|
|
||||||
forAll(patchNames, patchI)
|
forAll(patchNames, patchI)
|
||||||
@ -441,8 +498,6 @@ int main(int argc, char *argv[])
|
|||||||
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,14 +519,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
|
||||||
|
|
||||||
if (!overwrite)
|
|
||||||
{
|
|
||||||
runTime++;
|
|
||||||
}
|
|
||||||
|
|
||||||
polyMesh mesh
|
meshPtr.reset
|
||||||
|
(
|
||||||
|
new polyMesh
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
@ -487,11 +539,14 @@ int main(int argc, char *argv[])
|
|||||||
defaultFacesName,
|
defaultFacesName,
|
||||||
defaultFacesType,
|
defaultFacesType,
|
||||||
patchPhysicalTypes
|
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