correct extrudeMesh

This commit is contained in:
mattijs
2009-07-09 16:01:36 +01:00
parent 1c095c249d
commit e6cdada5d6
4 changed files with 94 additions and 42 deletions

View File

@ -23,8 +23,9 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Extrude mesh from existing patch (flipped so has inwards pointing
normals) or from patch read from file.
Extrude mesh from existing patch (by default outwards facing normals;
optional flips faces)
or from patch read from file.
Note: Merges close points so be careful.
Type of extrusion prescribed by run-time selectable model.
@ -108,14 +109,11 @@ int main(int argc, char *argv[])
const polyPatch& pp = mesh.boundaryMesh()[patchID];
fMesh.reset(new faceMesh(pp.localFaces(), pp.localPoints()));
fMesh().flip();
{
fileName surfName(patchName + ".sMesh");
Info<< "Writing (flipped) patch as surfaceMesh to "
fileName surfName(runTime.path()/patchName + ".sMesh");
Info<< "Writing patch as surfaceMesh to "
<< surfName << nl << endl;
OFstream os(surfName);
os << fMesh() << nl;
}
@ -142,6 +140,20 @@ int main(int argc, char *argv[])
<< "patch or surface." << exit(FatalError);
}
Switch flipNormals(dict.lookup("flipNormals"));
if (flipNormals)
{
Info<< "Flipping faces." << nl << endl;
faceList faces(fMesh().size());
forAll(faces, i)
{
faces[i] = fMesh()[i].reverseFace();
}
fMesh.reset(new faceMesh(faces, fMesh().localPoints()));
}
Info<< "Extruding patch with :" << nl
<< " points : " << fMesh().points().size() << nl

View File

@ -47,7 +47,14 @@ linearNormal::linearNormal(const dictionary& dict)
:
extrudeModel(typeName, dict),
thickness_(readScalar(coeffDict_.lookup("thickness")))
{}
{
if (thickness_ <= 0)
{
FatalErrorIn("linearNormal(const dictionary&)")
<< "thickness should be positive : " << thickness_
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -19,31 +19,40 @@ FoamFile
constructFrom patch; //surface;
// If construct from (flipped) patch
sourceCase "../cavity";
sourceCase "$FOAM_RUN/icoFoam/cavity";
sourcePatch movingWall;
// Flip surface normals before usage.
flipNormals false;
// If construct from surface
surface "movingWall.sMesh";
// Do front and back need to be merged?
mergeFaces false;
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces true;
//- Linear extrusion in point-normal direction
//extrudeModel linearNormal;
//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
extrudeModel wedge;
//- Extrudes into sphere around (0 0 0)
//extrudeModel linearRadial;
//- Extrudes into sphere with grading according to pressure (atmospherics)
//extrudeModel sigmaRadial;
nLayers 6;
nLayers 20;
wedgeCoeffs
{
axisPt (0 0.1 0);
axis (1 0 0);
angle 90.0; // For nLayers=1 assume symmetry so angle/2 on each side
axis (-1 0 0);
angle 360; // For nLayers=1 assume symmetry so angle/2 on each side
}
linearNormalCoeffs

View File

@ -109,15 +109,33 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
label currentLayerOffset = layer*surfacePoints.size();
label nextLayerOffset = currentLayerOffset + surfacePoints.size();
// Side faces from layer to layer+1
for (label i=0; i<nInternalEdges; i++)
// Vertical faces from layer to layer+1
for (label edgeI=0; edgeI<nInternalEdges; edgeI++)
{
quad[0] = surfaceEdges[i][1] + currentLayerOffset;
quad[1] = surfaceEdges[i][0] + currentLayerOffset;
quad[2] = surfaceEdges[i][0] + nextLayerOffset;
quad[3] = surfaceEdges[i][1] + nextLayerOffset;
const edge& e = surfaceEdges[edgeI];
const labelList& edgeFaces = extrudePatch.edgeFaces()[edgeI];
eFaces[facei++] = face(quad).reverseFace();
face& f = eFaces[facei++];
f.setSize(4);
if
(
(edgeFaces[0] < edgeFaces[1])
== sameOrder(surfaceFaces[edgeFaces[0]], e)
)
{
f[0] = e[0] + currentLayerOffset;
f[1] = e[1] + currentLayerOffset;
f[2] = e[1] + nextLayerOffset;
f[3] = e[0] + nextLayerOffset;
}
else
{
f[0] = e[1] + currentLayerOffset;
f[1] = e[0] + currentLayerOffset;
f[2] = e[0] + nextLayerOffset;
f[3] = e[1] + nextLayerOffset;
}
}
// Faces between layer and layer+1
@ -128,9 +146,9 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
eFaces[facei++] =
face
(
surfaceFaces[i].reverseFace()
surfaceFaces[i] //.reverseFace()
+ nextLayerOffset
).reverseFace();
);
}
}
}
@ -142,40 +160,46 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
label nextLayerOffset = currentLayerOffset + surfacePoints.size();
// Side faces across layer
for (label i=nInternalEdges; i<surfaceEdges.size(); i++)
for (label edgeI=nInternalEdges; edgeI<surfaceEdges.size(); edgeI++)
{
const edge& e = surfaceEdges[i];
quad[0] = e[1] + currentLayerOffset;
quad[1] = e[0] + currentLayerOffset;
quad[2] = e[0] + nextLayerOffset;
quad[3] = e[1] + nextLayerOffset;
const edge& e = surfaceEdges[edgeI];
const labelList& edgeFaces = extrudePatch.edgeFaces()[edgeI];
label ownerFace = extrudePatch.edgeFaces()[i][0];
face& f = eFaces[facei++];
f.setSize(4);
if (sameOrder(surfaceFaces[ownerFace], e))
if (sameOrder(surfaceFaces[edgeFaces[0]], e))
{
reverse(quad);
f[0] = e[0] + currentLayerOffset;
f[1] = e[1] + currentLayerOffset;
f[2] = e[1] + nextLayerOffset;
f[3] = e[0] + nextLayerOffset;
}
else
{
f[0] = e[1] + currentLayerOffset;
f[1] = e[0] + currentLayerOffset;
f[2] = e[0] + nextLayerOffset;
f[3] = e[1] + nextLayerOffset;
}
eFaces[facei++] = face(quad);
}
}
// Top faces
forAll(surfaceFaces, i)
{
eFaces[facei++] = face(surfaceFaces[i]).reverseFace();
}
// Bottom faces
forAll(surfaceFaces, i)
{
eFaces[facei++] = face(surfaceFaces[i]).reverseFace();
}
// Top faces
forAll(surfaceFaces, i)
{
eFaces[facei++] =
face
(
surfaceFaces[i].reverseFace()
surfaceFaces[i]
+ nLayers*surfacePoints.size()
).reverseFace();
);
}
// return points for transferring