mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: application to extrude a faceZone into a separate region mesh
Extrudes either internal faces to inflate a baffle or extrudes boundary faces to create separate mesh. Inserts directMappedWall between the two meshes.
This commit is contained in:
@ -0,0 +1,7 @@
|
|||||||
|
patchPointEdgeCirculator.C
|
||||||
|
createShellMesh.C
|
||||||
|
extrudeToRegionMesh.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/extrudeToRegionMesh
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
/* -I$(LIB_SRC)/surfMesh/lnInclude */ \
|
||||||
|
/* -I$(LIB_SRC)/lagrangian/basic/lnInclude */ \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-lfiniteVolume \
|
||||||
|
/* -lsurfMesh */ \
|
||||||
|
/* -llagrangian */ \
|
||||||
|
-lmeshTools \
|
||||||
|
-ldynamicMesh
|
||||||
|
|
||||||
@ -0,0 +1,592 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "createShellMesh.H"
|
||||||
|
#include "polyTopoChange.H"
|
||||||
|
#include "meshTools.H"
|
||||||
|
#include "mapPolyMesh.H"
|
||||||
|
#include "polyAddPoint.H"
|
||||||
|
#include "polyAddFace.H"
|
||||||
|
#include "polyModifyFace.H"
|
||||||
|
#include "polyAddCell.H"
|
||||||
|
#include "patchPointEdgeCirculator.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(Foam::createShellMesh, 0);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::createShellMesh::calcPointRegions
|
||||||
|
(
|
||||||
|
const primitiveFacePatch& patch,
|
||||||
|
const PackedBoolList& nonManifoldEdge,
|
||||||
|
faceList& pointRegions,
|
||||||
|
labelList& regionPoints
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pointRegions.setSize(patch.size());
|
||||||
|
forAll(pointRegions, faceI)
|
||||||
|
{
|
||||||
|
const face& f = patch.localFaces()[faceI];
|
||||||
|
pointRegions[faceI].setSize(f.size(), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
label nRegions = 0;
|
||||||
|
|
||||||
|
forAll(pointRegions, faceI)
|
||||||
|
{
|
||||||
|
const face& f = patch.localFaces()[faceI];
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
if (pointRegions[faceI][fp] == -1)
|
||||||
|
{
|
||||||
|
// Found unassigned point. Distribute current region.
|
||||||
|
label pointI = f[fp];
|
||||||
|
label edgeI = patch.faceEdges()[faceI][fp];
|
||||||
|
|
||||||
|
patchPointEdgeCirculator circ
|
||||||
|
(
|
||||||
|
patch,
|
||||||
|
nonManifoldEdge,
|
||||||
|
edgeI,
|
||||||
|
findIndex(patch.edgeFaces()[edgeI], faceI),
|
||||||
|
pointI
|
||||||
|
);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
patchPointEdgeCirculator iter = circ.begin();
|
||||||
|
iter != circ.end();
|
||||||
|
++iter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
label face2 = iter.faceID();
|
||||||
|
|
||||||
|
if (face2 != -1)
|
||||||
|
{
|
||||||
|
const face& f2 = patch.localFaces()[face2];
|
||||||
|
label fp2 = findIndex(f2, pointI);
|
||||||
|
label& region = pointRegions[face2][fp2];
|
||||||
|
if (region != -1)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"createShellMesh::calcPointRegions(..)"
|
||||||
|
) << "On point " << pointI
|
||||||
|
<< " at:" << patch.localPoints()[pointI]
|
||||||
|
<< " found region:" << region
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
region = nRegions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nRegions++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// From region back to originating point (many to one, a point might
|
||||||
|
// have multiple regions though)
|
||||||
|
regionPoints.setSize(nRegions);
|
||||||
|
forAll(pointRegions, faceI)
|
||||||
|
{
|
||||||
|
const face& f = patch.localFaces()[faceI];
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
regionPoints[pointRegions[faceI][fp]] = f[fp];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
const labelListList& pointFaces = patch.pointFaces();
|
||||||
|
forAll(pointFaces, pointI)
|
||||||
|
{
|
||||||
|
label region = -1;
|
||||||
|
const labelList& pFaces = pointFaces[pointI];
|
||||||
|
forAll(pFaces, i)
|
||||||
|
{
|
||||||
|
label faceI = pFaces[i];
|
||||||
|
const face& f = patch.localFaces()[faceI];
|
||||||
|
label fp = findIndex(f, pointI);
|
||||||
|
|
||||||
|
if (region == -1)
|
||||||
|
{
|
||||||
|
region = pointRegions[faceI][fp];
|
||||||
|
}
|
||||||
|
else if (region != pointRegions[faceI][fp])
|
||||||
|
{
|
||||||
|
Pout<< "Non-manifold point:" << pointI
|
||||||
|
<< " at " << patch.localPoints()[pointI]
|
||||||
|
<< " region:" << region
|
||||||
|
<< " otherRegion:" << pointRegions[faceI][fp]
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::createShellMesh::createShellMesh
|
||||||
|
(
|
||||||
|
const primitiveFacePatch& patch,
|
||||||
|
const faceList& pointRegions,
|
||||||
|
const labelList& regionPoints
|
||||||
|
)
|
||||||
|
:
|
||||||
|
patch_(patch),
|
||||||
|
pointRegions_(pointRegions),
|
||||||
|
regionPoints_(regionPoints)
|
||||||
|
{
|
||||||
|
if (pointRegions_.size() != patch_.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn("createShellMesh::createShellMesh(..)")
|
||||||
|
<< "nFaces:" << patch_.size()
|
||||||
|
<< " pointRegions:" << pointRegions.size()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::createShellMesh::setRefinement
|
||||||
|
(
|
||||||
|
const pointField& thickness,
|
||||||
|
const labelList& extrudeMasterPatchID,
|
||||||
|
const labelList& extrudeSlavePatchID,
|
||||||
|
const labelListList& extrudeEdgePatches,
|
||||||
|
polyTopoChange& meshMod
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (thickness.size() != regionPoints_.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn("createShellMesh::setRefinement(..)")
|
||||||
|
<< "nRegions:" << regionPoints_.size()
|
||||||
|
<< " thickness:" << thickness.size()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
extrudeMasterPatchID.size() != patch_.size()
|
||||||
|
&& extrudeSlavePatchID.size() != patch_.size()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FatalErrorIn("createShellMesh::setRefinement(..)")
|
||||||
|
<< "nFaces:" << patch_.size()
|
||||||
|
<< " extrudeMasterPatchID:" << extrudeMasterPatchID.size()
|
||||||
|
<< " extrudeSlavePatchID:" << extrudeSlavePatchID.size()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extrudeEdgePatches.size() != patch_.nEdges())
|
||||||
|
{
|
||||||
|
FatalErrorIn("createShellMesh::setRefinement(..)")
|
||||||
|
<< "nEdges:" << patch_.nEdges()
|
||||||
|
<< " extrudeEdgePatches:" << extrudeEdgePatches.size()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// From cell to patch (trivial)
|
||||||
|
DynamicList<label> cellToFaceMap(patch_.size());
|
||||||
|
// From face to patch+turning index
|
||||||
|
DynamicList<label> faceToFaceMap(2*patch_.size()+patch_.nEdges());
|
||||||
|
// From face to patch edge index
|
||||||
|
DynamicList<label> faceToEdgeMap(patch_.nEdges()+patch_.nEdges());
|
||||||
|
// From point to patch point index
|
||||||
|
DynamicList<label> pointToPointMap(2*patch_.nPoints());
|
||||||
|
|
||||||
|
|
||||||
|
// Introduce new cell for every face
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
labelList addedCells(patch_.size());
|
||||||
|
forAll(patch_, faceI)
|
||||||
|
{
|
||||||
|
addedCells[faceI] = meshMod.addCell
|
||||||
|
(
|
||||||
|
-1, // masterPointID
|
||||||
|
-1, // masterEdgeID
|
||||||
|
-1, // masterFaceID
|
||||||
|
cellToFaceMap.size(), // masterCellID
|
||||||
|
-1 // zoneID
|
||||||
|
);
|
||||||
|
cellToFaceMap.append(faceI);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Introduce original points
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
// Original point numbers in local point ordering so no need to store.
|
||||||
|
forAll(patch_.localPoints(), pointI)
|
||||||
|
{
|
||||||
|
//label addedPointI =
|
||||||
|
meshMod.addPoint
|
||||||
|
(
|
||||||
|
patch_.localPoints()[pointI], // point
|
||||||
|
pointToPointMap.size(), // masterPointID
|
||||||
|
-1, // zoneID
|
||||||
|
true // inCell
|
||||||
|
);
|
||||||
|
pointToPointMap.append(pointI);
|
||||||
|
|
||||||
|
//Pout<< "Added bottom point " << addedPointI
|
||||||
|
// << " at " << patch_.localPoints()[pointI]
|
||||||
|
// << " from point " << pointI
|
||||||
|
// << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Introduce new points (one for every region)
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
labelList addedPoints(regionPoints_.size());
|
||||||
|
forAll(regionPoints_, regionI)
|
||||||
|
{
|
||||||
|
label pointI = regionPoints_[regionI];
|
||||||
|
point extrudedPt = patch_.localPoints()[pointI] + thickness[regionI];
|
||||||
|
|
||||||
|
addedPoints[regionI] = meshMod.addPoint
|
||||||
|
(
|
||||||
|
extrudedPt, // point
|
||||||
|
pointToPointMap.size(), // masterPointID - used only addressing
|
||||||
|
-1, // zoneID
|
||||||
|
true // inCell
|
||||||
|
);
|
||||||
|
pointToPointMap.append(pointI);
|
||||||
|
|
||||||
|
//Pout<< "Added top point " << addedPoints[regionI]
|
||||||
|
// << " at " << extrudedPt
|
||||||
|
// << " from point " << pointI
|
||||||
|
// << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add face on patch' master side
|
||||||
|
//labelList masterFaces(patch_.localFaces().size());
|
||||||
|
forAll(patch_.localFaces(), faceI)
|
||||||
|
{
|
||||||
|
//masterFaces[faceI] =
|
||||||
|
meshMod.addFace
|
||||||
|
(
|
||||||
|
patch_.localFaces()[faceI].reverseFace(),// vertices
|
||||||
|
addedCells[faceI], // own
|
||||||
|
-1, // nei
|
||||||
|
-1, // masterPointID
|
||||||
|
-1, // masterEdgeID
|
||||||
|
faceToFaceMap.size(), // masterFaceID : current faceI
|
||||||
|
true, // flipFaceFlux
|
||||||
|
extrudeMasterPatchID[faceI],// patchID
|
||||||
|
-1, // zoneID
|
||||||
|
false // zoneFlip
|
||||||
|
);
|
||||||
|
faceToFaceMap.append(faceI+1); // points to unflipped original face
|
||||||
|
faceToEdgeMap.append(-1);
|
||||||
|
|
||||||
|
//Pout<< "Added master face "
|
||||||
|
// << patch_.localFaces()[faceI].reverseFace()
|
||||||
|
// << " own " << addedCells[faceI]
|
||||||
|
// << " at " << patch_.faceCentres()[faceI]
|
||||||
|
// << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add face on patch' slave side
|
||||||
|
//labelList slaveFaces(patch_.localFaces().size());
|
||||||
|
forAll(patch_.localFaces(), faceI)
|
||||||
|
{
|
||||||
|
// Get face in original ordering
|
||||||
|
const face& f = patch_.localFaces()[faceI];
|
||||||
|
|
||||||
|
// Pick up point based on region
|
||||||
|
face newF(f.size());
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
label region = pointRegions_[faceI][fp];
|
||||||
|
newF[fp] = addedPoints[region];
|
||||||
|
}
|
||||||
|
|
||||||
|
//slaveFaces[faceI] =
|
||||||
|
meshMod.addFace
|
||||||
|
(
|
||||||
|
newF, // vertices
|
||||||
|
addedCells[faceI], // own
|
||||||
|
-1, // nei
|
||||||
|
-1, // masterPointID
|
||||||
|
-1, // masterEdgeID
|
||||||
|
faceToFaceMap.size(), // masterFaceID : current faceI
|
||||||
|
false, // flipFaceFlux
|
||||||
|
extrudeSlavePatchID[faceI], // patchID
|
||||||
|
-1, // zoneID
|
||||||
|
false // zoneFlip
|
||||||
|
);
|
||||||
|
faceToFaceMap.append(-faceI-1);
|
||||||
|
faceToEdgeMap.append(-1);
|
||||||
|
|
||||||
|
//Pout<< "Added slave face " << newF
|
||||||
|
// << " own " << addedCells[faceI]
|
||||||
|
// << " at " << patch_.faceCentres()[faceI]
|
||||||
|
// << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add side faces
|
||||||
|
// ~~~~~~~~~~~~~~
|
||||||
|
// Note that we loop over edges multiple times so for edges with
|
||||||
|
// two cyclic faces they get added in two passes (for correct ordering)
|
||||||
|
|
||||||
|
// Pass1. Internal edges and first face of other edges
|
||||||
|
forAll(extrudeEdgePatches, edgeI)
|
||||||
|
{
|
||||||
|
const labelList& eFaces = patch_.edgeFaces()[edgeI];
|
||||||
|
const labelList& ePatches = extrudeEdgePatches[edgeI];
|
||||||
|
|
||||||
|
if (ePatches.size() == 0)
|
||||||
|
{
|
||||||
|
// internal face.
|
||||||
|
|
||||||
|
if (eFaces.size() != 2)
|
||||||
|
{
|
||||||
|
FatalErrorIn("createShellMesh::setRefinement(..)")
|
||||||
|
<< "edge:" << edgeI
|
||||||
|
<< " not internal but does not have side-patches defined."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extrude
|
||||||
|
|
||||||
|
// Make face pointing in to eFaces[0] so out of new master face
|
||||||
|
const face& f = patch_.localFaces()[eFaces[0]];
|
||||||
|
const edge& e = patch_.edges()[edgeI];
|
||||||
|
|
||||||
|
label fp0 = findIndex(f, e[0]);
|
||||||
|
label fp1 = f.fcIndex(fp0);
|
||||||
|
|
||||||
|
if (f[fp1] != e[1])
|
||||||
|
{
|
||||||
|
fp1 = fp0;
|
||||||
|
fp0 = f.rcIndex(fp1);
|
||||||
|
}
|
||||||
|
|
||||||
|
face newF(4);
|
||||||
|
newF[0] = f[fp0];
|
||||||
|
newF[1] = f[fp1];
|
||||||
|
newF[2] = addedPoints[pointRegions_[eFaces[0]][fp1]];
|
||||||
|
newF[3] = addedPoints[pointRegions_[eFaces[0]][fp0]];
|
||||||
|
|
||||||
|
label minCellI = addedCells[eFaces[0]];
|
||||||
|
label maxCellI = addedCells[eFaces[1]];
|
||||||
|
|
||||||
|
if (minCellI > maxCellI)
|
||||||
|
{
|
||||||
|
// Swap
|
||||||
|
Swap(minCellI, maxCellI);
|
||||||
|
newF = newF.reverseFace();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Pout<< "for internal edge:" << e
|
||||||
|
// << " at:" << patch_.localPoints()[e[0]]
|
||||||
|
// << patch_.localPoints()[e[1]]
|
||||||
|
// << " adding face:" << newF
|
||||||
|
// << " from f:" << f
|
||||||
|
// << " inbetween " << minCellI << " and " << maxCellI << endl;
|
||||||
|
|
||||||
|
// newF already outwards pointing.
|
||||||
|
meshMod.addFace
|
||||||
|
(
|
||||||
|
newF, // vertices
|
||||||
|
minCellI, // own
|
||||||
|
maxCellI, // nei
|
||||||
|
-1, // masterPointID
|
||||||
|
-1, // masterEdgeID
|
||||||
|
faceToFaceMap.size(), // masterFaceID
|
||||||
|
false, // flipFaceFlux
|
||||||
|
-1, // patchID
|
||||||
|
-1, // zoneID
|
||||||
|
false // zoneFlip
|
||||||
|
);
|
||||||
|
faceToFaceMap.append(0);
|
||||||
|
faceToEdgeMap.append(edgeI);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (eFaces.size() != ePatches.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn("createShellMesh::setRefinement(..)")
|
||||||
|
<< "external/feature edge:" << edgeI
|
||||||
|
<< " has " << eFaces.size() << " connected extruded faces "
|
||||||
|
<< " but only " << ePatches.size()
|
||||||
|
<< " boundary faces defined." << exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Extrude eFaces[0]
|
||||||
|
label minFaceI = eFaces[0];
|
||||||
|
|
||||||
|
// Make face pointing in to eFaces[0] so out of new master face
|
||||||
|
const face& f = patch_.localFaces()[minFaceI];
|
||||||
|
|
||||||
|
const edge& e = patch_.edges()[edgeI];
|
||||||
|
label fp0 = findIndex(f, e[0]);
|
||||||
|
label fp1 = f.fcIndex(fp0);
|
||||||
|
|
||||||
|
if (f[fp1] != e[1])
|
||||||
|
{
|
||||||
|
fp1 = fp0;
|
||||||
|
fp0 = f.rcIndex(fp1);
|
||||||
|
}
|
||||||
|
|
||||||
|
face newF(4);
|
||||||
|
newF[0] = f[fp0];
|
||||||
|
newF[1] = f[fp1];
|
||||||
|
newF[2] = addedPoints[pointRegions_[minFaceI][fp1]];
|
||||||
|
newF[3] = addedPoints[pointRegions_[minFaceI][fp0]];
|
||||||
|
|
||||||
|
|
||||||
|
//Pout<< "for external edge:" << e
|
||||||
|
// << " at:" << patch_.localPoints()[e[0]]
|
||||||
|
// << patch_.localPoints()[e[1]]
|
||||||
|
// << " adding first patch face:" << newF
|
||||||
|
// << " from:" << f
|
||||||
|
// << " into patch:" << ePatches[0]
|
||||||
|
// << " own:" << addedCells[minFaceI]
|
||||||
|
// << endl;
|
||||||
|
|
||||||
|
|
||||||
|
// newF already outwards pointing.
|
||||||
|
meshMod.addFace
|
||||||
|
(
|
||||||
|
newF, // vertices
|
||||||
|
addedCells[minFaceI], // own
|
||||||
|
-1, // nei
|
||||||
|
-1, // masterPointID
|
||||||
|
-1, // masterEdgeID
|
||||||
|
faceToFaceMap.size(), // masterFaceID
|
||||||
|
false, // flipFaceFlux
|
||||||
|
ePatches[0], // patchID
|
||||||
|
-1, // zoneID
|
||||||
|
false // zoneFlip
|
||||||
|
);
|
||||||
|
faceToFaceMap.append(0);
|
||||||
|
faceToEdgeMap.append(edgeI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass2. Other faces of boundary edges
|
||||||
|
forAll(extrudeEdgePatches, edgeI)
|
||||||
|
{
|
||||||
|
const labelList& eFaces = patch_.edgeFaces()[edgeI];
|
||||||
|
const labelList& ePatches = extrudeEdgePatches[edgeI];
|
||||||
|
|
||||||
|
if (ePatches.size() >= 2)
|
||||||
|
{
|
||||||
|
for (label i = 1; i < ePatches.size(); i++)
|
||||||
|
{
|
||||||
|
// Extrude eFaces[i]
|
||||||
|
label minFaceI = eFaces[i];
|
||||||
|
|
||||||
|
// Make face pointing in to eFaces[0] so out of new master face
|
||||||
|
const face& f = patch_.localFaces()[minFaceI];
|
||||||
|
|
||||||
|
const edge& e = patch_.edges()[edgeI];
|
||||||
|
label fp0 = findIndex(f, e[0]);
|
||||||
|
label fp1 = f.fcIndex(fp0);
|
||||||
|
|
||||||
|
if (f[fp1] != e[1])
|
||||||
|
{
|
||||||
|
fp1 = fp0;
|
||||||
|
fp0 = f.rcIndex(fp1);
|
||||||
|
}
|
||||||
|
|
||||||
|
face newF(4);
|
||||||
|
newF[0] = f[fp0];
|
||||||
|
newF[1] = f[fp1];
|
||||||
|
newF[2] = addedPoints[pointRegions_[minFaceI][fp1]];
|
||||||
|
newF[3] = addedPoints[pointRegions_[minFaceI][fp0]];
|
||||||
|
|
||||||
|
//Pout<< "for external edge:" << e
|
||||||
|
// << " at:" << patch_.localPoints()[e[0]]
|
||||||
|
// << patch_.localPoints()[e[1]]
|
||||||
|
// << " adding patch face:" << newF
|
||||||
|
// << " from:" << f
|
||||||
|
// << " into patch:" << ePatches[i]
|
||||||
|
// << endl;
|
||||||
|
|
||||||
|
// newF already outwards pointing.
|
||||||
|
meshMod.addFace
|
||||||
|
(
|
||||||
|
newF, // vertices
|
||||||
|
addedCells[minFaceI], // own
|
||||||
|
-1, // nei
|
||||||
|
-1, // masterPointID
|
||||||
|
-1, // masterEdgeID
|
||||||
|
faceToFaceMap.size(), // masterFaceID
|
||||||
|
false, // flipFaceFlux
|
||||||
|
ePatches[i], // patchID
|
||||||
|
-1, // zoneID
|
||||||
|
false // zoneFlip
|
||||||
|
);
|
||||||
|
faceToFaceMap.append(0);
|
||||||
|
faceToEdgeMap.append(edgeI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cellToFaceMap_.transfer(cellToFaceMap);
|
||||||
|
faceToFaceMap_.transfer(faceToFaceMap);
|
||||||
|
faceToEdgeMap_.transfer(faceToEdgeMap);
|
||||||
|
pointToPointMap_.transfer(pointToPointMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::createShellMesh::updateMesh(const mapPolyMesh& map)
|
||||||
|
{
|
||||||
|
inplaceReorder(map.reverseCellMap(), cellToFaceMap_);
|
||||||
|
inplaceReorder(map.reverseFaceMap(), faceToFaceMap_);
|
||||||
|
inplaceReorder(map.reverseFaceMap(), faceToEdgeMap_);
|
||||||
|
inplaceReorder(map.reversePointMap(), pointToPointMap_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,177 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::createShellMesh
|
||||||
|
|
||||||
|
Description
|
||||||
|
Creates mesh by extruding a patch.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
createShellMesh.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef createShellMesh_H
|
||||||
|
#define createShellMesh_H
|
||||||
|
|
||||||
|
#include "primitiveFacePatch.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration of classes
|
||||||
|
class mapPolyMesh;
|
||||||
|
class polyTopoChange;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class createShellMesh Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class createShellMesh
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Reference to patch to extrude
|
||||||
|
const primitiveFacePatch& patch_;
|
||||||
|
|
||||||
|
// //- Non-manifold edges on patch
|
||||||
|
// const PackedBoolList& nonManifoldEdge_;
|
||||||
|
|
||||||
|
//- Per point on face the region
|
||||||
|
const faceList& pointRegions_;
|
||||||
|
|
||||||
|
//- From region to original patch point
|
||||||
|
const labelList& regionPoints_;
|
||||||
|
|
||||||
|
|
||||||
|
labelList cellToFaceMap_;
|
||||||
|
|
||||||
|
labelList faceToFaceMap_;
|
||||||
|
|
||||||
|
labelList faceToEdgeMap_;
|
||||||
|
|
||||||
|
labelList pointToPointMap_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
createShellMesh(const createShellMesh&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const createShellMesh&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
ClassName("createShellMesh");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from mesh.
|
||||||
|
createShellMesh
|
||||||
|
(
|
||||||
|
const primitiveFacePatch& patch,
|
||||||
|
// const PackedBoolList& nonManifoldEdge,
|
||||||
|
const faceList& pointRegions,
|
||||||
|
const labelList& regionPoints
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- From region cell to patch face
|
||||||
|
const labelList& cellToFaceMap() const
|
||||||
|
{
|
||||||
|
return cellToFaceMap_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- From region face to patch face. Contains turning index:
|
||||||
|
// > 0 : face originating from master side
|
||||||
|
// (owner side for unflipped face)
|
||||||
|
// < 0 : (bottom) face originating from slave side
|
||||||
|
// (neighbour side for unflipped face)
|
||||||
|
// = 0 : for all side faces
|
||||||
|
const labelList& faceToFaceMap() const
|
||||||
|
{
|
||||||
|
return faceToFaceMap_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- From region side-face to patch edge. -1 for non-edge faces.
|
||||||
|
const labelList& faceToEdgeMap() const
|
||||||
|
{
|
||||||
|
return faceToEdgeMap_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- From region point to patch point.
|
||||||
|
const labelList& pointToPointMap() const
|
||||||
|
{
|
||||||
|
return pointToPointMap_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Other
|
||||||
|
|
||||||
|
//- Helper: calculate point regions
|
||||||
|
static void calcPointRegions
|
||||||
|
(
|
||||||
|
const primitiveFacePatch& patch,
|
||||||
|
const PackedBoolList& nonManifoldEdge,
|
||||||
|
faceList& pointRegions,
|
||||||
|
labelList& regionPoints
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Play commands into polyTopoChange to create layer mesh.
|
||||||
|
void setRefinement
|
||||||
|
(
|
||||||
|
const pointField& thickness,
|
||||||
|
const labelList& extrudeMasterPatchID,
|
||||||
|
const labelList& extrudeSlavePatchID,
|
||||||
|
const labelListList& extrudeEdgePatches,
|
||||||
|
polyTopoChange& meshMod
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Update any locally stored mesh information.
|
||||||
|
void updateMesh(const mapPolyMesh&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,68 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "patchPointEdgeCirculator.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::patchPointEdgeCirculator
|
||||||
|
Foam::patchPointEdgeCirculator::endConstIter
|
||||||
|
(
|
||||||
|
*reinterpret_cast<primitiveFacePatch*>(0), // primitiveFacePatch
|
||||||
|
*reinterpret_cast<PackedBoolList*>(0), // PackedBoolList
|
||||||
|
-1, // edgeID
|
||||||
|
-1, // index
|
||||||
|
-1 // pointID
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const InfoProxy<patchPointEdgeCirculator>& ip
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const patchPointEdgeCirculator& c = ip.t_;
|
||||||
|
|
||||||
|
const pointField& pts = c.patch_.localPoints();
|
||||||
|
const edge& e = c.patch_.edges()[c.edgeID_];
|
||||||
|
label faceI = c.faceID();
|
||||||
|
|
||||||
|
os << "around point:" << c.pointID_
|
||||||
|
<< " coord:" << pts[c.pointID_]
|
||||||
|
<< " at edge:" << c.edgeID_
|
||||||
|
<< " coord:" << pts[e.otherVertex(c.pointID_)]
|
||||||
|
<< " in direction of face:" << faceI;
|
||||||
|
|
||||||
|
if (faceI != -1)
|
||||||
|
{
|
||||||
|
os<< " fc:" << c.patch_.localFaces()[faceI].centre(pts);
|
||||||
|
}
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,206 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::patchPointEdgeCirculator
|
||||||
|
|
||||||
|
Description
|
||||||
|
Walks from starting edge/face around point on patch.
|
||||||
|
|
||||||
|
-# Use in-place: \n
|
||||||
|
@code
|
||||||
|
patchPointEdgeCirculator circ(..);
|
||||||
|
|
||||||
|
// Walk
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Info<< "edge:" << circ.edgeID() << endl;
|
||||||
|
++circ;
|
||||||
|
}
|
||||||
|
while (circ != circ.end());
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
-# Use like STL iterator: \n
|
||||||
|
@code
|
||||||
|
patchPointEdgeCirculator circ(..);
|
||||||
|
for
|
||||||
|
(
|
||||||
|
patchPointEdgeCirculator iter = circ.begin();
|
||||||
|
iter != circ.end();
|
||||||
|
++iter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< "edge:" << iter.edgeID() << endl;
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
patchPointEdgeCirculator.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef patchPointEdgeCirculator_H
|
||||||
|
#define patchPointEdgeCirculator_H
|
||||||
|
|
||||||
|
#include "face.H"
|
||||||
|
#include "ListOps.H"
|
||||||
|
#include "primitiveFacePatch.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
#include "InfoProxy.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration of classes
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class patchPointEdgeCirculator Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class patchPointEdgeCirculator
|
||||||
|
{
|
||||||
|
// Static data members
|
||||||
|
|
||||||
|
//- end iterator
|
||||||
|
static const patchPointEdgeCirculator endConstIter;
|
||||||
|
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Patch
|
||||||
|
const primitiveFacePatch& patch_;
|
||||||
|
|
||||||
|
const PackedBoolList& nonManifoldEdge_;
|
||||||
|
|
||||||
|
//- Current edge
|
||||||
|
label edgeID_;
|
||||||
|
|
||||||
|
//- Current direction (face, expressed as index into edgeFaces()[edgeID]
|
||||||
|
label index_;
|
||||||
|
|
||||||
|
//- Point
|
||||||
|
label pointID_;
|
||||||
|
|
||||||
|
//- Starting edge so we know when to stop.
|
||||||
|
label startEdgeID_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Set to end() iterator
|
||||||
|
inline void setEnd();
|
||||||
|
|
||||||
|
//- Set edgeID_ to be the other edge on the face that uses the
|
||||||
|
// point.
|
||||||
|
inline void otherEdge(const label cellI);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
inline patchPointEdgeCirculator
|
||||||
|
(
|
||||||
|
const primitiveFacePatch&,
|
||||||
|
const PackedBoolList& nonManifoldEdge,
|
||||||
|
const label edgeID,
|
||||||
|
const label index,
|
||||||
|
const label pointID
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
inline patchPointEdgeCirculator(const patchPointEdgeCirculator&);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
inline label edgeID() const;
|
||||||
|
|
||||||
|
inline label index() const;
|
||||||
|
|
||||||
|
inline label pointID() const;
|
||||||
|
|
||||||
|
//- Helper: get face according to the index.
|
||||||
|
// Returns -1 if on end.
|
||||||
|
inline label faceID() const;
|
||||||
|
|
||||||
|
//- Walk back until non-manifold edge (if any) or minimum edge.
|
||||||
|
inline void setCanonical();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
inline void operator=(const patchPointEdgeCirculator& iter);
|
||||||
|
|
||||||
|
inline bool operator==(const patchPointEdgeCirculator& iter) const;
|
||||||
|
|
||||||
|
inline bool operator!=(const patchPointEdgeCirculator& iter) const;
|
||||||
|
|
||||||
|
//- Step to next face.
|
||||||
|
inline patchPointEdgeCirculator& operator++();
|
||||||
|
|
||||||
|
//- iterator set to the beginning face. For internal edges this is
|
||||||
|
// the current face. For boundary edges this is the first boundary face
|
||||||
|
// reached from walking back (i.e. in opposite direction to ++)
|
||||||
|
inline patchPointEdgeCirculator begin() const;
|
||||||
|
inline patchPointEdgeCirculator cbegin() const;
|
||||||
|
|
||||||
|
//- iterator set to beyond the end of the walk.
|
||||||
|
inline const patchPointEdgeCirculator& end() const;
|
||||||
|
inline const patchPointEdgeCirculator& cend() const;
|
||||||
|
|
||||||
|
// Info
|
||||||
|
|
||||||
|
//- Return info proxy.
|
||||||
|
// Used to print token information to a stream
|
||||||
|
InfoProxy<patchPointEdgeCirculator> info() const
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const InfoProxy<patchPointEdgeCirculator>&
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Ostream& operator<<(Ostream&, const InfoProxy<patchPointEdgeCirculator>&);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "patchPointEdgeCirculatorI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,309 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::patchPointEdgeCirculator::setEnd()
|
||||||
|
{
|
||||||
|
edgeID_ = -1;
|
||||||
|
pointID_ = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Cross face to other edge on point
|
||||||
|
void Foam::patchPointEdgeCirculator::otherEdge(const label faceI)
|
||||||
|
{
|
||||||
|
const labelList& fEdges = patch_.faceEdges()[faceI];
|
||||||
|
const face& f = patch_.localFaces()[faceI];
|
||||||
|
label fp = findIndex(f, pointID_);
|
||||||
|
|
||||||
|
if (fEdges[fp] == edgeID_)
|
||||||
|
{
|
||||||
|
edgeID_ = fEdges[f.rcIndex(fp)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check for now
|
||||||
|
if (fEdges[f.rcIndex(fp)] != edgeID_)
|
||||||
|
{
|
||||||
|
FatalErrorIn("patchPointEdgeCirculator::otherEdge(const label)")
|
||||||
|
<< "face:" << faceI
|
||||||
|
<< " verts:" << f
|
||||||
|
<< " edges:" << fEdges
|
||||||
|
<< " looking for other edge than " << edgeID_
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
edgeID_ = fEdges[fp];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
Foam::patchPointEdgeCirculator::patchPointEdgeCirculator
|
||||||
|
(
|
||||||
|
const primitiveFacePatch& patch,
|
||||||
|
const PackedBoolList& nonManifoldEdge,
|
||||||
|
const label edgeID,
|
||||||
|
const label index,
|
||||||
|
|
||||||
|
const label pointID
|
||||||
|
)
|
||||||
|
:
|
||||||
|
patch_(patch),
|
||||||
|
nonManifoldEdge_(nonManifoldEdge),
|
||||||
|
edgeID_(edgeID),
|
||||||
|
index_(index),
|
||||||
|
pointID_(pointID),
|
||||||
|
startEdgeID_(edgeID_)
|
||||||
|
{
|
||||||
|
if (edgeID_ != -1)
|
||||||
|
{
|
||||||
|
const edge& e = patch_.edges()[edgeID_];
|
||||||
|
|
||||||
|
if (pointID_ != e[0] && pointID_ != e[1])
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"patchPointEdgeCirculator::patchPointEdgeCirculator(..)"
|
||||||
|
) << "edge " << edgeID_ << " verts " << e
|
||||||
|
<< " does not contain point " << pointID_ << abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Construct copy
|
||||||
|
Foam::patchPointEdgeCirculator::patchPointEdgeCirculator
|
||||||
|
(
|
||||||
|
const patchPointEdgeCirculator& circ
|
||||||
|
)
|
||||||
|
:
|
||||||
|
patch_(circ.patch_),
|
||||||
|
nonManifoldEdge_(circ.nonManifoldEdge_),
|
||||||
|
edgeID_(circ.edgeID_),
|
||||||
|
index_(circ.index_),
|
||||||
|
pointID_(circ.pointID_),
|
||||||
|
startEdgeID_(circ.startEdgeID_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::label Foam::patchPointEdgeCirculator::edgeID() const
|
||||||
|
{
|
||||||
|
return edgeID_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::patchPointEdgeCirculator::index() const
|
||||||
|
{
|
||||||
|
return index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::patchPointEdgeCirculator::pointID() const
|
||||||
|
{
|
||||||
|
return pointID_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::patchPointEdgeCirculator::faceID() const
|
||||||
|
{
|
||||||
|
if (edgeID_ != -1 && index_ != -1)
|
||||||
|
{
|
||||||
|
return patch_.edgeFaces()[edgeID_][index_];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::patchPointEdgeCirculator::operator=
|
||||||
|
(
|
||||||
|
const patchPointEdgeCirculator& circ
|
||||||
|
)
|
||||||
|
{
|
||||||
|
edgeID_ = circ.edgeID_;
|
||||||
|
index_ = circ.index_;
|
||||||
|
pointID_ = circ.pointID_;
|
||||||
|
startEdgeID_ = circ.startEdgeID_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::patchPointEdgeCirculator::operator==
|
||||||
|
(
|
||||||
|
const patchPointEdgeCirculator& circ
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Do just enough to have setEnd() produce an iterator equal to end().
|
||||||
|
// Could include the direction(i.e. index_) to make sure that two
|
||||||
|
// circulators around same point but in different direction are not equal.
|
||||||
|
return edgeID_ == circ.edgeID_ && pointID_ == circ.pointID_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::patchPointEdgeCirculator::operator!=
|
||||||
|
(
|
||||||
|
const patchPointEdgeCirculator& circ
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return !(*this == circ);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::patchPointEdgeCirculator::setCanonical()
|
||||||
|
{
|
||||||
|
if (edgeID_ == -1)
|
||||||
|
{
|
||||||
|
FatalErrorIn("patchPointEdgeCirculator::setCanonical()")
|
||||||
|
<< "Already reached end(). Cannot walk any further."
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
label minEdgeID = edgeID_;
|
||||||
|
label minIndex = index_;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (nonManifoldEdge_[edgeID_])
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step back
|
||||||
|
const labelList& eFaces = patch_.edgeFaces()[edgeID_];
|
||||||
|
|
||||||
|
if (eFaces.size() != 2)
|
||||||
|
{
|
||||||
|
FatalErrorIn("patchPointEdgeCirculator::setCanonical()")
|
||||||
|
<< "problem eFaces:" << eFaces << abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
label faceI = (index_ == 0 ? eFaces[1] : eFaces[0]);
|
||||||
|
|
||||||
|
// Step to other edge on face
|
||||||
|
otherEdge(faceI);
|
||||||
|
|
||||||
|
// Update index
|
||||||
|
index_ = findIndex(patch_.edgeFaces()[edgeID_], faceI);
|
||||||
|
|
||||||
|
if (edgeID_ < minEdgeID)
|
||||||
|
{
|
||||||
|
minEdgeID = edgeID_;
|
||||||
|
minIndex = index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edgeID_ == startEdgeID_)
|
||||||
|
{
|
||||||
|
edgeID_ = minEdgeID;
|
||||||
|
index_ = minIndex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
startEdgeID_ = edgeID_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Step to next edge.
|
||||||
|
Foam::patchPointEdgeCirculator::patchPointEdgeCirculator&
|
||||||
|
Foam::patchPointEdgeCirculator::operator++()
|
||||||
|
{
|
||||||
|
if (index_ == -1)
|
||||||
|
{
|
||||||
|
setEnd();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Step to other edge on face
|
||||||
|
label faceI = patch_.edgeFaces()[edgeID_][index_];
|
||||||
|
otherEdge(faceI);
|
||||||
|
|
||||||
|
if (edgeID_ == startEdgeID_)
|
||||||
|
{
|
||||||
|
setEnd();
|
||||||
|
}
|
||||||
|
else if (nonManifoldEdge_[edgeID_])
|
||||||
|
{
|
||||||
|
// Reached non-manifold edge. Cannot walk further.
|
||||||
|
// Mark so it gets set to end next time.
|
||||||
|
index_ = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const labelList& eFaces = patch_.edgeFaces()[edgeID_];
|
||||||
|
|
||||||
|
if (eFaces.size() != 2)
|
||||||
|
{
|
||||||
|
FatalErrorIn("patchPointEdgeCirculator:::operator++()")
|
||||||
|
<< "problem eFaces:" << eFaces << abort(FatalError);
|
||||||
|
}
|
||||||
|
// Point to the face that is not faceI
|
||||||
|
index_ = (eFaces[0] != faceI ? 0 : 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::patchPointEdgeCirculator Foam::patchPointEdgeCirculator::begin() const
|
||||||
|
{
|
||||||
|
patchPointEdgeCirculator iter(*this);
|
||||||
|
iter.setCanonical();
|
||||||
|
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::patchPointEdgeCirculator Foam::patchPointEdgeCirculator::cbegin() const
|
||||||
|
{
|
||||||
|
patchPointEdgeCirculator iter(*this);
|
||||||
|
iter.setCanonical();
|
||||||
|
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::patchPointEdgeCirculator& Foam::patchPointEdgeCirculator::end()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return endConstIter;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Foam::patchPointEdgeCirculator& Foam::patchPointEdgeCirculator::cend()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return endConstIter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user