polyTopoChanger::attachDetach: Removed unusable and unmaintained code

This commit is contained in:
Henry Weller
2023-12-14 10:29:38 +00:00
parent eed7a62b98
commit 0949b7aa43
28 changed files with 57 additions and 3120 deletions

View File

@ -101,8 +101,7 @@
new slidingInterface
(
"couple" + name(pairI),
pairI,
polyMeshAttacher,
mesh,
mergeName + "MasterZone",
mergeName + "SlaveZone",
mergeName + "CutPointZone",

View File

@ -37,7 +37,6 @@ Description
#include "argList.H"
#include "Time.H"
#include "polyTopoChange.H"
#include "polyTopoChanger.H"
#include "edgeCollapser.H"
#include "perfectInterface.H"
#include "addPatchCellLayer.H"
@ -883,9 +882,6 @@ int main(int argc, char *argv[])
polyTopoChanger stitcher(mesh);
stitcher.setSize(1);
const word cutZoneName("originalCutFaceZone");
List<faceZone*> fz
@ -907,8 +903,7 @@ int main(int argc, char *argv[])
perfectInterface perfectStitcher
(
"couple",
0,
stitcher,
mesh,
cutZoneName,
word::null, // dummy patch name
word::null // dummy patch name

View File

@ -1,4 +0,0 @@
regionSide.C
splitMesh.C
EXE = $(FOAM_APPBIN)/splitMesh

View File

@ -1,8 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-ldynamicMesh \
-lgenericPatches \
-lmeshTools

View File

@ -1,454 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "regionSide.H"
#include "meshTools.H"
#include "primitiveMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(regionSide, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Step across edge onto other face on cell
Foam::label Foam::regionSide::otherFace
(
const primitiveMesh& mesh,
const label celli,
const label facei,
const label edgeI
)
{
label f0I, f1I;
meshTools::getEdgeFaces(mesh, celli, edgeI, f0I, f1I);
if (f0I == facei)
{
return f1I;
}
else
{
return f0I;
}
}
// Step across point to other edge on face
Foam::label Foam::regionSide::otherEdge
(
const primitiveMesh& mesh,
const label facei,
const label edgeI,
const label pointi
)
{
const edge& e = mesh.edges()[edgeI];
// Get other point on edge.
label freePointi = e.otherVertex(pointi);
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
const label otherEdgeI = fEdges[fEdgeI];
const edge& otherE = mesh.edges()[otherEdgeI];
if
(
(
otherE.start() == pointi
&& otherE.end() != freePointi
)
|| (
otherE.end() == pointi
&& otherE.start() != freePointi
)
)
{
// otherE shares one (but not two) points with e.
return otherEdgeI;
}
}
FatalErrorInFunction
<< "Cannot find other edge on face " << facei << " that uses point "
<< pointi << " but not point " << freePointi << endl
<< "Edges on face:" << fEdges
<< " verts:" << UIndirectList<edge>(mesh.edges(), fEdges)()
<< " Vertices on face:"
<< mesh.faces()[facei]
<< " Vertices on original edge:" << e << abort(FatalError);
return -1;
}
// Step from facei (on side celli) to connected face & cell without crossing
// fenceEdges.
void Foam::regionSide::visitConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& region,
const labelHashSet& fenceEdges,
const label celli,
const label facei,
labelHashSet& visitedFace
)
{
if (!visitedFace.found(facei))
{
if (debug)
{
Info<< "visitConnectedFaces : celli:" << celli << " facei:"
<< facei << " isOwner:" << (celli == mesh.faceOwner()[facei])
<< endl;
}
// Mark as visited
visitedFace.insert(facei);
// Mark which side of face was visited.
if (celli == mesh.faceOwner()[facei])
{
sideOwner_.insert(facei);
}
// Visit all neighbouring faces on faceSet. Stay on this 'side' of
// face by doing edge-face-cell walk.
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
label edgeI = fEdges[fEdgeI];
if (!fenceEdges.found(edgeI))
{
// Step along faces on edge from cell to cell until
// we hit face on faceSet.
// Find face reachable from edge
label otherFacei = otherFace(mesh, celli, facei, edgeI);
if (mesh.isInternalFace(otherFacei))
{
label otherCelli = celli;
// Keep on crossing faces/cells until back on face on
// surface
while (!region.found(otherFacei))
{
visitedFace.insert(otherFacei);
if (debug)
{
Info<< "visitConnectedFaces : celli:" << celli
<< " found insideEdgeFace:" << otherFacei
<< endl;
}
// Cross otherFacei into neighbouring cell
otherCelli =
meshTools::otherCell
(
mesh,
otherCelli,
otherFacei
);
otherFacei =
otherFace
(
mesh,
otherCelli,
otherFacei,
edgeI
);
}
visitConnectedFaces
(
mesh,
region,
fenceEdges,
otherCelli,
otherFacei,
visitedFace
);
}
}
}
}
}
// From edge on face connected to point on region (regionPointi) cross
// to all other edges using this point by walking across faces
// Does not cross regionEdges so stays on one side
// of region
void Foam::regionSide::walkPointConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& regionEdges,
const label regionPointi,
const label startFacei,
const label startEdgeI,
labelHashSet& visitedEdges
)
{
// Mark as visited
insidePointFaces_.insert(startFacei);
if (debug)
{
Info<< "walkPointConnectedFaces : regionPointi:" << regionPointi
<< " facei:" << startFacei
<< " edgeI:" << startEdgeI << " verts:"
<< mesh.edges()[startEdgeI]
<< endl;
}
// Cross facei i.e. get edge not startEdgeI which uses regionPointi
label edgeI = otherEdge(mesh, startFacei, startEdgeI, regionPointi);
if (!regionEdges.found(edgeI))
{
if (!visitedEdges.found(edgeI))
{
visitedEdges.insert(edgeI);
if (debug)
{
Info<< "Crossed face from "
<< " edgeI:" << startEdgeI << " verts:"
<< mesh.edges()[startEdgeI]
<< " to edge:" << edgeI << " verts:"
<< mesh.edges()[edgeI]
<< endl;
}
// Cross edge to all faces connected to it.
const labelList& eFaces = mesh.edgeFaces()[edgeI];
forAll(eFaces, eFacei)
{
label facei = eFaces[eFacei];
walkPointConnectedFaces
(
mesh,
regionEdges,
regionPointi,
facei,
edgeI,
visitedEdges
);
}
}
}
}
// Find all faces reachable from all non-fence points and staying on
// regionFaces side.
void Foam::regionSide::walkAllPointConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& regionFaces,
const labelHashSet& fencePoints
)
{
//
// Get all (internal and external) edges on region.
//
labelHashSet regionEdges(4*regionFaces.size());
forAllConstIter(labelHashSet, regionFaces, iter)
{
const label facei = iter.key();
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
regionEdges.insert(fEdges[fEdgeI]);
}
}
//
// Visit all internal points on surface.
//
// Storage for visited points
labelHashSet visitedPoint(4*regionFaces.size());
// Insert fence points so we don't visit them
forAllConstIter(labelHashSet, fencePoints, iter)
{
visitedPoint.insert(iter.key());
}
labelHashSet visitedEdges(2*fencePoints.size());
if (debug)
{
Info<< "Excluding visit of points:" << visitedPoint << endl;
}
forAllConstIter(labelHashSet, regionFaces, iter)
{
const label facei = iter.key();
// Get side of face.
label celli;
if (sideOwner_.found(facei))
{
celli = mesh.faceOwner()[facei];
}
else
{
celli = mesh.faceNeighbour()[facei];
}
// Find starting point and edge on face.
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
label edgeI = fEdges[fEdgeI];
// Get the face 'perpendicular' to facei on region.
label otherFacei = otherFace(mesh, celli, facei, edgeI);
// Edge
const edge& e = mesh.edges()[edgeI];
if (!visitedPoint.found(e.start()))
{
Info<< "Determining visibility from point " << e.start()
<< endl;
visitedPoint.insert(e.start());
// edgeI = otherEdge(mesh, otherFacei, edgeI, e.start());
walkPointConnectedFaces
(
mesh,
regionEdges,
e.start(),
otherFacei,
edgeI,
visitedEdges
);
}
if (!visitedPoint.found(e.end()))
{
Info<< "Determining visibility from point " << e.end()
<< endl;
visitedPoint.insert(e.end());
// edgeI = otherEdge(mesh, otherFacei, edgeI, e.end());
walkPointConnectedFaces
(
mesh,
regionEdges,
e.end(),
otherFacei,
edgeI,
visitedEdges
);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::regionSide::regionSide
(
const primitiveMesh& mesh,
const labelHashSet& region, // faces of region
const labelHashSet& fenceEdges, // outside edges
const label startCelli,
const label startFacei
)
:
sideOwner_(region.size()),
insidePointFaces_(region.size())
{
// Storage for visited faces
labelHashSet visitedFace(region.size());
// Visit all faces on this side of region.
// Mark for each face whether owner (or neighbour) has been visited.
// Sets sideOwner_
visitConnectedFaces
(
mesh,
region,
fenceEdges,
startCelli,
startFacei,
visitedFace
);
//
// Visit all internal points on region and mark faces visitable from these.
// Sets insidePointFaces_.
//
labelHashSet fencePoints(fenceEdges.size());
forAllConstIter(labelHashSet, fenceEdges, iter)
{
const edge& e = mesh.edges()[iter.key()];
fencePoints.insert(e.start());
fencePoints.insert(e.end());
}
walkAllPointConnectedFaces(mesh, region, fencePoints);
}
// ************************************************************************* //

View File

@ -1,174 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::regionSide
Description
Determines the 'side' for every face and connected to a
singly-connected (through edges) region of faces. Gets set of faces and
a list of mesh edges ('fenceEdges') which should not be crossed.
Used in splitting a mesh region.
Determines:
- For every face on the surface: whether the owner was visited
from starting face.
- List of faces using an internal point of the region visitable by
edge-face-edge walking from the correct side of the region.
SourceFiles
regionSide.C
\*---------------------------------------------------------------------------*/
#ifndef regionSide_H
#define regionSide_H
#include "HashSet.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class primitiveMesh;
/*---------------------------------------------------------------------------*\
Class regionSide Declaration
\*---------------------------------------------------------------------------*/
class regionSide
{
// Private Data
//- For every face on region tells whether the owner is on the
// 'regionside'.
labelHashSet sideOwner_;
//- Contains the faces using an internal point and visited face
labelHashSet insidePointFaces_;
// Private Member Functions
//- Step across point to other edge on face
static label otherEdge
(
const primitiveMesh& mesh,
const label facei,
const label edgeI,
const label pointi
);
//- From facei, side celli, cross to other faces/cells by
// face-cell walking and store visited faces and update sideOwner_.
void visitConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& region,
const labelHashSet& fenceEdges,
const label celli,
const label facei,
labelHashSet& visitedFace
);
//- From edge on face connected to point on region (regionPointi) cross
// to all other edges using this point by walking across faces
// Does not cross regionEdges so stays on one side of region
void walkPointConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& regionEdges,
const label regionPointi,
const label startFacei,
const label startEdgeI,
labelHashSet& visitedEdges
);
//- Visits all internal points on region and marks edges reachable
// from sideOwner side (using walkPointConnectedFaces)
void walkAllPointConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& regionFaces,
const labelHashSet& fenceEdges
);
public:
//- Runtime type information
ClassName("regionSide");
// Static Functions
//- Step across edge onto other face on cell
static label otherFace
(
const primitiveMesh& mesh,
const label celli,
const label excludeFacei,
const label edgeI
);
// Constructors
//- Construct from components
regionSide
(
const primitiveMesh& mesh,
const labelHashSet& region,
const labelHashSet& fenceEdges, // labels of fence edges
const label startCell,
const label startFace
);
// Member Functions
// Access
const labelHashSet& sideOwner() const
{
return sideOwner_;
}
const labelHashSet& insidePointFaces() const
{
return insidePointFaces_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,292 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Application
splitMesh
Description
Splits mesh by making internal faces external. Uses attachDetach.
Generates a meshModifier of the form:
Splitter
{
type attachDetach;
faceZoneName membraneFaces;
masterPatchName masterPatch;
slavePatchName slavePatch;
triggerTimes runTime.value();
}
so will detach at the current time and split all faces in membraneFaces
into masterPatch and slavePatch (which have to be present but of 0 size)
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "polyMesh.H"
#include "Time.H"
#include "polyTopoChange.H"
#include "polyTopoChangeMap.H"
#include "faceSet.H"
#include "attachDetach.H"
#include "attachPolyTopoChanger.H"
#include "regionSide.H"
#include "primitiveFacePatch.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Find edge between points v0 and v1.
label findEdge(const primitiveMesh& mesh, const label v0, const label v1)
{
const labelList& pEdges = mesh.pointEdges()[v0];
forAll(pEdges, pEdgeI)
{
label edgeI = pEdges[pEdgeI];
const edge& e = mesh.edges()[edgeI];
if (e.otherVertex(v0) == v1)
{
return edgeI;
}
}
FatalErrorInFunction
<< "Cannot find edge between mesh points " << v0 << " and " << v1
<< abort(FatalError);
return -1;
}
// Checks whether patch present
void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
{
const label patchi = bMesh.findPatchID(name);
if (patchi == -1)
{
FatalErrorInFunction
<< "Cannot find patch " << name << nl
<< "It should be present but of zero size" << endl
<< "Valid patches are " << bMesh.names()
<< exit(FatalError);
}
if (bMesh[patchi].size())
{
FatalErrorInFunction
<< "Patch " << name << " is present but non-zero size"
<< exit(FatalError);
}
}
int main(int argc, char *argv[])
{
argList::noParallel();
#include "addOverwriteOption.H"
argList::validArgs.append("faceSet");
argList::validArgs.append("masterPatch");
argList::validArgs.append("slavePatch");
#include "setRootCase.H"
#include "createTimeNoFunctionObjects.H"
#include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
const word setName = args[1];
const word masterPatch = args[2];
const word slavePatch = args[3];
const bool overwrite = args.optionFound("overwrite");
// List of faces to split
faceSet facesSet(mesh, setName);
Info<< "Read " << facesSet.size() << " faces to split" << endl << endl;
// Convert into labelList and check
labelList faces(facesSet.toc());
forAll(faces, i)
{
if (!mesh.isInternalFace(faces[i]))
{
FatalErrorInFunction
<< "Face " << faces[i] << " in faceSet " << setName
<< " is not an internal face."
<< exit(FatalError);
}
}
// Check for empty master and slave patches
checkPatch(mesh.boundaryMesh(), masterPatch);
checkPatch(mesh.boundaryMesh(), slavePatch);
//
// Find 'side' of all faces on splitregion. Uses regionSide which needs
// set of edges on side of this region. Use PrimitivePatch to find these.
//
// Addressing on faces only in mesh vertices.
primitiveFacePatch fPatch
(
faceList
(
UIndirectList<face>
(
mesh.faces(),
faces
)
),
mesh.points()
);
const labelList& meshPoints = fPatch.meshPoints();
// Mark all fence edges : edges on boundary of fPatch but not on boundary
// of polyMesh
labelHashSet fenceEdges(fPatch.size());
const labelListList& allEdgeFaces = fPatch.edgeFaces();
forAll(allEdgeFaces, patchEdgeI)
{
if (allEdgeFaces[patchEdgeI].size() == 1)
{
const edge& e = fPatch.edges()[patchEdgeI];
label edgeI =
findEdge
(
mesh,
meshPoints[e.start()],
meshPoints[e.end()]
);
fenceEdges.insert(edgeI);
}
}
// Find sides reachable from 0th face of faceSet
label startFacei = faces[0];
regionSide regionInfo
(
mesh,
facesSet,
fenceEdges,
mesh.faceOwner()[startFacei],
startFacei
);
// Determine flip state for all faces in faceSet
boolList zoneFlip(faces.size());
forAll(faces, i)
{
zoneFlip[i] = !regionInfo.sideOwner().found(faces[i]);
}
// Create and add face zones and mesh modifiers
List<pointZone*> pz(0);
List<faceZone*> fz(1);
List<cellZone*> cz(0);
fz[0] =
new faceZone
(
"membraneFaces",
faces,
zoneFlip,
0,
mesh.faceZones()
);
Info<< "Adding point and face zones" << endl;
mesh.addZones(pz, fz, cz);
attachPolyTopoChanger splitter(mesh);
splitter.setSize(1);
// Add the sliding interface mesh modifier to start working at current
// time
splitter.set
(
0,
new attachDetach
(
"Splitter",
0,
splitter,
"membraneFaces",
masterPatch,
slavePatch,
scalarField(1, runTime.value())
)
);
Info<< nl << "Constructed topologyModifier:" << endl;
splitter[0].writeDict(Info);
if (!overwrite)
{
runTime++;
}
splitter.attach();
if (overwrite)
{
mesh.setInstance(oldInstance);
}
else
{
mesh.setInstance(runTime.name());
}
Info<< "Writing mesh to " << runTime.name() << endl;
if (!mesh.write())
{
FatalErrorInFunction
<< "Failed writing polyMesh."
<< exit(FatalError);
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -358,8 +358,7 @@ int main(int argc, char *argv[])
new perfectInterface
(
"couple",
0,
stitcher,
mesh,
cutZoneName,
masterPatchName,
slavePatchName
@ -412,8 +411,7 @@ int main(int argc, char *argv[])
new slidingInterface
(
"couple",
0,
stitcher,
mesh,
mergePatchName + "MasterZone",
mergePatchName + "SlaveZone",
mergePatchName + "CutPointZone",