From e6cdada5d6e336755f0559c6cd233d2b5509f36d Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 9 Jul 2009 16:01:36 +0100 Subject: [PATCH] correct extrudeMesh --- .../mesh/generation/extrudeMesh/extrudeMesh.C | 26 ++++-- .../extrudeModel/linearNormal/linearNormal.C | 9 ++- .../generation/extrudeMesh/extrudeProperties | 21 +++-- .../extrudeMesh/extrudedMesh/extrudedMesh.C | 80 ++++++++++++------- 4 files changed, 94 insertions(+), 42 deletions(-) diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C index 69dc36bccf..7380562664 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C @@ -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 diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C index 99c02d214f..c36098ab1e 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C @@ -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 * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties b/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties index 20de7b2152..8bf73c4bf2 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties @@ -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 diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudedMesh/extrudedMesh.C b/applications/utilities/mesh/generation/extrudeMesh/extrudedMesh/extrudedMesh.C index b258c59445..16bab41094 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudedMesh/extrudedMesh.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudedMesh/extrudedMesh.C @@ -109,15 +109,33 @@ Foam::Xfer 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 Foam::extrudedMesh::extrudedFaces eFaces[facei++] = face ( - surfaceFaces[i].reverseFace() + surfaceFaces[i] //.reverseFace() + nextLayerOffset - ).reverseFace(); + ); } } } @@ -142,40 +160,46 @@ Foam::Xfer Foam::extrudedMesh::extrudedFaces label nextLayerOffset = currentLayerOffset + surfacePoints.size(); // Side faces across layer - for (label i=nInternalEdges; i