Commit 4f85f763 authored by mattijs's avatar mattijs
Browse files

allow stand-alone extrusion

parent 61b29463
......@@ -335,17 +335,19 @@ Foam::label Foam::addPatchCellLayer::addSideFace
label inflateEdgeI = -1;
// Check mesh faces using edge
forAll(meshFaces, i)
if (addToMesh_)
{
if (mesh_.isInternalFace(meshFaces[i]))
forAll(meshFaces, i)
{
// meshEdge uses internal faces so ok to inflate from it
inflateEdgeI = meshEdgeI;
break;
if (mesh_.isInternalFace(meshFaces[i]))
{
// meshEdge uses internal faces so ok to inflate from it
inflateEdgeI = meshEdgeI;
break;
}
}
}
// Get my mesh face and its zone.
label meshFaceI = pp.addressing()[ownFaceI];
label zoneI = mesh_.faceZones().whichZone(meshFaceI);
......@@ -504,9 +506,14 @@ Foam::label Foam::addPatchCellLayer::addSideFace
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from mesh
Foam::addPatchCellLayer::addPatchCellLayer(const polyMesh& mesh)
Foam::addPatchCellLayer::addPatchCellLayer
(
const polyMesh& mesh,
const bool addToMesh
)
:
mesh_(mesh),
addToMesh_(addToMesh),
addedPoints_(0),
layerFaces_(0)
{}
......@@ -827,6 +834,19 @@ void Foam::addPatchCellLayer::setRefinement
}
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// Precalculated patchID for each patch face
labelList patchID(pp.size());
forAll(pp, patchFaceI)
{
label meshFaceI = pp.addressing()[patchFaceI];
patchID[patchFaceI] = patches.whichPatch(meshFaceI);
}
// From master point (in patch point label) to added points (in mesh point
// label)
addedPoints_.setSize(pp.nPoints());
......@@ -857,6 +877,33 @@ void Foam::addPatchCellLayer::setRefinement
// Create new points
//
// If creating new mesh: copy existing patch points
labelList copiedPatchPoints;
if (!addToMesh_)
{
copiedPatchPoints.setSize(firstLayerDisp.size());
forAll(firstLayerDisp, patchPointI)
{
if (addedPoints_[patchPointI].size())
{
label meshPointI = meshPoints[patchPointI];
label zoneI = mesh_.pointZones().whichZone(meshPointI);
copiedPatchPoints[patchPointI] = meshMod.setAction
(
polyAddPoint
(
mesh_.points()[meshPointI], // point
-1, // master point
zoneI, // zone for point
true // supports a cell
)
);
}
}
}
// Create points for additional layers
forAll(firstLayerDisp, patchPointI)
{
if (addedPoints_[patchPointI].size())
......@@ -878,7 +925,7 @@ void Foam::addPatchCellLayer::setRefinement
polyAddPoint
(
pt, // point
meshPointI, // master point
(addToMesh_ ? meshPointI : -1), // master point
zoneI, // zone for point
true // supports a cell
)
......@@ -922,7 +969,7 @@ void Foam::addPatchCellLayer::setRefinement
-1, // master point
-1, // master edge
-1, // master face
mesh_.faceOwner()[meshFaceI], // master cell id
(addToMesh_ ? mesh_.faceOwner()[meshFaceI] : -1),//master
ownZoneI // zone for cell
)
);
......@@ -930,26 +977,12 @@ void Foam::addPatchCellLayer::setRefinement
//Pout<< "For patchFace:" << patchFaceI
// << " meshFace:" << pp.addressing()[patchFaceI]
// << " layer:" << i << " added cell:"
// << addedCells[patchFaceI][i]
// << endl;
// << addedCells[patchFaceI][i] << endl;
}
}
}
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// Precalculated patchID for each patch face
labelList patchID(pp.size());
forAll(pp, patchFaceI)
{
label meshFaceI = pp.addressing()[patchFaceI];
patchID[patchFaceI] = patches.whichPatch(meshFaceI);
}
// Create faces on top of the original patch faces.
// These faces are created from original patch faces outwards so in order
......@@ -981,7 +1014,12 @@ void Foam::addPatchCellLayer::setRefinement
if (addedPoints_[f[fp]].empty())
{
// Keep original point
newFace[fp] = meshPoints[f[fp]];
newFace[fp] =
(
addToMesh_
? meshPoints[f[fp]]
: copiedPatchPoints[f[fp]]
);
}
else
{
......@@ -1040,35 +1078,85 @@ void Foam::addPatchCellLayer::setRefinement
//
// Modify old patch faces to be on the inside
//
forAll(pp, patchFaceI)
labelList copiedPatchFaces;
if (addToMesh_)
{
if (addedCells[patchFaceI].size())
forAll(pp, patchFaceI)
{
label meshFaceI = pp.addressing()[patchFaceI];
if (addedCells[patchFaceI].size())
{
label meshFaceI = pp.addressing()[patchFaceI];
label zoneI = mesh_.faceZones().whichZone(meshFaceI);
label zoneI = mesh_.faceZones().whichZone(meshFaceI);
meshMod.setAction
(
polyModifyFace
meshMod.setAction
(
pp[patchFaceI], // modified face
meshFaceI, // label of face
mesh_.faceOwner()[meshFaceI], // owner
addedCells[patchFaceI][0], // neighbour
false, // face flip
-1, // patch for face
false, // remove from zone
zoneI, // zone for face
false // face flip in zone
)
);
//Pout<< "Modified old patch face " << meshFaceI
// << " own:" << mesh_.faceOwner()[meshFaceI]
// << " nei:" << addedCells[patchFaceI][0]
// << endl;
polyModifyFace
(
pp[patchFaceI], // modified face
meshFaceI, // label of face
mesh_.faceOwner()[meshFaceI], // owner
addedCells[patchFaceI][0], // neighbour
false, // face flip
-1, // patch for face
false, // remove from zone
zoneI, // zone for face
false // face flip in zone
)
);
//Pout<< "Modified old patch face " << meshFaceI
// << " own:" << mesh_.faceOwner()[meshFaceI]
// << " nei:" << addedCells[patchFaceI][0]
// << endl;
}
}
}
else
{
// If creating new mesh: copy existing patch points
copiedPatchFaces.setSize(pp.size());
forAll(pp, patchFaceI)
{
if (nFaceLayers[patchFaceI] > 0)
{
label meshFaceI = pp.addressing()[patchFaceI];
label zoneI = mesh_.faceZones().whichZone(meshFaceI);
bool zoneFlip = false;
if (zoneI != -1)
{
const faceZone& fz = mesh_.faceZones()[zoneI];
zoneFlip = !fz.flipMap()[fz.whichFace(meshFaceI)];
}
// Reverse and renumber old patch face.
face f(pp.localFaces()[patchFaceI].reverseFace());
forAll(f, fp)
{
f[fp] = copiedPatchPoints[f[fp]];
}
copiedPatchFaces[patchFaceI] = meshMod.setAction
(
polyAddFace
(
f, // modified face
addedCells[patchFaceI][0], // owner
-1, // neighbour
-1, // masterPoint
-1, // masterEdge
-1, // masterFace
true, // face flip
patchID[patchFaceI], // patch for face
zoneI, // zone for face
zoneFlip // face flip in zone
)
);
}
}
}
//
......@@ -1255,7 +1343,16 @@ void Foam::addPatchCellLayer::setRefinement
forAll(stringedVerts, stringedI)
{
label v = stringedVerts[stringedI];
addVertex(meshPoints[v], newFace, newFp);
addVertex
(
(
addToMesh_
? meshPoints[v]
: copiedPatchPoints[v]
),
newFace,
newFp
);
}
}
else
......@@ -1276,7 +1373,16 @@ void Foam::addPatchCellLayer::setRefinement
}
else
{
addVertex(meshPoints[v], newFace, newFp);
addVertex
(
(
addToMesh_
? meshPoints[v]
: copiedPatchPoints[v]
),
newFace,
newFp
);
}
}
}
......@@ -1316,7 +1422,16 @@ void Foam::addPatchCellLayer::setRefinement
}
else
{
addVertex(meshPoints[v], newFace, newFp);
addVertex
(
(
addToMesh_
? meshPoints[v]
: copiedPatchPoints[v]
),
newFace,
newFp
);
}
}
......
......@@ -26,7 +26,8 @@ Class
Foam::addPatchCellLayer
Description
Adds layers of cells to outside of polyPatch.
Adds layers of cells to outside of polyPatch. Can optionally create
stand-alone extruded mesh (addToMesh=false).
Call setRefinement with offset vector for every patch point and number
of layers per patch face and number of layers per patch point.
......@@ -164,6 +165,9 @@ class addPatchCellLayer
//- Reference to mesh
const polyMesh& mesh_;
//- Add layers to existing mesh or create new mesh
const bool addToMesh_;
//- For all patchpoints: list of added points (size 0 or nLayers)
// First point in list is one nearest to original point in patch,
// last one is the new point on the surface.
......@@ -253,7 +257,7 @@ public:
// Constructors
//- Construct from mesh.
addPatchCellLayer(const polyMesh& mesh);
addPatchCellLayer(const polyMesh& mesh, const bool addToMesh = true);
// Member Functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment