mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
correct extrudeMesh
This commit is contained in:
@ -23,8 +23,9 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Extrude mesh from existing patch (flipped so has inwards pointing
|
Extrude mesh from existing patch (by default outwards facing normals;
|
||||||
normals) or from patch read from file.
|
optional flips faces)
|
||||||
|
or from patch read from file.
|
||||||
Note: Merges close points so be careful.
|
Note: Merges close points so be careful.
|
||||||
|
|
||||||
Type of extrusion prescribed by run-time selectable model.
|
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];
|
const polyPatch& pp = mesh.boundaryMesh()[patchID];
|
||||||
fMesh.reset(new faceMesh(pp.localFaces(), pp.localPoints()));
|
fMesh.reset(new faceMesh(pp.localFaces(), pp.localPoints()));
|
||||||
fMesh().flip();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
fileName surfName(patchName + ".sMesh");
|
fileName surfName(runTime.path()/patchName + ".sMesh");
|
||||||
|
Info<< "Writing patch as surfaceMesh to "
|
||||||
Info<< "Writing (flipped) patch as surfaceMesh to "
|
|
||||||
<< surfName << nl << endl;
|
<< surfName << nl << endl;
|
||||||
|
|
||||||
OFstream os(surfName);
|
OFstream os(surfName);
|
||||||
os << fMesh() << nl;
|
os << fMesh() << nl;
|
||||||
}
|
}
|
||||||
@ -142,6 +140,20 @@ int main(int argc, char *argv[])
|
|||||||
<< "patch or surface." << exit(FatalError);
|
<< "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
|
Info<< "Extruding patch with :" << nl
|
||||||
<< " points : " << fMesh().points().size() << nl
|
<< " points : " << fMesh().points().size() << nl
|
||||||
|
|||||||
@ -47,7 +47,14 @@ linearNormal::linearNormal(const dictionary& dict)
|
|||||||
:
|
:
|
||||||
extrudeModel(typeName, dict),
|
extrudeModel(typeName, dict),
|
||||||
thickness_(readScalar(coeffDict_.lookup("thickness")))
|
thickness_(readScalar(coeffDict_.lookup("thickness")))
|
||||||
{}
|
{
|
||||||
|
if (thickness_ <= 0)
|
||||||
|
{
|
||||||
|
FatalErrorIn("linearNormal(const dictionary&)")
|
||||||
|
<< "thickness should be positive : " << thickness_
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -19,31 +19,40 @@ FoamFile
|
|||||||
constructFrom patch; //surface;
|
constructFrom patch; //surface;
|
||||||
|
|
||||||
// If construct from (flipped) patch
|
// If construct from (flipped) patch
|
||||||
sourceCase "../cavity";
|
sourceCase "$FOAM_RUN/icoFoam/cavity";
|
||||||
sourcePatch movingWall;
|
sourcePatch movingWall;
|
||||||
|
|
||||||
|
// Flip surface normals before usage.
|
||||||
|
flipNormals false;
|
||||||
|
|
||||||
// If construct from surface
|
// If construct from surface
|
||||||
surface "movingWall.sMesh";
|
surface "movingWall.sMesh";
|
||||||
|
|
||||||
|
|
||||||
// Do front and back need to be merged?
|
// Do front and back need to be merged? Usually only makes sense for 360
|
||||||
mergeFaces false;
|
// degree wedges.
|
||||||
|
mergeFaces true;
|
||||||
|
|
||||||
|
|
||||||
//- Linear extrusion in point-normal direction
|
//- Linear extrusion in point-normal direction
|
||||||
//extrudeModel linearNormal;
|
//extrudeModel linearNormal;
|
||||||
|
|
||||||
//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
|
//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
|
||||||
extrudeModel wedge;
|
extrudeModel wedge;
|
||||||
|
|
||||||
//- Extrudes into sphere around (0 0 0)
|
//- Extrudes into sphere around (0 0 0)
|
||||||
//extrudeModel linearRadial;
|
//extrudeModel linearRadial;
|
||||||
|
|
||||||
|
//- Extrudes into sphere with grading according to pressure (atmospherics)
|
||||||
//extrudeModel sigmaRadial;
|
//extrudeModel sigmaRadial;
|
||||||
|
|
||||||
nLayers 6;
|
nLayers 20;
|
||||||
|
|
||||||
wedgeCoeffs
|
wedgeCoeffs
|
||||||
{
|
{
|
||||||
axisPt (0 0.1 0);
|
axisPt (0 0.1 0);
|
||||||
axis (1 0 0);
|
axis (-1 0 0);
|
||||||
angle 90.0; // For nLayers=1 assume symmetry so angle/2 on each side
|
angle 360; // For nLayers=1 assume symmetry so angle/2 on each side
|
||||||
}
|
}
|
||||||
|
|
||||||
linearNormalCoeffs
|
linearNormalCoeffs
|
||||||
|
|||||||
@ -109,15 +109,33 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
|
|||||||
label currentLayerOffset = layer*surfacePoints.size();
|
label currentLayerOffset = layer*surfacePoints.size();
|
||||||
label nextLayerOffset = currentLayerOffset + surfacePoints.size();
|
label nextLayerOffset = currentLayerOffset + surfacePoints.size();
|
||||||
|
|
||||||
// Side faces from layer to layer+1
|
// Vertical faces from layer to layer+1
|
||||||
for (label i=0; i<nInternalEdges; i++)
|
for (label edgeI=0; edgeI<nInternalEdges; edgeI++)
|
||||||
{
|
{
|
||||||
quad[0] = surfaceEdges[i][1] + currentLayerOffset;
|
const edge& e = surfaceEdges[edgeI];
|
||||||
quad[1] = surfaceEdges[i][0] + currentLayerOffset;
|
const labelList& edgeFaces = extrudePatch.edgeFaces()[edgeI];
|
||||||
quad[2] = surfaceEdges[i][0] + nextLayerOffset;
|
|
||||||
quad[3] = surfaceEdges[i][1] + nextLayerOffset;
|
|
||||||
|
|
||||||
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
|
// Faces between layer and layer+1
|
||||||
@ -128,9 +146,9 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
|
|||||||
eFaces[facei++] =
|
eFaces[facei++] =
|
||||||
face
|
face
|
||||||
(
|
(
|
||||||
surfaceFaces[i].reverseFace()
|
surfaceFaces[i] //.reverseFace()
|
||||||
+ nextLayerOffset
|
+ nextLayerOffset
|
||||||
).reverseFace();
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,40 +160,46 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
|
|||||||
label nextLayerOffset = currentLayerOffset + surfacePoints.size();
|
label nextLayerOffset = currentLayerOffset + surfacePoints.size();
|
||||||
|
|
||||||
// Side faces across layer
|
// 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];
|
const edge& e = surfaceEdges[edgeI];
|
||||||
quad[0] = e[1] + currentLayerOffset;
|
const labelList& edgeFaces = extrudePatch.edgeFaces()[edgeI];
|
||||||
quad[1] = e[0] + currentLayerOffset;
|
|
||||||
quad[2] = e[0] + nextLayerOffset;
|
|
||||||
quad[3] = e[1] + nextLayerOffset;
|
|
||||||
|
|
||||||
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
|
// Bottom faces
|
||||||
forAll(surfaceFaces, i)
|
forAll(surfaceFaces, i)
|
||||||
|
{
|
||||||
|
eFaces[facei++] = face(surfaceFaces[i]).reverseFace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Top faces
|
||||||
|
forAll(surfaceFaces, i)
|
||||||
{
|
{
|
||||||
eFaces[facei++] =
|
eFaces[facei++] =
|
||||||
face
|
face
|
||||||
(
|
(
|
||||||
surfaceFaces[i].reverseFace()
|
surfaceFaces[i]
|
||||||
+ nLayers*surfacePoints.size()
|
+ nLayers*surfacePoints.size()
|
||||||
).reverseFace();
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return points for transferring
|
// return points for transferring
|
||||||
|
|||||||
Reference in New Issue
Block a user