extrudeMesh improvements

This commit is contained in:
mattijs
2009-06-16 16:44:35 +01:00
parent 72d8456951
commit e92d84b7a9
8 changed files with 663 additions and 83 deletions

View File

@ -23,7 +23,8 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Extrude mesh from existing patch or from patch read from file.
Extrude mesh from existing patch (flipped so has inwards pointing
normals) or from patch read from file.
Note: Merges close points so be careful.
Type of extrusion prescribed by run-time selectable model.
@ -52,43 +53,34 @@ using namespace Foam;
int main(int argc, char *argv[])
{
#include "setRoots.H"
#include "setRootCase.H"
#include "createTimeExtruded.H"
if (args.optionFound("sourceCase") == args.optionFound("surface"))
{
FatalErrorIn(args.executable())
<< "Specify either -sourceCase and -sourcePatch"
" or -surface options\n"
" to specify the source of the patch to extrude"
<< exit(FatalError);
}
autoPtr<extrudedMesh> meshPtr(NULL);
autoPtr<extrudeModel> model
IOdictionary dict
(
extrudeModel::New
IOobject
(
IOdictionary
(
IOobject
(
"extrudeProperties",
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::MUST_READ
)
)
"extrudeProperties",
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::MUST_READ
)
);
if (args.optionFound("sourceCase"))
autoPtr<extrudeModel> model(extrudeModel::New(dict));
const word sourceType(dict.lookup("constructFrom"));
autoPtr<faceMesh> fMesh;
if (sourceType == "patch")
{
fileName sourceCasePath(args.option("sourceCase"));
fileName sourceCasePath(dict.lookup("sourceCase"));
fileName sourceRootDir = sourceCasePath.path();
fileName sourceCaseDir = sourceCasePath.name();
word patchName(args.option("sourcePatch"));
word patchName(dict.lookup("sourcePatch"));
Info<< "Extruding patch " << patchName
<< " on mesh " << sourceCasePath << nl
@ -114,75 +106,69 @@ 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 patch as surfaceMesh to " << surfName << nl << endl;
faceMesh fMesh(pp.localFaces(), pp.localPoints());
Info<< "Writing (flipped) patch as surfaceMesh to "
<< surfName << nl << endl;
OFstream os(surfName);
os << fMesh << nl;
os << fMesh() << nl;
}
meshPtr.reset
(
new extrudedMesh
(
IOobject
(
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
pp,
model()
)
);
}
else
else if (sourceType == "surface")
{
// Read from surface
fileName surfName(args.option("surface"));
fileName surfName(dict.lookup("surface"));
Info<< "Extruding surfaceMesh read from file " << surfName << nl
<< endl;
IFstream is(surfName);
faceMesh fMesh(is);
fMesh.reset(new faceMesh(is));
Info<< "Read patch from file " << surfName << ':' << nl
<< " points : " << fMesh.points().size() << nl
<< " faces : " << fMesh.size() << nl
Info<< "Read patch from file " << surfName << nl
<< endl;
}
else
{
FatalErrorIn(args.executable())
<< "Illegal 'constructFrom' specification. Should either be "
<< "patch or surface." << exit(FatalError);
}
Info<< "Extruding patch with :" << nl
<< " points : " << fMesh().points().size() << nl
<< " faces : " << fMesh().size() << nl
<< " normals[0] : " << fMesh().faceNormals()[0]
<< nl
<< endl;
meshPtr.reset
extrudedMesh mesh
(
IOobject
(
new extrudedMesh
(
IOobject
(
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
fMesh,
model()
)
);
}
extrudedMesh& mesh = meshPtr();
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
fMesh(),
model()
);
const boundBox& bb = mesh.globalData().bb();
const vector span = bb.span();
const scalar mergeDim = 1E-4 * bb.minDim();
Info<< "Mesh bounding box:" << bb << nl
<< " with span:" << span << nl
<< "Merge distance :" << mergeDim << nl
Info<< "Mesh bounding box : " << bb << nl
<< " with span : " << span << nl
<< "Merge distance : " << mergeDim << nl
<< endl;
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -250,7 +236,8 @@ int main(int argc, char *argv[])
// Merging front and back patch faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (args.optionFound("mergeFaces"))
Switch mergeFaces(dict.lookup("mergeFaces"));
if (mergeFaces)
{
Info<< "Assuming full 360 degree axisymmetric case;"
<< " stitching faces on patches "

View File

@ -88,7 +88,8 @@ point wedge::operator()
}
else
{
sliceAngle = angle_*(layer + 1)/nLayers_;
//sliceAngle = angle_*(layer + 1)/nLayers_;
sliceAngle = angle_*layer/nLayers_;
}
// Find projection onto axis (or rather decompose surfacePoint

View File

@ -14,23 +14,41 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
extrudeModel wedge;
// Where to get surface from: either from surface ('surface') or
// from (flipped) patch of existing case ('patch')
constructFrom patch; //surface;
// If construct from (flipped) patch
sourceCase "../cavity";
sourcePatch movingWall;
// If construct from surface
surface "movingWall.sMesh";
// Do front and back need to be merged?
mergeFaces false;
//- 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;
//extrudeModel sigmaRadial;
nLayers 1;
nLayers 6;
wedgeCoeffs
{
axisPt (0 0 0);
axis (0 -1 0);
angle 2.0;
axisPt (0 0.1 0);
axis (1 0 0);
angle 90.0; // For nLayers=1 assume symmetry so angle/2 on each side
}
linearNormalCoeffs
{
thickness 0.1;
thickness 0.05;
}
linearRadialCoeffs
@ -47,3 +65,4 @@ sigmaRadialCoeffs
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -117,7 +117,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
quad[2] = surfaceEdges[i][0] + nextLayerOffset;
quad[3] = surfaceEdges[i][1] + nextLayerOffset;
eFaces[facei++] = face(quad);
eFaces[facei++] = face(quad).reverseFace();
}
// Faces between layer and layer+1
@ -130,7 +130,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
(
surfaceFaces[i].reverseFace()
+ nextLayerOffset
);
).reverseFace();
}
}
}
@ -152,7 +152,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
label ownerFace = extrudePatch.edgeFaces()[i][0];
if (!sameOrder(surfaceFaces[ownerFace], e))
if (sameOrder(surfaceFaces[ownerFace], e))
{
reverse(quad);
}
@ -164,7 +164,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
// Top faces
forAll(surfaceFaces, i)
{
eFaces[facei++] = face(surfaceFaces[i]);
eFaces[facei++] = face(surfaceFaces[i]).reverseFace();
}
// Bottom faces
@ -175,7 +175,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
(
surfaceFaces[i].reverseFace()
+ nLayers*surfacePoints.size()
);
).reverseFace();
}
// return points for transferring

View File

@ -78,6 +78,18 @@ public:
{}
// Member Functions
void flip()
{
forAll(*this, i)
{
face& f = operator[](i);
f = f.reverseFace();
}
clearOut();
}
// IOstream Operators
friend Ostream& operator<<(Ostream& os, const faceMesh& fm)
@ -85,7 +97,8 @@ public:
return os
<< fm.points()
<< token::NL
<< static_cast<PrimitivePatch<face, Foam::List, pointField> >(fm);
<< static_cast<PrimitivePatch<face, Foam::List, pointField> >
(fm);
}
};