foamyHexMesh, foamyQuadMesh: Removed pending funding for further development and maintenance
This commit is contained in:
@ -1,2 +1 @@
|
||||
EXE_INC = \
|
||||
-I$(FOAM_APP)/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/vectorTools
|
||||
EXE_INC =
|
||||
|
||||
@ -10,9 +10,4 @@ wmake -all $targetType extrudeMesh
|
||||
wmake -all $targetType extrudeToRegionMesh
|
||||
wmake -all $targetType snappyHexMesh
|
||||
|
||||
if [ -n "$FOAMY_HEX_MESH" ]
|
||||
then
|
||||
foamyMesh/Allwmake $targetType $*
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
wclean conformalVoronoiMesh
|
||||
wclean conformalVoronoi2DMesh
|
||||
wclean foamyQuadMesh
|
||||
wclean foamyHexMesh
|
||||
wclean foamyHexMeshSurfaceSimplify
|
||||
wclean foamyHexMeshBackgroundMesh
|
||||
wclean cellSizeAndAlignmentGrid
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
# Get BOOST_ARCH_PATH, CGAL_ARCH_PATH
|
||||
if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL`
|
||||
then
|
||||
. $settings
|
||||
if [ -n "$BOOST_ARCH_PATH" ]
|
||||
then
|
||||
echo " using BOOST_ARCH_PATH=$BOOST_ARCH_PATH"
|
||||
fi
|
||||
if [ -n "$CGAL_ARCH_PATH" ]
|
||||
then
|
||||
echo " using CGAL_ARCH_PATH=$CGAL_ARCH_PATH"
|
||||
fi
|
||||
else
|
||||
echo
|
||||
echo " Error: no config.sh/CGAL settings"
|
||||
echo
|
||||
fi
|
||||
|
||||
wmake $targetType conformalVoronoiMesh
|
||||
wmake $targetType conformalVoronoi2DMesh
|
||||
|
||||
wmake $targetType foamyQuadMesh
|
||||
wmake $targetType foamyHexMesh
|
||||
#wmake $targetType foamyHexMeshBackgroundMesh
|
||||
#wmake -a $targetType foamyHexMeshSurfaceSimplify
|
||||
#wmake $targetType cellSizeAndAlignmentGrid
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,2 +0,0 @@
|
||||
cellSizeAndAlignmentGrid.C
|
||||
EXE = $(FOAM_APPBIN)/cellSizeAndAlignmentGrid
|
||||
@ -1,37 +0,0 @@
|
||||
EXE_DEBUG = -DFULLDEBUG -g -O0
|
||||
EXE_NDEBUG = -DNDEBUG
|
||||
|
||||
CGAL_EXACT =
|
||||
#CGAL_EXACT = -DCGAL_DONT_USE_LAZY_KERNEL
|
||||
CGAL_INEXACT = -DCGAL_INEXACT
|
||||
|
||||
include $(GENERAL_RULES)/CGAL
|
||||
|
||||
EXE_INC = \
|
||||
${ROUNDING_MATH} \
|
||||
${EXE_NDEBUG} \
|
||||
${CGAL_INEXACT} \
|
||||
${CGAL_INC} \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/snappyHexMesh/lnInclude \
|
||||
-I../conformalVoronoiMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
$(CGAL_LIBS) \
|
||||
-lmpfr \
|
||||
-lboost_thread \
|
||||
-lconformalVoronoiMesh \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-ldecompositionMethods \
|
||||
-L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp \
|
||||
-ltriSurface \
|
||||
-ldynamicMesh \
|
||||
-lsampling \
|
||||
-lfileFormats
|
||||
@ -1,717 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2022 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
|
||||
Test-distributedDelaunayMesh
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CGALTriangulation3DKernel.H"
|
||||
|
||||
#include "indexedVertex.H"
|
||||
#include "indexedCell.H"
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "DistributedDelaunayMesh.H"
|
||||
#include "backgroundMeshDecomposition.H"
|
||||
#include "searchableSurfaces.H"
|
||||
#include "conformationSurfaces.H"
|
||||
#include "PrintTable.H"
|
||||
#include "Random.H"
|
||||
#include "boundBox.H"
|
||||
#include "point.H"
|
||||
#include "cellShapeControlMesh.H"
|
||||
#include "triadField.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "pointIOField.H"
|
||||
#include "triadIOField.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
template<class Triangulation, class Type>
|
||||
Foam::tmp<Foam::Field<Type>> filterFarPoints
|
||||
(
|
||||
const Triangulation& mesh,
|
||||
const Field<Type>& field
|
||||
)
|
||||
{
|
||||
tmp<Field<Type>> tNewField(new Field<Type>(field.size()));
|
||||
Field<Type>& newField = tNewField.ref();
|
||||
|
||||
label added = 0;
|
||||
label count = 0;
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->real())
|
||||
{
|
||||
newField[added++] = field[count];
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
newField.resize(added);
|
||||
|
||||
return tNewField;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
autoPtr<distributionMap> buildMap
|
||||
(
|
||||
const T& mesh,
|
||||
labelListList& pointPoints
|
||||
)
|
||||
{
|
||||
pointPoints.setSize(mesh.vertexCount());
|
||||
|
||||
globalIndex globalIndexing(mesh.vertexCount());
|
||||
|
||||
for
|
||||
(
|
||||
typename T::Finite_vertices_iterator vit = mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->real())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::list<typename T::Vertex_handle> adjVerts;
|
||||
mesh.finite_adjacent_vertices(vit, std::back_inserter(adjVerts));
|
||||
|
||||
DynamicList<label> indices(adjVerts.size());
|
||||
|
||||
for
|
||||
(
|
||||
typename std::list<typename T::Vertex_handle>::const_iterator
|
||||
adjVertI = adjVerts.begin();
|
||||
adjVertI != adjVerts.end();
|
||||
++adjVertI
|
||||
)
|
||||
{
|
||||
typename T::Vertex_handle vh = *adjVertI;
|
||||
|
||||
if (!vh->farPoint())
|
||||
{
|
||||
indices.append
|
||||
(
|
||||
globalIndexing.toGlobal(vh->procIndex(), vh->index())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pointPoints[vit->index()].transfer(indices);
|
||||
}
|
||||
|
||||
List<Map<label>> compactMap;
|
||||
|
||||
return autoPtr<distributionMap>
|
||||
(
|
||||
new distributionMap
|
||||
(
|
||||
globalIndexing,
|
||||
pointPoints,
|
||||
compactMap
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::tmp<Foam::triadField> buildAlignmentField(const T& mesh)
|
||||
{
|
||||
tmp<triadField> tAlignments
|
||||
(
|
||||
new triadField(mesh.vertexCount(), triad::unset)
|
||||
);
|
||||
triadField& alignments = tAlignments.ref();
|
||||
|
||||
for
|
||||
(
|
||||
typename T::Finite_vertices_iterator vit = mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->real())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
alignments[vit->index()] = vit->alignment();
|
||||
}
|
||||
|
||||
return tAlignments;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::tmp<Foam::pointField> buildPointField(const T& mesh)
|
||||
{
|
||||
tmp<pointField> tPoints
|
||||
(
|
||||
new pointField(mesh.vertexCount(), point(great, great, great))
|
||||
);
|
||||
pointField& points = tPoints.ref();
|
||||
|
||||
for
|
||||
(
|
||||
typename T::Finite_vertices_iterator vit = mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->real())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
points[vit->index()] = topoint(vit->point());
|
||||
}
|
||||
|
||||
return tPoints;
|
||||
}
|
||||
|
||||
|
||||
void refine
|
||||
(
|
||||
cellShapeControlMesh& mesh,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const label maxRefinementIterations,
|
||||
const scalar defaultCellSize
|
||||
)
|
||||
{
|
||||
for (label iter = 0; iter < maxRefinementIterations; ++iter)
|
||||
{
|
||||
DynamicList<point> ptsToInsert;
|
||||
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_cells_iterator cit =
|
||||
mesh.finite_cells_begin();
|
||||
cit != mesh.finite_cells_end();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
const point newPoint =
|
||||
topoint
|
||||
(
|
||||
CGAL::centroid
|
||||
(
|
||||
cit->vertex(0)->point(),
|
||||
cit->vertex(1)->point(),
|
||||
cit->vertex(2)->point(),
|
||||
cit->vertex(3)->point()
|
||||
)
|
||||
);
|
||||
|
||||
if (geometryToConformTo.inside(newPoint))
|
||||
{
|
||||
ptsToInsert.append(newPoint);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< " Adding " << returnReduce(ptsToInsert.size(), sumOp<label>())
|
||||
<< endl;
|
||||
|
||||
forAll(ptsToInsert, ptI)
|
||||
{
|
||||
mesh.insert
|
||||
(
|
||||
ptsToInsert[ptI],
|
||||
defaultCellSize,
|
||||
triad::unset,
|
||||
Vb::vtInternal
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
label maxRefinementIterations = 2;
|
||||
label maxSmoothingIterations = 200;
|
||||
scalar minResidual = 0;
|
||||
scalar defaultCellSize = 0.001;
|
||||
scalar nearFeatDistSqrCoeff = 1e-8;
|
||||
|
||||
|
||||
// Need to decouple vertex and cell type from this class?
|
||||
// Vertex must have:
|
||||
// + index
|
||||
// + procIndex
|
||||
// - type should be optional
|
||||
cellShapeControlMesh mesh(runTime);
|
||||
|
||||
IOdictionary foamyHexMeshDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"foamyHexMeshDict",
|
||||
runTime.system(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
Random rndGen(64293*Pstream::myProcNo());
|
||||
|
||||
searchableSurfaces allGeometry
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cvSearchableSurfaces",
|
||||
runTime.constant(),
|
||||
searchableSurface::geometryDir(runTime),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
foamyHexMeshDict.subDict("geometry"),
|
||||
foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
|
||||
);
|
||||
|
||||
conformationSurfaces geometryToConformTo
|
||||
(
|
||||
runTime,
|
||||
rndGen,
|
||||
allGeometry,
|
||||
foamyHexMeshDict.subDict("surfaceConformation")
|
||||
);
|
||||
|
||||
autoPtr<backgroundMeshDecomposition> bMesh;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
bMesh.set
|
||||
(
|
||||
new backgroundMeshDecomposition
|
||||
(
|
||||
runTime,
|
||||
rndGen,
|
||||
geometryToConformTo,
|
||||
foamyHexMeshDict.subDict("backgroundMeshDecomposition")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Nice to have IO for the delaunay mesh
|
||||
// IO depend on vertex type.
|
||||
//
|
||||
// Define a delaunay mesh as:
|
||||
// + list of points of the triangulation
|
||||
// + optionally a list of cells
|
||||
|
||||
Info<< nl << "Loop over surfaces" << endl;
|
||||
|
||||
forAll(geometryToConformTo.surfaces(), sI)
|
||||
{
|
||||
const label surfI = geometryToConformTo.surfaces()[sI];
|
||||
|
||||
const searchableSurface& surface =
|
||||
geometryToConformTo.geometry()[surfI];
|
||||
|
||||
Info<< nl << "Inserting points from surface " << surface.name()
|
||||
<< " (" << surface.type() << ")" << endl;
|
||||
|
||||
const tmp<pointField> tpoints(surface.points());
|
||||
const pointField& points = tpoints();
|
||||
|
||||
Info<< " Number of points = " << points.size() << endl;
|
||||
|
||||
forAll(points, pI)
|
||||
{
|
||||
// Is the point in the extendedFeatureEdgeMesh? If so get the
|
||||
// point normal, otherwise get the surface normal from
|
||||
// searchableSurface
|
||||
|
||||
pointIndexHit info;
|
||||
label infoFeature;
|
||||
geometryToConformTo.findFeaturePointNearest
|
||||
(
|
||||
points[pI],
|
||||
nearFeatDistSqrCoeff,
|
||||
info,
|
||||
infoFeature
|
||||
);
|
||||
|
||||
|
||||
autoPtr<triad> pointAlignment;
|
||||
|
||||
if (info.hit())
|
||||
{
|
||||
const extendedFeatureEdgeMesh& features =
|
||||
geometryToConformTo.features()[infoFeature];
|
||||
|
||||
vectorField norms = features.featurePointNormals(info.index());
|
||||
|
||||
// Create a triad from these norms.
|
||||
pointAlignment.set(new triad());
|
||||
forAll(norms, nI)
|
||||
{
|
||||
pointAlignment() += norms[nI];
|
||||
}
|
||||
|
||||
pointAlignment().normalise();
|
||||
pointAlignment().orthogonalise();
|
||||
}
|
||||
else
|
||||
{
|
||||
geometryToConformTo.findEdgeNearest
|
||||
(
|
||||
points[pI],
|
||||
nearFeatDistSqrCoeff,
|
||||
info,
|
||||
infoFeature
|
||||
);
|
||||
|
||||
if (info.hit())
|
||||
{
|
||||
const extendedFeatureEdgeMesh& features =
|
||||
geometryToConformTo.features()[infoFeature];
|
||||
|
||||
vectorField norms = features.edgeNormals(info.index());
|
||||
|
||||
// Create a triad from these norms.
|
||||
pointAlignment.set(new triad());
|
||||
forAll(norms, nI)
|
||||
{
|
||||
pointAlignment() += norms[nI];
|
||||
}
|
||||
|
||||
pointAlignment().normalise();
|
||||
pointAlignment().orthogonalise();
|
||||
}
|
||||
else
|
||||
{
|
||||
pointField ptField(1, points[pI]);
|
||||
scalarField distField(1, nearFeatDistSqrCoeff);
|
||||
List<pointIndexHit> infoList(1, pointIndexHit());
|
||||
|
||||
surface.findNearest(ptField, distField, infoList);
|
||||
|
||||
vectorField normals(1);
|
||||
surface.getNormal(infoList, normals);
|
||||
|
||||
pointAlignment.set(new triad(normals[0]));
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (bMesh().positionOnThisProcessor(points[pI]))
|
||||
{
|
||||
CellSizeDelaunay::Vertex_handle vh = mesh.insert
|
||||
(
|
||||
points[pI],
|
||||
defaultCellSize,
|
||||
pointAlignment(),
|
||||
Vb::vtInternalNearBoundary
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CellSizeDelaunay::Vertex_handle vh = mesh.insert
|
||||
(
|
||||
points[pI],
|
||||
defaultCellSize,
|
||||
pointAlignment(),
|
||||
Vb::vtInternalNearBoundary
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Refine the mesh
|
||||
refine
|
||||
(
|
||||
mesh,
|
||||
geometryToConformTo,
|
||||
maxRefinementIterations,
|
||||
defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
mesh.distribute(bMesh);
|
||||
}
|
||||
|
||||
|
||||
labelListList pointPoints;
|
||||
autoPtr<distributionMap> meshDistributor = buildMap(mesh, pointPoints);
|
||||
|
||||
|
||||
triadField alignments(buildAlignmentField(mesh));
|
||||
pointField points(buildPointField(mesh));
|
||||
|
||||
mesh.printInfo(Info);
|
||||
|
||||
|
||||
// Setup the sizes and alignments on each point
|
||||
triadField fixedAlignments(mesh.vertexCount(), triad::unset);
|
||||
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||
mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->nearBoundary())
|
||||
{
|
||||
fixedAlignments[vit->index()] = vit->alignment();
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nl << "Smoothing alignments" << endl;
|
||||
|
||||
for (label iter = 0; iter < maxSmoothingIterations; iter++)
|
||||
{
|
||||
Info<< "Iteration " << iter;
|
||||
|
||||
meshDistributor().distribute(points);
|
||||
meshDistributor().distribute(alignments);
|
||||
|
||||
scalar residual = 0;
|
||||
|
||||
triadField triadAv(alignments.size(), triad::unset);
|
||||
|
||||
forAll(pointPoints, pI)
|
||||
{
|
||||
const labelList& pPoints = pointPoints[pI];
|
||||
|
||||
if (pPoints.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const triad& oldTriad = alignments[pI];
|
||||
triad& newTriad = triadAv[pI];
|
||||
|
||||
// Enforce the boundary conditions
|
||||
const triad& fixedAlignment = fixedAlignments[pI];
|
||||
|
||||
forAll(pPoints, adjPointi)
|
||||
{
|
||||
const label adjPointIndex = pPoints[adjPointi];
|
||||
|
||||
scalar dist = mag(points[pI] - points[adjPointIndex]);
|
||||
|
||||
// dist = max(dist, small);
|
||||
|
||||
triad tmpTriad = alignments[adjPointIndex];
|
||||
|
||||
for (direction dir = 0; dir < 3; dir++)
|
||||
{
|
||||
if (tmpTriad.set(dir))
|
||||
{
|
||||
tmpTriad[dir] *= (1.0/dist);
|
||||
}
|
||||
}
|
||||
|
||||
newTriad += tmpTriad;
|
||||
}
|
||||
|
||||
newTriad.normalise();
|
||||
newTriad.orthogonalise();
|
||||
// newTriad = newTriad.sortxyz();
|
||||
|
||||
label nFixed = 0;
|
||||
|
||||
forAll(fixedAlignment, dirI)
|
||||
{
|
||||
if (fixedAlignment.set(dirI))
|
||||
{
|
||||
nFixed++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFixed == 1)
|
||||
{
|
||||
forAll(fixedAlignment, dirI)
|
||||
{
|
||||
if (fixedAlignment.set(dirI))
|
||||
{
|
||||
newTriad.align(fixedAlignment[dirI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nFixed == 2)
|
||||
{
|
||||
forAll(fixedAlignment, dirI)
|
||||
{
|
||||
if (fixedAlignment.set(dirI))
|
||||
{
|
||||
newTriad[dirI] = fixedAlignment[dirI];
|
||||
}
|
||||
else
|
||||
{
|
||||
newTriad[dirI] = triad::unset[dirI];
|
||||
}
|
||||
}
|
||||
|
||||
newTriad.orthogonalise();
|
||||
}
|
||||
else if (nFixed == 3)
|
||||
{
|
||||
forAll(fixedAlignment, dirI)
|
||||
{
|
||||
if (fixedAlignment.set(dirI))
|
||||
{
|
||||
newTriad[dirI] = fixedAlignment[dirI];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (direction dir = 0; dir < 3; ++dir)
|
||||
{
|
||||
if
|
||||
(
|
||||
newTriad.set(dir)
|
||||
&& oldTriad.set(dir)
|
||||
//&& !fixedAlignment.set(dir)
|
||||
)
|
||||
{
|
||||
scalar dotProd = (oldTriad[dir] & newTriad[dir]);
|
||||
scalar diff = mag(dotProd) - 1.0;
|
||||
|
||||
residual += mag(diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forAll(alignments, pI)
|
||||
{
|
||||
alignments[pI] = triadAv[pI].sortxyz();
|
||||
}
|
||||
|
||||
reduce(residual, sumOp<scalar>());
|
||||
|
||||
Info<< ", Residual = " << residual << endl;
|
||||
|
||||
if (residual <= minResidual)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write alignments to a .obj file
|
||||
OFstream str(runTime.path()/"alignments.obj");
|
||||
|
||||
forAll(alignments, pI)
|
||||
{
|
||||
const triad& tri = alignments[pI];
|
||||
|
||||
if (tri.set())
|
||||
{
|
||||
forAll(tri, dirI)
|
||||
{
|
||||
meshTools::writeOBJ(str, points[pI], tri[dirI] + points[pI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remove the far points
|
||||
pointIOField pointsIO
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
filterFarPoints(mesh, points)
|
||||
);
|
||||
|
||||
scalarField sizes(points.size(), defaultCellSize);
|
||||
scalarIOField sizesIO
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"sizes",
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
filterFarPoints(mesh, sizes)
|
||||
);
|
||||
|
||||
triadIOField alignmentsIO
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"alignments",
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
filterFarPoints(mesh, alignments)
|
||||
);
|
||||
|
||||
pointsIO.write();
|
||||
sizesIO.write();
|
||||
alignmentsIO.write();
|
||||
|
||||
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,3 +0,0 @@
|
||||
cv2DControls/cv2DControls.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libcv2DMesh
|
||||
@ -1,3 +0,0 @@
|
||||
EXE_INC =
|
||||
|
||||
LIB_LIBS =
|
||||
@ -1,152 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2019 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 "cv2DControls.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
Foam::cv2DControls::cv2DControls
|
||||
(
|
||||
const dictionary& controlDict,
|
||||
const boundBox& bb
|
||||
)
|
||||
:
|
||||
motionControl_(controlDict.subDict("motionControl")),
|
||||
conformationControl_(controlDict.subDict("surfaceConformation")),
|
||||
|
||||
minCellSize_(motionControl_.lookup<scalar>("minCellSize")),
|
||||
minCellSize2_(Foam::sqr(minCellSize_)),
|
||||
|
||||
maxQuadAngle_(conformationControl_.lookup<scalar>("maxQuadAngle")),
|
||||
|
||||
nearWallAlignedDist_
|
||||
(
|
||||
motionControl_.lookup<scalar>("nearWallAlignedDist")*minCellSize_
|
||||
),
|
||||
nearWallAlignedDist2_(Foam::sqr(nearWallAlignedDist_)),
|
||||
|
||||
insertSurfaceNearestPointPairs_
|
||||
(
|
||||
conformationControl_.lookup("insertSurfaceNearestPointPairs")
|
||||
),
|
||||
mirrorPoints_(conformationControl_.lookup("mirrorPoints")),
|
||||
insertSurfaceNearPointPairs_
|
||||
(
|
||||
conformationControl_.lookup("insertSurfaceNearPointPairs")
|
||||
),
|
||||
|
||||
objOutput_(motionControl_.lookupOrDefault<Switch>("objOutput", false)),
|
||||
|
||||
meshedSurfaceOutput_
|
||||
(
|
||||
motionControl_.lookupOrDefault<Switch>("meshedSurfaceOutput", false)
|
||||
),
|
||||
|
||||
randomiseInitialGrid_(conformationControl_.lookup("randomiseInitialGrid")),
|
||||
randomPerturbation_
|
||||
(
|
||||
conformationControl_.lookup<scalar>("randomPerturbation")
|
||||
),
|
||||
|
||||
maxBoundaryConformingIter_
|
||||
(
|
||||
conformationControl_.lookup<label>("maxBoundaryConformingIter")
|
||||
),
|
||||
|
||||
span_
|
||||
(
|
||||
max(mag(bb.max().x()), mag(bb.min().x()))
|
||||
+ max(mag(bb.max().y()), mag(bb.min().y()))
|
||||
),
|
||||
span2_(Foam::sqr(span_)),
|
||||
|
||||
minEdgeLen_
|
||||
(
|
||||
conformationControl_.lookup<scalar>("minEdgeLenCoeff")
|
||||
*minCellSize_
|
||||
),
|
||||
minEdgeLen2_(Foam::sqr(minEdgeLen_)),
|
||||
|
||||
maxNotchLen_
|
||||
(
|
||||
conformationControl_.lookup<scalar>("maxNotchLenCoeff")
|
||||
*minCellSize_
|
||||
),
|
||||
maxNotchLen2_(Foam::sqr(maxNotchLen_)),
|
||||
|
||||
minNearPointDist_
|
||||
(
|
||||
conformationControl_.lookup<scalar>("minNearPointDistCoeff")
|
||||
*minCellSize_
|
||||
),
|
||||
minNearPointDist2_(Foam::sqr(minNearPointDist_)),
|
||||
|
||||
ppDist_
|
||||
(
|
||||
conformationControl_.lookup<scalar>("pointPairDistanceCoeff")
|
||||
*minCellSize_
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cv2DControls::~cv2DControls()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::cv2DControls::write(Ostream& os) const
|
||||
{
|
||||
os.indentLevel() = 1;
|
||||
os.precision(2);
|
||||
os.flags(ios_base::scientific);
|
||||
|
||||
os << nl << "Outputting CV2D Mesher controls:" << nl
|
||||
<< token::BEGIN_BLOCK << nl
|
||||
<< indent << "minCellSize2_ : " << minCellSize2_ << nl
|
||||
<< indent << "span_ / span2_ : " << span_ << " / " << span2_ << nl
|
||||
<< indent << "maxNotchLen2_ : " << maxNotchLen2_ << nl
|
||||
<< indent << "minNearPointDist2_ : " << minNearPointDist2_ << nl
|
||||
<< indent << "nearWallAlignedDist2_ : " << nearWallAlignedDist2_ << nl
|
||||
<< indent << "ppDist_ : " << ppDist_ << nl
|
||||
<< indent << "minEdgeLen2_ : " << minEdgeLen2_ << nl
|
||||
<< token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const cv2DControls& s)
|
||||
{
|
||||
s.write(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,264 +0,0 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2019 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::cv2DControls
|
||||
|
||||
Description
|
||||
Controls for the 2D CV mesh generator.
|
||||
|
||||
SourceFiles
|
||||
cv2DControls.C
|
||||
cv2DControlsI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cv2DControls_H
|
||||
#define cv2DControls_H
|
||||
|
||||
#include "Switch.H"
|
||||
#include "dictionary.H"
|
||||
#include "boundBox.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class cv2DControls;
|
||||
|
||||
Ostream& operator<<(Ostream&, const cv2DControls&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cv2DControls Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cv2DControls
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const dictionary& motionControl_;
|
||||
|
||||
const dictionary& conformationControl_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Controls
|
||||
|
||||
//- Minimum cell size below which protrusions through the surface
|
||||
// are not split
|
||||
scalar minCellSize_;
|
||||
|
||||
//- Square of minCellSize
|
||||
scalar minCellSize2_;
|
||||
|
||||
//- Maximum quadrant angle allowed at a concave corner before
|
||||
// additional "mitering" lines are added
|
||||
scalar maxQuadAngle_;
|
||||
|
||||
//- Near-wall region where cells are aligned with the wall
|
||||
scalar nearWallAlignedDist_;
|
||||
|
||||
//- Square of nearWallAlignedDist
|
||||
scalar nearWallAlignedDist2_;
|
||||
|
||||
//- Insert near-boundary point mirror or point-pairs
|
||||
Switch insertSurfaceNearestPointPairs_;
|
||||
|
||||
//- Mirror near-boundary points rather than insert point-pairs
|
||||
Switch mirrorPoints_;
|
||||
|
||||
//- Insert point-pairs vor dual-cell vertices very near the surface
|
||||
Switch insertSurfaceNearPointPairs_;
|
||||
|
||||
Switch objOutput_;
|
||||
|
||||
Switch meshedSurfaceOutput_;
|
||||
|
||||
Switch randomiseInitialGrid_;
|
||||
|
||||
scalar randomPerturbation_;
|
||||
|
||||
label maxBoundaryConformingIter_;
|
||||
|
||||
|
||||
// Tolerances
|
||||
|
||||
//- Maximum cartesian span of the geometry
|
||||
scalar span_;
|
||||
|
||||
//- Square of span
|
||||
scalar span2_;
|
||||
|
||||
//- Minimum edge-length of the cell size below which protrusions
|
||||
// through the surface are not split
|
||||
scalar minEdgeLen_;
|
||||
|
||||
//- Square of minEdgeLen
|
||||
scalar minEdgeLen2_;
|
||||
|
||||
//- Maximum notch size below which protrusions into the surface are
|
||||
// not filled
|
||||
scalar maxNotchLen_;
|
||||
|
||||
//- Square of maxNotchLen
|
||||
scalar maxNotchLen2_;
|
||||
|
||||
//- The minimum distance allowed between a dual-cell vertex
|
||||
// and the surface before a point-pair is introduced
|
||||
scalar minNearPointDist_;
|
||||
|
||||
//- Square of minNearPoint
|
||||
scalar minNearPointDist2_;
|
||||
|
||||
//- Distance between boundary conforming point-pairs
|
||||
scalar ppDist_;
|
||||
|
||||
//- Square of ppDist
|
||||
scalar ppDist2_;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
cv2DControls
|
||||
(
|
||||
const dictionary& controlDict,
|
||||
const boundBox& bb
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
cv2DControls(const cv2DControls&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~cv2DControls();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the minimum cell size
|
||||
inline scalar minCellSize() const;
|
||||
|
||||
//- Return the square of the minimum cell size
|
||||
inline scalar minCellSize2() const;
|
||||
|
||||
//- Return the maximum quadrant angle
|
||||
inline scalar maxQuadAngle() const;
|
||||
|
||||
//- Return number of layers to align with the nearest wall
|
||||
inline scalar nearWallAlignedDist() const;
|
||||
|
||||
//- Return square of nearWallAlignedDist
|
||||
inline scalar nearWallAlignedDist2() const;
|
||||
|
||||
//- Return insertSurfaceNearestPointPairs Switch
|
||||
inline Switch insertSurfaceNearestPointPairs() const;
|
||||
|
||||
//- Return mirrorPoints Switch
|
||||
inline Switch mirrorPoints() const;
|
||||
|
||||
//- Return insertSurfaceNearPointPairs Switch
|
||||
inline Switch insertSurfaceNearPointPairs() const;
|
||||
|
||||
//- Return the objOutput Switch
|
||||
inline Switch objOutput() const;
|
||||
|
||||
//- Return the meshedSurfaceOutput Switch
|
||||
inline Switch meshedSurfaceOutput() const;
|
||||
|
||||
//- Return the randomise initial point layout Switch
|
||||
inline Switch randomiseInitialGrid() const;
|
||||
|
||||
//- Return the random perturbation factor
|
||||
inline scalar randomPerturbation() const;
|
||||
|
||||
//- Return the maximum number of boundary conformation iterations
|
||||
inline label maxBoundaryConformingIter() const;
|
||||
|
||||
//- Return the span
|
||||
inline scalar span() const;
|
||||
|
||||
//- Return the span squared
|
||||
inline scalar span2() const;
|
||||
|
||||
//- Return the minEdgeLen
|
||||
inline scalar minEdgeLen() const;
|
||||
|
||||
//- Return the minEdgeLen squared
|
||||
inline scalar minEdgeLen2() const;
|
||||
|
||||
//- Return the maxNotchLen
|
||||
inline scalar maxNotchLen() const;
|
||||
|
||||
//- Return the maxNotchLen squared
|
||||
inline scalar maxNotchLen2() const;
|
||||
|
||||
//- Return the minNearPointDist
|
||||
inline scalar minNearPointDist() const;
|
||||
|
||||
//- Return the minNearPointDist squared
|
||||
inline scalar minNearPointDist2() const;
|
||||
|
||||
//- Return the ppDist
|
||||
inline scalar ppDist() const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write controls to output stream.
|
||||
void write(Ostream& os) const;
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const cv2DControls& s
|
||||
);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cv2DControls&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "cv2DControlsI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,158 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::minCellSize() const
|
||||
{
|
||||
return minCellSize_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::minCellSize2() const
|
||||
{
|
||||
return minCellSize2_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::maxQuadAngle() const
|
||||
{
|
||||
return maxQuadAngle_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::nearWallAlignedDist() const
|
||||
{
|
||||
return nearWallAlignedDist_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::nearWallAlignedDist2() const
|
||||
{
|
||||
return nearWallAlignedDist2_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::Switch Foam::cv2DControls::insertSurfaceNearestPointPairs() const
|
||||
{
|
||||
return insertSurfaceNearestPointPairs_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::Switch Foam::cv2DControls::mirrorPoints() const
|
||||
{
|
||||
return mirrorPoints_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::Switch Foam::cv2DControls::insertSurfaceNearPointPairs() const
|
||||
{
|
||||
return insertSurfaceNearPointPairs_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::Switch Foam::cv2DControls::objOutput() const
|
||||
{
|
||||
return objOutput_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::Switch Foam::cv2DControls::meshedSurfaceOutput() const
|
||||
{
|
||||
return meshedSurfaceOutput_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::Switch Foam::cv2DControls::randomiseInitialGrid() const
|
||||
{
|
||||
return randomiseInitialGrid_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::randomPerturbation() const
|
||||
{
|
||||
return randomPerturbation_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::cv2DControls::maxBoundaryConformingIter() const
|
||||
{
|
||||
return maxBoundaryConformingIter_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::span() const
|
||||
{
|
||||
return span_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::span2() const
|
||||
{
|
||||
return span2_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::minEdgeLen() const
|
||||
{
|
||||
return minEdgeLen_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::minEdgeLen2() const
|
||||
{
|
||||
return minEdgeLen2_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::maxNotchLen() const
|
||||
{
|
||||
return maxNotchLen_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::maxNotchLen2() const
|
||||
{
|
||||
return maxNotchLen2_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::minNearPointDist() const
|
||||
{
|
||||
return minNearPointDist_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::minNearPointDist2() const
|
||||
{
|
||||
return minNearPointDist2_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::cv2DControls::ppDist() const
|
||||
{
|
||||
return ppDist_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,369 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2022 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 "DelaunayMesh.H"
|
||||
#include "labelPair.H"
|
||||
#include "PrintTable.H"
|
||||
#include "pointIOField.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "labelIOField.H"
|
||||
#include "pointConversion.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::DelaunayMesh<Triangulation>::DelaunayMesh(const Time& runTime)
|
||||
:
|
||||
Triangulation(),
|
||||
vertexCount_(0),
|
||||
cellCount_(0),
|
||||
runTime_(runTime),
|
||||
rndGen_(64293*Pstream::myProcNo())
|
||||
{}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::DelaunayMesh<Triangulation>::DelaunayMesh
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& meshName
|
||||
)
|
||||
:
|
||||
Triangulation(),
|
||||
vertexCount_(0),
|
||||
cellCount_(0),
|
||||
runTime_(runTime),
|
||||
rndGen_(64293*Pstream::myProcNo())
|
||||
{
|
||||
Info<< "Reading " << meshName << " from " << runTime.name() << endl;
|
||||
|
||||
pointIOField pts
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
runTime.name(),
|
||||
meshName/polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
if (pts.headerOk())
|
||||
{
|
||||
labelIOField types
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"types",
|
||||
runTime.name(),
|
||||
meshName,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
// Do not read in indices
|
||||
// labelIOField indices
|
||||
// (
|
||||
// IOobject
|
||||
// (
|
||||
// "indices",
|
||||
// runTime.name(),
|
||||
// meshName,
|
||||
// runTime,
|
||||
// IOobject::MUST_READ,
|
||||
// IOobject::NO_WRITE
|
||||
// )
|
||||
// );
|
||||
|
||||
labelIOField processorIndices
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"processorIndices",
|
||||
runTime.name(),
|
||||
meshName,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
List<Vb> pointsToInsert(pts.size());
|
||||
|
||||
forAll(pointsToInsert, pI)
|
||||
{
|
||||
pointsToInsert[pI] =
|
||||
Vb
|
||||
(
|
||||
toPoint(pts[pI]),
|
||||
pI,
|
||||
static_cast<indexedVertexEnum::vertexType>(types[pI]),
|
||||
processorIndices[pI]
|
||||
);
|
||||
}
|
||||
|
||||
rangeInsertWithInfo
|
||||
(
|
||||
pointsToInsert.begin(),
|
||||
pointsToInsert.end(),
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
vertexCount_ = Triangulation::number_of_vertices();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::DelaunayMesh<Triangulation>::~DelaunayMesh()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMesh<Triangulation>::reset()
|
||||
{
|
||||
Info<< "Clearing triangulation" << endl;
|
||||
|
||||
DynamicList<Vb> vertices;
|
||||
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||
vit != Triangulation::finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->fixed())
|
||||
{
|
||||
vertices.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
vit->point(),
|
||||
vit->index(),
|
||||
vit->type(),
|
||||
vit->procIndex()
|
||||
)
|
||||
);
|
||||
|
||||
vertices.last().fixed() = vit->fixed();
|
||||
}
|
||||
}
|
||||
|
||||
this->clear();
|
||||
|
||||
resetVertexCount();
|
||||
resetCellCount();
|
||||
|
||||
insertPoints(vertices, false);
|
||||
|
||||
Info<< "Inserted " << vertexCount() << " fixed points" << endl;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::Map<Foam::label> Foam::DelaunayMesh<Triangulation>::insertPoints
|
||||
(
|
||||
const List<Vb>& vertices,
|
||||
const bool reIndex
|
||||
)
|
||||
{
|
||||
return rangeInsertWithInfo
|
||||
(
|
||||
vertices.begin(),
|
||||
vertices.end(),
|
||||
false,
|
||||
reIndex
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
bool Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_x_3::
|
||||
operator()
|
||||
(
|
||||
const Point_3& p,
|
||||
const Point_3& q
|
||||
) const
|
||||
{
|
||||
return typename Gt::Less_x_3()(*(p.first), *(q.first));
|
||||
}
|
||||
|
||||
template<class Triangulation>
|
||||
bool Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_y_3::
|
||||
operator()
|
||||
(
|
||||
const Point_3& p,
|
||||
const Point_3& q
|
||||
) const
|
||||
{
|
||||
return typename Gt::Less_y_3()(*(p.first), *(q.first));
|
||||
}
|
||||
|
||||
template<class Triangulation>
|
||||
bool Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_z_3::
|
||||
operator()
|
||||
(
|
||||
const Point_3& p,
|
||||
const Point_3& q
|
||||
) const
|
||||
{
|
||||
return typename Gt::Less_z_3()(*(p.first), *(q.first));
|
||||
}
|
||||
|
||||
template<class Triangulation>
|
||||
typename Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_x_3
|
||||
Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::less_x_3_object()
|
||||
const
|
||||
{
|
||||
return Less_x_3();
|
||||
}
|
||||
|
||||
template<class Triangulation>
|
||||
typename Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_y_3
|
||||
Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::less_y_3_object()
|
||||
const
|
||||
{
|
||||
return Less_y_3();
|
||||
}
|
||||
|
||||
template<class Triangulation>
|
||||
typename Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_z_3
|
||||
Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::less_z_3_object()
|
||||
const
|
||||
{
|
||||
return Less_z_3();
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
template<class PointIterator>
|
||||
Foam::Map<Foam::label> Foam::DelaunayMesh<Triangulation>::rangeInsertWithInfo
|
||||
(
|
||||
PointIterator begin,
|
||||
PointIterator end,
|
||||
bool printErrors,
|
||||
bool reIndex
|
||||
)
|
||||
{
|
||||
typedef DynamicList
|
||||
<
|
||||
std::pair
|
||||
<
|
||||
const typename Triangulation::Point*,
|
||||
label
|
||||
>
|
||||
> vectorPairPointIndex;
|
||||
|
||||
vectorPairPointIndex points;
|
||||
|
||||
label count = 0;
|
||||
for (PointIterator it = begin; it != end; ++it)
|
||||
{
|
||||
points.append
|
||||
(
|
||||
std::make_pair(&(it->point()), count++)
|
||||
);
|
||||
}
|
||||
|
||||
rndGen().permute(points);
|
||||
|
||||
spatial_sort
|
||||
(
|
||||
points.begin(),
|
||||
points.end(),
|
||||
Traits_for_spatial_sort()
|
||||
);
|
||||
|
||||
Vertex_handle hint;
|
||||
|
||||
Map<label> oldToNewIndex(points.size());
|
||||
|
||||
for
|
||||
(
|
||||
typename vectorPairPointIndex::const_iterator p = points.begin();
|
||||
p != points.end();
|
||||
++p
|
||||
)
|
||||
{
|
||||
const size_t checkInsertion = Triangulation::number_of_vertices();
|
||||
|
||||
hint = this->insert(*(p->first), hint);
|
||||
|
||||
const Vb& vert = *(begin + p->second);
|
||||
|
||||
if (checkInsertion != Triangulation::number_of_vertices() - 1)
|
||||
{
|
||||
if (printErrors)
|
||||
{
|
||||
Vertex_handle nearV =
|
||||
Triangulation::nearest_vertex(*(p->first));
|
||||
|
||||
Pout<< "Failed insertion : " << vert.info()
|
||||
<< " nearest : " << nearV->info();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const label oldIndex = vert.index();
|
||||
hint->index() = getNewVertexIndex();
|
||||
|
||||
if (reIndex)
|
||||
{
|
||||
oldToNewIndex.insert(oldIndex, hint->index());
|
||||
}
|
||||
|
||||
hint->type() = vert.type();
|
||||
hint->procIndex() = vert.procIndex();
|
||||
hint->targetCellSize() = vert.targetCellSize();
|
||||
hint->alignment() = vert.alignment();
|
||||
}
|
||||
}
|
||||
|
||||
return oldToNewIndex;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "DelaunayMeshIO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,302 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2022 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::DelaunayMesh
|
||||
|
||||
Description
|
||||
The vertex and cell classes must have an index defined
|
||||
|
||||
SourceFiles
|
||||
DelaunayMeshI.H
|
||||
DelaunayMesh.C
|
||||
DelaunayMeshIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DelaunayMesh_H
|
||||
#define DelaunayMesh_H
|
||||
|
||||
#include "Pair.H"
|
||||
#include "HashSet.H"
|
||||
#include "FixedList.H"
|
||||
#include "boundBox.H"
|
||||
#include "indexedVertex.H"
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
#include "Time.H"
|
||||
#include "autoPtr.H"
|
||||
#include "Random.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DelaunayMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Triangulation>
|
||||
class DelaunayMesh
|
||||
:
|
||||
public Triangulation
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename Triangulation::Cell_handle Cell_handle;
|
||||
typedef typename Triangulation::Vertex_handle Vertex_handle;
|
||||
typedef typename Triangulation::Edge Edge;
|
||||
typedef typename Triangulation::Point Point;
|
||||
typedef typename Triangulation::Facet Facet;
|
||||
|
||||
typedef typename Triangulation::Finite_vertices_iterator
|
||||
Finite_vertices_iterator;
|
||||
typedef typename Triangulation::Finite_cells_iterator
|
||||
Finite_cells_iterator;
|
||||
typedef typename Triangulation::Finite_facets_iterator
|
||||
Finite_facets_iterator;
|
||||
|
||||
typedef HashSet
|
||||
<
|
||||
Pair<label>,
|
||||
FixedList<label, 2>::Hash<>
|
||||
> labelPairHashSet;
|
||||
|
||||
typedef HashTable
|
||||
<
|
||||
label,
|
||||
labelPair,
|
||||
FixedList<label, 2>::Hash<>
|
||||
> labelTolabelPairHashTable;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Keep track of the number of vertices that have been added.
|
||||
// This allows a unique index to be assigned to each vertex.
|
||||
mutable label vertexCount_;
|
||||
|
||||
//- Keep track of the number of cells that have been added.
|
||||
// This allows a unique index to be assigned to each cell.
|
||||
mutable label cellCount_;
|
||||
|
||||
//- Reference to Time
|
||||
const Time& runTime_;
|
||||
|
||||
//- Random number generator
|
||||
mutable Random rndGen_;
|
||||
|
||||
//- Spatial sort traits to use with a pair of point pointers and an int.
|
||||
// Taken from a post on the CGAL lists: 2010-01/msg00004.html by
|
||||
// Sebastien Loriot (Geometry Factory).
|
||||
struct Traits_for_spatial_sort
|
||||
:
|
||||
public Triangulation::Geom_traits
|
||||
{
|
||||
typedef typename Triangulation::Geom_traits Gt;
|
||||
|
||||
typedef std::pair<const typename Triangulation::Point*, label>
|
||||
Point_3;
|
||||
|
||||
struct Less_x_3
|
||||
{
|
||||
bool operator()(const Point_3& p, const Point_3& q) const;
|
||||
};
|
||||
|
||||
struct Less_y_3
|
||||
{
|
||||
bool operator()(const Point_3& p, const Point_3& q) const;
|
||||
};
|
||||
|
||||
struct Less_z_3
|
||||
{
|
||||
bool operator()(const Point_3& p, const Point_3& q) const;
|
||||
};
|
||||
|
||||
Less_x_3 less_x_3_object() const;
|
||||
Less_y_3 less_y_3_object() const;
|
||||
Less_z_3 less_z_3_object() const;
|
||||
};
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void sortFaces
|
||||
(
|
||||
faceList& faces,
|
||||
labelList& owner,
|
||||
labelList& neighbour
|
||||
) const;
|
||||
|
||||
void addPatches
|
||||
(
|
||||
const label nInternalFaces,
|
||||
faceList& faces,
|
||||
labelList& owner,
|
||||
PtrList<dictionary>& patchDicts,
|
||||
const List<DynamicList<face>>& patchFaces,
|
||||
const List<DynamicList<label>>& patchOwners
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
explicit DelaunayMesh(const Time& runTime);
|
||||
|
||||
DelaunayMesh
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& meshName
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
DelaunayMesh(const DelaunayMesh<Triangulation>&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~DelaunayMesh();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return a reference to the Time object
|
||||
inline const Time& time() const;
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Write the cpuTime to screen
|
||||
inline void timeCheck
|
||||
(
|
||||
const string& description,
|
||||
const bool check = true
|
||||
) const;
|
||||
|
||||
|
||||
// Indexing functions
|
||||
|
||||
//- Create a new unique cell index and return
|
||||
inline label getNewCellIndex() const;
|
||||
|
||||
//- Create a new unique vertex index and return
|
||||
inline label getNewVertexIndex() const;
|
||||
|
||||
//- Return the cell count (the next unique cell index)
|
||||
inline label cellCount() const;
|
||||
|
||||
//- Return the vertex count (the next unique vertex index)
|
||||
inline label vertexCount() const;
|
||||
|
||||
//- Set the cell count to zero
|
||||
inline void resetCellCount();
|
||||
|
||||
//- Set the vertex count to zero
|
||||
inline void resetVertexCount();
|
||||
|
||||
|
||||
//- Access the random number generator
|
||||
inline Random& rndGen() const;
|
||||
|
||||
|
||||
// Triangulation manipulation functions
|
||||
|
||||
//- Clear the entire triangulation
|
||||
void reset();
|
||||
|
||||
//- Insert the list of vertices (calls rangeInsertWithInfo)
|
||||
Map<label> insertPoints
|
||||
(
|
||||
const List<Vb>& vertices,
|
||||
const bool reIndex
|
||||
);
|
||||
|
||||
//- Function inserting points into a triangulation and setting the
|
||||
// index and type data of the point in the correct order. This is
|
||||
// faster than inserting points individually.
|
||||
//
|
||||
// Adapted from a post on the CGAL lists: 2010-01/msg00004.html by
|
||||
// Sebastien Loriot (Geometry Factory).
|
||||
template<class PointIterator>
|
||||
Map<label> rangeInsertWithInfo
|
||||
(
|
||||
PointIterator begin,
|
||||
PointIterator end,
|
||||
bool printErrors = false,
|
||||
bool reIndex = true
|
||||
);
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write mesh statistics to stream
|
||||
void printInfo(Ostream& os) const;
|
||||
|
||||
//- Write vertex statistics in the form of a table to stream
|
||||
void printVertexInfo(Ostream& os) const;
|
||||
|
||||
//- Create an fvMesh from the triangulation.
|
||||
// The mesh is not parallel consistent - only used for viewing
|
||||
autoPtr<polyMesh> createMesh
|
||||
(
|
||||
const fileName& name,
|
||||
labelTolabelPairHashTable& vertexMap,
|
||||
labelList& cellMap,
|
||||
const bool writeDelaunayData = true
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const DelaunayMesh<Triangulation>&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "DelaunayMeshI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "DelaunayMesh.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,127 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2022 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation>
|
||||
inline const Foam::Time& Foam::DelaunayMesh<Triangulation>::time() const
|
||||
{
|
||||
return runTime_;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
inline void Foam::DelaunayMesh<Triangulation>::timeCheck
|
||||
(
|
||||
const string& description,
|
||||
const bool check
|
||||
) const
|
||||
{
|
||||
if (check)
|
||||
{
|
||||
Info<< nl << "--- [ cpuTime "
|
||||
<< time().elapsedCpuTime() << " s, "
|
||||
<< "delta " << time().cpuTimeIncrement()<< " s";
|
||||
|
||||
if (description != word::null)
|
||||
{
|
||||
Info<< ", " << description << " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " ";
|
||||
}
|
||||
|
||||
Info<< "] --- " << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
inline Foam::label Foam::DelaunayMesh<Triangulation>::getNewCellIndex() const
|
||||
{
|
||||
label id = cellCount_++;
|
||||
|
||||
if (id == labelMax)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Cell counter has overflowed." << endl;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
inline Foam::label Foam::DelaunayMesh<Triangulation>::getNewVertexIndex() const
|
||||
{
|
||||
label id = vertexCount_++;
|
||||
|
||||
if (id == labelMax)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Vertex counter has overflowed." << endl;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
inline Foam::label Foam::DelaunayMesh<Triangulation>::cellCount() const
|
||||
{
|
||||
return cellCount_;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
inline Foam::label Foam::DelaunayMesh<Triangulation>::vertexCount() const
|
||||
{
|
||||
return vertexCount_;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
inline void Foam::DelaunayMesh<Triangulation>::resetCellCount()
|
||||
{
|
||||
cellCount_ = 0;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
inline void Foam::DelaunayMesh<Triangulation>::resetVertexCount()
|
||||
{
|
||||
vertexCount_ = 0;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
inline Foam::Random& Foam::DelaunayMesh<Triangulation>::rndGen() const
|
||||
{
|
||||
return rndGen_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,634 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "DelaunayMesh.H"
|
||||
#include "fvMesh.H"
|
||||
#include "pointConversion.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "processorPolyPatch.H"
|
||||
#include "labelIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMesh<Triangulation>::sortFaces
|
||||
(
|
||||
faceList& faces,
|
||||
labelList& owner,
|
||||
labelList& neighbour
|
||||
) const
|
||||
{
|
||||
// Upper triangular order:
|
||||
// + owner is sorted in ascending cell order
|
||||
// + within each block of equal value for owner, neighbour is sorted in
|
||||
// ascending cell order.
|
||||
// + faces sorted to correspond
|
||||
// e.g.
|
||||
// owner | neighbour
|
||||
// 0 | 2
|
||||
// 0 | 23
|
||||
// 0 | 71
|
||||
// 1 | 23
|
||||
// 1 | 24
|
||||
// 1 | 91
|
||||
|
||||
List<labelPair> ownerNeighbourPair(owner.size());
|
||||
|
||||
forAll(ownerNeighbourPair, oNI)
|
||||
{
|
||||
ownerNeighbourPair[oNI] = labelPair(owner[oNI], neighbour[oNI]);
|
||||
}
|
||||
|
||||
Info<< nl
|
||||
<< "Sorting faces, owner and neighbour into upper triangular order"
|
||||
<< endl;
|
||||
|
||||
labelList oldToNew;
|
||||
|
||||
sortedOrder(ownerNeighbourPair, oldToNew);
|
||||
|
||||
oldToNew = invert(oldToNew.size(), oldToNew);
|
||||
|
||||
inplaceReorder(oldToNew, faces);
|
||||
inplaceReorder(oldToNew, owner);
|
||||
inplaceReorder(oldToNew, neighbour);
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMesh<Triangulation>::addPatches
|
||||
(
|
||||
const label nInternalFaces,
|
||||
faceList& faces,
|
||||
labelList& owner,
|
||||
PtrList<dictionary>& patchDicts,
|
||||
const List<DynamicList<face>>& patchFaces,
|
||||
const List<DynamicList<label>>& patchOwners
|
||||
) const
|
||||
{
|
||||
label nPatches = patchFaces.size();
|
||||
|
||||
patchDicts.setSize(nPatches);
|
||||
forAll(patchDicts, patchi)
|
||||
{
|
||||
patchDicts.set(patchi, new dictionary());
|
||||
}
|
||||
|
||||
label nBoundaryFaces = 0;
|
||||
|
||||
forAll(patchFaces, p)
|
||||
{
|
||||
patchDicts[p].set("nFaces", patchFaces[p].size());
|
||||
patchDicts[p].set("startFace", nInternalFaces + nBoundaryFaces);
|
||||
|
||||
nBoundaryFaces += patchFaces[p].size();
|
||||
}
|
||||
|
||||
faces.setSize(nInternalFaces + nBoundaryFaces);
|
||||
owner.setSize(nInternalFaces + nBoundaryFaces);
|
||||
|
||||
label facei = nInternalFaces;
|
||||
|
||||
forAll(patchFaces, p)
|
||||
{
|
||||
forAll(patchFaces[p], f)
|
||||
{
|
||||
faces[facei] = patchFaces[p][f];
|
||||
owner[facei] = patchOwners[p][f];
|
||||
|
||||
facei++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMesh<Triangulation>::printInfo(Ostream& os) const
|
||||
{
|
||||
PrintTable<word, label> triInfoTable("Mesh Statistics");
|
||||
|
||||
triInfoTable.add("Points", Triangulation::number_of_vertices());
|
||||
triInfoTable.add("Edges", Triangulation::number_of_finite_edges());
|
||||
triInfoTable.add("Faces", Triangulation::number_of_finite_facets());
|
||||
triInfoTable.add("Cells", Triangulation::number_of_finite_cells());
|
||||
|
||||
scalar minSize = great;
|
||||
scalar maxSize = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||
vit != Triangulation::finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
// Only internal or boundary vertices have a size
|
||||
if (vit->internalOrBoundaryPoint())
|
||||
{
|
||||
minSize = min(vit->targetCellSize(), minSize);
|
||||
maxSize = max(vit->targetCellSize(), maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< incrIndent;
|
||||
triInfoTable.print(Info, true, true);
|
||||
|
||||
Info<< "Size (Min/Max) = "
|
||||
<< returnReduce(minSize, minOp<scalar>()) << " "
|
||||
<< returnReduce(maxSize, maxOp<scalar>()) << endl;
|
||||
|
||||
Info<< decrIndent;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMesh<Triangulation>::printVertexInfo(Ostream& os) const
|
||||
{
|
||||
label nInternal = 0;
|
||||
label nUnassigned = 0;
|
||||
label nInternalNearBoundary = 0;
|
||||
label nInternalSurface = 0;
|
||||
label nInternalFeatureEdge = 0;
|
||||
label nInternalFeaturePoint = 0;
|
||||
label nExternalSurface = 0;
|
||||
label nExternalFeatureEdge = 0;
|
||||
label nExternalFeaturePoint = 0;
|
||||
label nFar = 0;
|
||||
label nReferred = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||
vit != Triangulation::finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->type() == Vb::vtInternal)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nInternal++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtUnassigned)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nUnassigned++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtInternalNearBoundary)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nInternalNearBoundary++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtInternalSurface)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nInternalSurface++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtInternalFeatureEdge)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nInternalFeatureEdge++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtInternalFeaturePoint)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nInternalFeaturePoint++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtExternalSurface)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nExternalSurface++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtExternalFeatureEdge)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nExternalFeatureEdge++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtExternalFeaturePoint)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
nReferred++;
|
||||
}
|
||||
|
||||
nExternalFeaturePoint++;
|
||||
}
|
||||
else if (vit->type() == Vb::vtFar)
|
||||
{
|
||||
nFar++;
|
||||
}
|
||||
}
|
||||
|
||||
label nTotalVertices =
|
||||
nUnassigned
|
||||
+ nInternal
|
||||
+ nInternalNearBoundary
|
||||
+ nInternalSurface
|
||||
+ nInternalFeatureEdge
|
||||
+ nInternalFeaturePoint
|
||||
+ nExternalSurface
|
||||
+ nExternalFeatureEdge
|
||||
+ nExternalFeaturePoint
|
||||
+ nFar;
|
||||
|
||||
if (nTotalVertices != label(Triangulation::number_of_vertices()))
|
||||
{
|
||||
WarningInFunction
|
||||
<< nTotalVertices << " does not equal "
|
||||
<< Triangulation::number_of_vertices()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
PrintTable<word, label> vertexTable("Vertex Type Information");
|
||||
|
||||
vertexTable.add("Total", nTotalVertices);
|
||||
vertexTable.add("Unassigned", nUnassigned);
|
||||
vertexTable.add("nInternal", nInternal);
|
||||
vertexTable.add("nInternalNearBoundary", nInternalNearBoundary);
|
||||
vertexTable.add("nInternalSurface", nInternalSurface);
|
||||
vertexTable.add("nInternalFeatureEdge", nInternalFeatureEdge);
|
||||
vertexTable.add("nInternalFeaturePoint", nInternalFeaturePoint);
|
||||
vertexTable.add("nExternalSurface", nExternalSurface);
|
||||
vertexTable.add("nExternalFeatureEdge", nExternalFeatureEdge);
|
||||
vertexTable.add("nExternalFeaturePoint", nExternalFeaturePoint);
|
||||
vertexTable.add("nFar", nFar);
|
||||
vertexTable.add("nReferred", nReferred);
|
||||
|
||||
os << endl;
|
||||
vertexTable.print(os);
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::autoPtr<Foam::polyMesh>
|
||||
Foam::DelaunayMesh<Triangulation>::createMesh
|
||||
(
|
||||
const fileName& name,
|
||||
labelTolabelPairHashTable& vertexMap,
|
||||
labelList& cellMap,
|
||||
const bool writeDelaunayData
|
||||
) const
|
||||
{
|
||||
pointField points(Triangulation::number_of_vertices());
|
||||
faceList faces(Triangulation::number_of_finite_facets());
|
||||
labelList owner(Triangulation::number_of_finite_facets());
|
||||
labelList neighbour(Triangulation::number_of_finite_facets());
|
||||
|
||||
wordList patchNames(1, "foamyHexMesh_defaultPatch");
|
||||
wordList patchTypes(1, wallPolyPatch::typeName);
|
||||
|
||||
PtrList<dictionary> patchDicts(1);
|
||||
patchDicts.set(0, new dictionary());
|
||||
|
||||
List<DynamicList<face>> patchFaces(1, DynamicList<face>());
|
||||
List<DynamicList<label>> patchOwners(1, DynamicList<label>());
|
||||
|
||||
vertexMap.resize(vertexCount());
|
||||
cellMap.setSize(Triangulation::number_of_finite_cells(), -1);
|
||||
|
||||
// Calculate pts and a map of point index to location in pts.
|
||||
label vertI = 0;
|
||||
|
||||
// labelIOField indices
|
||||
// (
|
||||
// IOobject
|
||||
// (
|
||||
// "indices",
|
||||
// time().name(),
|
||||
// name,
|
||||
// time(),
|
||||
// IOobject::NO_READ,
|
||||
// IOobject::AUTO_WRITE
|
||||
// ),
|
||||
// Triangulation::number_of_vertices()
|
||||
// );
|
||||
|
||||
labelIOField types
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"types",
|
||||
time().name(),
|
||||
name,
|
||||
time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
label(Triangulation::number_of_vertices())
|
||||
);
|
||||
|
||||
labelIOField processorIndices
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"processorIndices",
|
||||
time().name(),
|
||||
name,
|
||||
time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
label(Triangulation::number_of_vertices())
|
||||
);
|
||||
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||
vit != Triangulation::finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->farPoint())
|
||||
{
|
||||
vertexMap(labelPair(vit->index(), vit->procIndex())) = vertI;
|
||||
points[vertI] = topoint(vit->point());
|
||||
// indices[vertI] = vit->index();
|
||||
types[vertI] = static_cast<label>(vit->type());
|
||||
processorIndices[vertI] = vit->procIndex();
|
||||
vertI++;
|
||||
}
|
||||
}
|
||||
|
||||
points.setSize(vertI);
|
||||
// indices.setSize(vertI);
|
||||
types.setSize(vertI);
|
||||
processorIndices.setSize(vertI);
|
||||
|
||||
|
||||
// Index the cells
|
||||
label celli = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Finite_cells_iterator cit = Triangulation::finite_cells_begin();
|
||||
cit != Triangulation::finite_cells_end();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
!cit->hasFarPoint()
|
||||
&& !Triangulation::is_infinite(cit)
|
||||
&& cit->real()
|
||||
)
|
||||
{
|
||||
cellMap[cit->cellIndex()] = celli++;
|
||||
}
|
||||
}
|
||||
|
||||
label facei = 0;
|
||||
labelList verticesOnTriFace(3, label(-1));
|
||||
face newFace(verticesOnTriFace);
|
||||
|
||||
for
|
||||
(
|
||||
Finite_facets_iterator fit = Triangulation::finite_facets_begin();
|
||||
fit != Triangulation::finite_facets_end();
|
||||
++fit
|
||||
)
|
||||
{
|
||||
const Cell_handle c1(fit->first);
|
||||
const label oppositeVertex = fit->second;
|
||||
const Cell_handle c2(c1->neighbor(oppositeVertex));
|
||||
|
||||
// Do not output if face has neither opposite vertex as an internal
|
||||
// if
|
||||
// (
|
||||
// !c1->vertex(oppositeVertex)->internalPoint()
|
||||
// || !Triangulation::mirror_vertex(c1, oppositeVertex)->internalPoint()
|
||||
// )
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
label c1I = Cb::ctFar;
|
||||
bool c1Real = false;
|
||||
if
|
||||
(
|
||||
!Triangulation::is_infinite(c1)
|
||||
&& !c1->hasFarPoint()
|
||||
&& c1->real()
|
||||
)
|
||||
{
|
||||
c1I = cellMap[c1->cellIndex()];
|
||||
c1Real = true;
|
||||
}
|
||||
|
||||
label c2I = Cb::ctFar;
|
||||
bool c2Real = false;
|
||||
if
|
||||
(
|
||||
!Triangulation::is_infinite(c2)
|
||||
&& !c2->hasFarPoint()
|
||||
&& c2->real()
|
||||
)
|
||||
{
|
||||
c2I = cellMap[c2->cellIndex()];
|
||||
c2Real = true;
|
||||
}
|
||||
|
||||
if (!c1Real && !c2Real)
|
||||
{
|
||||
// Both tets are outside, skip
|
||||
continue;
|
||||
}
|
||||
|
||||
label ownerCell = -1;
|
||||
label neighbourCell = -1;
|
||||
|
||||
for (label i = 0; i < 3; i++)
|
||||
{
|
||||
verticesOnTriFace[i] = vertexMap
|
||||
[
|
||||
labelPair
|
||||
(
|
||||
c1->vertex
|
||||
(
|
||||
Triangulation::vertex_triple_index(oppositeVertex, i)
|
||||
)->index(),
|
||||
c1->vertex
|
||||
(
|
||||
Triangulation::vertex_triple_index(oppositeVertex, i)
|
||||
)->procIndex()
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
newFace = face(verticesOnTriFace);
|
||||
|
||||
if (!c1Real || !c2Real)
|
||||
{
|
||||
// Boundary face...
|
||||
if (!c1Real)
|
||||
{
|
||||
//... with c1 outside
|
||||
ownerCell = c2I;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ... with c2 outside
|
||||
ownerCell = c1I;
|
||||
|
||||
reverse(newFace);
|
||||
}
|
||||
|
||||
patchFaces[0].append(newFace);
|
||||
patchOwners[0].append(ownerCell);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Internal face...
|
||||
if (c1I < c2I)
|
||||
{
|
||||
// ...with c1 as the ownerCell
|
||||
ownerCell = c1I;
|
||||
neighbourCell = c2I;
|
||||
|
||||
reverse(newFace);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ...with c2 as the ownerCell
|
||||
ownerCell = c2I;
|
||||
neighbourCell = c1I;
|
||||
}
|
||||
|
||||
faces[facei] = newFace;
|
||||
owner[facei] = ownerCell;
|
||||
neighbour[facei] = neighbourCell;
|
||||
facei++;
|
||||
}
|
||||
}
|
||||
|
||||
faces.setSize(facei);
|
||||
owner.setSize(facei);
|
||||
neighbour.setSize(facei);
|
||||
|
||||
sortFaces(faces, owner, neighbour);
|
||||
|
||||
Info<< "Creating patches" << endl;
|
||||
|
||||
addPatches
|
||||
(
|
||||
facei,
|
||||
faces,
|
||||
owner,
|
||||
patchDicts,
|
||||
patchFaces,
|
||||
patchOwners
|
||||
);
|
||||
|
||||
Info<< "Creating mesh" << endl;
|
||||
|
||||
autoPtr<polyMesh> meshPtr
|
||||
(
|
||||
new polyMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
time().name(),
|
||||
time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
move(points),
|
||||
move(faces),
|
||||
move(owner),
|
||||
move(neighbour)
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Adding patches" << endl;
|
||||
|
||||
List<polyPatch*> patches(patchNames.size());
|
||||
|
||||
label nValidPatches = 0;
|
||||
|
||||
forAll(patches, p)
|
||||
{
|
||||
patches[nValidPatches] = polyPatch::New
|
||||
(
|
||||
patchTypes[p],
|
||||
patchNames[p],
|
||||
patchDicts[p],
|
||||
nValidPatches,
|
||||
meshPtr().boundaryMesh()
|
||||
).ptr();
|
||||
|
||||
nValidPatches++;
|
||||
}
|
||||
|
||||
patches.setSize(nValidPatches);
|
||||
|
||||
meshPtr().addPatches(patches);
|
||||
|
||||
if (writeDelaunayData)
|
||||
{
|
||||
// indices.write();
|
||||
types.write();
|
||||
processorIndices.write();
|
||||
}
|
||||
|
||||
Info<< "Mesh created" << endl;
|
||||
|
||||
return meshPtr;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,218 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2022 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::DistributedDelaunayMesh
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
DistributedDelaunayMeshI.H
|
||||
DistributedDelaunayMesh.C
|
||||
DistributedDelaunayMeshIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DistributedDelaunayMesh_H
|
||||
#define DistributedDelaunayMesh_H
|
||||
|
||||
#include "DelaunayMesh.H"
|
||||
#include "backgroundMeshDecomposition.H"
|
||||
#include "autoPtr.H"
|
||||
#include "boundBox.H"
|
||||
#include "indexedVertex.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class distributionMap;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DistributedDelaunayMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Triangulation>
|
||||
class DistributedDelaunayMesh
|
||||
:
|
||||
public DelaunayMesh<Triangulation>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename Triangulation::Vertex_handle Vertex_handle;
|
||||
typedef typename Triangulation::Cell_handle Cell_handle;
|
||||
typedef typename Triangulation::Point Point;
|
||||
|
||||
typedef typename Triangulation::Finite_vertices_iterator
|
||||
Finite_vertices_iterator;
|
||||
typedef typename Triangulation::Finite_cells_iterator
|
||||
Finite_cells_iterator;
|
||||
typedef typename Triangulation::All_cells_iterator
|
||||
All_cells_iterator;
|
||||
|
||||
typedef typename DelaunayMesh<Triangulation>::labelPairHashSet
|
||||
labelPairHashSet;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
autoPtr<List<boundBox>> allBackgroundMeshBounds_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//-
|
||||
bool distributeBoundBoxes(const boundBox& bb);
|
||||
|
||||
//-
|
||||
bool isLocal(const Vertex_handle& v) const;
|
||||
|
||||
bool isLocal(const label localProcIndex) const;
|
||||
|
||||
labelList overlapProcessors
|
||||
(
|
||||
const point& centre,
|
||||
const scalar radiusSqr
|
||||
) const;
|
||||
|
||||
bool checkProcBoundaryCell
|
||||
(
|
||||
const Cell_handle& cit,
|
||||
Map<labelList>& circumsphereOverlaps
|
||||
) const;
|
||||
|
||||
void findProcessorBoundaryCells
|
||||
(
|
||||
Map<labelList>& circumsphereOverlaps
|
||||
) const;
|
||||
|
||||
void markVerticesToRefer
|
||||
(
|
||||
const Map<labelList>& circumsphereOverlaps,
|
||||
PtrList<labelPairHashSet>& referralVertices,
|
||||
DynamicList<label>& targetProcessor,
|
||||
DynamicList<Vb>& parallelInfluenceVertices
|
||||
);
|
||||
|
||||
label referVertices
|
||||
(
|
||||
const DynamicList<label>& targetProcessor,
|
||||
DynamicList<Vb>& parallelVertices,
|
||||
PtrList<labelPairHashSet>& referralVertices,
|
||||
labelPairHashSet& receivedVertices
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
explicit DistributedDelaunayMesh(const Time& runTime);
|
||||
|
||||
DistributedDelaunayMesh
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& meshName
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
DistributedDelaunayMesh
|
||||
(
|
||||
const DistributedDelaunayMesh<Triangulation>&
|
||||
) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~DistributedDelaunayMesh();
|
||||
|
||||
|
||||
// Queries
|
||||
|
||||
//- Use DelaunayMesh timeCheck function
|
||||
using DelaunayMesh<Triangulation>::timeCheck;
|
||||
|
||||
scalar calculateLoadUnbalance() const;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Build a distributionMap for the supplied destination processor data
|
||||
static autoPtr<distributionMap> buildMap(const List<label>& toProc);
|
||||
|
||||
//-
|
||||
bool distribute(const boundBox& bb);
|
||||
|
||||
autoPtr<distributionMap> distribute
|
||||
(
|
||||
const backgroundMeshDecomposition& decomposition,
|
||||
List<Foam::point>& points
|
||||
);
|
||||
|
||||
//- Refer vertices so that the processor interfaces are consistent
|
||||
void sync(const boundBox& bb);
|
||||
|
||||
//- Refer vertices so that the processor interfaces are consistent
|
||||
void sync
|
||||
(
|
||||
const boundBox& bb,
|
||||
PtrList<labelPairHashSet>& referralVertices,
|
||||
labelPairHashSet& receivedVertices,
|
||||
bool iterateReferral = true
|
||||
);
|
||||
|
||||
//- Inserts points into the triangulation if the point is within
|
||||
// the circumsphere of another cell. Returns HashSet of failed
|
||||
// point insertions
|
||||
template<class PointIterator>
|
||||
labelPairHashSet rangeInsertReferredWithInfo
|
||||
(
|
||||
PointIterator begin,
|
||||
PointIterator end,
|
||||
bool printErrors = true
|
||||
);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const DistributedDelaunayMesh<Triangulation>&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "DistributedDelaunayMesh.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,110 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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 "DelaunayMeshTools.H"
|
||||
#include "meshTools.H"
|
||||
#include "OFstream.H"
|
||||
#include "pointConversion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::DelaunayMeshTools::writeOBJ
|
||||
(
|
||||
const fileName& fName,
|
||||
const List<Foam::point>& points
|
||||
)
|
||||
{
|
||||
if (points.size())
|
||||
{
|
||||
OFstream str(fName);
|
||||
|
||||
Pout<< nl
|
||||
<< "Writing " << points.size() << " points from pointList to "
|
||||
<< str.name() << endl;
|
||||
|
||||
forAll(points, p)
|
||||
{
|
||||
meshTools::writeOBJ(str, points[p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::DelaunayMeshTools::writeOBJ
|
||||
(
|
||||
const fileName& fName,
|
||||
const List<Vb>& points
|
||||
)
|
||||
{
|
||||
if (points.size())
|
||||
{
|
||||
OFstream str(fName);
|
||||
|
||||
Pout<< nl
|
||||
<< "Writing " << points.size() << " points from pointList to "
|
||||
<< str.name() << endl;
|
||||
|
||||
forAll(points, p)
|
||||
{
|
||||
meshTools::writeOBJ(str, topoint(points[p].point()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::DelaunayMeshTools::writeObjMesh
|
||||
(
|
||||
const fileName& fName,
|
||||
const pointField& points,
|
||||
const faceList& faces
|
||||
)
|
||||
{
|
||||
OFstream str(fName);
|
||||
|
||||
Pout<< nl
|
||||
<< "Writing points and faces to " << str.name() << endl;
|
||||
|
||||
forAll(points, p)
|
||||
{
|
||||
meshTools::writeOBJ(str, points[p]);
|
||||
}
|
||||
|
||||
forAll(faces, f)
|
||||
{
|
||||
str<< 'f';
|
||||
|
||||
const face& fP = faces[f];
|
||||
|
||||
forAll(fP, p)
|
||||
{
|
||||
str<< ' ' << fP[p] + 1;
|
||||
}
|
||||
|
||||
str<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,152 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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::DelaunayMeshTools
|
||||
|
||||
Description
|
||||
Collection of functions for operating on a Delaunay mesh. Includes:
|
||||
|
||||
- Functions for writing to an OBJ file
|
||||
- Functions for extracting fields from the Delaunay triangulation
|
||||
|
||||
SourceFiles
|
||||
DelaunayMeshToolsI.H
|
||||
DelaunayMeshTools.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DelaunayMeshTools_H
|
||||
#define DelaunayMeshTools_H
|
||||
|
||||
#include "fileName.H"
|
||||
#include "List.H"
|
||||
#include "point.H"
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
#include "indexedVertexEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Namespace DelaunayMeshTools Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
namespace DelaunayMeshTools
|
||||
{
|
||||
|
||||
// OBJ writing
|
||||
|
||||
//- Write list of points to file
|
||||
void writeOBJ(const fileName& fName, const List<Foam::point>& points);
|
||||
|
||||
//- Write list of points to file
|
||||
void writeOBJ(const fileName& fName, const List<Vb>& points);
|
||||
|
||||
//- Write an OBJ mesh consisting of points and faces
|
||||
void writeObjMesh
|
||||
(
|
||||
const fileName& fName,
|
||||
const pointField& points,
|
||||
const faceList& faces
|
||||
);
|
||||
|
||||
//- Write Delaunay points in the range between (and including)
|
||||
// type startPointType and endPointType to an OBJ file
|
||||
template<class Triangulation>
|
||||
void writeOBJ
|
||||
(
|
||||
const fileName& fName,
|
||||
const Triangulation& t,
|
||||
const indexedVertexEnum::vertexType startPointType,
|
||||
const indexedVertexEnum::vertexType endPointType
|
||||
);
|
||||
|
||||
//- Write Delaunay points of type pointType to .obj file
|
||||
template<class Triangulation>
|
||||
void writeOBJ
|
||||
(
|
||||
const fileName& fName,
|
||||
const Triangulation& t,
|
||||
const indexedVertexEnum::vertexType pointType
|
||||
);
|
||||
|
||||
//- Write the fixed Delaunay points to an OBJ file
|
||||
template<class Triangulation>
|
||||
void writeFixedPoints(const fileName& fName, const Triangulation& t);
|
||||
|
||||
//- Write the boundary Delaunay points to an OBJ file
|
||||
template<class Triangulation>
|
||||
void writeBoundaryPoints(const fileName& fName, const Triangulation& t);
|
||||
|
||||
//- Write the processor interface to an OBJ file
|
||||
template<class Triangulation>
|
||||
void writeProcessorInterface
|
||||
(
|
||||
const fileName& fName,
|
||||
const Triangulation& t,
|
||||
const faceList& faces
|
||||
);
|
||||
|
||||
//- Write the internal Delaunay vertices of the tessellation as a
|
||||
// pointField that may be used to restart the meshing process
|
||||
template<class Triangulation>
|
||||
void writeInternalDelaunayVertices
|
||||
(
|
||||
const fileName& instance,
|
||||
const Triangulation& t
|
||||
);
|
||||
|
||||
//- Draws a tet cell to an output stream. The offset is supplied as the tet
|
||||
// number to be drawn.
|
||||
template<class CellHandle>
|
||||
void drawDelaunayCell(Ostream& os, const CellHandle& c, label offset = 0);
|
||||
|
||||
|
||||
// Field extraction
|
||||
|
||||
//- Extract all points in vertex-index order
|
||||
template<class Triangulation>
|
||||
tmp<pointField> allPoints(const Triangulation& t);
|
||||
|
||||
|
||||
} // End namespace DelaunayMeshTools
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "DelaunayMeshToolsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,303 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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 "DelaunayMeshTools.H"
|
||||
#include "meshTools.H"
|
||||
#include "OFstream.H"
|
||||
#include "pointConversion.H"
|
||||
#include "pointIOField.H"
|
||||
#include "indexedVertexOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMeshTools::writeOBJ
|
||||
(
|
||||
const fileName& fName,
|
||||
const Triangulation& t,
|
||||
const indexedVertexEnum::vertexType startPointType,
|
||||
const indexedVertexEnum::vertexType endPointType
|
||||
)
|
||||
{
|
||||
OFstream str(fName);
|
||||
|
||||
Pout<< nl
|
||||
<< "Writing points of types:" << nl;
|
||||
|
||||
forAllConstIter
|
||||
(
|
||||
HashTable<unsigned int>,
|
||||
indexedVertexEnum::vertexTypeNames_,
|
||||
iter
|
||||
)
|
||||
{
|
||||
if (iter() >= startPointType && iter() <= endPointType)
|
||||
{
|
||||
Pout<< " " << iter.key() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
Pout<< "to " << str.name() << endl;
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
t.finite_vertices_begin();
|
||||
vit != t.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->type() >= startPointType && vit->type() <= endPointType)
|
||||
{
|
||||
meshTools::writeOBJ(str, topoint(vit->point()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMeshTools::writeOBJ
|
||||
(
|
||||
const fileName& fName,
|
||||
const Triangulation& t,
|
||||
const indexedVertexEnum::vertexType pointType
|
||||
)
|
||||
{
|
||||
writeOBJ(fName, t, pointType, pointType);
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMeshTools::writeFixedPoints
|
||||
(
|
||||
const fileName& fName,
|
||||
const Triangulation& t
|
||||
)
|
||||
{
|
||||
OFstream str(fName);
|
||||
|
||||
Pout<< nl
|
||||
<< "Writing fixed points to " << str.name() << endl;
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
t.finite_vertices_begin();
|
||||
vit != t.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->fixed())
|
||||
{
|
||||
meshTools::writeOBJ(str, topoint(vit->point()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMeshTools::writeBoundaryPoints
|
||||
(
|
||||
const fileName& fName,
|
||||
const Triangulation& t
|
||||
)
|
||||
{
|
||||
OFstream str(fName);
|
||||
|
||||
Pout<< nl
|
||||
<< "Writing boundary points to " << str.name() << endl;
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
t.finite_vertices_begin();
|
||||
vit != t.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->internalPoint())
|
||||
{
|
||||
meshTools::writeOBJ(str, topoint(vit->point()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMeshTools::writeProcessorInterface
|
||||
(
|
||||
const fileName& fName,
|
||||
const Triangulation& t,
|
||||
const faceList& faces
|
||||
)
|
||||
{
|
||||
OFstream str(fName);
|
||||
|
||||
pointField points(t.number_of_finite_cells(), point::max);
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_cells_iterator cit =
|
||||
t.finite_cells_begin();
|
||||
cit != t.finite_cells_end();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
if (!cit->hasFarPoint() && !t.is_infinite(cit))
|
||||
{
|
||||
points[cit->cellIndex()] = cit->dual();
|
||||
}
|
||||
}
|
||||
|
||||
meshTools::writeOBJ(str, faces, points);
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
void Foam::DelaunayMeshTools::writeInternalDelaunayVertices
|
||||
(
|
||||
const fileName& instance,
|
||||
const Triangulation& t
|
||||
)
|
||||
{
|
||||
pointField internalDelaunayVertices(t.number_of_vertices());
|
||||
|
||||
label vertI = 0;
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
t.finite_vertices_begin();
|
||||
vit != t.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->internalPoint())
|
||||
{
|
||||
internalDelaunayVertices[vertI++] = topoint(vit->point());
|
||||
}
|
||||
}
|
||||
|
||||
internalDelaunayVertices.setSize(vertI);
|
||||
|
||||
pointIOField internalDVs
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"internalDelaunayVertices",
|
||||
instance,
|
||||
t.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
internalDelaunayVertices
|
||||
);
|
||||
|
||||
Info<< nl
|
||||
<< "Writing " << internalDVs.name()
|
||||
<< " to " << internalDVs.instance()
|
||||
<< endl;
|
||||
|
||||
internalDVs.write();
|
||||
}
|
||||
|
||||
|
||||
template<class CellHandle>
|
||||
void Foam::DelaunayMeshTools::drawDelaunayCell
|
||||
(
|
||||
Ostream& os,
|
||||
const CellHandle& c,
|
||||
label offset
|
||||
)
|
||||
{
|
||||
// Supply offset as tet number
|
||||
offset *= 4;
|
||||
|
||||
os << "# cell index: " << label(c->cellIndex())
|
||||
<< " INT_MIN = " << INT_MIN
|
||||
<< endl;
|
||||
|
||||
os << "# circumradius "
|
||||
<< mag(c->dual() - topoint(c->vertex(0)->point()))
|
||||
<< endl;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
os << "# index / type / procIndex: "
|
||||
<< label(c->vertex(i)->index()) << " "
|
||||
<< label(c->vertex(i)->type()) << " "
|
||||
<< label(c->vertex(i)->procIndex())
|
||||
<<
|
||||
(
|
||||
CGAL::indexedVertexOps::uninitialised(c->vertex(i))
|
||||
? " # This vertex is uninitialised!"
|
||||
: ""
|
||||
)
|
||||
<< endl;
|
||||
|
||||
meshTools::writeOBJ(os, topoint(c->vertex(i)->point()));
|
||||
}
|
||||
|
||||
os << "f " << 1 + offset << " " << 3 + offset << " " << 2 + offset << nl
|
||||
<< "f " << 2 + offset << " " << 3 + offset << " " << 4 + offset << nl
|
||||
<< "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl
|
||||
<< "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl;
|
||||
|
||||
// os << "# cicumcentre " << endl;
|
||||
|
||||
// meshTools::writeOBJ(os, c->dual());
|
||||
|
||||
// os << "l " << 1 + offset << " " << 5 + offset << endl;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::tmp<Foam::pointField> Foam::DelaunayMeshTools::allPoints
|
||||
(
|
||||
const Triangulation& t
|
||||
)
|
||||
{
|
||||
tmp<pointField> tpts(new pointField(t.vertexCount(), point::max));
|
||||
pointField& pts = tpts.ref();
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
t.finite_vertices_begin();
|
||||
vit != t.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->internalOrBoundaryPoint() && !vit->referred())
|
||||
{
|
||||
pts[vit->index()] = topoint(vit->point());
|
||||
}
|
||||
}
|
||||
|
||||
return tpts;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,80 +0,0 @@
|
||||
DelaunayMeshTools/DelaunayMeshTools.C
|
||||
|
||||
conformalVoronoiMesh/indexedVertex/indexedVertexEnum.C
|
||||
conformalVoronoiMesh/indexedCell/indexedCellEnum.C
|
||||
|
||||
conformalVoronoiMesh/conformalVoronoiMesh.C
|
||||
conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
|
||||
conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C
|
||||
conformalVoronoiMesh/conformalVoronoiMeshZones.C
|
||||
conformalVoronoiMesh/conformalVoronoiMeshIO.C
|
||||
conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C
|
||||
|
||||
conformalVoronoiMesh/featurePointConformer/pointFeatureEdgesTypes.C
|
||||
conformalVoronoiMesh/featurePointConformer/featurePointConformer.C
|
||||
conformalVoronoiMesh/featurePointConformer/featurePointConformerSpecialisations.C
|
||||
|
||||
cvControls/cvControls.C
|
||||
|
||||
conformationSurfaces/conformationSurfaces.C
|
||||
|
||||
backgroundMeshDecomposition/backgroundMeshDecomposition.C
|
||||
|
||||
cellShapeControl/cellShapeControl/cellShapeControl.C
|
||||
|
||||
cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C
|
||||
|
||||
cellSizeAndAlignmentControl = cellShapeControl/cellSizeAndAlignmentControl
|
||||
$(cellSizeAndAlignmentControl)/cellSizeAndAlignmentControls.C
|
||||
$(cellSizeAndAlignmentControl)/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C
|
||||
$(cellSizeAndAlignmentControl)/fileControl/fileControl.C
|
||||
$(cellSizeAndAlignmentControl)/searchableSurfaceControl/searchableSurfaceControl.C
|
||||
# cellShapeControl/pQuadCoorControl/pQuadCoorControl.C
|
||||
|
||||
cellShapeControl/cellAspectRatioControl/cellAspectRatioControl.C
|
||||
|
||||
cellShapeControl/smoothAlignmentSolver/smoothAlignmentSolver.C
|
||||
|
||||
cellShapeControl/controlMeshRefinement/controlMeshRefinement.C
|
||||
|
||||
# cellSizeControlSurfaces/cellSizeControlSurfaces.C
|
||||
|
||||
cellSizeFunctions = cellSizeControlSurfaces/cellSizeFunction
|
||||
$(cellSizeFunctions)/cellSizeFunction/cellSizeFunction.C
|
||||
$(cellSizeFunctions)/uniform/uniform.C
|
||||
$(cellSizeFunctions)/uniformDistance/uniformDistance.C
|
||||
$(cellSizeFunctions)/linearDistance/linearDistance.C
|
||||
$(cellSizeFunctions)/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C
|
||||
$(cellSizeFunctions)/linearSpatial/linearSpatial.C
|
||||
|
||||
surfaceCellSizeFunctions = cellSizeControlSurfaces/surfaceCellSizeFunction
|
||||
$(surfaceCellSizeFunctions)/surfaceCellSizeFunction/surfaceCellSizeFunction.C
|
||||
$(surfaceCellSizeFunctions)/uniformValue/uniformValue.C
|
||||
$(surfaceCellSizeFunctions)/nonUniformField/nonUniformField.C
|
||||
|
||||
cellSizeCalculationType = $(surfaceCellSizeFunctions)/cellSizeCalculationType
|
||||
$(cellSizeCalculationType)/cellSizeCalculationType/cellSizeCalculationType.C
|
||||
$(cellSizeCalculationType)/fieldFromFile/fieldFromFile.C
|
||||
$(cellSizeCalculationType)/automatic/automatic.C
|
||||
|
||||
initialPointsMethod/initialPointsMethod/initialPointsMethod.C
|
||||
initialPointsMethod/uniformGrid/uniformGrid.C
|
||||
initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C
|
||||
initialPointsMethod/faceCentredCubic/faceCentredCubic.C
|
||||
initialPointsMethod/pointFile/pointFile.C
|
||||
initialPointsMethod/autoDensity/autoDensity.C
|
||||
initialPointsMethod/rayShooting/rayShooting.C
|
||||
|
||||
relaxationModel/relaxationModel/relaxationModel.C
|
||||
relaxationModel/adaptiveLinear/adaptiveLinear.C
|
||||
relaxationModel/rampHoldFall/rampHoldFall.C
|
||||
|
||||
faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C
|
||||
faceAreaWeightModel/piecewiseLinearRamp/piecewiseLinearRamp.C
|
||||
|
||||
searchableSurfaceFeatures/searchableSurfaceFeatures.C
|
||||
searchableSurfaceFeatures/searchableBoxFeatures.C
|
||||
searchableSurfaceFeatures/searchablePlateFeatures.C
|
||||
searchableSurfaceFeatures/triSurfaceMeshFeatures.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libconformalVoronoiMesh
|
||||
@ -1,36 +0,0 @@
|
||||
EXE_DEBUG = -DFULLDEBUG -g -O0
|
||||
EXE_NDEBUG = -DNDEBUG
|
||||
|
||||
CGAL_EXACT =
|
||||
#CGAL_EXACT = -DCGAL_DONT_USE_LAZY_KERNEL
|
||||
CGAL_INEXACT = -DCGAL_INEXACT
|
||||
|
||||
include $(GENERAL_RULES)/CGAL
|
||||
|
||||
EXE_INC = \
|
||||
${ROUNDING_MATH} \
|
||||
${EXE_NDEBUG} \
|
||||
${CGAL_EXACT} \
|
||||
${CGAL_INEXACT} \
|
||||
${CGAL_INC} \
|
||||
${c++LESSWARN} \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/snappyHexMesh/lnInclude \
|
||||
-IPrintTable
|
||||
|
||||
LIB_LIBS = \
|
||||
${CGAL_LIBS} \
|
||||
-lmeshTools \
|
||||
-lfileFormats \
|
||||
-ltriSurface \
|
||||
-ldynamicMesh \
|
||||
-lsurfMesh \
|
||||
-lsampling \
|
||||
-lsnappyHexMesh
|
||||
@ -1,214 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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 "PrintTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class KeyType, class DataType>
|
||||
Foam::PrintTable<KeyType, DataType>::PrintTable()
|
||||
:
|
||||
table_(),
|
||||
title_(string::null)
|
||||
{}
|
||||
|
||||
|
||||
template<class KeyType, class DataType>
|
||||
Foam::PrintTable<KeyType, DataType>::PrintTable(const string& title)
|
||||
:
|
||||
table_(),
|
||||
title_(title)
|
||||
{}
|
||||
|
||||
|
||||
template<class KeyType, class DataType>
|
||||
Foam::PrintTable<KeyType, DataType>::PrintTable
|
||||
(
|
||||
const PrintTable<KeyType, DataType>& table
|
||||
)
|
||||
:
|
||||
table_(table.table_),
|
||||
title_(table.title_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class KeyType, class DataType>
|
||||
Foam::PrintTable<KeyType, DataType>::~PrintTable()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class KeyType, class DataType>
|
||||
void Foam::PrintTable<KeyType, DataType>::print
|
||||
(
|
||||
Ostream& os,
|
||||
const bool printSum,
|
||||
const bool printAverage
|
||||
) const
|
||||
{
|
||||
HashTable<HashTable<DataType, label>, KeyType> combinedTable;
|
||||
|
||||
List<HashTableData> procData(Pstream::nProcs(), HashTableData());
|
||||
|
||||
procData[Pstream::myProcNo()] = table_;
|
||||
|
||||
Pstream::gatherList(procData);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
label largestKeyLength = 6;
|
||||
label largestDataLength = 0;
|
||||
|
||||
List<label> largestProcSize(Pstream::nProcs(), 0);
|
||||
|
||||
forAll(procData, proci)
|
||||
{
|
||||
const HashTableData& procIData = procData[proci];
|
||||
|
||||
for
|
||||
(
|
||||
typename HashTableData::const_iterator iter = procIData.begin();
|
||||
iter != procIData.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
if (!combinedTable.found(iter.key()))
|
||||
{
|
||||
combinedTable.insert
|
||||
(
|
||||
iter.key(),
|
||||
HashTable<DataType, label>()
|
||||
);
|
||||
}
|
||||
|
||||
HashTable<DataType, label>& key = combinedTable[iter.key()];
|
||||
|
||||
key.insert(proci, iter());
|
||||
|
||||
for
|
||||
(
|
||||
typename HashTable<DataType, label>
|
||||
::const_iterator dataIter = key.begin();
|
||||
dataIter != key.end();
|
||||
++dataIter
|
||||
)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << dataIter();
|
||||
|
||||
largestDataLength = max
|
||||
(
|
||||
largestDataLength,
|
||||
label(buf.str().length())
|
||||
);
|
||||
}
|
||||
|
||||
std::ostringstream buf;
|
||||
buf << iter.key();
|
||||
|
||||
largestKeyLength = max
|
||||
(
|
||||
largestKeyLength,
|
||||
label(buf.str().length())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
os.width(largestKeyLength);
|
||||
os << nl << indent << tab << "# " << title_.c_str() << endl;
|
||||
|
||||
os.width(largestKeyLength);
|
||||
os << indent << "# Proc";
|
||||
|
||||
forAll(procData, proci)
|
||||
{
|
||||
os << tab;
|
||||
os.width(largestDataLength);
|
||||
os << proci;
|
||||
}
|
||||
|
||||
if (printSum)
|
||||
{
|
||||
os << tab;
|
||||
os.width(largestDataLength);
|
||||
os << "Sum";
|
||||
}
|
||||
|
||||
if (printAverage)
|
||||
{
|
||||
os << tab;
|
||||
os.width(largestDataLength);
|
||||
os << "Average";
|
||||
}
|
||||
|
||||
os << endl;
|
||||
|
||||
const List<KeyType>& sortedTable = combinedTable.sortedToc();
|
||||
|
||||
forAll(sortedTable, keyI)
|
||||
{
|
||||
const HashTable<DataType, label>& procDataList
|
||||
= combinedTable[sortedTable[keyI]];
|
||||
|
||||
os.width(largestKeyLength);
|
||||
os << indent << sortedTable[keyI];
|
||||
|
||||
forAll(procDataList, elemI)
|
||||
{
|
||||
os << tab;
|
||||
os.width(largestDataLength);
|
||||
os << procDataList[elemI];
|
||||
}
|
||||
|
||||
if (printSum)
|
||||
{
|
||||
DataType sum = 0;
|
||||
forAll(procDataList, elemI)
|
||||
{
|
||||
sum += procDataList[elemI];
|
||||
}
|
||||
|
||||
os << tab;
|
||||
os.width(largestDataLength);
|
||||
os << sum;
|
||||
|
||||
if (printAverage)
|
||||
{
|
||||
os << tab;
|
||||
os.width(largestDataLength);
|
||||
os << sum/Pstream::nProcs();
|
||||
}
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,140 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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::PrintTable
|
||||
|
||||
Description
|
||||
Print a table in parallel, e.g.;
|
||||
|
||||
\verbatim
|
||||
Vertex Type Information
|
||||
Proc # 0 1 2 3
|
||||
Total 145680 145278 145751 145359
|
||||
Unassigned 0 0 0 0
|
||||
nExternalFeatureEdge 883 829 828 960
|
||||
nExternalFeaturePoint 8 10 10 12
|
||||
nExternalSurface 9533 9488 9502 9482
|
||||
nFar 0 0 0 0
|
||||
nInternal 125494 125198 125642 125174
|
||||
nInternalFeatureEdge 238 241 241 240
|
||||
nInternalFeaturePoint 2 2 2 2
|
||||
nInternalNearBoundary 0 0 0 0
|
||||
nInternalSurface 9522 9510 9526 9489
|
||||
nReferred 7545 7497 7500 7587
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
PrintTableI.H
|
||||
PrintTable.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PrintTable_H
|
||||
#define PrintTable_H
|
||||
|
||||
#include "HashTable.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PrintTable Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class KeyType, class DataType>
|
||||
class PrintTable
|
||||
{
|
||||
typedef HashTable<DataType, KeyType> HashTableData;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Hash table holding the data
|
||||
HashTableData table_;
|
||||
|
||||
//- Title of the table
|
||||
string title_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor
|
||||
PrintTable();
|
||||
|
||||
//- Construct with a title
|
||||
explicit PrintTable(const string& title);
|
||||
|
||||
//- Copy constructor
|
||||
PrintTable(const PrintTable<KeyType, DataType>& table);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~PrintTable();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add an entry (D) to the given key(K)
|
||||
void add(const KeyType& K, const DataType& D);
|
||||
|
||||
//- Print the table
|
||||
void print
|
||||
(
|
||||
Ostream& os,
|
||||
const bool printSum = false,
|
||||
const bool printAverage = false
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const PrintTable<KeyType, DataType>&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "PrintTableI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "PrintTable.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,42 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class KeyType, class DataType>
|
||||
void Foam::PrintTable<KeyType, DataType>::add
|
||||
(
|
||||
const KeyType& K,
|
||||
const DataType& D
|
||||
)
|
||||
{
|
||||
table_.set(K, D);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,336 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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::backgroundMeshDecomposition
|
||||
|
||||
Description
|
||||
Store a background polyMesh to use for the decomposition of space and
|
||||
queries for parallel conformalVoronoiMesh.
|
||||
|
||||
The requirements are:
|
||||
|
||||
- To have a decomposition of space which can quickly interrogate an
|
||||
arbitrary location from any processor to reliably and unambiguously
|
||||
determine which processor owns the space that the point is in, i.e. as
|
||||
the vertices move, or need inserted as part of the surface conformation,
|
||||
send them to the correct proc.
|
||||
|
||||
- To be able to be dynamically built, refined and redistributed to other
|
||||
procs the partitioning as the meshing progresses to balance the load.
|
||||
|
||||
- To be able to query whether a sphere (the circumsphere of a Delaunay tet)
|
||||
overlaps any part of the space defined by the structure, and whether a
|
||||
ray (Voronoi edge) penetrates any part of the space defined by the
|
||||
structure, this is what determines if points get referred to a processor.
|
||||
|
||||
SourceFiles
|
||||
backgroundMeshDecompositionI.H
|
||||
backgroundMeshDecomposition.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef backgroundMeshDecomposition_H
|
||||
#define backgroundMeshDecomposition_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
#include "hexRef8.H"
|
||||
#include "cellSet.H"
|
||||
#include "meshTools.H"
|
||||
#include "polyTopoChange.H"
|
||||
#include "polyTopoChangeMap.H"
|
||||
#include "decompositionMethod.H"
|
||||
#include "fvMeshDistribute.H"
|
||||
#include "removeCells.H"
|
||||
#include "polyDistributionMap.H"
|
||||
#include "globalIndex.H"
|
||||
#include "treeBoundBox.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "face.H"
|
||||
#include "labelList.H"
|
||||
#include "pointField.H"
|
||||
#include "indexedOctree.H"
|
||||
#include "treeDataPrimitivePatch.H"
|
||||
#include "volumeType.H"
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
typedef PrimitivePatch<faceList, const pointField> bPatch;
|
||||
typedef treeDataPrimitivePatch<bPatch> treeDataBPatch;
|
||||
|
||||
class Time;
|
||||
class Random;
|
||||
class conformationSurfaces;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class backgroundMeshDecomposition Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class backgroundMeshDecomposition
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Method details dictionary
|
||||
// dictionary coeffsDict_;
|
||||
|
||||
//- Reference to runtime
|
||||
const Time& runTime_;
|
||||
|
||||
//- Reference to surface
|
||||
const conformationSurfaces& geometryToConformTo_;
|
||||
|
||||
//- Mesh stored on for this processor, specifying the domain that it
|
||||
// is responsible for.
|
||||
fvMesh mesh_;
|
||||
|
||||
//- Refinement object
|
||||
hexRef8 meshCutter_;
|
||||
|
||||
//- Patch containing an independent representation of the surface of the
|
||||
// mesh of this processor
|
||||
autoPtr<bPatch> boundaryFacesPtr_;
|
||||
|
||||
//- Search tree for the boundaryFaces_ patch
|
||||
autoPtr<indexedOctree<treeDataBPatch>> bFTreePtr_;
|
||||
|
||||
//- The bounds of all background meshes on all processors
|
||||
treeBoundBoxList allBackgroundMeshBounds_;
|
||||
|
||||
//- The overall bounds of all of the background meshes, used to test if
|
||||
// a point that is not found on any processor is in the domain at all
|
||||
treeBoundBox globalBackgroundBounds_;
|
||||
|
||||
//- Decomposition method
|
||||
autoPtr<decompositionMethod> decomposerPtr_;
|
||||
|
||||
//- Scale of a cell span vs cell size used to decide to refine a cell
|
||||
scalar spanScale_;
|
||||
|
||||
//- Smallest minimum cell size allowed, i.e. to avoid high initial
|
||||
// refinement of areas of small size
|
||||
scalar minCellSizeLimit_;
|
||||
|
||||
//- Minimum normal level of refinement
|
||||
label minLevels_;
|
||||
|
||||
//- How fine should the initial sample of the volume a box be to
|
||||
// investigate the local cell size
|
||||
label volRes_;
|
||||
|
||||
//- Allowed factor above the average cell weight before a background
|
||||
// cell needs to be split
|
||||
scalar maxCellWeightCoeff_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void initialRefinement();
|
||||
|
||||
//- Print details of the decomposed mesh
|
||||
void printMeshData(const polyMesh& mesh) const;
|
||||
|
||||
//- Estimate the number of vertices that will be in this cell, returns
|
||||
// true if the cell is to be split because of the density ratio inside
|
||||
// it
|
||||
bool refineCell
|
||||
(
|
||||
label celli,
|
||||
volumeType volType,
|
||||
scalar& weightEstimate
|
||||
) const;
|
||||
|
||||
//- Select cells for refinement at the surface of the geometry to be
|
||||
// meshed
|
||||
labelList selectRefinementCells
|
||||
(
|
||||
List<volumeType>& volumeStatus,
|
||||
volScalarField& cellWeights
|
||||
) const;
|
||||
|
||||
//- Build the surface patch and search tree
|
||||
void buildPatchAndTree();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("backgroundMeshDecomposition");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components in foamyHexMesh operation
|
||||
backgroundMeshDecomposition
|
||||
(
|
||||
const Time& runTime,
|
||||
Random& rndGen,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const dictionary& coeffsDict
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
backgroundMeshDecomposition
|
||||
(
|
||||
const backgroundMeshDecomposition&
|
||||
) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~backgroundMeshDecomposition();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Build a distributionMap for the supplied destination processor data
|
||||
static autoPtr<distributionMap> buildMap(const List<label>& toProc);
|
||||
|
||||
//- Redistribute the background mesh based on a supplied weight field,
|
||||
// returning a map to use to redistribute vertices.
|
||||
autoPtr<polyDistributionMap> distribute
|
||||
(
|
||||
volScalarField& cellWeights
|
||||
);
|
||||
|
||||
//- Distribute supplied the points to the appropriate processor
|
||||
template<class PointType>
|
||||
autoPtr<distributionMap> distributePoints
|
||||
(
|
||||
List<PointType>& points
|
||||
) const;
|
||||
|
||||
//- Is the given position inside the domain of this decomposition
|
||||
bool positionOnThisProcessor(const point& pt) const;
|
||||
|
||||
//- Are the given positions inside the domain of this decomposition
|
||||
boolList positionOnThisProcessor(const List<point>& pts) const;
|
||||
|
||||
//- Does the given box overlap the faces of the boundary of this
|
||||
// processor
|
||||
bool overlapsThisProcessor(const treeBoundBox& box) const;
|
||||
|
||||
//- Does the given sphere overlap the faces of the boundary of this
|
||||
// processor
|
||||
bool overlapsThisProcessor
|
||||
(
|
||||
const point& centre,
|
||||
const scalar radiusSqr
|
||||
) const;
|
||||
|
||||
//- Find nearest intersection of line between start and end, (exposing
|
||||
// underlying indexedOctree)
|
||||
pointIndexHit findLine
|
||||
(
|
||||
const point& start,
|
||||
const point& end
|
||||
) const;
|
||||
|
||||
//- Find any intersection of line between start and end, (exposing
|
||||
// underlying indexedOctree)
|
||||
pointIndexHit findLineAny
|
||||
(
|
||||
const point& start,
|
||||
const point& end
|
||||
) const;
|
||||
|
||||
//- What processor is the given position on?
|
||||
template<class PointType>
|
||||
labelList processorPosition(const List<PointType>& pts) const;
|
||||
|
||||
//- What is the nearest processor to the given position?
|
||||
labelList processorNearestPosition(const List<point>& pts) const;
|
||||
|
||||
//- Which processors are intersected by the line segment, returns all
|
||||
// processors whose boundary patch is intersected by the sphere. By
|
||||
// default this does not return the processor that the query is
|
||||
// launched from, it is assumed that the point is on that processor.
|
||||
// The index data member of the pointIndexHit is replaced with the
|
||||
// processor index.
|
||||
List<List<pointIndexHit>> intersectsProcessors
|
||||
(
|
||||
const List<point>& starts,
|
||||
const List<point>& ends,
|
||||
bool includeOwnProcessor = false
|
||||
) const;
|
||||
|
||||
bool overlapsOtherProcessors
|
||||
(
|
||||
const point& centre,
|
||||
const scalar& radiusSqr
|
||||
) const;
|
||||
|
||||
labelList overlapProcessors
|
||||
(
|
||||
const point& centre,
|
||||
const scalar radiusSqr
|
||||
) const;
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return access to the underlying mesh
|
||||
inline const fvMesh& mesh() const;
|
||||
|
||||
//- Return access to the underlying tree
|
||||
inline const indexedOctree<treeDataBPatch>& tree() const;
|
||||
|
||||
//- Return the boundBox of this processor
|
||||
inline const treeBoundBox& procBounds() const;
|
||||
|
||||
//- Return the cell level of the underlying mesh
|
||||
inline const labelList& cellLevel() const;
|
||||
|
||||
//- Return the point level of the underlying mesh
|
||||
inline const labelList& pointLevel() const;
|
||||
|
||||
//- Return the current decomposition method
|
||||
inline const decompositionMethod& decomposer() const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const backgroundMeshDecomposition&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "backgroundMeshDecompositionI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "backgroundMeshDecompositionTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,67 +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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::fvMesh& Foam::backgroundMeshDecomposition::mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::indexedOctree<Foam::treeDataBPatch>&
|
||||
Foam::backgroundMeshDecomposition::tree() const
|
||||
{
|
||||
return bFTreePtr_();
|
||||
}
|
||||
|
||||
|
||||
const Foam::treeBoundBox&
|
||||
Foam::backgroundMeshDecomposition::procBounds() const
|
||||
{
|
||||
return allBackgroundMeshBounds_[Pstream::myProcNo()];
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::backgroundMeshDecomposition::cellLevel() const
|
||||
{
|
||||
return meshCutter_.cellLevel();
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::backgroundMeshDecomposition::pointLevel() const
|
||||
{
|
||||
return meshCutter_.pointLevel();
|
||||
}
|
||||
|
||||
|
||||
const Foam::decompositionMethod&
|
||||
Foam::backgroundMeshDecomposition::decomposer() const
|
||||
{
|
||||
return decomposerPtr_();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,173 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2022 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 "backgroundMeshDecomposition.H"
|
||||
#include "pointConversion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class PointType>
|
||||
Foam::autoPtr<Foam::distributionMap>
|
||||
Foam::backgroundMeshDecomposition::distributePoints
|
||||
(
|
||||
List<PointType>& points
|
||||
) const
|
||||
{
|
||||
labelList toProc(processorPosition(points));
|
||||
|
||||
autoPtr<distributionMap> map(buildMap(toProc));
|
||||
|
||||
map().distribute(points);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
template<class PointType>
|
||||
Foam::labelList Foam::backgroundMeshDecomposition::processorPosition
|
||||
(
|
||||
const List<PointType>& pts
|
||||
) const
|
||||
{
|
||||
DynamicList<label> toCandidateProc;
|
||||
DynamicList<point> testPoints;
|
||||
labelList ptBlockStart(pts.size(), -1);
|
||||
labelList ptBlockSize(pts.size(), -1);
|
||||
|
||||
label nTotalCandidates = 0;
|
||||
|
||||
forAll(pts, pI)
|
||||
{
|
||||
pointFromPoint pt = topoint(pts[pI]);
|
||||
|
||||
label nCandidates = 0;
|
||||
|
||||
forAll(allBackgroundMeshBounds_, proci)
|
||||
{
|
||||
if (allBackgroundMeshBounds_[proci].contains(pt))
|
||||
{
|
||||
toCandidateProc.append(proci);
|
||||
testPoints.append(pt);
|
||||
|
||||
nCandidates++;
|
||||
}
|
||||
}
|
||||
|
||||
ptBlockStart[pI] = nTotalCandidates;
|
||||
ptBlockSize[pI] = nCandidates;
|
||||
|
||||
nTotalCandidates += nCandidates;
|
||||
}
|
||||
|
||||
// Needed for reverseDistribute
|
||||
label preDistributionToCandidateProcSize = toCandidateProc.size();
|
||||
|
||||
autoPtr<distributionMap> map(buildMap(toCandidateProc));
|
||||
|
||||
map().distribute(testPoints);
|
||||
|
||||
List<bool> pointOnCandidate(testPoints.size(), false);
|
||||
|
||||
// Test candidate points on candidate processors
|
||||
forAll(testPoints, tPI)
|
||||
{
|
||||
pointOnCandidate[tPI] = positionOnThisProcessor(testPoints[tPI]);
|
||||
}
|
||||
|
||||
map().reverseDistribute
|
||||
(
|
||||
preDistributionToCandidateProcSize,
|
||||
pointOnCandidate
|
||||
);
|
||||
|
||||
labelList ptProc(pts.size(), -1);
|
||||
|
||||
DynamicList<label> failedPointIndices;
|
||||
DynamicList<point> failedPoints;
|
||||
|
||||
forAll(pts, pI)
|
||||
{
|
||||
// Extract the sub list of results for this point
|
||||
|
||||
SubList<bool> ptProcResults
|
||||
(
|
||||
pointOnCandidate,
|
||||
ptBlockSize[pI],
|
||||
ptBlockStart[pI]
|
||||
);
|
||||
|
||||
forAll(ptProcResults, pPRI)
|
||||
{
|
||||
if (ptProcResults[pPRI])
|
||||
{
|
||||
ptProc[pI] = toCandidateProc[ptBlockStart[pI] + pPRI];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptProc[pI] < 0)
|
||||
{
|
||||
pointFromPoint pt = topoint(pts[pI]);
|
||||
|
||||
if (!globalBackgroundBounds_.contains(pt))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "The position " << pt
|
||||
<< " is not in any part of the background mesh "
|
||||
<< globalBackgroundBounds_ << endl
|
||||
<< "A background mesh with a wider margin around "
|
||||
<< "the geometry may help."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "The position " << pt
|
||||
<< " was not found in the background mesh "
|
||||
<< globalBackgroundBounds_ << ", finding nearest."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
failedPointIndices.append(pI);
|
||||
failedPoints.append(pt);
|
||||
}
|
||||
}
|
||||
|
||||
labelList ptNearestProc(processorNearestPosition(failedPoints));
|
||||
|
||||
forAll(failedPoints, fPI)
|
||||
{
|
||||
label pI = failedPointIndices[fPI];
|
||||
|
||||
ptProc[pI] = ptNearestProc[fPI];
|
||||
}
|
||||
|
||||
return ptProc;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,112 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "cellAspectRatioControl.H"
|
||||
#include "vectorTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellAspectRatioControl::cellAspectRatioControl
|
||||
(
|
||||
const dictionary& motionDict
|
||||
)
|
||||
:
|
||||
aspectRatioDict_(motionDict.subOrEmptyDict("cellAspectRatioControl")),
|
||||
aspectRatio_(aspectRatioDict_.lookupOrDefault<scalar>("aspectRatio", 1.0)),
|
||||
aspectRatioDirection_
|
||||
(
|
||||
aspectRatioDict_.lookupOrDefault<vector>
|
||||
(
|
||||
"aspectRatioDirection",
|
||||
Zero
|
||||
)
|
||||
)
|
||||
{
|
||||
// Normalise the direction
|
||||
aspectRatioDirection_ /= mag(aspectRatioDirection_) + small;
|
||||
|
||||
Info<< nl
|
||||
<< "Cell Aspect Ratio Control" << nl
|
||||
<< " Ratio : " << aspectRatio_ << nl
|
||||
<< " Direction : " << aspectRatioDirection_
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellAspectRatioControl::~cellAspectRatioControl()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::cellAspectRatioControl::updateCellSizeAndFaceArea
|
||||
(
|
||||
vector& alignmentDir,
|
||||
scalar& targetFaceArea,
|
||||
scalar& targetCellSize
|
||||
) const
|
||||
{
|
||||
const scalar cosAngle =
|
||||
mag(vectorTools::cosPhi(alignmentDir, aspectRatioDirection_));
|
||||
|
||||
// Change target face area based on aspect ratio
|
||||
targetFaceArea +=
|
||||
targetFaceArea
|
||||
*(aspectRatio_ - 1.0)
|
||||
*(1.0 - cosAngle);
|
||||
|
||||
// Change target cell size based on aspect ratio
|
||||
targetCellSize +=
|
||||
targetCellSize
|
||||
*(aspectRatio_ - 1.0)
|
||||
*cosAngle;
|
||||
|
||||
alignmentDir *= 0.5*targetCellSize;
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellAspectRatioControl::updateDeltaVector
|
||||
(
|
||||
const vector& alignmentDir,
|
||||
const scalar targetCellSize,
|
||||
const scalar rABMag,
|
||||
vector& delta
|
||||
) const
|
||||
{
|
||||
const scalar cosAngle =
|
||||
mag(vectorTools::cosPhi(alignmentDir, aspectRatioDirection_));
|
||||
|
||||
delta +=
|
||||
0.5
|
||||
*delta
|
||||
*cosAngle
|
||||
*(targetCellSize/rABMag)
|
||||
*(aspectRatio_ - 1.0);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,112 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::cellAspectRatioControl
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
cellAspectRatioControl.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cellAspectRatioControl_H
|
||||
#define cellAspectRatioControl_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "vector.H"
|
||||
#include "scalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellAspectRatioControl Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellAspectRatioControl
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const dictionary aspectRatioDict_;
|
||||
|
||||
const scalar aspectRatio_;
|
||||
|
||||
vector aspectRatioDirection_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
cellAspectRatioControl(const dictionary& motionDict);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
cellAspectRatioControl(const cellAspectRatioControl&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cellAspectRatioControl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Query
|
||||
|
||||
void updateCellSizeAndFaceArea
|
||||
(
|
||||
vector& alignmentDir,
|
||||
scalar& targetFaceArea,
|
||||
scalar& targetCellSize
|
||||
) const;
|
||||
|
||||
void updateDeltaVector
|
||||
(
|
||||
const vector& alignmentDir,
|
||||
const scalar targetCellSize,
|
||||
const scalar rABMag,
|
||||
vector& delta
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cellAspectRatioControl&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,330 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cellShapeControl.H"
|
||||
#include "pointField.H"
|
||||
#include "scalarField.H"
|
||||
#include "triadField.H"
|
||||
#include "cellSizeAndAlignmentControl.H"
|
||||
#include "searchableSurfaceControl.H"
|
||||
#include "cellSizeFunction.H"
|
||||
#include "indexedVertexOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellShapeControl, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellShapeControl::cellShapeControl
|
||||
(
|
||||
const Time& runTime,
|
||||
const cvControls& foamyHexMeshControls,
|
||||
const searchableSurfaces& allGeometry,
|
||||
const conformationSurfaces& geometryToConformTo
|
||||
)
|
||||
:
|
||||
dictionary
|
||||
(
|
||||
foamyHexMeshControls.foamyHexMeshDict().subDict("motionControl")
|
||||
),
|
||||
geometryToConformTo_(geometryToConformTo),
|
||||
defaultCellSize_(foamyHexMeshControls.defaultCellSize()),
|
||||
minimumCellSize_(foamyHexMeshControls.minimumCellSize()),
|
||||
shapeControlMesh_(runTime),
|
||||
aspectRatio_(*this),
|
||||
sizeAndAlignment_
|
||||
(
|
||||
runTime,
|
||||
subDict("shapeControlFunctions"),
|
||||
geometryToConformTo_,
|
||||
defaultCellSize_
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellShapeControl::~cellShapeControl()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalarField Foam::cellShapeControl::cellSize
|
||||
(
|
||||
const pointField& pts
|
||||
) const
|
||||
{
|
||||
scalarField cellSizes(pts.size());
|
||||
|
||||
forAll(pts, i)
|
||||
{
|
||||
cellSizes[i] = cellSize(pts[i]);
|
||||
}
|
||||
|
||||
return cellSizes;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::cellShapeControl::cellSize(const point& pt) const
|
||||
{
|
||||
barycentric bary;
|
||||
cellShapeControlMesh::Cell_handle ch;
|
||||
|
||||
shapeControlMesh_.barycentricCoords(pt, bary, ch);
|
||||
|
||||
scalar size = 0;
|
||||
|
||||
if (shapeControlMesh_.dimension() < 3)
|
||||
{
|
||||
size = sizeAndAlignment_.cellSize(pt);
|
||||
}
|
||||
else if (shapeControlMesh_.is_infinite(ch))
|
||||
{
|
||||
// if (nFarPoints != 0)
|
||||
// {
|
||||
// for (label pI = 0; pI < 4; ++pI)
|
||||
// {
|
||||
// if (!ch->vertex(pI)->farPoint())
|
||||
// {
|
||||
// size = ch->vertex(pI)->targetCellSize();
|
||||
// return size;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// cellShapeControlMesh::Vertex_handle nearV =
|
||||
// shapeControlMesh_.nearest_vertex_in_cell
|
||||
// (
|
||||
// toPoint<cellShapeControlMesh::Point>(pt),
|
||||
// ch
|
||||
// );
|
||||
//
|
||||
// size = nearV->targetCellSize();
|
||||
|
||||
// Find nearest surface. This can be quite slow if there are a lot of
|
||||
// surfaces
|
||||
size = sizeAndAlignment_.cellSize(pt);
|
||||
}
|
||||
else
|
||||
{
|
||||
label nFarPoints = 0;
|
||||
for (label pI = 0; pI < 4; ++pI)
|
||||
{
|
||||
if (ch->vertex(pI)->farPoint())
|
||||
{
|
||||
nFarPoints++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFarPoints != 0)
|
||||
{
|
||||
for (label pI = 0; pI < 4; ++pI)
|
||||
{
|
||||
if (!CGAL::indexedVertexOps::uninitialised(ch->vertex(pI)))
|
||||
{
|
||||
size = ch->vertex(pI)->targetCellSize();
|
||||
return size;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(bary, pI)
|
||||
{
|
||||
size += bary[pI]*ch->vertex(pI)->targetCellSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
Foam::tensor Foam::cellShapeControl::cellAlignment(const point& pt) const
|
||||
{
|
||||
barycentric bary;
|
||||
cellShapeControlMesh::Cell_handle ch;
|
||||
|
||||
shapeControlMesh_.barycentricCoords(pt, bary, ch);
|
||||
|
||||
tensor alignment = Zero;
|
||||
|
||||
if (shapeControlMesh_.dimension() < 3 || shapeControlMesh_.is_infinite(ch))
|
||||
{
|
||||
alignment = tensor::I;
|
||||
}
|
||||
else
|
||||
{
|
||||
triad tri;
|
||||
|
||||
for (label pI = 0; pI < 4; ++pI)
|
||||
{
|
||||
if (bary[pI] > small)
|
||||
{
|
||||
tri += triad(bary[pI]*ch->vertex(pI)->alignment());
|
||||
}
|
||||
}
|
||||
|
||||
tri.normalise();
|
||||
tri.orthogonalise();
|
||||
tri = tri.sortxyz();
|
||||
|
||||
alignment = tri;
|
||||
}
|
||||
|
||||
return alignment;
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellShapeControl::cellSizeAndAlignment
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size,
|
||||
tensor& alignment
|
||||
) const
|
||||
{
|
||||
barycentric bary;
|
||||
cellShapeControlMesh::Cell_handle ch;
|
||||
|
||||
shapeControlMesh_.barycentricCoords(pt, bary, ch);
|
||||
|
||||
alignment = Zero;
|
||||
size = 0;
|
||||
|
||||
if (shapeControlMesh_.dimension() < 3 || shapeControlMesh_.is_infinite(ch))
|
||||
{
|
||||
// Find nearest surface
|
||||
size = sizeAndAlignment_.cellSize(pt);
|
||||
alignment = tensor::I;
|
||||
}
|
||||
else
|
||||
{
|
||||
label nFarPoints = 0;
|
||||
for (label pI = 0; pI < 4; ++pI)
|
||||
{
|
||||
if (ch->vertex(pI)->farPoint())
|
||||
{
|
||||
nFarPoints++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFarPoints != 0)
|
||||
{
|
||||
for (label pI = 0; pI < 4; ++pI)
|
||||
{
|
||||
if (!CGAL::indexedVertexOps::uninitialised(ch->vertex(pI)))
|
||||
{
|
||||
size = ch->vertex(pI)->targetCellSize();
|
||||
alignment = ch->vertex(pI)->alignment();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
triad tri;
|
||||
|
||||
for (label pI = 0; pI < 4; ++pI)
|
||||
{
|
||||
size += bary[pI]*ch->vertex(pI)->targetCellSize();
|
||||
|
||||
if (bary[pI] > small)
|
||||
{
|
||||
tri += triad(bary[pI]*ch->vertex(pI)->alignment());
|
||||
}
|
||||
}
|
||||
|
||||
tri.normalise();
|
||||
tri.orthogonalise();
|
||||
tri = tri.sortxyz();
|
||||
|
||||
alignment = tri;
|
||||
|
||||
// cellShapeControlMesh::Vertex_handle nearV =
|
||||
// shapeControlMesh_.nearest_vertex
|
||||
// (
|
||||
// toPoint<cellShapeControlMesh::Point>(pt)
|
||||
// );
|
||||
//
|
||||
// alignment = nearV->alignment();
|
||||
}
|
||||
}
|
||||
|
||||
for (label dir = 0; dir < 3; dir++)
|
||||
{
|
||||
triad v = alignment;
|
||||
|
||||
if (!v.set(dir) || size == 0)
|
||||
{
|
||||
// Force orthogonalisation of triad.
|
||||
|
||||
scalar dotProd = great;
|
||||
if (dir == 0)
|
||||
{
|
||||
dotProd = v[1] & v[2];
|
||||
|
||||
v[dir] = v[1] ^ v[2];
|
||||
}
|
||||
if (dir == 1)
|
||||
{
|
||||
dotProd = v[0] & v[2];
|
||||
|
||||
v[dir] = v[0] ^ v[2];
|
||||
}
|
||||
if (dir == 2)
|
||||
{
|
||||
dotProd = v[0] & v[1];
|
||||
|
||||
v[dir] = v[0] ^ v[1];
|
||||
}
|
||||
|
||||
v.normalise();
|
||||
v.orthogonalise();
|
||||
|
||||
Pout<< "Dot prod = " << dotProd << endl;
|
||||
Pout<< "Alignment = " << v << endl;
|
||||
|
||||
alignment = v;
|
||||
|
||||
// FatalErrorInFunction
|
||||
// << "Point has bad alignment! "
|
||||
// << pt << " " << size << " " << alignment << nl
|
||||
// << "Bary Coords = " << bary << nl
|
||||
// << ch->vertex(0)->info() << nl
|
||||
// << ch->vertex(1)->info() << nl
|
||||
// << ch->vertex(2)->info() << nl
|
||||
// << ch->vertex(3)->info()
|
||||
// << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,162 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::cellShapeControl
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
cellShapeControlI.H
|
||||
cellShapeControl.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cellShapeControl_H
|
||||
#define cellShapeControl_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "autoPtr.H"
|
||||
#include "tensor.H"
|
||||
#include "point.H"
|
||||
#include "primitiveFieldsFwd.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "Time.H"
|
||||
#include "searchableSurfaces.H"
|
||||
#include "conformationSurfaces.H"
|
||||
#include "cellAspectRatioControl.H"
|
||||
#include "cellSizeAndAlignmentControls.H"
|
||||
#include "cellShapeControlMesh.H"
|
||||
#include "backgroundMeshDecomposition.H"
|
||||
#include "cvControls.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellShapeControl Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellShapeControl
|
||||
:
|
||||
public dictionary
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const conformationSurfaces& geometryToConformTo_;
|
||||
|
||||
const scalar defaultCellSize_;
|
||||
|
||||
const scalar minimumCellSize_;
|
||||
|
||||
cellShapeControlMesh shapeControlMesh_;
|
||||
|
||||
cellAspectRatioControl aspectRatio_;
|
||||
|
||||
cellSizeAndAlignmentControls sizeAndAlignment_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("cellShapeControl");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary and references to conformalVoronoiMesh and
|
||||
// searchableSurfaces
|
||||
cellShapeControl
|
||||
(
|
||||
const Time& runTime,
|
||||
const cvControls& foamyHexMeshControls,
|
||||
const searchableSurfaces& allGeometry,
|
||||
const conformationSurfaces& geometryToConformTo
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
cellShapeControl(const cellShapeControl&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~cellShapeControl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
inline const scalar& defaultCellSize() const;
|
||||
|
||||
inline cellShapeControlMesh& shapeControlMesh();
|
||||
|
||||
inline const cellShapeControlMesh& shapeControlMesh() const;
|
||||
|
||||
inline const cellAspectRatioControl& aspectRatio() const;
|
||||
|
||||
inline const cellSizeAndAlignmentControls& sizeAndAlignment() const;
|
||||
|
||||
inline const scalar& minimumCellSize() const;
|
||||
|
||||
|
||||
// Query
|
||||
|
||||
//- Return the cell size at the given location
|
||||
scalar cellSize(const point& pt) const;
|
||||
|
||||
scalarField cellSize(const pointField& pts) const;
|
||||
|
||||
//- Return the cell alignment at the given location
|
||||
tensor cellAlignment(const point& pt) const;
|
||||
|
||||
void cellSizeAndAlignment
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size,
|
||||
tensor& alignment
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cellShapeControl&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "cellShapeControlI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,68 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::cellShapeControlMesh&
|
||||
Foam::cellShapeControl::shapeControlMesh()
|
||||
{
|
||||
return shapeControlMesh_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::cellShapeControlMesh&
|
||||
Foam::cellShapeControl::shapeControlMesh() const
|
||||
{
|
||||
return shapeControlMesh_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::scalar& Foam::cellShapeControl::defaultCellSize() const
|
||||
{
|
||||
return defaultCellSize_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::cellAspectRatioControl&
|
||||
Foam::cellShapeControl::aspectRatio() const
|
||||
{
|
||||
return aspectRatio_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::cellSizeAndAlignmentControls&
|
||||
Foam::cellShapeControl::sizeAndAlignment() const
|
||||
{
|
||||
return sizeAndAlignment_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::scalar& Foam::cellShapeControl::minimumCellSize() const
|
||||
{
|
||||
return minimumCellSize_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,806 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2022 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 "cellShapeControlMesh.H"
|
||||
#include "cellSizeAndAlignmentControls.H"
|
||||
#include "pointFields.H"
|
||||
#include "pointIOField.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "triadIOField.H"
|
||||
#include "tetPointRef.H"
|
||||
#include "plane.H"
|
||||
#include "transform.H"
|
||||
#include "meshTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellShapeControlMesh, 0);
|
||||
|
||||
word cellShapeControlMesh::meshSubDir = "cellShapeControlMesh";
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
//Foam::tensor Foam::cellShapeControlMesh::requiredAlignment
|
||||
//(
|
||||
// const Foam::point& pt,
|
||||
// const searchableSurfaces& allGeometry,
|
||||
// const conformationSurfaces& geometryToConformTo
|
||||
//) const
|
||||
//{
|
||||
// pointIndexHit surfHit;
|
||||
// label hitSurface;
|
||||
//
|
||||
// geometryToConformTo.findSurfaceNearest
|
||||
// (
|
||||
// pt,
|
||||
// sqr(great),
|
||||
// surfHit,
|
||||
// hitSurface
|
||||
// );
|
||||
//
|
||||
// if (!surfHit.hit())
|
||||
// {
|
||||
// FatalErrorInFunction
|
||||
// << "findSurfaceNearest did not find a hit across the surfaces."
|
||||
// << exit(FatalError) << endl;
|
||||
// }
|
||||
//
|
||||
// // Primary alignment
|
||||
//
|
||||
// vectorField norm(1);
|
||||
//
|
||||
// allGeometry[hitSurface].getNormal
|
||||
// (
|
||||
// List<pointIndexHit>(1, surfHit),
|
||||
// norm
|
||||
// );
|
||||
//
|
||||
// const vector np = norm[0];
|
||||
//
|
||||
// // Generate equally spaced 'spokes' in a circle normal to the
|
||||
// // direction from the vertex to the closest point on the surface
|
||||
// // and look for a secondary intersection.
|
||||
//
|
||||
// const vector d = surfHit.hitPoint() - pt;
|
||||
//
|
||||
// const tensor Rp = rotationTensor(vector(0,0,1), np);
|
||||
//
|
||||
// const label s = 36;//foamyHexMeshControls().alignmentSearchSpokes();
|
||||
//
|
||||
// scalar closestSpokeHitDistance = great;
|
||||
//
|
||||
// pointIndexHit closestSpokeHit;
|
||||
//
|
||||
// label closestSpokeSurface = -1;
|
||||
//
|
||||
// const scalar spanMag = geometryToConformTo.globalBounds().mag();
|
||||
//
|
||||
// for (label i = 0; i < s; i++)
|
||||
// {
|
||||
// vector spoke
|
||||
// (
|
||||
// Foam::cos(i*constant::mathematical::twoPi/s),
|
||||
// Foam::sin(i*constant::mathematical::twoPi/s),
|
||||
// 0
|
||||
// );
|
||||
//
|
||||
// spoke *= spanMag;
|
||||
//
|
||||
// spoke = Rp & spoke;
|
||||
//
|
||||
// pointIndexHit spokeHit;
|
||||
//
|
||||
// label spokeSurface = -1;
|
||||
//
|
||||
// // internal spoke
|
||||
//
|
||||
// geometryToConformTo.findSurfaceNearestIntersection
|
||||
// (
|
||||
// pt,
|
||||
// pt + spoke,
|
||||
// spokeHit,
|
||||
// spokeSurface
|
||||
// );
|
||||
//
|
||||
// if (spokeHit.hit())
|
||||
// {
|
||||
// scalar spokeHitDistance = mag
|
||||
// (
|
||||
// spokeHit.hitPoint() - pt
|
||||
// );
|
||||
//
|
||||
// if (spokeHitDistance < closestSpokeHitDistance)
|
||||
// {
|
||||
// closestSpokeHit = spokeHit;
|
||||
// closestSpokeSurface = spokeSurface;
|
||||
// closestSpokeHitDistance = spokeHitDistance;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // external spoke
|
||||
//
|
||||
// Foam::point mirrorPt = pt + 2*d;
|
||||
//
|
||||
// geometryToConformTo.findSurfaceNearestIntersection
|
||||
// (
|
||||
// mirrorPt,
|
||||
// mirrorPt + spoke,
|
||||
// spokeHit,
|
||||
// spokeSurface
|
||||
// );
|
||||
//
|
||||
// if (spokeHit.hit())
|
||||
// {
|
||||
// scalar spokeHitDistance = mag
|
||||
// (
|
||||
// spokeHit.hitPoint() - mirrorPt
|
||||
// );
|
||||
//
|
||||
// if (spokeHitDistance < closestSpokeHitDistance)
|
||||
// {
|
||||
// closestSpokeHit = spokeHit;
|
||||
// closestSpokeSurface = spokeSurface;
|
||||
// closestSpokeHitDistance = spokeHitDistance;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (closestSpokeSurface == -1)
|
||||
// {
|
||||
//// WarningInFunction
|
||||
//// << "No secondary surface hit found in spoke search "
|
||||
//// << "using " << s
|
||||
//// << " spokes, try increasing alignmentSearchSpokes."
|
||||
//// << endl;
|
||||
//
|
||||
// return I;
|
||||
// }
|
||||
//
|
||||
// // Auxiliary alignment generated by spoke intersection normal.
|
||||
//
|
||||
// allGeometry[closestSpokeSurface].getNormal
|
||||
// (
|
||||
// List<pointIndexHit>(1, closestSpokeHit),
|
||||
// norm
|
||||
// );
|
||||
//
|
||||
// const vector& na = norm[0];
|
||||
//
|
||||
// // Secondary alignment
|
||||
// vector ns = np ^ na;
|
||||
//
|
||||
// if (mag(ns) < small)
|
||||
// {
|
||||
// FatalErrorInFunction
|
||||
// << "Parallel normals detected in spoke search." << nl
|
||||
// << "point: " << pt << nl
|
||||
// << "closest surface point: " << surfHit.hitPoint() << nl
|
||||
// << "closest spoke hit: " << closestSpokeHit.hitPoint() << nl
|
||||
// << "np: " << surfHit.hitPoint() + np << nl
|
||||
// << "ns: " << closestSpokeHit.hitPoint() + na << nl
|
||||
// << exit(FatalError);
|
||||
// }
|
||||
//
|
||||
// ns /= mag(ns);
|
||||
//
|
||||
// tensor Rs = rotationTensor((Rp & vector(0,1,0)), ns);
|
||||
//
|
||||
// return (Rs & Rp);
|
||||
//}
|
||||
|
||||
|
||||
Foam::label Foam::cellShapeControlMesh::removePoints()
|
||||
{
|
||||
label nRemoved = 0;
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||
finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
std::list<Vertex_handle> verts;
|
||||
adjacent_vertices(vit, std::back_inserter(verts));
|
||||
|
||||
bool removePt = true;
|
||||
for
|
||||
(
|
||||
std::list<Vertex_handle>::iterator aVit = verts.begin();
|
||||
aVit != verts.end();
|
||||
++aVit
|
||||
)
|
||||
{
|
||||
Vertex_handle avh = *aVit;
|
||||
|
||||
scalar diff =
|
||||
mag(avh->targetCellSize() - vit->targetCellSize())
|
||||
/max(vit->targetCellSize(), 1e-6);
|
||||
|
||||
if (diff > 0.05)
|
||||
{
|
||||
removePt = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (removePt)
|
||||
{
|
||||
remove(vit);
|
||||
nRemoved++;
|
||||
}
|
||||
}
|
||||
|
||||
return nRemoved;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::cellShapeControlMesh::cellCentres() const
|
||||
{
|
||||
tmp<pointField> tcellCentres(new pointField(number_of_finite_cells()));
|
||||
pointField& cellCentres = tcellCentres.ref();
|
||||
|
||||
label count = 0;
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_cells_iterator c = finite_cells_begin();
|
||||
c != finite_cells_end();
|
||||
++c
|
||||
)
|
||||
{
|
||||
if (c->hasFarPoint())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
scalarList bary;
|
||||
cellShapeControlMesh::Cell_handle ch;
|
||||
|
||||
const Foam::point centre = topoint
|
||||
(
|
||||
CGAL::centroid<baseK>
|
||||
(
|
||||
c->vertex(0)->point(),
|
||||
c->vertex(1)->point(),
|
||||
c->vertex(2)->point(),
|
||||
c->vertex(3)->point()
|
||||
)
|
||||
);
|
||||
|
||||
cellCentres[count++] = centre;
|
||||
}
|
||||
|
||||
cellCentres.resize(count);
|
||||
|
||||
return tcellCentres;
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellShapeControlMesh::writeTriangulation()
|
||||
{
|
||||
OFstream str
|
||||
(
|
||||
"refinementTriangulation_"
|
||||
+ name(Pstream::myProcNo())
|
||||
+ ".obj"
|
||||
);
|
||||
|
||||
label count = 0;
|
||||
|
||||
Info<< "Write refinementTriangulation" << endl;
|
||||
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_edges_iterator e = finite_edges_begin();
|
||||
e != finite_edges_end();
|
||||
++e
|
||||
)
|
||||
{
|
||||
Cell_handle c = e->first;
|
||||
Vertex_handle vA = c->vertex(e->second);
|
||||
Vertex_handle vB = c->vertex(e->third);
|
||||
|
||||
// Don't write far edges
|
||||
if (vA->farPoint() || vB->farPoint())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't write unowned edges
|
||||
if (vA->referred() && vB->referred())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pointFromPoint p1 = topoint(vA->point());
|
||||
pointFromPoint p2 = topoint(vB->point());
|
||||
|
||||
meshTools::writeOBJ(str, p1, p2, count);
|
||||
}
|
||||
|
||||
if (is_valid())
|
||||
{
|
||||
Info<< " Triangulation is valid" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Triangulation is not valid"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellShapeControlMesh::cellShapeControlMesh(const Time& runTime)
|
||||
:
|
||||
DistributedDelaunayMesh<CellSizeDelaunay>
|
||||
(
|
||||
runTime,
|
||||
meshSubDir
|
||||
),
|
||||
runTime_(runTime)
|
||||
{
|
||||
if (this->vertexCount())
|
||||
{
|
||||
fvMesh mesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
meshSubDir,
|
||||
runTime.name(),
|
||||
runTime,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
if (mesh.nPoints() == this->vertexCount())
|
||||
{
|
||||
pointScalarField sizes
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"sizes",
|
||||
runTime.name(),
|
||||
meshSubDir,
|
||||
runTime,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
pointMesh::New(mesh)
|
||||
);
|
||||
|
||||
triadIOField alignments
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"alignments",
|
||||
mesh.time().name(),
|
||||
meshSubDir,
|
||||
mesh.time(),
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
sizes.size() == this->vertexCount()
|
||||
&& alignments.size() == this->vertexCount()
|
||||
)
|
||||
{
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
vit->targetCellSize() = sizes[vit->index()];
|
||||
vit->alignment() = alignments[vit->index()];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cell size point field is not the same size as the "
|
||||
<< "mesh."
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellShapeControlMesh::~cellShapeControlMesh()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::cellShapeControlMesh::barycentricCoords
|
||||
(
|
||||
const Foam::point& pt,
|
||||
barycentric& bary,
|
||||
Cell_handle& ch
|
||||
) const
|
||||
{
|
||||
// Use the previous cell handle as a hint on where to start searching
|
||||
// Giving a hint causes strange errors...
|
||||
ch = locate(toPoint(pt));
|
||||
|
||||
if (dimension() > 2 && !is_infinite(ch))
|
||||
{
|
||||
oldCellHandle_ = ch;
|
||||
|
||||
tetPointRef tet
|
||||
(
|
||||
topoint(ch->vertex(0)->point()),
|
||||
topoint(ch->vertex(1)->point()),
|
||||
topoint(ch->vertex(2)->point()),
|
||||
topoint(ch->vertex(3)->point())
|
||||
);
|
||||
|
||||
bary = tet.pointToBarycentric(pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::boundBox Foam::cellShapeControlMesh::bounds() const
|
||||
{
|
||||
DynamicList<Foam::point> pts(number_of_vertices());
|
||||
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->real())
|
||||
{
|
||||
pts.append(topoint(vit->point()));
|
||||
}
|
||||
}
|
||||
|
||||
boundBox bb(pts);
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellShapeControlMesh::distribute
|
||||
(
|
||||
const backgroundMeshDecomposition& decomposition
|
||||
)
|
||||
{
|
||||
DynamicList<Foam::point> points(number_of_vertices());
|
||||
DynamicList<scalar> sizes(number_of_vertices());
|
||||
DynamicList<tensor> alignments(number_of_vertices());
|
||||
|
||||
DynamicList<Vb> farPts(8);
|
||||
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->real())
|
||||
{
|
||||
points.append(topoint(vit->point()));
|
||||
sizes.append(vit->targetCellSize());
|
||||
alignments.append(vit->alignment());
|
||||
}
|
||||
else if (vit->farPoint())
|
||||
{
|
||||
farPts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
vit->point(),
|
||||
-1,
|
||||
Vb::vtFar,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
farPts.last().targetCellSize() = vit->targetCellSize();
|
||||
farPts.last().alignment() = vit->alignment();
|
||||
}
|
||||
}
|
||||
|
||||
autoPtr<distributionMap> mapDist =
|
||||
DistributedDelaunayMesh<CellSizeDelaunay>::distribute
|
||||
(
|
||||
decomposition,
|
||||
points
|
||||
);
|
||||
|
||||
mapDist().distribute(sizes);
|
||||
mapDist().distribute(alignments);
|
||||
|
||||
// Reset the entire tessellation
|
||||
DelaunayMesh<CellSizeDelaunay>::reset();
|
||||
|
||||
|
||||
// Internal points have to be inserted first
|
||||
DynamicList<Vb> verticesToInsert(points.size());
|
||||
|
||||
|
||||
forAll(farPts, ptI)
|
||||
{
|
||||
verticesToInsert.append(farPts[ptI]);
|
||||
}
|
||||
|
||||
|
||||
forAll(points, pI)
|
||||
{
|
||||
verticesToInsert.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
toPoint(points[pI]),
|
||||
-1,
|
||||
Vb::vtInternal,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
verticesToInsert.last().targetCellSize() = sizes[pI];
|
||||
verticesToInsert.last().alignment() = alignments[pI];
|
||||
}
|
||||
|
||||
Info<< nl << " Inserting distributed background tessellation..." << endl;
|
||||
|
||||
this->rangeInsertWithInfo
|
||||
(
|
||||
verticesToInsert.begin(),
|
||||
verticesToInsert.end(),
|
||||
true
|
||||
);
|
||||
|
||||
sync(decomposition.procBounds());
|
||||
|
||||
Info<< " Total number of vertices after redistribution "
|
||||
<< returnReduce(label(number_of_vertices()), sumOp<label>()) << endl;
|
||||
}
|
||||
|
||||
|
||||
Foam::tensorField Foam::cellShapeControlMesh::dumpAlignments() const
|
||||
{
|
||||
tensorField alignmentsTmp(number_of_vertices(), Zero);
|
||||
|
||||
label count = 0;
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
alignmentsTmp[count++] = vit->alignment();
|
||||
}
|
||||
|
||||
return alignmentsTmp;
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellShapeControlMesh::write() const
|
||||
{
|
||||
Info<< "Writing " << meshSubDir << endl;
|
||||
|
||||
// Reindex the cells
|
||||
label cellCount = 0;
|
||||
for
|
||||
(
|
||||
Finite_cells_iterator cit = finite_cells_begin();
|
||||
cit != finite_cells_end();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
if (!cit->hasFarPoint() && !is_infinite(cit))
|
||||
{
|
||||
cit->cellIndex() = cellCount++;
|
||||
}
|
||||
}
|
||||
|
||||
DelaunayMesh<CellSizeDelaunay>::labelTolabelPairHashTable vertexMap;
|
||||
labelList cellMap;
|
||||
|
||||
autoPtr<polyMesh> meshPtr = DelaunayMesh<CellSizeDelaunay>::createMesh
|
||||
(
|
||||
meshSubDir,
|
||||
vertexMap,
|
||||
cellMap
|
||||
);
|
||||
const polyMesh& mesh = meshPtr();
|
||||
|
||||
pointScalarField sizes
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"sizes",
|
||||
mesh.time().name(),
|
||||
meshSubDir,
|
||||
mesh.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
pointMesh::New(mesh),
|
||||
scalar(0)
|
||||
);
|
||||
|
||||
triadIOField alignments
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"alignments",
|
||||
mesh.time().name(),
|
||||
meshSubDir,
|
||||
mesh.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
sizes.size()
|
||||
);
|
||||
|
||||
// Write alignments
|
||||
// OFstream str(runTime_.path()/"alignments.obj");
|
||||
|
||||
for
|
||||
(
|
||||
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->farPoint())
|
||||
{
|
||||
// Populate sizes
|
||||
sizes[vertexMap[labelPair(vit->index(), vit->procIndex())]] =
|
||||
vit->targetCellSize();
|
||||
|
||||
alignments[vertexMap[labelPair(vit->index(), vit->procIndex())]] =
|
||||
vit->alignment();
|
||||
|
||||
// // Write alignments
|
||||
// const tensor& alignment = vit->alignment();
|
||||
// pointFromPoint pt = topoint(vit->point());
|
||||
//
|
||||
// if
|
||||
// (
|
||||
// alignment.x() == triad::unset[0]
|
||||
// || alignment.y() == triad::unset[0]
|
||||
// || alignment.z() == triad::unset[0]
|
||||
// )
|
||||
// {
|
||||
// Info<< "Bad alignment = " << vit->info();
|
||||
//
|
||||
// vit->alignment() = tensor::I;
|
||||
//
|
||||
// Info<< "New alignment = " << vit->info();
|
||||
//
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// meshTools::writeOBJ(str, pt, alignment.x() + pt);
|
||||
// meshTools::writeOBJ(str, pt, alignment.y() + pt);
|
||||
// meshTools::writeOBJ(str, pt, alignment.z() + pt);
|
||||
}
|
||||
}
|
||||
|
||||
mesh.write();
|
||||
sizes.write();
|
||||
alignments.write();
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::cellShapeControlMesh::estimateCellCount
|
||||
(
|
||||
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||
) const
|
||||
{
|
||||
// Loop over all the tets and estimate the cell count in each one
|
||||
|
||||
scalar cellCount = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Finite_cells_iterator cit = finite_cells_begin();
|
||||
cit != finite_cells_end();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
if (!cit->hasFarPoint() && !is_infinite(cit))
|
||||
{
|
||||
// TODO: Check if tet centre is on the processor..
|
||||
CGAL::Tetrahedron_3<baseK> tet
|
||||
(
|
||||
cit->vertex(0)->point(),
|
||||
cit->vertex(1)->point(),
|
||||
cit->vertex(2)->point(),
|
||||
cit->vertex(3)->point()
|
||||
);
|
||||
|
||||
const Foam::point centre(topoint(CGAL::centroid(tet)));
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::parRun()
|
||||
&& !decomposition().positionOnThisProcessor(centre)
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
scalar volume = CGAL::to_double(tet.volume());
|
||||
|
||||
scalar averagedPointCellSize = 0;
|
||||
// scalar averagedPointCellSize = 1;
|
||||
|
||||
// Get an average volume by averaging the cell size of the vertices
|
||||
for (label vI = 0; vI < 4; ++vI)
|
||||
{
|
||||
averagedPointCellSize += cit->vertex(vI)->targetCellSize();
|
||||
// averagedPointCellSize *= cit->vertex(vI)->targetCellSize();
|
||||
}
|
||||
|
||||
averagedPointCellSize /= 4;
|
||||
// averagedPointCellSize = ::sqrt(averagedPointCellSize);
|
||||
|
||||
// if (averagedPointCellSize < small)
|
||||
// {
|
||||
// Pout<< "Volume = " << volume << endl;
|
||||
//
|
||||
// for (label vI = 0; vI < 4; ++vI)
|
||||
// {
|
||||
// Pout<< "Point " << vI
|
||||
// << ", point = " << topoint(cit->vertex(vI)->point())
|
||||
// << ", size = " << cit->vertex(vI)->targetCellSize()
|
||||
// << endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
cellCount += volume/pow(averagedPointCellSize, 3);
|
||||
}
|
||||
}
|
||||
|
||||
return cellCount;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,176 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::cellShapeControlMesh
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
cellShapeControlMeshI.H
|
||||
cellShapeControlMesh.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cellShapeControlMesh_H
|
||||
#define cellShapeControlMesh_H
|
||||
|
||||
#include "Time.H"
|
||||
#include "scalar.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
#include "triad.H"
|
||||
#include "fileName.H"
|
||||
#include "searchableSurfaces.H"
|
||||
#include "conformationSurfaces.H"
|
||||
#include "DistributedDelaunayMesh.H"
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
#include "backgroundMeshDecomposition.H"
|
||||
#include "boundBox.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class cellSizeAndAlignmentControls;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellShapeControlMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellShapeControlMesh
|
||||
:
|
||||
public DistributedDelaunayMesh<CellSizeDelaunay>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef CellSizeDelaunay::Cell_handle Cell_handle;
|
||||
typedef CellSizeDelaunay::Vertex_handle Vertex_handle;
|
||||
typedef CellSizeDelaunay::Point Point;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
const Time& runTime_;
|
||||
|
||||
mutable Cell_handle oldCellHandle_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("cellShapeControlMesh");
|
||||
|
||||
//- Return the mesh sub-directory name (usually "cellShapeControlMesh")
|
||||
static word meshSubDir;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
explicit cellShapeControlMesh(const Time& runTime);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
cellShapeControlMesh(const cellShapeControlMesh&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~cellShapeControlMesh();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Query
|
||||
|
||||
const Time& time() const
|
||||
{
|
||||
return runTime_;
|
||||
}
|
||||
|
||||
//- Calculate and return the barycentric coordinates for
|
||||
// interpolating quantities on the background mesh
|
||||
void barycentricCoords
|
||||
(
|
||||
const Foam::point& pt,
|
||||
barycentric& bary,
|
||||
Cell_handle& ch
|
||||
) const;
|
||||
|
||||
boundBox bounds() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
label removePoints();
|
||||
|
||||
//- Get the centres of all the tets
|
||||
tmp<pointField> cellCentres() const;
|
||||
|
||||
inline Vertex_handle insert
|
||||
(
|
||||
const Foam::point& pt,
|
||||
const scalar& size,
|
||||
const triad& alignment,
|
||||
const Foam::indexedVertexEnum::vertexType type = Vb::vtInternal
|
||||
);
|
||||
|
||||
inline Vertex_handle insertFar
|
||||
(
|
||||
const Foam::point& pt
|
||||
);
|
||||
|
||||
void distribute(const backgroundMeshDecomposition& decomposition);
|
||||
|
||||
tensorField dumpAlignments() const;
|
||||
|
||||
void writeTriangulation();
|
||||
|
||||
void write() const;
|
||||
|
||||
label estimateCellCount
|
||||
(
|
||||
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cellShapeControlMesh&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "cellShapeControlMeshI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,68 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellShapeControlMesh::Vertex_handle Foam::cellShapeControlMesh::insert
|
||||
(
|
||||
const Foam::point& pt,
|
||||
const scalar& size,
|
||||
const triad& alignment,
|
||||
const Foam::indexedVertexEnum::vertexType type
|
||||
)
|
||||
{
|
||||
Vertex_handle v = CellSizeDelaunay::insert
|
||||
(
|
||||
Point(pt.x(), pt.y(), pt.z())
|
||||
);
|
||||
v->type() = type;
|
||||
v->index() = getNewVertexIndex();
|
||||
v->procIndex() = Pstream::myProcNo();
|
||||
v->targetCellSize() = size;
|
||||
v->alignment() = tensor(alignment.x(), alignment.y(), alignment.z());
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
Foam::cellShapeControlMesh::Vertex_handle Foam::cellShapeControlMesh::insertFar
|
||||
(
|
||||
const Foam::point& pt
|
||||
)
|
||||
{
|
||||
Vertex_handle v = CellSizeDelaunay::insert
|
||||
(
|
||||
Point(pt.x(), pt.y(), pt.z())
|
||||
);
|
||||
v->type() = Vb::vtFar;
|
||||
// v->type() = Vb::vtExternalFeaturePoint;
|
||||
v->index() = getNewVertexIndex();
|
||||
v->procIndex() = Pstream::myProcNo();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,128 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "cellSizeAndAlignmentControl.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellSizeAndAlignmentControl, 0);
|
||||
defineRunTimeSelectionTable(cellSizeAndAlignmentControl, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellSizeAndAlignmentControl::cellSizeAndAlignmentControl
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
runTime_(runTime),
|
||||
defaultCellSize_(defaultCellSize),
|
||||
forceInitialPointInsertion_
|
||||
(
|
||||
controlFunctionDict.lookupOrDefault<Switch>
|
||||
(
|
||||
"forceInitialPointInsertion",
|
||||
"off"
|
||||
)
|
||||
),
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::cellSizeAndAlignmentControl>
|
||||
Foam::cellSizeAndAlignmentControl::New
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
{
|
||||
word cellSizeAndAlignmentControlTypeName
|
||||
(
|
||||
controlFunctionDict.lookup("type")
|
||||
);
|
||||
|
||||
Info<< indent << "Selecting cellSizeAndAlignmentControl "
|
||||
<< cellSizeAndAlignmentControlTypeName << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find
|
||||
(
|
||||
cellSizeAndAlignmentControlTypeName
|
||||
);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown cellSizeAndAlignmentControl type "
|
||||
<< cellSizeAndAlignmentControlTypeName
|
||||
<< endl << endl
|
||||
<< "Valid cellSizeAndAlignmentControl types are :" << endl
|
||||
<< dictionaryConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<cellSizeAndAlignmentControl>
|
||||
(
|
||||
cstrIter()
|
||||
(
|
||||
runTime,
|
||||
name,
|
||||
controlFunctionDict,
|
||||
geometryToConformTo,
|
||||
defaultCellSize
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellSizeAndAlignmentControl::~cellSizeAndAlignmentControl()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,187 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::cellSizeAndAlignmentControl
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
cellSizeAndAlignmentControlI.H
|
||||
cellSizeAndAlignmentControl.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cellSizeAndAlignmentControl_H
|
||||
#define cellSizeAndAlignmentControl_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "conformationSurfaces.H"
|
||||
#include "Time.H"
|
||||
#include "quaternion.H"
|
||||
#include "triadField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellSizeAndAlignmentControl Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellSizeAndAlignmentControl
|
||||
{
|
||||
protected:
|
||||
|
||||
const Time& runTime_;
|
||||
|
||||
const scalar& defaultCellSize_;
|
||||
|
||||
Switch forceInitialPointInsertion_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
const word name_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cellSizeAndAlignmentControl");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
cellSizeAndAlignmentControl,
|
||||
dictionary,
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
),
|
||||
(
|
||||
runTime,
|
||||
name,
|
||||
controlFunctionDict,
|
||||
geometryToConformTo,
|
||||
defaultCellSize
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary and references to conformalVoronoiMesh and
|
||||
// searchableSurfaces
|
||||
cellSizeAndAlignmentControl
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
cellSizeAndAlignmentControl
|
||||
(
|
||||
const cellSizeAndAlignmentControl&
|
||||
) = delete;
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected cellShapeControl
|
||||
static autoPtr<cellSizeAndAlignmentControl> New
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cellSizeAndAlignmentControl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
const Switch& forceInitialPointInsertion() const
|
||||
{
|
||||
return forceInitialPointInsertion_;
|
||||
}
|
||||
|
||||
|
||||
// Query
|
||||
|
||||
virtual label maxPriority() const = 0;
|
||||
|
||||
virtual void cellSizeFunctionVertices
|
||||
(
|
||||
DynamicList<Foam::point>& pts,
|
||||
DynamicList<scalar>& sizes
|
||||
) const = 0;
|
||||
|
||||
virtual void initialVertices
|
||||
(
|
||||
pointField& pts,
|
||||
scalarField& sizes,
|
||||
triadField& alignments
|
||||
) const = 0;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cellSizeAndAlignmentControl&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,180 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "cellSizeAndAlignmentControls.H"
|
||||
#include "searchableSurfaceControl.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellSizeAndAlignmentControls, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::cellSizeAndAlignmentControls::evalCellSizeFunctions
|
||||
(
|
||||
const point& pt,
|
||||
scalar& minSize,
|
||||
label& maxPriority
|
||||
) const
|
||||
{
|
||||
bool anyFunctionFound = false;
|
||||
|
||||
// Regions requesting with the same priority take the smallest
|
||||
|
||||
if (controlFunctions_.size())
|
||||
{
|
||||
// Maintain priority of current hit. Initialise so it always goes
|
||||
// through at least once.
|
||||
label previousPriority = labelMin;
|
||||
|
||||
forAll(controlFunctions_, i)
|
||||
{
|
||||
const cellSizeAndAlignmentControl& cSF = controlFunctions_[i];
|
||||
|
||||
if (isA<searchableSurfaceControl>(cSF))
|
||||
{
|
||||
const searchableSurfaceControl& sSC =
|
||||
refCast<const searchableSurfaceControl>(cSF);
|
||||
|
||||
anyFunctionFound = sSC.cellSize(pt, minSize, previousPriority);
|
||||
|
||||
if (previousPriority > maxPriority)
|
||||
{
|
||||
maxPriority = previousPriority;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return anyFunctionFound;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
|
||||
(
|
||||
const Time& runTime,
|
||||
const dictionary& shapeControlDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
shapeControlDict_(shapeControlDict),
|
||||
geometryToConformTo_(geometryToConformTo),
|
||||
controlFunctions_(shapeControlDict_.size()),
|
||||
defaultCellSize_(defaultCellSize)
|
||||
{
|
||||
label functionI = 0;
|
||||
|
||||
forAllConstIter(dictionary, shapeControlDict_, iter)
|
||||
{
|
||||
word shapeControlEntryName = iter().keyword();
|
||||
|
||||
const dictionary& controlFunctionDict
|
||||
(
|
||||
shapeControlDict_.subDict(shapeControlEntryName)
|
||||
);
|
||||
|
||||
Info<< nl << "Shape Control : " << shapeControlEntryName << endl;
|
||||
Info<< incrIndent;
|
||||
|
||||
controlFunctions_.set
|
||||
(
|
||||
functionI,
|
||||
cellSizeAndAlignmentControl::New
|
||||
(
|
||||
runTime,
|
||||
shapeControlEntryName,
|
||||
controlFunctionDict,
|
||||
geometryToConformTo_,
|
||||
defaultCellSize_
|
||||
)
|
||||
);
|
||||
|
||||
Info<< decrIndent;
|
||||
|
||||
functionI++;
|
||||
}
|
||||
|
||||
// Sort controlFunctions_ by maxPriority
|
||||
SortableList<label> functionPriorities(functionI);
|
||||
|
||||
forAll(controlFunctions_, funcI)
|
||||
{
|
||||
functionPriorities[funcI] = controlFunctions_[funcI].maxPriority();
|
||||
}
|
||||
|
||||
functionPriorities.reverseSort();
|
||||
|
||||
labelList invertedFunctionPriorities =
|
||||
invert(functionPriorities.size(), functionPriorities.indices());
|
||||
|
||||
controlFunctions_.reorder(invertedFunctionPriorities);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellSizeAndAlignmentControls::~cellSizeAndAlignmentControls()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::cellSizeAndAlignmentControls::cellSize
|
||||
(
|
||||
const point& pt
|
||||
) const
|
||||
{
|
||||
scalar size = defaultCellSize_;
|
||||
label maxPriority = -1;
|
||||
|
||||
evalCellSizeFunctions(pt, size, maxPriority);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::cellSizeAndAlignmentControls::cellSize
|
||||
(
|
||||
const point& pt,
|
||||
label& maxPriority
|
||||
) const
|
||||
{
|
||||
scalar size = defaultCellSize_;
|
||||
maxPriority = -1;
|
||||
|
||||
evalCellSizeFunctions(pt, size, maxPriority);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,135 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::cellSizeAndAlignmentControls
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
cellSizeAndAlignmentControls.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cellSizeAndAlignmentControls_H
|
||||
#define cellSizeAndAlignmentControls_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "cellSizeAndAlignmentControl.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellSizeAndAlignmentControls Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellSizeAndAlignmentControls
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const dictionary& shapeControlDict_;
|
||||
|
||||
const conformationSurfaces& geometryToConformTo_;
|
||||
|
||||
PtrList<cellSizeAndAlignmentControl> controlFunctions_;
|
||||
|
||||
const scalar defaultCellSize_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
bool evalCellSizeFunctions
|
||||
(
|
||||
const point& pt,
|
||||
scalar& minSize,
|
||||
label& maxPriority
|
||||
) const;
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
cellSizeAndAlignmentControls
|
||||
(
|
||||
const cellSizeAndAlignmentControls&
|
||||
) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cellSizeAndAlignmentControls&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("cellSizeAndAlignmentControls");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
cellSizeAndAlignmentControls
|
||||
(
|
||||
const Time& runTime,
|
||||
const dictionary& shapeControlDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cellSizeAndAlignmentControls();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
inline const PtrList<cellSizeAndAlignmentControl>&
|
||||
controlFunctions() const
|
||||
{
|
||||
return controlFunctions_;
|
||||
}
|
||||
|
||||
inline const conformationSurfaces& geometryToConformTo() const
|
||||
{
|
||||
return geometryToConformTo_;
|
||||
}
|
||||
|
||||
|
||||
// Query
|
||||
|
||||
scalar cellSize(const point& pt) const;
|
||||
|
||||
scalar cellSize(const point& pt, label& maxPriority) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,249 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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 "fileControl.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "tetPointRef.H"
|
||||
#include "scalarList.H"
|
||||
#include "vectorTools.H"
|
||||
#include "pointIOField.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "triadIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(fileControl, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
cellSizeAndAlignmentControl,
|
||||
fileControl,
|
||||
dictionary
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileControl::fileControl
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
cellSizeAndAlignmentControl
|
||||
(
|
||||
runTime,
|
||||
name,
|
||||
controlFunctionDict,
|
||||
geometryToConformTo,
|
||||
defaultCellSize
|
||||
),
|
||||
pointsFile_(controlFunctionDict.lookup("pointsFile")),
|
||||
sizesFile_(controlFunctionDict.lookup("sizesFile")),
|
||||
alignmentsFile_(controlFunctionDict.lookup("alignmentsFile")),
|
||||
maxPriority_(controlFunctionDict.lookup<label>("priority"))
|
||||
{
|
||||
Info<< indent << "Loading " << name << " from file:" << nl
|
||||
<< indent << " priority : " << maxPriority_ << nl
|
||||
<< indent << " points : " << pointsFile_ << nl
|
||||
<< indent << " sizes : " << sizesFile_ << nl
|
||||
<< indent << " alignments : " << alignmentsFile_
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileControl::~fileControl()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
//
|
||||
//Foam::scalar Foam::fileControl::cellSize(const point& pt) const
|
||||
//{
|
||||
// FixedList<scalar, 4> bary;
|
||||
// Cell_handle ch;
|
||||
//
|
||||
// triangulatedMesh_.barycentricCoords(pt, bary, ch);
|
||||
//
|
||||
// scalar size = 0;
|
||||
// forAll(bary, pI)
|
||||
// {
|
||||
// size += bary[pI]*ch->vertex(pI)->size();
|
||||
// }
|
||||
//
|
||||
// return size;
|
||||
//}
|
||||
//
|
||||
//
|
||||
////- Return the cell alignment at the given location
|
||||
//Foam::tensor Foam::fileControl::cellAlignment(const point& pt) const
|
||||
//{
|
||||
// FixedList<scalar, 4> bary;
|
||||
// Cell_handle ch;
|
||||
//
|
||||
// triangulatedMesh_.barycentricCoords(pt, bary, ch);
|
||||
//
|
||||
// label nearest = 0;
|
||||
//
|
||||
// tensor alignment = Zero;
|
||||
// forAll(bary, pI)
|
||||
// {
|
||||
// // alignment += bary[pI]*ch->vertex(pI)->alignment();
|
||||
//
|
||||
// // Find nearest point
|
||||
// if (bary[pI] > nearest)
|
||||
// {
|
||||
// alignment = ch->vertex(pI)->alignment();
|
||||
// nearest = bary[pI];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return alignment;
|
||||
//}
|
||||
//
|
||||
//
|
||||
////- Return the cell alignment at the given location
|
||||
//void Foam::fileControl::cellSizeAndAlignment
|
||||
//(
|
||||
// const point& pt,
|
||||
// scalar& size,
|
||||
// tensor& alignment
|
||||
//) const
|
||||
//{
|
||||
// FixedList<scalar, 4> bary;
|
||||
// Cell_handle ch;
|
||||
//
|
||||
// triangulatedMesh_.barycentricCoords(pt, bary, ch);
|
||||
//
|
||||
// size = 0;
|
||||
// forAll(bary, pI)
|
||||
// {
|
||||
// size += bary[pI]*ch->vertex(pI)->size();
|
||||
// }
|
||||
//
|
||||
//// alignment = Zero;
|
||||
//// forAll(bary, pI)
|
||||
//// {
|
||||
//// alignment += bary[pI]*ch->vertex(pI)->alignment();
|
||||
//// }
|
||||
//
|
||||
// alignment = cellAlignment(pt);
|
||||
//}
|
||||
|
||||
|
||||
void Foam::fileControl::cellSizeFunctionVertices
|
||||
(
|
||||
DynamicList<Foam::point>& pts,
|
||||
DynamicList<scalar>& sizes
|
||||
) const
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileControl::initialVertices
|
||||
(
|
||||
pointField& pts,
|
||||
scalarField& sizes,
|
||||
triadField& alignments
|
||||
) const
|
||||
{
|
||||
Info<< " Reading points from file : " << pointsFile_ << endl;
|
||||
|
||||
pointIOField pointsTmp
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
pointsFile_,
|
||||
runTime_.constant(),
|
||||
runTime_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
pts.transfer(pointsTmp);
|
||||
|
||||
Info<< " Reading sizes from file : " << sizesFile_ << endl;
|
||||
|
||||
scalarIOField sizesTmp
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
sizesFile_,
|
||||
runTime_.constant(),
|
||||
runTime_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
sizes.transfer(sizesTmp);
|
||||
|
||||
Info<< " Reading alignments from file : " << alignmentsFile_ << endl;
|
||||
|
||||
triadIOField alignmentsTmp
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
alignmentsFile_,
|
||||
runTime_.constant(),
|
||||
runTime_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
alignments.transfer(alignmentsTmp);
|
||||
|
||||
if ((pts.size() != sizes.size()) || (pts.size() != alignments.size()))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Size of list of points, sizes and alignments do not match:"
|
||||
<< nl
|
||||
<< "Points size = " << pts.size() << nl
|
||||
<< "Sizes size = " << sizes.size() << nl
|
||||
<< "Alignments size = " << alignments.size()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,132 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::fileControl
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
fileControl.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fileControl_H
|
||||
#define fileControl_H
|
||||
|
||||
#include "cellSizeAndAlignmentControl.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fileControl Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fileControl
|
||||
:
|
||||
public cellSizeAndAlignmentControl
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const fileName pointsFile_;
|
||||
|
||||
const fileName sizesFile_;
|
||||
|
||||
const fileName alignmentsFile_;
|
||||
|
||||
label maxPriority_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fileControl");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary and references to conformalVoronoiMesh and
|
||||
// searchableSurfaces
|
||||
fileControl
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
fileControl(const fileControl&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~fileControl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
virtual label maxPriority() const
|
||||
{
|
||||
return maxPriority_;
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
virtual void cellSizeFunctionVertices
|
||||
(
|
||||
DynamicList<Foam::point>& pts,
|
||||
DynamicList<scalar>& sizes
|
||||
) const;
|
||||
|
||||
virtual void initialVertices
|
||||
(
|
||||
pointField& pts,
|
||||
scalarField& sizes,
|
||||
triadField& alignments
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fileControl&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,580 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2021 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 "searchableSurfaceControl.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "cellSizeFunction.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
#include "searchableBox.H"
|
||||
#include "tetPointRef.H"
|
||||
#include "vectorTools.H"
|
||||
#include "quaternion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(searchableSurfaceControl, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
cellSizeAndAlignmentControl,
|
||||
searchableSurfaceControl,
|
||||
dictionary
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
//Foam::tensor Foam::surfaceControl::requiredAlignment
|
||||
//(
|
||||
// const Foam::point& pt,
|
||||
// const vectorField& ptNormals
|
||||
//) const
|
||||
//{
|
||||
//// pointIndexHit surfHit;
|
||||
//// label hitSurface;
|
||||
////
|
||||
//// geometryToConformTo_.findSurfaceNearest
|
||||
//// (
|
||||
//// pt,
|
||||
//// sqr(great),
|
||||
//// surfHit,
|
||||
//// hitSurface
|
||||
//// );
|
||||
////
|
||||
//// if (!surfHit.hit())
|
||||
//// {
|
||||
//// FatalErrorInFunction
|
||||
//// << "findSurfaceNearest did not find a hit across the surfaces."
|
||||
//// << exit(FatalError) << endl;
|
||||
//// }
|
||||
////
|
||||
////// Primary alignment
|
||||
////
|
||||
//// vectorField norm(1);
|
||||
////
|
||||
//// allGeometry_[hitSurface].getNormal
|
||||
//// (
|
||||
//// List<pointIndexHit>(1, surfHit),
|
||||
//// norm
|
||||
//// );
|
||||
////
|
||||
//// const vector np = norm[0];
|
||||
////
|
||||
//// const tensor Rp = rotationTensor(vector(0,0,1), np);
|
||||
////
|
||||
//// return (Rp);
|
||||
//
|
||||
//// Info<< "Point : " << pt << endl;
|
||||
//// forAll(ptNormals, pnI)
|
||||
//// {
|
||||
//// Info<< " normal " << pnI << " : " << ptNormals[pnI] << endl;
|
||||
//// }
|
||||
//
|
||||
// vector np = ptNormals[0];
|
||||
//
|
||||
// const tensor Rp = rotationTensor(vector(0,0,1), np);
|
||||
//
|
||||
// vector na = Zero;
|
||||
//
|
||||
// scalar smallestAngle = great;
|
||||
//
|
||||
// for (label pnI = 1; pnI < ptNormals.size(); ++pnI)
|
||||
// {
|
||||
// const vector& nextNormal = ptNormals[pnI];
|
||||
//
|
||||
// const scalar cosPhi = vectorTools::cosPhi(np, nextNormal);
|
||||
//
|
||||
// if (mag(cosPhi) < smallestAngle)
|
||||
// {
|
||||
// na = nextNormal;
|
||||
// smallestAngle = cosPhi;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Secondary alignment
|
||||
// vector ns = np ^ na;
|
||||
//
|
||||
// if (mag(ns) < small)
|
||||
// {
|
||||
// WarningInFunction
|
||||
// << "Parallel normals detected in spoke search." << nl
|
||||
// << "point: " << pt << nl
|
||||
// << "np : " << np << nl
|
||||
// << "na : " << na << nl
|
||||
// << "ns : " << ns << nl
|
||||
// << endl;
|
||||
//
|
||||
// ns = np;
|
||||
// }
|
||||
//
|
||||
// ns /= mag(ns);
|
||||
//
|
||||
// tensor Rs = rotationTensor((Rp & vector(0,1,0)), ns);
|
||||
//
|
||||
//// Info<< "Point " << pt << nl
|
||||
//// << " np : " << np << nl
|
||||
//// << " ns : " << ns << nl
|
||||
//// << " Rp : " << Rp << nl
|
||||
//// << " Rs : " << Rs << nl
|
||||
//// << " Rs&Rp: " << (Rs & Rp) << endl;
|
||||
//
|
||||
// return (Rs & Rp);
|
||||
//}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::searchableSurfaceControl::searchableSurfaceControl
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
cellSizeAndAlignmentControl
|
||||
(
|
||||
runTime,
|
||||
name,
|
||||
controlFunctionDict,
|
||||
geometryToConformTo,
|
||||
defaultCellSize
|
||||
),
|
||||
surfaceName_(controlFunctionDict.lookupOrDefault<word>("surface", name)),
|
||||
searchableSurface_(geometryToConformTo.geometry()[surfaceName_]),
|
||||
geometryToConformTo_(geometryToConformTo),
|
||||
cellSizeFunctions_(1),
|
||||
regionToCellSizeFunctions_(searchableSurface_.regions().size(), -1),
|
||||
maxPriority_(-1)
|
||||
{
|
||||
Info<< indent << "Master settings:" << endl;
|
||||
Info<< incrIndent;
|
||||
|
||||
cellSizeFunctions_.set
|
||||
(
|
||||
0,
|
||||
cellSizeFunction::New
|
||||
(
|
||||
controlFunctionDict,
|
||||
searchableSurface_,
|
||||
defaultCellSize_,
|
||||
labelList()
|
||||
)
|
||||
);
|
||||
|
||||
Info<< decrIndent;
|
||||
|
||||
PtrList<cellSizeFunction> regionCellSizeFunctions;
|
||||
|
||||
DynamicList<label> defaultCellSizeRegions;
|
||||
|
||||
label nRegionCellSizeFunctions = 0;
|
||||
|
||||
// Loop over regions - if any entry is not specified they should
|
||||
// inherit values from the parent surface.
|
||||
if (controlFunctionDict.found("regions"))
|
||||
{
|
||||
const dictionary& regionsDict = controlFunctionDict.subDict("regions");
|
||||
const wordList& regionNames = searchableSurface_.regions();
|
||||
|
||||
label nRegions = regionsDict.size();
|
||||
|
||||
regionCellSizeFunctions.setSize(nRegions);
|
||||
defaultCellSizeRegions.setCapacity(nRegions);
|
||||
|
||||
forAll(regionNames, regionI)
|
||||
{
|
||||
const word& regionName = regionNames[regionI];
|
||||
|
||||
label regionID = geometryToConformTo_.geometry().findSurfaceRegionID
|
||||
(
|
||||
this->name(),
|
||||
regionName
|
||||
);
|
||||
|
||||
if (regionsDict.found(regionName))
|
||||
{
|
||||
// Get the dictionary for region
|
||||
const dictionary& regionDict = regionsDict.subDict(regionName);
|
||||
|
||||
Info<< indent << "Region " << regionName
|
||||
<< " (ID = " << regionID << ")" << " settings:"
|
||||
<< endl;
|
||||
Info<< incrIndent;
|
||||
|
||||
regionCellSizeFunctions.set
|
||||
(
|
||||
nRegionCellSizeFunctions,
|
||||
cellSizeFunction::New
|
||||
(
|
||||
regionDict,
|
||||
searchableSurface_,
|
||||
defaultCellSize_,
|
||||
labelList(1, regionID)
|
||||
)
|
||||
);
|
||||
Info<< decrIndent;
|
||||
|
||||
regionToCellSizeFunctions_[regionID] = nRegionCellSizeFunctions;
|
||||
|
||||
nRegionCellSizeFunctions++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add to default list
|
||||
defaultCellSizeRegions.append(regionID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultCellSizeRegions.empty() && !regionCellSizeFunctions.empty())
|
||||
{
|
||||
cellSizeFunctions_.transfer(regionCellSizeFunctions);
|
||||
}
|
||||
else if (nRegionCellSizeFunctions > 0)
|
||||
{
|
||||
regionCellSizeFunctions.setSize(nRegionCellSizeFunctions + 1);
|
||||
|
||||
regionCellSizeFunctions.set
|
||||
(
|
||||
nRegionCellSizeFunctions,
|
||||
cellSizeFunction::New
|
||||
(
|
||||
controlFunctionDict,
|
||||
searchableSurface_,
|
||||
defaultCellSize_,
|
||||
labelList()
|
||||
)
|
||||
);
|
||||
|
||||
const wordList& regionNames = searchableSurface_.regions();
|
||||
|
||||
forAll(regionNames, regionI)
|
||||
{
|
||||
if (regionToCellSizeFunctions_[regionI] == -1)
|
||||
{
|
||||
regionToCellSizeFunctions_[regionI] = nRegionCellSizeFunctions;
|
||||
}
|
||||
}
|
||||
|
||||
cellSizeFunctions_.transfer(regionCellSizeFunctions);
|
||||
}
|
||||
else
|
||||
{
|
||||
const wordList& regionNames = searchableSurface_.regions();
|
||||
|
||||
forAll(regionNames, regionI)
|
||||
{
|
||||
if (regionToCellSizeFunctions_[regionI] == -1)
|
||||
{
|
||||
regionToCellSizeFunctions_[regionI] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
forAll(cellSizeFunctions_, funcI)
|
||||
{
|
||||
const label funcPriority = cellSizeFunctions_[funcI].priority();
|
||||
|
||||
if (funcPriority > maxPriority_)
|
||||
{
|
||||
maxPriority_ = funcPriority;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort controlFunctions_ by maxPriority
|
||||
SortableList<label> functionPriorities(cellSizeFunctions_.size());
|
||||
|
||||
forAll(cellSizeFunctions_, funcI)
|
||||
{
|
||||
functionPriorities[funcI] = cellSizeFunctions_[funcI].priority();
|
||||
}
|
||||
|
||||
functionPriorities.reverseSort();
|
||||
|
||||
labelList invertedFunctionPriorities =
|
||||
invert(functionPriorities.size(), functionPriorities.indices());
|
||||
|
||||
cellSizeFunctions_.reorder(invertedFunctionPriorities);
|
||||
|
||||
Info<< nl << indent << "There are " << cellSizeFunctions_.size()
|
||||
<< " region control functions" << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::searchableSurfaceControl::~searchableSurfaceControl()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::searchableSurfaceControl::initialVertices
|
||||
(
|
||||
pointField& pts,
|
||||
scalarField& sizes,
|
||||
triadField& alignments
|
||||
) const
|
||||
{
|
||||
pts = searchableSurface_.points();
|
||||
sizes.setSize(pts.size());
|
||||
alignments.setSize(pts.size());
|
||||
|
||||
const scalar nearFeatDistSqrCoeff = 1e-8;
|
||||
|
||||
forAll(pts, pI)
|
||||
{
|
||||
// Is the point in the extendedFeatureEdgeMesh? If so get the
|
||||
// point normal, otherwise get the surface normal from
|
||||
// searchableSurface
|
||||
|
||||
pointIndexHit info;
|
||||
label infoFeature;
|
||||
geometryToConformTo_.findFeaturePointNearest
|
||||
(
|
||||
pts[pI],
|
||||
nearFeatDistSqrCoeff,
|
||||
info,
|
||||
infoFeature
|
||||
);
|
||||
|
||||
scalar limitedCellSize = great;
|
||||
|
||||
autoPtr<triad> pointAlignment;
|
||||
|
||||
if (info.hit())
|
||||
{
|
||||
const extendedFeatureEdgeMesh& features =
|
||||
geometryToConformTo_.features()[infoFeature];
|
||||
|
||||
vectorField norms = features.featurePointNormals(info.index());
|
||||
|
||||
// Create a triad from these norms.
|
||||
pointAlignment.set(new triad());
|
||||
forAll(norms, nI)
|
||||
{
|
||||
pointAlignment() += norms[nI];
|
||||
}
|
||||
|
||||
pointAlignment().normalise();
|
||||
pointAlignment().orthogonalise();
|
||||
}
|
||||
else
|
||||
{
|
||||
geometryToConformTo_.findEdgeNearest
|
||||
(
|
||||
pts[pI],
|
||||
nearFeatDistSqrCoeff,
|
||||
info,
|
||||
infoFeature
|
||||
);
|
||||
|
||||
if (info.hit())
|
||||
{
|
||||
const extendedFeatureEdgeMesh& features =
|
||||
geometryToConformTo_.features()[infoFeature];
|
||||
|
||||
vectorField norms = features.edgeNormals(info.index());
|
||||
|
||||
// Create a triad from these norms.
|
||||
pointAlignment.set(new triad());
|
||||
forAll(norms, nI)
|
||||
{
|
||||
pointAlignment() += norms[nI];
|
||||
}
|
||||
|
||||
pointAlignment().normalise();
|
||||
pointAlignment().orthogonalise();
|
||||
}
|
||||
else
|
||||
{
|
||||
pointField ptField(1, pts[pI]);
|
||||
scalarField distField(1, nearFeatDistSqrCoeff);
|
||||
List<pointIndexHit> infoList(1, pointIndexHit());
|
||||
|
||||
searchableSurface_.findNearest(ptField, distField, infoList);
|
||||
|
||||
vectorField normals(1);
|
||||
searchableSurface_.getNormal(infoList, normals);
|
||||
|
||||
if (mag(normals[0]) < small)
|
||||
{
|
||||
normals[0] = vector(1, 1, 1);
|
||||
}
|
||||
|
||||
pointAlignment.set(new triad(normals[0]));
|
||||
|
||||
if (infoList[0].hit())
|
||||
{
|
||||
// Limit cell size
|
||||
const vector vN =
|
||||
infoList[0].hitPoint()
|
||||
- 2.0*normals[0]*defaultCellSize_;
|
||||
|
||||
List<pointIndexHit> intersectionList;
|
||||
searchableSurface_.findLineAny
|
||||
(
|
||||
ptField,
|
||||
pointField(1, vN),
|
||||
intersectionList
|
||||
);
|
||||
}
|
||||
|
||||
// if (intersectionList[0].hit())
|
||||
// {
|
||||
// scalar dist =
|
||||
// mag(intersectionList[0].hitPoint() - pts[pI]);
|
||||
//
|
||||
// limitedCellSize = dist/2.0;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
label priority = -1;
|
||||
if (!cellSize(pts[pI], sizes[pI], priority))
|
||||
{
|
||||
sizes[pI] = defaultCellSize_;
|
||||
// FatalErrorInFunction
|
||||
// << "Could not calculate cell size"
|
||||
// << abort(FatalError);
|
||||
}
|
||||
|
||||
sizes[pI] = min(limitedCellSize, sizes[pI]);
|
||||
|
||||
alignments[pI] = pointAlignment();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::searchableSurfaceControl::cellSizeFunctionVertices
|
||||
(
|
||||
DynamicList<Foam::point>& pts,
|
||||
DynamicList<scalar>& sizes
|
||||
) const
|
||||
{
|
||||
const tmp<pointField> tmpPoints = searchableSurface_.points();
|
||||
const pointField& points = tmpPoints();
|
||||
|
||||
const scalar nearFeatDistSqrCoeff = 1e-8;
|
||||
|
||||
pointField ptField(1, vector::min);
|
||||
scalarField distField(1, nearFeatDistSqrCoeff);
|
||||
List<pointIndexHit> infoList(1, pointIndexHit());
|
||||
|
||||
vectorField normals(1);
|
||||
labelList region(1, label(-1));
|
||||
|
||||
forAll(points, pI)
|
||||
{
|
||||
// Is the point in the extendedFeatureEdgeMesh? If so get the
|
||||
// point normal, otherwise get the surface normal from
|
||||
// searchableSurface
|
||||
ptField[0] = points[pI];
|
||||
|
||||
searchableSurface_.findNearest(ptField, distField, infoList);
|
||||
|
||||
if (infoList[0].hit())
|
||||
{
|
||||
searchableSurface_.getNormal(infoList, normals);
|
||||
searchableSurface_.getRegion(infoList, region);
|
||||
|
||||
const cellSizeFunction& sizeFunc =
|
||||
sizeFunctions()[regionToCellSizeFunctions_[region[0]]];
|
||||
|
||||
pointField extraPts;
|
||||
scalarField extraSizes;
|
||||
sizeFunc.sizeLocations
|
||||
(
|
||||
infoList[0],
|
||||
normals[0],
|
||||
extraPts,
|
||||
extraSizes
|
||||
);
|
||||
|
||||
pts.append(extraPts);
|
||||
sizes.append(extraSizes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::searchableSurfaceControl::cellSize
|
||||
(
|
||||
const Foam::point& pt,
|
||||
scalar& cellSize,
|
||||
label& priority
|
||||
) const
|
||||
{
|
||||
bool anyFunctionFound = false;
|
||||
|
||||
forAll(sizeFunctions(), funcI)
|
||||
{
|
||||
const cellSizeFunction& sizeFunc = sizeFunctions()[funcI];
|
||||
|
||||
if (sizeFunc.priority() < priority)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
scalar sizeI = -1;
|
||||
|
||||
if (sizeFunc.cellSize(pt, sizeI))
|
||||
{
|
||||
anyFunctionFound = true;
|
||||
|
||||
if (sizeFunc.priority() == priority)
|
||||
{
|
||||
if (sizeI < cellSize)
|
||||
{
|
||||
cellSize = sizeI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cellSize = sizeI;
|
||||
|
||||
priority = sizeFunc.priority();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< " sizeI " << sizeI
|
||||
<<" minSize " << cellSize << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return anyFunctionFound;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,146 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::searchableSurfaceControl
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
searchableSurfaceControl.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef searchableSurfaceControl_H
|
||||
#define searchableSurfaceControl_H
|
||||
|
||||
#include "cellSizeFunction.H"
|
||||
#include "triad.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceControl Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class searchableSurfaceControl
|
||||
:
|
||||
public cellSizeAndAlignmentControl
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Name of the surface
|
||||
const word surfaceName_;
|
||||
|
||||
//- Reference to the searchableSurface object holding the geometry data
|
||||
const searchableSurface& searchableSurface_;
|
||||
|
||||
const conformationSurfaces& geometryToConformTo_;
|
||||
|
||||
PtrList<cellSizeFunction> cellSizeFunctions_;
|
||||
|
||||
labelList regionToCellSizeFunctions_;
|
||||
|
||||
label maxPriority_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("searchableSurfaceControl");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary and references to conformalVoronoiMesh and
|
||||
// searchableSurfaces
|
||||
searchableSurfaceControl
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const dictionary& controlFunctionDict,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
searchableSurfaceControl(const searchableSurfaceControl&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~searchableSurfaceControl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual void cellSizeFunctionVertices
|
||||
(
|
||||
DynamicList<Foam::point>& pts,
|
||||
DynamicList<scalar>& sizes
|
||||
) const;
|
||||
|
||||
virtual void initialVertices
|
||||
(
|
||||
pointField& pts,
|
||||
scalarField& sizes,
|
||||
triadField& alignments
|
||||
) const;
|
||||
|
||||
const PtrList<cellSizeFunction>& sizeFunctions() const
|
||||
{
|
||||
return cellSizeFunctions_;
|
||||
}
|
||||
|
||||
virtual label maxPriority() const
|
||||
{
|
||||
return maxPriority_;
|
||||
}
|
||||
|
||||
bool cellSize
|
||||
(
|
||||
const Foam::point& pt,
|
||||
scalar& cellSize,
|
||||
label& priority
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const searchableSurfaceControl&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,779 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "controlMeshRefinement.H"
|
||||
#include "cellSizeAndAlignmentControl.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(controlMeshRefinement, 0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::controlMeshRefinement::calcFirstDerivative
|
||||
(
|
||||
const Foam::point& a,
|
||||
const scalar& cellSizeA,
|
||||
const Foam::point& b,
|
||||
const scalar& cellSizeB
|
||||
) const
|
||||
{
|
||||
return (cellSizeA - cellSizeB)/mag(a - b);
|
||||
}
|
||||
|
||||
|
||||
//Foam::scalar Foam::controlMeshRefinement::calcSecondDerivative
|
||||
//(
|
||||
// const Foam::point& a,
|
||||
// const scalar& cellSizeA,
|
||||
// const Foam::point& midPoint,
|
||||
// const scalar& cellSizeMid,
|
||||
// const Foam::point& b,
|
||||
// const scalar& cellSizeB
|
||||
//) const
|
||||
//{
|
||||
// return (cellSizeA - 2*cellSizeMid + cellSizeB)/magSqr((a - b)/2);
|
||||
//}
|
||||
|
||||
|
||||
bool Foam::controlMeshRefinement::detectEdge
|
||||
(
|
||||
const Foam::point& startPt,
|
||||
const Foam::point& endPt,
|
||||
pointHit& pointFound,
|
||||
const scalar tolSqr,
|
||||
const scalar secondDerivTolSqr
|
||||
) const
|
||||
{
|
||||
Foam::point a(startPt);
|
||||
Foam::point b(endPt);
|
||||
|
||||
Foam::point midPoint = (a + b)/2.0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (magSqr(a - b) < tolSqr)
|
||||
{
|
||||
pointFound.setPoint(midPoint);
|
||||
pointFound.setHit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Split into two regions
|
||||
|
||||
scalar cellSizeA = sizeControls_.cellSize(a);
|
||||
scalar cellSizeB = sizeControls_.cellSize(b);
|
||||
|
||||
// if (magSqr(cellSizeA - cellSizeB) < 1e-6)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
scalar cellSizeMid = sizeControls_.cellSize(midPoint);
|
||||
|
||||
// Region 1
|
||||
Foam::point midPoint1 = (a + midPoint)/2.0;
|
||||
const scalar cellSizeMid1 = sizeControls_.cellSize(midPoint1);
|
||||
|
||||
// scalar firstDerivative1 =
|
||||
// calcFirstDerivative(cellSizeA, cellSizeMid);
|
||||
|
||||
scalar secondDerivative1 =
|
||||
calcSecondDerivative
|
||||
(
|
||||
a,
|
||||
cellSizeA,
|
||||
midPoint1,
|
||||
cellSizeMid1,
|
||||
midPoint,
|
||||
cellSizeMid
|
||||
);
|
||||
|
||||
// Region 2
|
||||
Foam::point midPoint2 = (midPoint + b)/2.0;
|
||||
const scalar cellSizeMid2 = sizeControls_.cellSize(midPoint2);
|
||||
|
||||
// scalar firstDerivative2 =
|
||||
// calcFirstDerivative(f, cellSizeMid, cellSizeB);
|
||||
|
||||
scalar secondDerivative2 =
|
||||
calcSecondDerivative
|
||||
(
|
||||
midPoint,
|
||||
cellSizeMid,
|
||||
midPoint2,
|
||||
cellSizeMid2,
|
||||
b,
|
||||
cellSizeB
|
||||
);
|
||||
|
||||
// Neither region appears to have an inflection
|
||||
// To be sure should use higher order derivatives
|
||||
if
|
||||
(
|
||||
magSqr(secondDerivative1) < secondDerivTolSqr
|
||||
&& magSqr(secondDerivative2) < secondDerivTolSqr
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pick region with greatest second derivative
|
||||
if (magSqr(secondDerivative1) > magSqr(secondDerivative2))
|
||||
{
|
||||
b = midPoint;
|
||||
midPoint = midPoint1;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = midPoint;
|
||||
midPoint = midPoint2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::pointHit Foam::controlMeshRefinement::findDiscontinuities
|
||||
(
|
||||
const linePointRef& l
|
||||
) const
|
||||
{
|
||||
pointHit p(point::max);
|
||||
|
||||
const scalar tolSqr = sqr(1e-3);
|
||||
const scalar secondDerivTolSqr = sqr(1e-3);
|
||||
|
||||
detectEdge
|
||||
(
|
||||
l.start(),
|
||||
l.end(),
|
||||
p,
|
||||
tolSqr,
|
||||
secondDerivTolSqr
|
||||
);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::controlMeshRefinement::controlMeshRefinement
|
||||
(
|
||||
cellShapeControl& shapeController
|
||||
)
|
||||
:
|
||||
shapeController_(shapeController),
|
||||
mesh_(shapeController.shapeControlMesh()),
|
||||
sizeControls_(shapeController.sizeAndAlignment()),
|
||||
geometryToConformTo_(sizeControls_.geometryToConformTo())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::controlMeshRefinement::~controlMeshRefinement()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::controlMeshRefinement::initialMeshPopulation
|
||||
(
|
||||
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||
)
|
||||
{
|
||||
if (shapeController_.shapeControlMesh().vertexCount() > 0)
|
||||
{
|
||||
// Mesh already populated.
|
||||
Info<< "Cell size and alignment mesh already populated." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
autoPtr<boundBox> overallBoundBox;
|
||||
|
||||
// Need to pass in the background mesh decomposition so that can test if
|
||||
// a point to insert is on the processor.
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// overallBoundBox.set(new boundBox(decomposition().procBounds()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// overallBoundBox.set
|
||||
// (
|
||||
// new boundBox(geometryToConformTo_.geometry().bounds())
|
||||
// );
|
||||
//
|
||||
// mesh_.insertBoundingPoints
|
||||
// (
|
||||
// overallBoundBox(),
|
||||
// sizeControls_
|
||||
// );
|
||||
}
|
||||
|
||||
Map<label> priorityMap;
|
||||
|
||||
const PtrList<cellSizeAndAlignmentControl>& controlFunctions =
|
||||
sizeControls_.controlFunctions();
|
||||
|
||||
forAll(controlFunctions, fI)
|
||||
{
|
||||
const cellSizeAndAlignmentControl& controlFunction =
|
||||
controlFunctions[fI];
|
||||
|
||||
const Switch& forceInsertion =
|
||||
controlFunction.forceInitialPointInsertion();
|
||||
|
||||
Info<< "Inserting points from " << controlFunction.name()
|
||||
<< " (" << controlFunction.type() << ")" << endl;
|
||||
Info<< " Force insertion is " << forceInsertion.asText() << endl;
|
||||
|
||||
pointField pts;
|
||||
scalarField sizes;
|
||||
triadField alignments;
|
||||
|
||||
controlFunction.initialVertices(pts, sizes, alignments);
|
||||
|
||||
Info<< " Got initial vertices list of size " << pts.size() << endl;
|
||||
|
||||
List<Vb> vertices(pts.size());
|
||||
|
||||
// Clip the minimum size
|
||||
for (label vI = 0; vI < pts.size(); ++vI)
|
||||
{
|
||||
vertices[vI] = Vb(pts[vI], Vb::vtInternalNearBoundary);
|
||||
|
||||
label maxPriority = -1;
|
||||
scalar size = sizeControls_.cellSize(pts[vI], maxPriority);
|
||||
|
||||
if (maxPriority > controlFunction.maxPriority())
|
||||
{
|
||||
vertices[vI].targetCellSize() = max
|
||||
(
|
||||
size,
|
||||
shapeController_.minimumCellSize()
|
||||
);
|
||||
}
|
||||
// else if (maxPriority == controlFunction.maxPriority())
|
||||
// {
|
||||
// vertices[vI].targetCellSize() = max
|
||||
// (
|
||||
// min(sizes[vI], size),
|
||||
// shapeController_.minimumCellSize()
|
||||
// );
|
||||
// }
|
||||
else
|
||||
{
|
||||
vertices[vI].targetCellSize() = max
|
||||
(
|
||||
sizes[vI],
|
||||
shapeController_.minimumCellSize()
|
||||
);
|
||||
}
|
||||
|
||||
vertices[vI].alignment() = alignments[vI];
|
||||
}
|
||||
|
||||
Info<< " Clipped minimum size" << endl;
|
||||
|
||||
pts.clear();
|
||||
sizes.clear();
|
||||
alignments.clear();
|
||||
|
||||
PackedBoolList keepVertex(vertices.size(), true);
|
||||
|
||||
forAll(vertices, vI)
|
||||
{
|
||||
bool keep = true;
|
||||
|
||||
pointFromPoint pt = topoint(vertices[vI].point());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
keep = decomposition().positionOnThisProcessor(pt);
|
||||
}
|
||||
|
||||
if (keep && geometryToConformTo_.wellOutside(pt, small))
|
||||
{
|
||||
keep = false;
|
||||
}
|
||||
|
||||
if (!keep)
|
||||
{
|
||||
keepVertex[vI] = false;
|
||||
}
|
||||
}
|
||||
|
||||
inplaceSubset(keepVertex, vertices);
|
||||
|
||||
const label preInsertedSize = mesh_.number_of_vertices();
|
||||
|
||||
Info<< " Check sizes" << endl;
|
||||
|
||||
forAll(vertices, vI)
|
||||
{
|
||||
bool insertPoint = false;
|
||||
|
||||
pointFromPoint pt(topoint(vertices[vI].point()));
|
||||
|
||||
if
|
||||
(
|
||||
mesh_.dimension() < 3
|
||||
|| mesh_.is_infinite
|
||||
(
|
||||
mesh_.locate(vertices[vI].point())
|
||||
)
|
||||
)
|
||||
{
|
||||
insertPoint = true;
|
||||
}
|
||||
|
||||
const scalar interpolatedCellSize = shapeController_.cellSize(pt);
|
||||
const triad interpolatedAlignment =
|
||||
shapeController_.cellAlignment(pt);
|
||||
const scalar calculatedCellSize = vertices[vI].targetCellSize();
|
||||
const triad calculatedAlignment = vertices[vI].alignment();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Point = " << pt << nl
|
||||
<< " Size(interp) = " << interpolatedCellSize << nl
|
||||
<< " Size(calc) = " << calculatedCellSize << nl
|
||||
<< " Align(interp) = " << interpolatedAlignment << nl
|
||||
<< " Align(calc) = " << calculatedAlignment << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const scalar sizeDiff =
|
||||
mag(interpolatedCellSize - calculatedCellSize);
|
||||
const scalar alignmentDiff =
|
||||
diff(interpolatedAlignment, calculatedAlignment);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< " size difference = " << sizeDiff << nl
|
||||
<< ", alignment difference = " << alignmentDiff << endl;
|
||||
}
|
||||
|
||||
// TODO: Also need to base it on the alignments
|
||||
if
|
||||
(
|
||||
sizeDiff/interpolatedCellSize > 0.1
|
||||
|| alignmentDiff > 0.15
|
||||
)
|
||||
{
|
||||
insertPoint = true;
|
||||
}
|
||||
|
||||
if (forceInsertion || insertPoint)
|
||||
{
|
||||
const label oldSize = mesh_.vertexCount();
|
||||
|
||||
cellShapeControlMesh::Vertex_handle insertedVert = mesh_.insert
|
||||
(
|
||||
pt,
|
||||
calculatedCellSize,
|
||||
vertices[vI].alignment(),
|
||||
Vb::vtInternalNearBoundary
|
||||
);
|
||||
|
||||
if (oldSize == mesh_.vertexCount() - 1)
|
||||
{
|
||||
priorityMap.insert
|
||||
(
|
||||
insertedVert->index(),
|
||||
controlFunction.maxPriority()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mesh_.rangeInsertWithInfo(vertices.begin(), vertices.end());
|
||||
|
||||
Info<< " Inserted "
|
||||
<< returnReduce
|
||||
(
|
||||
label(mesh_.number_of_vertices()) - preInsertedSize,
|
||||
sumOp<label>()
|
||||
)
|
||||
<< "/" << returnReduce(vertices.size(), sumOp<label>())
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
forAll(controlFunctions, fI)
|
||||
{
|
||||
const cellSizeAndAlignmentControl& controlFunction =
|
||||
controlFunctions[fI];
|
||||
|
||||
const Switch& forceInsertion =
|
||||
controlFunction.forceInitialPointInsertion();
|
||||
|
||||
Info<< "Inserting points from " << controlFunction.name()
|
||||
<< " (" << controlFunction.type() << ")" << endl;
|
||||
Info<< " Force insertion is " << forceInsertion.asText() << endl;
|
||||
|
||||
DynamicList<Foam::point> extraPts;
|
||||
DynamicList<scalar> extraSizes;
|
||||
|
||||
controlFunction.cellSizeFunctionVertices(extraPts, extraSizes);
|
||||
|
||||
List<Vb> vertices(extraPts.size());
|
||||
|
||||
// Clip the minimum size
|
||||
for (label vI = 0; vI < extraPts.size(); ++vI)
|
||||
{
|
||||
vertices[vI] = Vb(extraPts[vI], Vb::vtUnassigned);
|
||||
|
||||
label maxPriority = -1;
|
||||
scalar size = sizeControls_.cellSize(extraPts[vI], maxPriority);
|
||||
|
||||
if (maxPriority > controlFunction.maxPriority())
|
||||
{
|
||||
vertices[vI].targetCellSize() = max
|
||||
(
|
||||
size,
|
||||
shapeController_.minimumCellSize()
|
||||
);
|
||||
}
|
||||
else if (maxPriority == controlFunction.maxPriority())
|
||||
{
|
||||
vertices[vI].targetCellSize() = max
|
||||
(
|
||||
min(extraSizes[vI], size),
|
||||
shapeController_.minimumCellSize()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
vertices[vI].targetCellSize() = max
|
||||
(
|
||||
extraSizes[vI],
|
||||
shapeController_.minimumCellSize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PackedBoolList keepVertex(vertices.size(), true);
|
||||
|
||||
forAll(vertices, vI)
|
||||
{
|
||||
bool keep = true;
|
||||
|
||||
pointFromPoint pt = topoint(vertices[vI].point());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
keep = decomposition().positionOnThisProcessor(pt);
|
||||
}
|
||||
|
||||
if (keep && geometryToConformTo_.wellOutside(pt, small))
|
||||
{
|
||||
keep = false;
|
||||
}
|
||||
|
||||
if (!keep)
|
||||
{
|
||||
keepVertex[vI] = false;
|
||||
}
|
||||
}
|
||||
|
||||
inplaceSubset(keepVertex, vertices);
|
||||
|
||||
const label preInsertedSize = mesh_.number_of_vertices();
|
||||
|
||||
forAll(vertices, vI)
|
||||
{
|
||||
bool insertPoint = false;
|
||||
|
||||
pointFromPoint pt(topoint(vertices[vI].point()));
|
||||
|
||||
if
|
||||
(
|
||||
mesh_.dimension() < 3
|
||||
|| mesh_.is_infinite
|
||||
(
|
||||
mesh_.locate(vertices[vI].point())
|
||||
)
|
||||
)
|
||||
{
|
||||
insertPoint = true;
|
||||
}
|
||||
|
||||
const scalar interpolatedCellSize = shapeController_.cellSize(pt);
|
||||
const scalar calculatedCellSize = vertices[vI].targetCellSize();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Point = " << pt << nl
|
||||
<< " Size(interp) = " << interpolatedCellSize << nl
|
||||
<< " Size(calc) = " << calculatedCellSize << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const scalar sizeDiff =
|
||||
mag(interpolatedCellSize - calculatedCellSize);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< " size difference = " << sizeDiff << endl;
|
||||
}
|
||||
|
||||
// TODO: Also need to base it on the alignments
|
||||
if (sizeDiff/interpolatedCellSize > 0.1)
|
||||
{
|
||||
insertPoint = true;
|
||||
}
|
||||
|
||||
if (forceInsertion || insertPoint)
|
||||
{
|
||||
// Check the priority
|
||||
|
||||
// cellShapeControlMesh::Cell_handle ch =
|
||||
// mesh_.locate(toPoint<cellShapeControlMesh::Point>(pt));
|
||||
|
||||
// if (mesh_.is_infinite(ch))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// const label newPtPriority = controlFunction.maxPriority();
|
||||
|
||||
// label highestPriority = -1;
|
||||
// for (label cI = 0; cI < 4; ++cI)
|
||||
// {
|
||||
// if (mesh_.is_infinite(ch->vertex(cI)))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// const label vertPriority =
|
||||
// priorityMap[ch->vertex(cI)->index()];
|
||||
|
||||
// if (vertPriority > highestPriority)
|
||||
// {
|
||||
// highestPriority = vertPriority;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (newPtPriority >= highestPriority)
|
||||
// {
|
||||
// const label oldSize = mesh_.vertexCount();
|
||||
//
|
||||
// cellShapeControlMesh::Vertex_handle insertedVert =
|
||||
mesh_.insert
|
||||
(
|
||||
pt,
|
||||
calculatedCellSize,
|
||||
vertices[vI].alignment(),
|
||||
Vb::vtInternal
|
||||
);
|
||||
|
||||
// if (oldSize == mesh_.vertexCount() - 1)
|
||||
// {
|
||||
// priorityMap.insert
|
||||
// (
|
||||
// insertedVert->index(),
|
||||
// newPtPriority
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// mesh_.rangeInsertWithInfo(vertices.begin(), vertices.end());
|
||||
|
||||
Info<< " Inserted extra points "
|
||||
<< returnReduce
|
||||
(
|
||||
label(mesh_.number_of_vertices()) - preInsertedSize,
|
||||
sumOp<label>()
|
||||
)
|
||||
<< "/" << returnReduce(vertices.size(), sumOp<label>())
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Change cell size function of bounding points to be consistent
|
||||
// with their nearest neighbours
|
||||
// for
|
||||
// (
|
||||
// CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||
// mesh_.finite_vertices_begin();
|
||||
// vit != mesh_.finite_vertices_end();
|
||||
// ++vit
|
||||
// )
|
||||
// {
|
||||
// if (vit->uninitialised())
|
||||
// {
|
||||
// // Get its adjacent vertices
|
||||
// std::list<CellSizeDelaunay::Vertex_handle> adjacentVertices;
|
||||
//
|
||||
// mesh_.adjacent_vertices
|
||||
// (
|
||||
// vit,
|
||||
// std::back_inserter(adjacentVertices)
|
||||
// );
|
||||
//
|
||||
// scalar totalCellSize = 0;
|
||||
// label nVerts = 0;
|
||||
//
|
||||
// for
|
||||
// (
|
||||
// std::list<CellSizeDelaunay::Vertex_handle>::iterator avit =
|
||||
// adjacentVertices.begin();
|
||||
// avit != adjacentVertices.end();
|
||||
// ++avit
|
||||
// )
|
||||
// {
|
||||
// if (!(*avit)->uninitialised())
|
||||
// {
|
||||
// totalCellSize += (*avit)->targetCellSize();
|
||||
// nVerts++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Pout<< "Changing " << vit->info();
|
||||
//
|
||||
// vit->targetCellSize() = totalCellSize/nVerts;
|
||||
// vit->type() = Vb::vtInternalNearBoundary;
|
||||
//
|
||||
// Pout<< "to " << vit->info() << endl;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::controlMeshRefinement::refineMesh
|
||||
(
|
||||
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||
)
|
||||
{
|
||||
Info<< "Iterate over "
|
||||
<< returnReduce(label(mesh_.number_of_finite_edges()), sumOp<label>())
|
||||
<< " cell size mesh edges" << endl;
|
||||
|
||||
DynamicList<Vb> verts(mesh_.number_of_vertices());
|
||||
|
||||
label count = 0;
|
||||
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_edges_iterator eit =
|
||||
mesh_.finite_edges_begin();
|
||||
eit != mesh_.finite_edges_end();
|
||||
++eit
|
||||
)
|
||||
{
|
||||
if (count % 10000 == 0)
|
||||
{
|
||||
Info<< count << " edges, inserted " << verts.size()
|
||||
<< " Time = " << mesh_.time().elapsedCpuTime()
|
||||
<< endl;
|
||||
}
|
||||
count++;
|
||||
|
||||
CellSizeDelaunay::Cell_handle c = eit->first;
|
||||
CellSizeDelaunay::Vertex_handle vA = c->vertex(eit->second);
|
||||
CellSizeDelaunay::Vertex_handle vB = c->vertex(eit->third);
|
||||
|
||||
if
|
||||
(
|
||||
mesh_.is_infinite(vA)
|
||||
|| mesh_.is_infinite(vB)
|
||||
|| (vA->referred() && vB->referred())
|
||||
|| (vA->referred() && (vA->procIndex() > vB->procIndex()))
|
||||
|| (vB->referred() && (vB->procIndex() > vA->procIndex()))
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pointFromPoint ptA(topoint(vA->point()));
|
||||
pointFromPoint ptB(topoint(vB->point()));
|
||||
|
||||
linePointRef l(ptA, ptB);
|
||||
|
||||
const pointHit hitPt = findDiscontinuities(l);
|
||||
|
||||
if (hitPt.hit())
|
||||
{
|
||||
const Foam::point& pt = hitPt.hitPoint();
|
||||
|
||||
if (!geometryToConformTo_.inside(pt))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (!decomposition().positionOnThisProcessor(pt))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
verts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
toPoint(pt),
|
||||
Vb::vtInternal
|
||||
)
|
||||
);
|
||||
|
||||
verts.last().targetCellSize() = sizeControls_.cellSize(pt);
|
||||
verts.last().alignment() = triad::unset;
|
||||
}
|
||||
}
|
||||
|
||||
mesh_.insertPoints(verts, false);
|
||||
|
||||
return verts.size();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,152 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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::controlMeshRefinement
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
controlMeshRefinementI.H
|
||||
controlMeshRefinement.C
|
||||
controlMeshRefinementIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef controlMeshRefinement_H
|
||||
#define controlMeshRefinement_H
|
||||
|
||||
#include "cellShapeControl.H"
|
||||
#include "cellShapeControlMesh.H"
|
||||
#include "cellSizeAndAlignmentControls.H"
|
||||
#include "conformationSurfaces.H"
|
||||
#include "backgroundMeshDecomposition.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class controlMeshRefinement Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class controlMeshRefinement
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const cellShapeControl& shapeController_;
|
||||
|
||||
cellShapeControlMesh& mesh_;
|
||||
|
||||
const cellSizeAndAlignmentControls& sizeControls_;
|
||||
|
||||
const conformationSurfaces& geometryToConformTo_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
scalar calcFirstDerivative
|
||||
(
|
||||
const Foam::point& a,
|
||||
const scalar& cellSizeA,
|
||||
const Foam::point& b,
|
||||
const scalar& cellSizeB
|
||||
) const;
|
||||
|
||||
scalar calcSecondDerivative
|
||||
(
|
||||
const Foam::point& a,
|
||||
const scalar& cellSizeA,
|
||||
const Foam::point& midPoint,
|
||||
const scalar& cellSizeMid,
|
||||
const Foam::point& b,
|
||||
const scalar& cellSizeB
|
||||
) const
|
||||
{
|
||||
return (cellSizeA - 2*cellSizeMid + cellSizeB)/magSqr((a - b)/2);
|
||||
}
|
||||
|
||||
|
||||
bool detectEdge
|
||||
(
|
||||
const Foam::point& startPt,
|
||||
const Foam::point& endPt,
|
||||
pointHit& pointFound,
|
||||
const scalar tolSqr,
|
||||
const scalar secondDerivTolSqr
|
||||
) const;
|
||||
|
||||
pointHit findDiscontinuities(const linePointRef& l) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("controlMeshRefinement");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
controlMeshRefinement(cellShapeControl& shapeController);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
controlMeshRefinement(const controlMeshRefinement&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~controlMeshRefinement();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Edit
|
||||
|
||||
void initialMeshPopulation
|
||||
(
|
||||
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||
);
|
||||
|
||||
label refineMesh
|
||||
(
|
||||
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||
);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const controlMeshRefinement&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,481 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2022 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 "smoothAlignmentSolver.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation, class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::smoothAlignmentSolver::filterFarPoints
|
||||
(
|
||||
const Triangulation& mesh,
|
||||
const Field<Type>& field
|
||||
)
|
||||
{
|
||||
tmp<Field<Type>> tNewField(new Field<Type>(field.size()));
|
||||
Field<Type>& newField = tNewField();
|
||||
|
||||
label added = 0;
|
||||
label count = 0;
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->real())
|
||||
{
|
||||
newField[added++] = field[count];
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
newField.resize(added);
|
||||
|
||||
return tNewField;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::autoPtr<Foam::distributionMap>
|
||||
Foam::smoothAlignmentSolver::buildReferredMap
|
||||
(
|
||||
const Triangulation& mesh,
|
||||
labelList& indices
|
||||
)
|
||||
{
|
||||
globalIndex globalIndexing(mesh.vertexCount());
|
||||
|
||||
DynamicList<label> dynIndices(mesh.vertexCount()/10);
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
dynIndices.append
|
||||
(
|
||||
globalIndexing.toGlobal(vit->procIndex(), vit->index())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
indices.transfer(dynIndices);
|
||||
|
||||
List<Map<label>> compactMap;
|
||||
return autoPtr<distributionMap>
|
||||
(
|
||||
new distributionMap
|
||||
(
|
||||
globalIndexing,
|
||||
indices,
|
||||
compactMap
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::autoPtr<Foam::distributionMap> Foam::smoothAlignmentSolver::buildMap
|
||||
(
|
||||
const Triangulation& mesh,
|
||||
labelListList& pointPoints
|
||||
)
|
||||
{
|
||||
pointPoints.setSize(mesh.vertexCount());
|
||||
|
||||
globalIndex globalIndexing(mesh.vertexCount());
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->real())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::list<typename Triangulation::Vertex_handle> adjVerts;
|
||||
mesh.finite_adjacent_vertices(vit, std::back_inserter(adjVerts));
|
||||
|
||||
DynamicList<label> indices(adjVerts.size());
|
||||
|
||||
for
|
||||
(
|
||||
typename std::list<typename Triangulation::Vertex_handle>::
|
||||
const_iterator adjVertI = adjVerts.begin();
|
||||
adjVertI != adjVerts.end();
|
||||
++adjVertI
|
||||
)
|
||||
{
|
||||
typename Triangulation::Vertex_handle vh = *adjVertI;
|
||||
|
||||
if (!vh->farPoint())
|
||||
{
|
||||
indices.append
|
||||
(
|
||||
globalIndexing.toGlobal(vh->procIndex(), vh->index())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pointPoints[vit->index()].transfer(indices);
|
||||
}
|
||||
|
||||
List<Map<label>> compactMap;
|
||||
return autoPtr<distributionMap>
|
||||
(
|
||||
new distributionMap
|
||||
(
|
||||
globalIndexing,
|
||||
pointPoints,
|
||||
compactMap
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::tmp<Foam::triadField> Foam::smoothAlignmentSolver::buildAlignmentField
|
||||
(
|
||||
const Triangulation& mesh
|
||||
)
|
||||
{
|
||||
tmp<triadField> tAlignments
|
||||
(
|
||||
new triadField(mesh.vertexCount(), triad::unset)
|
||||
);
|
||||
triadField& alignments = tAlignments.ref();
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->real())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
alignments[vit->index()] = vit->alignment();
|
||||
}
|
||||
|
||||
return tAlignments;
|
||||
}
|
||||
|
||||
|
||||
template<class Triangulation>
|
||||
Foam::tmp<Foam::pointField> Foam::smoothAlignmentSolver::buildPointField
|
||||
(
|
||||
const Triangulation& mesh
|
||||
)
|
||||
{
|
||||
tmp<pointField> tPoints
|
||||
(
|
||||
new pointField(mesh.vertexCount(), point(great, great, great))
|
||||
);
|
||||
pointField& points = tPoints.ref();
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit =
|
||||
mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!vit->real())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
points[vit->index()] = topoint(vit->point());
|
||||
}
|
||||
|
||||
return tPoints;
|
||||
}
|
||||
|
||||
|
||||
void Foam::smoothAlignmentSolver::applyBoundaryConditions
|
||||
(
|
||||
const triad& fixedAlignment,
|
||||
triad& t
|
||||
) const
|
||||
{
|
||||
label nFixed = 0;
|
||||
|
||||
forAll(fixedAlignment, dirI)
|
||||
{
|
||||
if (fixedAlignment.set(dirI))
|
||||
{
|
||||
nFixed++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFixed == 1)
|
||||
{
|
||||
forAll(fixedAlignment, dirI)
|
||||
{
|
||||
if (fixedAlignment.set(dirI))
|
||||
{
|
||||
t.align(fixedAlignment[dirI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nFixed == 2)
|
||||
{
|
||||
forAll(fixedAlignment, dirI)
|
||||
{
|
||||
if (fixedAlignment.set(dirI))
|
||||
{
|
||||
t[dirI] = fixedAlignment[dirI];
|
||||
}
|
||||
else
|
||||
{
|
||||
t[dirI] = triad::unset[dirI];
|
||||
}
|
||||
}
|
||||
|
||||
t.orthogonalise();
|
||||
}
|
||||
else if (nFixed == 3)
|
||||
{
|
||||
forAll(fixedAlignment, dirI)
|
||||
{
|
||||
if (fixedAlignment.set(dirI))
|
||||
{
|
||||
t[dirI] = fixedAlignment[dirI];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::smoothAlignmentSolver::smoothAlignmentSolver(cellShapeControlMesh& mesh)
|
||||
:
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::smoothAlignmentSolver::~smoothAlignmentSolver()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::smoothAlignmentSolver::smoothAlignments
|
||||
(
|
||||
const label maxSmoothingIterations
|
||||
)
|
||||
{
|
||||
scalar minResidual = 0;
|
||||
|
||||
labelListList pointPoints;
|
||||
autoPtr<distributionMap> meshDistributor = buildMap
|
||||
(
|
||||
mesh_,
|
||||
pointPoints
|
||||
);
|
||||
|
||||
triadField alignments(buildAlignmentField(mesh_));
|
||||
pointField points(buildPointField(mesh_));
|
||||
|
||||
// Setup the sizes and alignments on each point
|
||||
triadField fixedAlignments(mesh_.vertexCount(), triad::unset);
|
||||
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||
mesh_.finite_vertices_begin();
|
||||
vit != mesh_.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->real())
|
||||
{
|
||||
fixedAlignments[vit->index()] = vit->alignment();
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nl << "Smoothing alignments" << endl;
|
||||
|
||||
|
||||
for (label iter = 0; iter < maxSmoothingIterations; iter++)
|
||||
{
|
||||
Info<< "Iteration " << iter;
|
||||
|
||||
meshDistributor().distribute(points);
|
||||
meshDistributor().distribute(fixedAlignments);
|
||||
meshDistributor().distribute(alignments);
|
||||
|
||||
scalar residual = 0;
|
||||
|
||||
triadField triadAv(alignments.size(), triad::unset);
|
||||
|
||||
forAll(pointPoints, pI)
|
||||
{
|
||||
const labelList& pPoints = pointPoints[pI];
|
||||
|
||||
if (pPoints.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
triad& newTriad = triadAv[pI];
|
||||
|
||||
forAll(pPoints, adjPointi)
|
||||
{
|
||||
const label adjPointIndex = pPoints[adjPointi];
|
||||
|
||||
scalar dist = mag(points[pI] - points[adjPointIndex]);
|
||||
|
||||
triad tmpTriad = alignments[adjPointIndex];
|
||||
|
||||
for (direction dir = 0; dir < 3; dir++)
|
||||
{
|
||||
if (tmpTriad.set(dir))
|
||||
{
|
||||
tmpTriad[dir] *= 1.0/(dist + small);
|
||||
}
|
||||
}
|
||||
|
||||
newTriad += tmpTriad;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the alignment field
|
||||
forAll(alignments, pI)
|
||||
{
|
||||
const triad& oldTriad = alignments[pI];
|
||||
triad& newTriad = triadAv[pI];
|
||||
|
||||
newTriad.normalise();
|
||||
newTriad.orthogonalise();
|
||||
|
||||
// Enforce the boundary conditions
|
||||
const triad& fixedAlignment = fixedAlignments[pI];
|
||||
|
||||
applyBoundaryConditions
|
||||
(
|
||||
fixedAlignment,
|
||||
newTriad
|
||||
);
|
||||
|
||||
newTriad = newTriad.sortxyz();
|
||||
|
||||
// Residual Calculation
|
||||
for (direction dir = 0; dir < 3; ++dir)
|
||||
{
|
||||
if
|
||||
(
|
||||
newTriad.set(dir)
|
||||
&& oldTriad.set(dir)
|
||||
&& !fixedAlignment.set(dir)
|
||||
)
|
||||
{
|
||||
residual += diff(oldTriad, newTriad);
|
||||
}
|
||||
}
|
||||
|
||||
alignments[pI] = newTriad;
|
||||
}
|
||||
|
||||
reduce(residual, sumOp<scalar>());
|
||||
|
||||
Info<< ", Residual = "
|
||||
<< residual
|
||||
/returnReduce(points.size(), sumOp<label>())
|
||||
<< endl;
|
||||
|
||||
if (iter > 0 && residual <= minResidual)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
meshDistributor().distribute(alignments);
|
||||
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||
mesh_.finite_vertices_begin();
|
||||
vit != mesh_.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->real())
|
||||
{
|
||||
vit->alignment() = alignments[vit->index()];
|
||||
}
|
||||
}
|
||||
|
||||
labelList referredPoints;
|
||||
autoPtr<distributionMap> referredDistributor = buildReferredMap
|
||||
(
|
||||
mesh_,
|
||||
referredPoints
|
||||
);
|
||||
|
||||
alignments.setSize(mesh_.vertexCount());
|
||||
referredDistributor().distribute(alignments);
|
||||
|
||||
label referredI = 0;
|
||||
for
|
||||
(
|
||||
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||
mesh_.finite_vertices_begin();
|
||||
vit != mesh_.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->referred())
|
||||
{
|
||||
vit->alignment() = alignments[referredPoints[referredI++]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,133 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2022 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::smoothAlignmentSolver
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
smoothAlignmentSolverI.H
|
||||
smoothAlignmentSolver.C
|
||||
smoothAlignmentSolverIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef smoothAlignmentSolver_H
|
||||
#define smoothAlignmentSolver_H
|
||||
|
||||
#include "cellShapeControlMesh.H"
|
||||
#include "triadField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class smoothAlignmentSolver Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class smoothAlignmentSolver
|
||||
{
|
||||
// Private Data
|
||||
|
||||
cellShapeControlMesh& mesh_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
template<class Triangulation, class Type>
|
||||
tmp<Field<Type>> filterFarPoints
|
||||
(
|
||||
const Triangulation& mesh,
|
||||
const Field<Type>& field
|
||||
);
|
||||
|
||||
template<class Triangulation>
|
||||
autoPtr<distributionMap> buildMap
|
||||
(
|
||||
const Triangulation& mesh,
|
||||
labelListList& pointPoints
|
||||
);
|
||||
|
||||
template<class Triangulation>
|
||||
autoPtr<distributionMap> buildReferredMap
|
||||
(
|
||||
const Triangulation& mesh,
|
||||
labelList& indices
|
||||
);
|
||||
|
||||
template<class Triangulation>
|
||||
tmp<triadField> buildAlignmentField(const Triangulation& mesh);
|
||||
|
||||
template<class Triangulation>
|
||||
tmp<pointField> buildPointField(const Triangulation& mesh);
|
||||
|
||||
//- Apply the fixed alignments to the triad
|
||||
void applyBoundaryConditions
|
||||
(
|
||||
const triad& fixedAlignment,
|
||||
triad& t
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
smoothAlignmentSolver(cellShapeControlMesh& mesh);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
smoothAlignmentSolver(const smoothAlignmentSolver&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~smoothAlignmentSolver();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Edit
|
||||
|
||||
//- Smooth the alignments on the mesh
|
||||
void smoothAlignments(const label maxSmoothingIterations);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const smoothAlignmentSolver&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,166 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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 "cellSizeFunction.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellSizeFunction, 0);
|
||||
defineRunTimeSelectionTable(cellSizeFunction, dictionary);
|
||||
|
||||
scalar cellSizeFunction::snapToSurfaceTol_ = 1e-10;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellSizeFunction::cellSizeFunction
|
||||
(
|
||||
const word& type,
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
)
|
||||
:
|
||||
dictionary(cellSizeFunctionDict),
|
||||
surface_(surface),
|
||||
surfaceCellSizeFunction_
|
||||
(
|
||||
surfaceCellSizeFunction::New
|
||||
(
|
||||
cellSizeFunctionDict,
|
||||
surface,
|
||||
defaultCellSize
|
||||
)
|
||||
),
|
||||
coeffsDict_(optionalSubDict(type + "Coeffs")),
|
||||
defaultCellSize_(defaultCellSize),
|
||||
regionIndices_(regionIndices),
|
||||
sideMode_(),
|
||||
priority_(cellSizeFunctionDict.lookup<label>("priority", true))
|
||||
{
|
||||
word mode = cellSizeFunctionDict.lookup("mode", true);
|
||||
|
||||
if (surface_.hasVolumeType())
|
||||
{
|
||||
if (mode == "inside")
|
||||
{
|
||||
sideMode_ = smInside;
|
||||
}
|
||||
else if (mode == "outside")
|
||||
{
|
||||
sideMode_ = smOutside;
|
||||
}
|
||||
else if (mode == "bothSides")
|
||||
{
|
||||
sideMode_ = rmBothsides;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown mode, expected: inside, outside or bothSides" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mode != "bothSides")
|
||||
{
|
||||
WarningInFunction
|
||||
<< "surface does not support volumeType, defaulting mode to "
|
||||
<< "bothSides."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
sideMode_ = rmBothsides;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< nl
|
||||
<< "Cell size function for surface " << surface.name()
|
||||
<< ", " << mode
|
||||
<< ", priority = " << priority_
|
||||
<< ", regions = " << regionIndices_
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
|
||||
(
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
)
|
||||
{
|
||||
word cellSizeFunctionTypeName
|
||||
(
|
||||
cellSizeFunctionDict.lookup("cellSizeFunction")
|
||||
);
|
||||
|
||||
Info<< indent << "Selecting cellSizeFunction " << cellSizeFunctionTypeName
|
||||
<< endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(cellSizeFunctionTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown cellSizeFunction type "
|
||||
<< cellSizeFunctionTypeName
|
||||
<< endl << endl
|
||||
<< "Valid cellSizeFunction types are :" << endl
|
||||
<< dictionaryConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<cellSizeFunction>
|
||||
(
|
||||
cstrIter()
|
||||
(
|
||||
cellSizeFunctionDict,
|
||||
surface,
|
||||
defaultCellSize,
|
||||
regionIndices
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellSizeFunction::~cellSizeFunction()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,219 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::cellSizeFunction
|
||||
|
||||
Description
|
||||
Abstract base class for specifying target cell sizes
|
||||
|
||||
SourceFiles
|
||||
cellSizeFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cellSizeFunction_H
|
||||
#define cellSizeFunction_H
|
||||
|
||||
#include "point.H"
|
||||
#include "conformalVoronoiMesh.H"
|
||||
#include "searchableSurface.H"
|
||||
#include "dictionary.H"
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "surfaceCellSizeFunction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellSizeFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellSizeFunction
|
||||
:
|
||||
public dictionary
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Surface side mode
|
||||
enum sideMode
|
||||
{
|
||||
smInside, // Control inside the surface
|
||||
smOutside, // Control outside the surface
|
||||
rmBothsides // Control on both sides of a surface
|
||||
};
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cellSizeFunction");
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Static data
|
||||
|
||||
//- Point closeness tolerance to a surface where the function "snaps" to
|
||||
// including the surface
|
||||
static scalar snapToSurfaceTol_;
|
||||
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the searchableSurface that cellSizeFunction
|
||||
// relates to
|
||||
const searchableSurface& surface_;
|
||||
|
||||
//- Cell size at the surface
|
||||
scalarField surfaceCellSize_;
|
||||
|
||||
autoPtr<surfaceCellSizeFunction> surfaceCellSizeFunction_;
|
||||
|
||||
//- Method details dictionary
|
||||
dictionary coeffsDict_;
|
||||
|
||||
const scalar& defaultCellSize_;
|
||||
|
||||
//- Index of the region of the surface that this cell size function
|
||||
// applies to
|
||||
const labelList regionIndices_;
|
||||
|
||||
//- Mode of size specification, i.e. inside, outside or bothSides
|
||||
sideMode sideMode_;
|
||||
|
||||
label priority_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
cellSizeFunction,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
),
|
||||
(cellSizeFunctionDict, surface, defaultCellSize, regionIndices)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
cellSizeFunction
|
||||
(
|
||||
const word& type,
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
cellSizeFunction(const cellSizeFunction&) = delete;
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected cellSizeFunction
|
||||
static autoPtr<cellSizeFunction> New
|
||||
(
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cellSizeFunction();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Const access to the details dictionary
|
||||
inline const dictionary& coeffsDict() const
|
||||
{
|
||||
return coeffsDict_;
|
||||
}
|
||||
|
||||
virtual bool sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const = 0;
|
||||
|
||||
//- Modify scalar argument to the cell size specified by function.
|
||||
// Return a boolean specifying if the function was used, i.e. false if
|
||||
// the point was not in range of the surface for a spatially varying
|
||||
// size.
|
||||
virtual bool cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const = 0;
|
||||
|
||||
|
||||
virtual bool setCellSize
|
||||
(
|
||||
const pointField& pts
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Not overloaded."
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
label priority() const
|
||||
{
|
||||
return priority_;
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cellSizeFunction&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,256 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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 "linearDistance.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
#include "triSurfaceFields.H"
|
||||
#include "volumeType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(linearDistance, 0);
|
||||
addToRunTimeSelectionTable(cellSizeFunction, linearDistance, dictionary);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
linearDistance::linearDistance
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
)
|
||||
:
|
||||
cellSizeFunction
|
||||
(
|
||||
typeName,
|
||||
initialPointsDict,
|
||||
surface,
|
||||
defaultCellSize,
|
||||
regionIndices
|
||||
),
|
||||
distanceCellSize_
|
||||
(
|
||||
coeffsDict().lookup<scalar>("distanceCellSizeCoeff")
|
||||
*defaultCellSize
|
||||
),
|
||||
distance_
|
||||
(
|
||||
coeffsDict().lookup<scalar>("distanceCoeff")*defaultCellSize
|
||||
),
|
||||
distanceSqr_(sqr(distance_))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
scalar linearDistance::sizeFunction
|
||||
(
|
||||
const point& pt,
|
||||
scalar d,
|
||||
label index
|
||||
) const
|
||||
{
|
||||
const scalar interpolatedSize
|
||||
= surfaceCellSizeFunction_().interpolate(pt, index);
|
||||
|
||||
scalar gradient
|
||||
= (distanceCellSize_ - interpolatedSize)
|
||||
/distance_;
|
||||
|
||||
scalar size = gradient*d + interpolatedSize;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool linearDistance::sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const
|
||||
{
|
||||
const Foam::point& pt = hitPt.hitPoint();
|
||||
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
shapePts.resize(2);
|
||||
shapeSizes.resize(2);
|
||||
|
||||
shapePts[0] = pt - n*distance_;
|
||||
shapeSizes[0] = distanceCellSize_;
|
||||
|
||||
shapePts[1] = pt + n*distance_;
|
||||
shapeSizes[1] = distanceCellSize_;
|
||||
}
|
||||
else if (sideMode_ == smInside)
|
||||
{
|
||||
shapePts.resize(1);
|
||||
shapeSizes.resize(1);
|
||||
|
||||
shapePts[0] = pt - n*distance_;
|
||||
shapeSizes[0] = distanceCellSize_;
|
||||
}
|
||||
else if (sideMode_ == smOutside)
|
||||
{
|
||||
shapePts.resize(1);
|
||||
shapeSizes.resize(1);
|
||||
|
||||
shapePts[0] = pt + n*distance_;
|
||||
shapeSizes[0] = distanceCellSize_;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool linearDistance::cellSize(const point& pt, scalar& size) const
|
||||
{
|
||||
size = 0;
|
||||
|
||||
List<pointIndexHit> hits;
|
||||
|
||||
surface_.findNearest
|
||||
(
|
||||
pointField(1, pt),
|
||||
scalarField(1, distanceSqr_),
|
||||
regionIndices_,
|
||||
hits
|
||||
);
|
||||
|
||||
const pointIndexHit& hitInfo = hits[0];
|
||||
|
||||
if (hitInfo.hit())
|
||||
{
|
||||
const point& hitPt = hitInfo.hitPoint();
|
||||
const label hitIndex = hitInfo.index();
|
||||
|
||||
const scalar dist = mag(pt - hitPt);
|
||||
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
size = sizeFunction(hitPt, dist, hitIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the nearest point is essentially on the surface, do not do a
|
||||
// getVolumeType calculation, as it will be prone to error.
|
||||
if (dist < snapToSurfaceTol_)
|
||||
{
|
||||
size = sizeFunction(hitPt, 0, hitIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pointField ptF(1, pt);
|
||||
List<volumeType> vTL;
|
||||
|
||||
surface_.getVolumeType(ptF, vTL);
|
||||
|
||||
bool functionApplied = false;
|
||||
|
||||
if
|
||||
(
|
||||
sideMode_ == smInside
|
||||
&& vTL[0] == volumeType::inside
|
||||
)
|
||||
{
|
||||
size = sizeFunction(hitPt, dist, hitIndex);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
else if
|
||||
(
|
||||
sideMode_ == smOutside
|
||||
&& vTL[0] == volumeType::outside
|
||||
)
|
||||
{
|
||||
size = sizeFunction(hitPt, dist, hitIndex);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
|
||||
return functionApplied;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool linearDistance::setCellSize(const pointField& pts)
|
||||
{
|
||||
// labelHashSet surfaceAlreadyHit(surfaceCellSize_.size());
|
||||
|
||||
// forAll(pts, ptI)
|
||||
// {
|
||||
// const Foam::point& pt = pts[ptI];
|
||||
|
||||
// List<pointIndexHit> hits;
|
||||
|
||||
// surface_.findNearest
|
||||
// (
|
||||
// pointField(1, pt),
|
||||
// scalarField(1, distanceSqr_),
|
||||
// regionIndices_,
|
||||
// hits
|
||||
// );
|
||||
|
||||
// const label surfHitI = hits[0].index();
|
||||
|
||||
// if
|
||||
// (
|
||||
// hits[0].hit()
|
||||
// && !surfaceAlreadyHit.found(surfHitI)
|
||||
// )
|
||||
// {
|
||||
// // Halving cell size is arbitrary
|
||||
// surfaceCellSizeFunction_().refineSurfaceSize(surfHitI);
|
||||
|
||||
// surfaceAlreadyHit.insert(surfHitI);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,132 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::linearDistance
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
linearDistance.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef linearDistance_H
|
||||
#define linearDistance_H
|
||||
|
||||
#include "cellSizeFunction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class linearDistance Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class linearDistance
|
||||
:
|
||||
public cellSizeFunction
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Cell size at distance_ from the surface
|
||||
scalar distanceCellSize_;
|
||||
|
||||
//- Distance from the surface to control over
|
||||
scalar distance_;
|
||||
|
||||
//- Distance squared
|
||||
scalar distanceSqr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the cell size as a function of the given distance
|
||||
scalar sizeFunction(const point& pt, scalar d, label index) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("linearDistance");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
linearDistance
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~linearDistance()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
|
||||
virtual bool sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const;
|
||||
|
||||
//- Modify scalar argument to the cell size specified by function.
|
||||
// Return a boolean specifying if the function was used, i.e. false if
|
||||
// the point was not in range of the surface for a spatially varying
|
||||
// size.
|
||||
virtual bool cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const;
|
||||
|
||||
//- Adapt local cell size. Return true if anything changed.
|
||||
virtual bool setCellSize
|
||||
(
|
||||
const pointField& pts
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,180 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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 "linearSpatial.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "volumeType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(linearSpatial, 0);
|
||||
addToRunTimeSelectionTable(cellSizeFunction, linearSpatial, dictionary);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
linearSpatial::linearSpatial
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
)
|
||||
:
|
||||
cellSizeFunction
|
||||
(
|
||||
typeName,
|
||||
initialPointsDict,
|
||||
surface,
|
||||
defaultCellSize,
|
||||
regionIndices
|
||||
),
|
||||
referencePoint_(coeffsDict().lookup("referencePoint")),
|
||||
referenceCellSize_
|
||||
(
|
||||
coeffsDict().lookup<scalar>("referenceCellSizeCoeff")
|
||||
*defaultCellSize
|
||||
),
|
||||
direction_(coeffsDict().lookup("direction")),
|
||||
cellSizeGradient_(coeffsDict().lookup<scalar>("cellSizeGradient"))
|
||||
{
|
||||
direction_ /= mag(direction_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
scalar linearSpatial::sizeFunction(const point& pt) const
|
||||
{
|
||||
return
|
||||
referenceCellSize_
|
||||
+ ((pt - referencePoint_) & direction_)*cellSizeGradient_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool linearSpatial::sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const
|
||||
{
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
}
|
||||
else if (sideMode_ == smInside)
|
||||
{
|
||||
}
|
||||
else if (sideMode_ == smOutside)
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool linearSpatial::cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const
|
||||
{
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
size = sizeFunction(pt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size = 0;
|
||||
|
||||
List<pointIndexHit> hits;
|
||||
|
||||
surface_.findNearest
|
||||
(
|
||||
pointField(1, pt),
|
||||
scalarField(1, sqr(snapToSurfaceTol_)),
|
||||
regionIndices_,
|
||||
hits
|
||||
);
|
||||
|
||||
const pointIndexHit& hitInfo = hits[0];
|
||||
|
||||
// If the nearest point is essentially on the surface, do not do a
|
||||
// getVolumeType calculation, as it will be prone to error.
|
||||
if (hitInfo.hit())
|
||||
{
|
||||
size = sizeFunction(pt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pointField ptF(1, pt);
|
||||
List<volumeType> vTL;
|
||||
|
||||
surface_.getVolumeType(ptF, vTL);
|
||||
|
||||
bool functionApplied = false;
|
||||
|
||||
if
|
||||
(
|
||||
sideMode_ == smInside
|
||||
&& vTL[0] == volumeType::inside
|
||||
)
|
||||
{
|
||||
size = sizeFunction(pt);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
else if
|
||||
(
|
||||
sideMode_ == smOutside
|
||||
&& vTL[0] == volumeType::outside
|
||||
)
|
||||
{
|
||||
size = sizeFunction(pt);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
|
||||
return functionApplied;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,130 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::linearSpatial
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
linearSpatial.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef linearSpatial_H
|
||||
#define linearSpatial_H
|
||||
|
||||
#include "cellSizeFunction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class linearSpatial Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class linearSpatial
|
||||
:
|
||||
public cellSizeFunction
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Reference point for spatial size grading
|
||||
point referencePoint_;
|
||||
|
||||
//- Cell size at reference point
|
||||
scalar referenceCellSize_;
|
||||
|
||||
//- Direction of cell size grading, stored as unit vector, may be
|
||||
// supplied with any magnitude
|
||||
vector direction_;
|
||||
|
||||
//- Gradient of cell size change in direction of direction_
|
||||
scalar cellSizeGradient_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the cell size as a function of the given position
|
||||
scalar sizeFunction(const point& pt) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("linearSpatial");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
linearSpatial
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~linearSpatial()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
|
||||
virtual bool sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const;
|
||||
|
||||
//- Modify scalar argument to the cell size specified by function.
|
||||
// Return a boolean specifying if the function was used, i.e. false if
|
||||
// the point was not in range of the surface for a spatially varying
|
||||
// size.
|
||||
virtual bool cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,282 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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 "surfaceOffsetLinearDistance.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "volumeType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(surfaceOffsetLinearDistance, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
cellSizeFunction,
|
||||
surfaceOffsetLinearDistance,
|
||||
dictionary
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
surfaceOffsetLinearDistance::surfaceOffsetLinearDistance
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
)
|
||||
:
|
||||
cellSizeFunction
|
||||
(
|
||||
typeName,
|
||||
initialPointsDict,
|
||||
surface,
|
||||
defaultCellSize,
|
||||
regionIndices
|
||||
),
|
||||
distanceCellSize_
|
||||
(
|
||||
coeffsDict().lookup<scalar>("distanceCellSizeCoeff")
|
||||
*defaultCellSize
|
||||
),
|
||||
surfaceOffset_
|
||||
(
|
||||
coeffsDict().lookup<scalar>("surfaceOffsetCoeff")*defaultCellSize
|
||||
),
|
||||
totalDistance_(),
|
||||
totalDistanceSqr_()
|
||||
{
|
||||
if
|
||||
(
|
||||
coeffsDict().found("totalDistanceCoeff")
|
||||
|| coeffsDict().found("linearDistanceCoeff")
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
coeffsDict().found("totalDistanceCoeff")
|
||||
&& coeffsDict().found("linearDistanceCoeff")
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "totalDistanceCoeff and linearDistanceCoeff found, "
|
||||
<< "specify one or other, not both."
|
||||
<< nl << exit(FatalError) << endl;
|
||||
}
|
||||
|
||||
if (coeffsDict().found("totalDistanceCoeff"))
|
||||
{
|
||||
totalDistance_ =
|
||||
coeffsDict().lookup<scalar>("totalDistanceCoeff")
|
||||
*defaultCellSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
totalDistance_ =
|
||||
coeffsDict().lookup<scalar>("linearDistanceCoeff")
|
||||
*defaultCellSize
|
||||
+ surfaceOffset_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "totalDistanceCoeff or linearDistanceCoeff not found."
|
||||
<< nl << exit(FatalError) << endl;
|
||||
}
|
||||
|
||||
totalDistanceSqr_ = sqr(totalDistance_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
scalar surfaceOffsetLinearDistance::sizeFunction
|
||||
(
|
||||
const point& pt,
|
||||
scalar d,
|
||||
label index
|
||||
) const
|
||||
{
|
||||
const scalar interpolatedSize
|
||||
= surfaceCellSizeFunction_().interpolate(pt, index);
|
||||
|
||||
if (d <= surfaceOffset_)
|
||||
{
|
||||
return interpolatedSize;
|
||||
}
|
||||
|
||||
scalar gradient =
|
||||
(distanceCellSize_ - interpolatedSize)
|
||||
/(totalDistance_ - surfaceOffset_);
|
||||
|
||||
scalar intercept = interpolatedSize - gradient*surfaceOffset_;
|
||||
|
||||
return gradient*d + intercept;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool surfaceOffsetLinearDistance::sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const
|
||||
{
|
||||
const Foam::point& pt = hitPt.hitPoint();
|
||||
|
||||
const scalar offsetCellSize =
|
||||
surfaceCellSizeFunction_().interpolate(pt, hitPt.index());
|
||||
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
shapePts.resize(4);
|
||||
shapeSizes.resize(4);
|
||||
|
||||
shapePts[0] = pt - n*surfaceOffset_;
|
||||
shapeSizes[0] = offsetCellSize;
|
||||
shapePts[1] = pt - n*totalDistance_;
|
||||
shapeSizes[1] = distanceCellSize_;
|
||||
|
||||
shapePts[2] = pt + n*surfaceOffset_;
|
||||
shapeSizes[2] = offsetCellSize;
|
||||
shapePts[3] = pt + n*totalDistance_;
|
||||
shapeSizes[3] = distanceCellSize_;
|
||||
}
|
||||
else if (sideMode_ == smInside)
|
||||
{
|
||||
shapePts.resize(2);
|
||||
shapeSizes.resize(2);
|
||||
|
||||
shapePts[0] = pt - n*surfaceOffset_;
|
||||
shapeSizes[0] = offsetCellSize;
|
||||
shapePts[1] = pt - n*totalDistance_;
|
||||
shapeSizes[1] = distanceCellSize_;
|
||||
}
|
||||
else if (sideMode_ == smOutside)
|
||||
{
|
||||
shapePts.resize(2);
|
||||
shapeSizes.resize(2);
|
||||
|
||||
shapePts[0] = pt + n*surfaceOffset_;
|
||||
shapeSizes[0] = offsetCellSize;
|
||||
shapePts[1] = pt + n*totalDistance_;
|
||||
shapeSizes[1] = distanceCellSize_;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool surfaceOffsetLinearDistance::cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const
|
||||
{
|
||||
size = 0;
|
||||
|
||||
List<pointIndexHit> hits;
|
||||
|
||||
surface_.findNearest
|
||||
(
|
||||
pointField(1, pt),
|
||||
scalarField(1, totalDistanceSqr_),
|
||||
regionIndices_,
|
||||
hits
|
||||
);
|
||||
|
||||
const pointIndexHit& hitInfo = hits[0];
|
||||
|
||||
if (hitInfo.hit())
|
||||
{
|
||||
const point& hitPt = hitInfo.hitPoint();
|
||||
const label hitIndex = hitInfo.index();
|
||||
|
||||
const scalar dist = mag(pt - hitPt);
|
||||
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
size = sizeFunction(hitPt, dist, hitIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the nearest point is essentially on the surface, do not do a
|
||||
// getVolumeType calculation, as it will be prone to error.
|
||||
if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_)
|
||||
{
|
||||
size = sizeFunction(hitPt, 0, hitIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pointField ptF(1, pt);
|
||||
List<volumeType> vTL;
|
||||
|
||||
surface_.getVolumeType(ptF, vTL);
|
||||
|
||||
bool functionApplied = false;
|
||||
|
||||
if
|
||||
(
|
||||
sideMode_ == smInside
|
||||
&& vTL[0] == volumeType::inside
|
||||
)
|
||||
{
|
||||
size = sizeFunction(hitPt, dist, hitIndex);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
else if
|
||||
(
|
||||
sideMode_ == smOutside
|
||||
&& vTL[0] == volumeType::outside
|
||||
)
|
||||
{
|
||||
size = sizeFunction(hitPt, dist, hitIndex);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
|
||||
return functionApplied;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,129 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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::surfaceOffsetLinearDistance
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
surfaceOffsetLinearDistance.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceOffsetLinearDistance_H
|
||||
#define surfaceOffsetLinearDistance_H
|
||||
|
||||
#include "cellSizeFunction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceOffsetLinearDistance Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfaceOffsetLinearDistance
|
||||
:
|
||||
public cellSizeFunction
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Cell size at distance_ from the surface
|
||||
scalar distanceCellSize_;
|
||||
|
||||
//- Offset distance from surface for constant size portion
|
||||
scalar surfaceOffset_;
|
||||
|
||||
//- Total distance from the surface to control over (distance +
|
||||
// surfaceOffset)
|
||||
scalar totalDistance_;
|
||||
|
||||
//- totalDistance squared
|
||||
scalar totalDistanceSqr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the cell size as a function of the given distance
|
||||
scalar sizeFunction(const point& pt, scalar d, label index) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfaceOffsetLinearDistance");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
surfaceOffsetLinearDistance
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfaceOffsetLinearDistance()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual bool sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const;
|
||||
|
||||
//- Modify scalar argument to the cell size specified by function.
|
||||
// Return a boolean specifying if the function was used, i.e. false if
|
||||
// the point was not in range of the surface for a spatially varying
|
||||
// size.
|
||||
virtual bool cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,202 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "uniform.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "volumeType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(uniform, 0);
|
||||
addToRunTimeSelectionTable(cellSizeFunction, uniform, dictionary);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
uniform::uniform
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
)
|
||||
:
|
||||
cellSizeFunction
|
||||
(
|
||||
typeName,
|
||||
initialPointsDict,
|
||||
surface,
|
||||
defaultCellSize,
|
||||
regionIndices
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool uniform::sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const
|
||||
{
|
||||
shapePts.setSize(0);
|
||||
shapeSizes.setSize(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool uniform::cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const
|
||||
{
|
||||
List<pointIndexHit> hits;
|
||||
|
||||
surface_.findNearest
|
||||
(
|
||||
pointField(1, pt),
|
||||
scalarField(1, sqr(great)),
|
||||
regionIndices_,
|
||||
hits
|
||||
);
|
||||
|
||||
const pointIndexHit& hitInfo = hits[0];
|
||||
|
||||
if (hitInfo.hit())
|
||||
{
|
||||
const point& hitPt = hitInfo.hitPoint();
|
||||
const label index = hitInfo.index();
|
||||
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size = 0;
|
||||
|
||||
List<pointIndexHit> closeToSurfaceHits;
|
||||
|
||||
surface_.findNearest
|
||||
(
|
||||
pointField(1, pt),
|
||||
scalarField(1, sqr(snapToSurfaceTol_)),
|
||||
regionIndices_,
|
||||
closeToSurfaceHits
|
||||
);
|
||||
|
||||
const pointIndexHit& closeToSurface = closeToSurfaceHits[0];
|
||||
|
||||
// If the nearest point is essentially on the surface, do not do a
|
||||
// getVolumeType calculation, as it will be prone to error.
|
||||
if (closeToSurface.hit())
|
||||
{
|
||||
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pointField ptF(1, pt);
|
||||
List<volumeType> vTL(1);
|
||||
|
||||
surface_.getVolumeType(ptF, vTL);
|
||||
|
||||
bool functionApplied = false;
|
||||
|
||||
if
|
||||
(
|
||||
sideMode_ == smInside
|
||||
&& vTL[0] == volumeType::inside
|
||||
)
|
||||
{
|
||||
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
else if
|
||||
(
|
||||
sideMode_ == smOutside
|
||||
&& vTL[0] == volumeType::outside
|
||||
)
|
||||
{
|
||||
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
|
||||
return functionApplied;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool uniform::setCellSize
|
||||
(
|
||||
const pointField& pts
|
||||
)
|
||||
{
|
||||
// labelHashSet surfaceAlreadyHit(cellSize_.size());
|
||||
//
|
||||
// forAll(pts, ptI)
|
||||
// {
|
||||
// const Foam::point& pt = pts[ptI];
|
||||
//
|
||||
// List<pointIndexHit> hits;
|
||||
//
|
||||
// surface_.findNearest
|
||||
// (
|
||||
// pointField(1, pt),
|
||||
// scalarField(1, sqr(great)),
|
||||
// hits
|
||||
// );
|
||||
//
|
||||
// if (hits[0].hit() && !surfaceAlreadyHit.found(hits[0].index()))
|
||||
// {
|
||||
// surfaceCellSizeFunction_().refineCellSize(hits[0].index());
|
||||
//
|
||||
// surfaceAlreadyHit.insert(hits[0].index());
|
||||
// }
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,116 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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::uniform
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
uniform.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uniform_H
|
||||
#define uniform_H
|
||||
|
||||
#include "cellSizeFunction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uniform Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class uniform
|
||||
:
|
||||
public cellSizeFunction
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("uniform");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
uniform
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~uniform()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual bool sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const;
|
||||
|
||||
//- Modify scalar argument to the cell size specified by function.
|
||||
// Return a boolean specifying if the function was used, i.e. false if
|
||||
// the point was not in range of the surface for a spatially varying
|
||||
// size.
|
||||
virtual bool cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const;
|
||||
|
||||
//- Adapt local cell size. Return true if anything changed.
|
||||
virtual bool setCellSize
|
||||
(
|
||||
const pointField& pts
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,229 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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 "uniformDistance.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "volumeType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(uniformDistance, 0);
|
||||
addToRunTimeSelectionTable(cellSizeFunction, uniformDistance, dictionary);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
uniformDistance::uniformDistance
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
)
|
||||
:
|
||||
cellSizeFunction
|
||||
(
|
||||
typeName,
|
||||
initialPointsDict,
|
||||
surface,
|
||||
defaultCellSize,
|
||||
regionIndices
|
||||
),
|
||||
distance_
|
||||
(
|
||||
coeffsDict().lookup<scalar>("distanceCoeff")*defaultCellSize
|
||||
),
|
||||
distanceSqr_(sqr(distance_))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
bool uniformDistance::sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const
|
||||
{
|
||||
const Foam::point& pt = hitPt.hitPoint();
|
||||
|
||||
const scalar distanceCellSize =
|
||||
surfaceCellSizeFunction_().interpolate(pt, hitPt.index());
|
||||
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
shapePts.resize(2);
|
||||
shapeSizes.resize(2);
|
||||
|
||||
shapePts[0] = pt - n*distance_;
|
||||
shapeSizes[0] = distanceCellSize;
|
||||
|
||||
shapePts[1] = pt + n*distance_;
|
||||
shapeSizes[1] = distanceCellSize;
|
||||
}
|
||||
else if (sideMode_ == smInside)
|
||||
{
|
||||
shapePts.resize(1);
|
||||
shapeSizes.resize(1);
|
||||
|
||||
shapePts[0] = pt - n*distance_;
|
||||
shapeSizes[0] = distanceCellSize;
|
||||
}
|
||||
else if (sideMode_ == smOutside)
|
||||
{
|
||||
shapePts.resize(1);
|
||||
shapeSizes.resize(1);
|
||||
|
||||
shapePts[0] = pt - n*distance_;
|
||||
shapeSizes[0] = distanceCellSize;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool uniformDistance::cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const
|
||||
{
|
||||
size = 0;
|
||||
|
||||
List<pointIndexHit> hits;
|
||||
|
||||
surface_.findNearest
|
||||
(
|
||||
pointField(1, pt),
|
||||
scalarField(1, distanceSqr_),
|
||||
regionIndices_,
|
||||
hits
|
||||
);
|
||||
|
||||
const pointIndexHit& hitInfo = hits[0];
|
||||
|
||||
if (hitInfo.hit())
|
||||
{
|
||||
const point& hitPt = hitInfo.hitPoint();
|
||||
const label index = hitInfo.index();
|
||||
|
||||
if (sideMode_ == rmBothsides)
|
||||
{
|
||||
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the nearest point is essentially on the surface, do not do a
|
||||
// getVolumeType calculation, as it will be prone to error.
|
||||
if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_)
|
||||
{
|
||||
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pointField ptF(1, pt);
|
||||
List<volumeType> vTL;
|
||||
|
||||
surface_.getVolumeType(ptF, vTL);
|
||||
|
||||
bool functionApplied = false;
|
||||
|
||||
if
|
||||
(
|
||||
sideMode_ == smInside
|
||||
&& vTL[0] == volumeType::inside
|
||||
)
|
||||
{
|
||||
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
else if
|
||||
(
|
||||
sideMode_ == smOutside
|
||||
&& vTL[0] == volumeType::outside
|
||||
)
|
||||
{
|
||||
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||
|
||||
functionApplied = true;
|
||||
}
|
||||
|
||||
return functionApplied;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool uniformDistance::setCellSize
|
||||
(
|
||||
const pointField& pts
|
||||
)
|
||||
{
|
||||
// labelHashSet surfaceAlreadyHit(surface_.size());
|
||||
//
|
||||
// forAll(pts, ptI)
|
||||
// {
|
||||
// const Foam::point& pt = pts[ptI];
|
||||
//
|
||||
// List<pointIndexHit> hits;
|
||||
//
|
||||
// surface_.findNearest
|
||||
// (
|
||||
// pointField(1, pt),
|
||||
// scalarField(1, distanceSqr_),
|
||||
// regionIndices_,
|
||||
// hits
|
||||
// );
|
||||
//
|
||||
// if (hits[0].hit() && !surfaceAlreadyHit.found(hits[0].index()))
|
||||
// {
|
||||
// surfaceCellSizeFunction_().refineSurfaceSize(hits[0].index());
|
||||
//
|
||||
// surfaceAlreadyHit.insert(hits[0].index());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,122 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::uniformDistance
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
uniformDistance.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uniformDistance_H
|
||||
#define uniformDistance_H
|
||||
|
||||
#include "cellSizeFunction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uniformDistance Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class uniformDistance
|
||||
:
|
||||
public cellSizeFunction
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Distance
|
||||
scalar distance_;
|
||||
|
||||
//- Distance squared
|
||||
scalar distanceSqr_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("uniformDistance");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
uniformDistance
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize,
|
||||
const labelList regionIndices
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~uniformDistance()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual bool sizeLocations
|
||||
(
|
||||
const pointIndexHit& hitPt,
|
||||
const vector& n,
|
||||
pointField& shapePts,
|
||||
scalarField& shapeSizes
|
||||
) const;
|
||||
|
||||
//- Modify scalar argument to the cell size specified by function.
|
||||
// Return a boolean specifying if the function was used, i.e. false if
|
||||
// the point was not in range of the surface for a spatially varying
|
||||
// size.
|
||||
virtual bool cellSize
|
||||
(
|
||||
const point& pt,
|
||||
scalar& size
|
||||
) const;
|
||||
|
||||
//- Adapt local cell size. Return true if anything changed.
|
||||
virtual bool setCellSize
|
||||
(
|
||||
const pointField& pts
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,325 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2021 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 "automatic.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
#include "vtkSurfaceWriter.H"
|
||||
#include "primitivePatchInterpolation.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(automatic, 0);
|
||||
addToRunTimeSelectionTable(cellSizeCalculationType, automatic, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::automatic::smoothField(triSurfaceScalarField& surf)
|
||||
{
|
||||
label nSmoothingIterations = 10;
|
||||
|
||||
for (label iter = 0; iter < nSmoothingIterations; ++iter)
|
||||
{
|
||||
const pointField& faceCentres = surface_.faceCentres();
|
||||
|
||||
forAll(surf, sI)
|
||||
{
|
||||
const labelList& faceFaces = surface_.faceFaces()[sI];
|
||||
|
||||
const point& fC = faceCentres[sI];
|
||||
const scalar value = surf[sI];
|
||||
|
||||
scalar newValue = 0;
|
||||
scalar totalDist = 0;
|
||||
|
||||
label nFaces = 0;
|
||||
|
||||
forAll(faceFaces, fI)
|
||||
{
|
||||
const label faceLabel = faceFaces[fI];
|
||||
const point& faceCentre = faceCentres[faceLabel];
|
||||
|
||||
const scalar faceValue = surf[faceLabel];
|
||||
const scalar distance = mag(faceCentre - fC);
|
||||
|
||||
newValue += faceValue/(distance + small);
|
||||
|
||||
totalDist += 1.0/(distance + small);
|
||||
|
||||
if (value < faceValue)
|
||||
{
|
||||
nFaces++;
|
||||
}
|
||||
}
|
||||
|
||||
// Do not smooth out the peak values
|
||||
if (nFaces == faceFaces.size())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
surf[sI] = newValue/totalDist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::automatic::automatic
|
||||
(
|
||||
const dictionary& cellSizeCalcTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
cellSizeCalculationType
|
||||
(
|
||||
typeName,
|
||||
cellSizeCalcTypeDict,
|
||||
surface,
|
||||
defaultCellSize
|
||||
),
|
||||
coeffsDict_(cellSizeCalcTypeDict.optionalSubDict(typeName + "Coeffs")),
|
||||
surfaceName_(surface.searchableSurface::name()),
|
||||
readCurvature_(Switch(coeffsDict_.lookup("curvature"))),
|
||||
curvatureFile_(coeffsDict_.lookup("curvatureFile")),
|
||||
readFeatureProximity_(Switch(coeffsDict_.lookup("featureProximity"))),
|
||||
featureProximityFile_(coeffsDict_.lookup("featureProximityFile")),
|
||||
readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))),
|
||||
internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")),
|
||||
internalClosenessCellSizeCoeff_
|
||||
(
|
||||
coeffsDict_.lookup<scalar>("internalClosenessCellSizeCoeff")
|
||||
),
|
||||
curvatureCellSizeCoeff_
|
||||
(
|
||||
coeffsDict_.lookup<scalar>("curvatureCellSizeCoeff")
|
||||
),
|
||||
maximumCellSize_
|
||||
(
|
||||
coeffsDict_.lookup<scalar>("maximumCellSizeCoeff")*defaultCellSize
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
|
||||
{
|
||||
Info<< indent
|
||||
<< "Calculating cell size on surface: " << surfaceName_ << endl;
|
||||
|
||||
tmp<triSurfacePointScalarField> tPointCellSize
|
||||
(
|
||||
new triSurfacePointScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
surfaceName_ + ".cellSize",
|
||||
surface_.searchableSurface::time().constant(),
|
||||
searchableSurface::geometryDir
|
||||
(
|
||||
surface_.searchableSurface::time()
|
||||
),
|
||||
surface_.searchableSurface::time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surface_,
|
||||
dimLength,
|
||||
scalarField(surface_.nPoints(), maximumCellSize_)
|
||||
)
|
||||
);
|
||||
|
||||
triSurfacePointScalarField& pointCellSize = tPointCellSize.ref();
|
||||
|
||||
if (readCurvature_)
|
||||
{
|
||||
Info<< indent
|
||||
<< "Reading curvature : " << curvatureFile_ << endl;
|
||||
|
||||
triSurfacePointScalarField curvature
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
curvatureFile_,
|
||||
surface_.searchableSurface::time().constant(),
|
||||
searchableSurface::geometryDir
|
||||
(
|
||||
surface_.searchableSurface::time()
|
||||
),
|
||||
surface_.searchableSurface::time(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surface_,
|
||||
dimLength,
|
||||
true
|
||||
);
|
||||
|
||||
forAll(pointCellSize, pI)
|
||||
{
|
||||
pointCellSize[pI] =
|
||||
min
|
||||
(
|
||||
1.0
|
||||
/max
|
||||
(
|
||||
(1.0/curvatureCellSizeCoeff_)*mag(curvature[pI]),
|
||||
1.0/maximumCellSize_
|
||||
),
|
||||
pointCellSize[pI]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PrimitivePatchInterpolation
|
||||
<
|
||||
PrimitivePatch<::Foam::List<labelledTri>, pointField>
|
||||
>
|
||||
patchInterpolate(surface_);
|
||||
|
||||
const Map<label>& meshPointMap = surface_.meshPointMap();
|
||||
|
||||
if (readInternalCloseness_)
|
||||
{
|
||||
Info<< indent
|
||||
<< "Reading internal closeness: " << internalClosenessFile_ << endl;
|
||||
|
||||
triSurfacePointScalarField internalClosenessPointField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
internalClosenessFile_,
|
||||
surface_.searchableSurface::time().constant(),
|
||||
searchableSurface::geometryDir
|
||||
(
|
||||
surface_.searchableSurface::time()
|
||||
),
|
||||
surface_.searchableSurface::time(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surface_,
|
||||
dimLength,
|
||||
true
|
||||
);
|
||||
|
||||
forAll(pointCellSize, pI)
|
||||
{
|
||||
pointCellSize[pI] =
|
||||
min
|
||||
(
|
||||
(1.0/internalClosenessCellSizeCoeff_)
|
||||
*internalClosenessPointField[meshPointMap[pI]],
|
||||
pointCellSize[pI]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (readFeatureProximity_)
|
||||
{
|
||||
Info<< indent
|
||||
<< "Reading feature proximity : " << featureProximityFile_ << endl;
|
||||
|
||||
triSurfaceScalarField featureProximity
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
featureProximityFile_,
|
||||
surface_.searchableSurface::time().constant(),
|
||||
searchableSurface::geometryDir
|
||||
(
|
||||
surface_.searchableSurface::time()
|
||||
),
|
||||
surface_.searchableSurface::time(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surface_,
|
||||
dimLength,
|
||||
true
|
||||
);
|
||||
|
||||
scalarField featureProximityPointField
|
||||
(
|
||||
patchInterpolate.faceToPointInterpolate(featureProximity)
|
||||
);
|
||||
|
||||
forAll(pointCellSize, pI)
|
||||
{
|
||||
pointCellSize[pI] =
|
||||
min
|
||||
(
|
||||
featureProximityPointField[meshPointMap[pI]],
|
||||
pointCellSize[pI]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// smoothField(surfaceCellSize);
|
||||
|
||||
pointCellSize.write();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
faceList faces(surface_.size());
|
||||
|
||||
forAll(surface_, fI)
|
||||
{
|
||||
faces[fI] = surface_.triSurface::operator[](fI).triFaceFace();
|
||||
}
|
||||
|
||||
vtkSurfaceWriter
|
||||
(
|
||||
surface_.searchableSurface::time().writeFormat(),
|
||||
surface_.searchableSurface::time().writeCompression()
|
||||
).write
|
||||
(
|
||||
surface_.searchableSurface::time().constant()/
|
||||
searchableSurface::geometryDir
|
||||
(
|
||||
surface_.searchableSurface::time()
|
||||
),
|
||||
"cellSize_" + surfaceName_.lessExt().name(),
|
||||
surface_.points(),
|
||||
faces,
|
||||
true,
|
||||
"cellSize",
|
||||
pointCellSize
|
||||
);
|
||||
}
|
||||
|
||||
return tPointCellSize;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,131 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::automatic
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
automatic.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef automatic_H
|
||||
#define automatic_H
|
||||
|
||||
#include "cellSizeCalculationType.H"
|
||||
#include "triSurfaceFields.H"
|
||||
#include "PrimitivePatchInterpolation.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class triSurfaceMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class automatic Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class automatic
|
||||
:
|
||||
public cellSizeCalculationType
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Dictionary of coefficients for automatic cell sizing
|
||||
const dictionary& coeffsDict_;
|
||||
|
||||
//- Name of the surface. Used to write the cell size field
|
||||
const fileName surfaceName_;
|
||||
|
||||
const Switch readCurvature_;
|
||||
const word curvatureFile_;
|
||||
|
||||
const Switch readFeatureProximity_;
|
||||
const word featureProximityFile_;
|
||||
|
||||
const Switch readInternalCloseness_;
|
||||
const word internalClosenessFile_;
|
||||
|
||||
//- The internalCloseness values are multiplied by the inverse
|
||||
// of this value to get the cell size
|
||||
const scalar internalClosenessCellSizeCoeff_;
|
||||
|
||||
//- The curvature values are multiplied by the inverse of this value to
|
||||
// get the cell size
|
||||
const scalar curvatureCellSizeCoeff_;
|
||||
|
||||
//- The maximum allowable sell size
|
||||
const scalar maximumCellSize_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void smoothField(triSurfaceScalarField& surf);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("automatic");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
automatic
|
||||
(
|
||||
const dictionary& cellSizeCalcTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~automatic()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Load the cell size field
|
||||
virtual tmp<triSurfacePointScalarField> load();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,98 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "cellSizeCalculationType.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellSizeCalculationType, 0);
|
||||
defineRunTimeSelectionTable(cellSizeCalculationType, dictionary);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellSizeCalculationType::cellSizeCalculationType
|
||||
(
|
||||
const word& type,
|
||||
const dictionary& cellSizeCalculationTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
cellSizeCalculationTypeDict_(cellSizeCalculationTypeDict),
|
||||
surface_(surface),
|
||||
defaultCellSize_(defaultCellSize)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
|
||||
(
|
||||
const dictionary& cellSizeCalculationTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
{
|
||||
word cellSizeCalculationTypeTypeName
|
||||
(
|
||||
cellSizeCalculationTypeDict.lookup("cellSizeCalculationType")
|
||||
);
|
||||
|
||||
Info<< indent << "Selecting cellSizeCalculationType "
|
||||
<< cellSizeCalculationTypeTypeName << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(cellSizeCalculationTypeTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown cellSizeCalculationType type "
|
||||
<< cellSizeCalculationTypeTypeName
|
||||
<< endl << endl
|
||||
<< "Valid cellSizeCalculationType types are :" << endl
|
||||
<< dictionaryConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<cellSizeCalculationType>
|
||||
(
|
||||
cstrIter()(cellSizeCalculationTypeDict, surface, defaultCellSize)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellSizeCalculationType::~cellSizeCalculationType()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,139 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::cellSizeCalculationType
|
||||
|
||||
Description
|
||||
Abstract base class for specifying target cell sizes
|
||||
|
||||
SourceFiles
|
||||
cellSizeCalculationType.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cellSizeCalculationType_H
|
||||
#define cellSizeCalculationType_H
|
||||
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "triSurfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class triSurfaceMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellSizeCalculationType Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellSizeCalculationType
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
const dictionary& cellSizeCalculationTypeDict_;
|
||||
|
||||
//- Reference to the triSurfaceMesh
|
||||
const triSurfaceMesh& surface_;
|
||||
|
||||
const scalar& defaultCellSize_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cellSizeCalculationType");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
cellSizeCalculationType,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& cellSizeCalculationTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
),
|
||||
(cellSizeCalculationTypeDict, surface, defaultCellSize)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
cellSizeCalculationType
|
||||
(
|
||||
const word& type,
|
||||
const dictionary& cellSizeCalculationTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
cellSizeCalculationType(const cellSizeCalculationType&) = delete;
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected cellSizeCalculationType
|
||||
static autoPtr<cellSizeCalculationType> New
|
||||
(
|
||||
const dictionary& cellSizeCalculationTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cellSizeCalculationType();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Load the cell size
|
||||
virtual tmp<triSurfacePointScalarField> load() = 0;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cellSizeCalculationType&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,110 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2021 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 "fieldFromFile.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
#include "triSurfaceFields.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(fieldFromFile, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
cellSizeCalculationType,
|
||||
fieldFromFile,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldFromFile::fieldFromFile
|
||||
(
|
||||
const dictionary& cellSizeCalcTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
cellSizeCalculationType
|
||||
(
|
||||
typeName,
|
||||
cellSizeCalcTypeDict,
|
||||
surface,
|
||||
defaultCellSize
|
||||
),
|
||||
coeffsDict_(cellSizeCalcTypeDict.optionalSubDict(typeName + "Coeffs")),
|
||||
fileName_
|
||||
(
|
||||
cellSizeCalcTypeDict.optionalSubDict
|
||||
(
|
||||
typeName + "Coeffs"
|
||||
).lookup("fieldFile")
|
||||
),
|
||||
cellSizeMultipleCoeff_
|
||||
(
|
||||
coeffsDict_.lookupOrDefault<scalar>("cellSizeMultipleCoeff", 1)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::triSurfacePointScalarField> Foam::fieldFromFile::load()
|
||||
{
|
||||
Info<< indent << "Loading: " << fileName_ << endl;
|
||||
|
||||
tmp<triSurfacePointScalarField> pointCellSize
|
||||
(
|
||||
new triSurfacePointScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fileName_,
|
||||
surface_.searchableSurface::time().constant(),
|
||||
searchableSurface::geometryDir
|
||||
(
|
||||
surface_.searchableSurface::time()
|
||||
),
|
||||
surface_.searchableSurface::time(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surface_,
|
||||
dimLength,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
pointCellSize.ref() *= cellSizeMultipleCoeff_;
|
||||
|
||||
return pointCellSize;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,109 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::fieldFromFile
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
fieldFromFile.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fieldFromFile_H
|
||||
#define fieldFromFile_H
|
||||
|
||||
#include "cellSizeCalculationType.H"
|
||||
#include "triSurfaceFields.H"
|
||||
#include "PrimitivePatchInterpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class triSurfaceMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldFromFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldFromFile
|
||||
:
|
||||
public cellSizeCalculationType
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Dictionary of coefficients for automatic cell sizing
|
||||
const dictionary& coeffsDict_;
|
||||
|
||||
//- Name of the triSurfaceScalarField file to load in. Must be in
|
||||
// constant/triSurface
|
||||
const word fileName_;
|
||||
|
||||
//- Multiply all the point sizes by this value
|
||||
const scalar cellSizeMultipleCoeff_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fieldFromFile");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fieldFromFile
|
||||
(
|
||||
const dictionary& cellSizeCalcTypeDict,
|
||||
const triSurfaceMesh& surface,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldFromFile()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Load the cell size field
|
||||
virtual tmp<triSurfacePointScalarField> load();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,135 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2021 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 "nonUniformField.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
#include "searchableSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(nonUniformField, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
surfaceCellSizeFunction,
|
||||
nonUniformField,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::nonUniformField::nonUniformField
|
||||
(
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
surfaceCellSizeFunction
|
||||
(
|
||||
typeName,
|
||||
cellSizeFunctionDict,
|
||||
surface,
|
||||
defaultCellSize
|
||||
),
|
||||
surfaceTriMesh_(refCast<const triSurfaceMesh>(surface)),
|
||||
cellSizeCalculationType_
|
||||
(
|
||||
cellSizeCalculationType::New
|
||||
(
|
||||
coeffsDict(),
|
||||
surfaceTriMesh_,
|
||||
defaultCellSize
|
||||
)
|
||||
),
|
||||
pointCellSize_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pointCellSize.cellSize",
|
||||
surfaceTriMesh_.searchableSurface::time().constant(),
|
||||
searchableSurface::geometryDir
|
||||
(
|
||||
surfaceTriMesh_.searchableSurface::time()
|
||||
),
|
||||
surfaceTriMesh_.searchableSurface::time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surfaceTriMesh_,
|
||||
dimLength,
|
||||
false
|
||||
)
|
||||
{
|
||||
Info<< incrIndent;
|
||||
|
||||
pointCellSize_ = cellSizeCalculationType_().load();
|
||||
|
||||
Info<< indent << "Cell size field statistics:" << nl
|
||||
<< indent << " Minimum: " << min(pointCellSize_).value() << nl
|
||||
<< indent << " Average: " << average(pointCellSize_).value() << nl
|
||||
<< indent << " Maximum: " << max(pointCellSize_).value() << endl;
|
||||
|
||||
Info<< decrIndent;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::nonUniformField::interpolate
|
||||
(
|
||||
const point& pt,
|
||||
const label index
|
||||
) const
|
||||
{
|
||||
const face& faceHitByPt = surfaceTriMesh_.triSurface::operator[](index);
|
||||
|
||||
const pointField& pts = surfaceTriMesh_.points();
|
||||
// const Map<label>& pMap = surfaceTriMesh_.meshPointMap();
|
||||
|
||||
triPointRef tri
|
||||
(
|
||||
pts[faceHitByPt[0]],
|
||||
pts[faceHitByPt[1]],
|
||||
pts[faceHitByPt[2]]
|
||||
);
|
||||
|
||||
const barycentric2D bary = tri.pointToBarycentric(pt);
|
||||
|
||||
// return pointCellSize_[pMap[faceHitByPt[0]]]*bary[0]
|
||||
// + pointCellSize_[pMap[faceHitByPt[1]]]*bary[1]
|
||||
// + pointCellSize_[pMap[faceHitByPt[2]]]*bary[2];
|
||||
return pointCellSize_[faceHitByPt[0]]*bary[0]
|
||||
+ pointCellSize_[faceHitByPt[1]]*bary[1]
|
||||
+ pointCellSize_[faceHitByPt[2]]*bary[2];
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,123 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::nonUniformField
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
nonUniformField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef nonUniformField_H
|
||||
#define nonUniformField_H
|
||||
|
||||
#include "triSurfaceFields.H"
|
||||
#include "PrimitivePatchInterpolation.H"
|
||||
#include "surfaceCellSizeFunction.H"
|
||||
#include "cellSizeCalculationType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class triSurfaceMesh;
|
||||
class searchableSurface;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class nonUniformField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class nonUniformField
|
||||
:
|
||||
public surfaceCellSizeFunction
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Private Typedefs
|
||||
|
||||
typedef PrimitivePatchInterpolation
|
||||
<
|
||||
PrimitivePatch<List<labelledTri>, pointField>
|
||||
>
|
||||
primitivePatchInterpolation;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
const triSurfaceMesh& surfaceTriMesh_;
|
||||
|
||||
autoPtr<cellSizeCalculationType> cellSizeCalculationType_;
|
||||
|
||||
triSurfacePointScalarField pointCellSize_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("nonUniformField");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
nonUniformField
|
||||
(
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~nonUniformField()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Query
|
||||
|
||||
//- Return the interpolated cell size for a point in the given
|
||||
// surface triangle
|
||||
virtual scalar interpolate
|
||||
(
|
||||
const point& pt,
|
||||
const label index
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,102 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "surfaceCellSizeFunction.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(surfaceCellSizeFunction, 0);
|
||||
defineRunTimeSelectionTable(surfaceCellSizeFunction, dictionary);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfaceCellSizeFunction::surfaceCellSizeFunction
|
||||
(
|
||||
const word& type,
|
||||
const dictionary& surfaceCellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
dictionary(surfaceCellSizeFunctionDict),
|
||||
surface_(surface),
|
||||
coeffsDict_(optionalSubDict(type + "Coeffs")),
|
||||
defaultCellSize_(defaultCellSize),
|
||||
refinementFactor_
|
||||
(
|
||||
lookupOrDefault<scalar>("refinementFactor", 1.0)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
|
||||
(
|
||||
const dictionary& surfaceCellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
{
|
||||
word surfaceCellSizeFunctionTypeName
|
||||
(
|
||||
surfaceCellSizeFunctionDict.lookup("surfaceCellSizeFunction")
|
||||
);
|
||||
|
||||
Info<< indent << "Selecting surfaceCellSizeFunction "
|
||||
<< surfaceCellSizeFunctionTypeName << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(surfaceCellSizeFunctionTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown surfaceCellSizeFunction type "
|
||||
<< surfaceCellSizeFunctionTypeName
|
||||
<< endl << endl
|
||||
<< "Valid surfaceCellSizeFunction types are :" << endl
|
||||
<< dictionaryConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<surfaceCellSizeFunction>
|
||||
(
|
||||
cstrIter()(surfaceCellSizeFunctionDict, surface, defaultCellSize)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfaceCellSizeFunction::~surfaceCellSizeFunction()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,156 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::surfaceCellSizeFunction
|
||||
|
||||
Description
|
||||
Abstract base class for specifying target cell sizes
|
||||
|
||||
SourceFiles
|
||||
surfaceCellSizeFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceCellSizeFunction_H
|
||||
#define surfaceCellSizeFunction_H
|
||||
|
||||
#include "searchableSurface.H"
|
||||
#include "dictionary.H"
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceCellSizeFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfaceCellSizeFunction
|
||||
:
|
||||
public dictionary
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the searchableSurface that surfaceCellSizeFunction
|
||||
// relates to
|
||||
const searchableSurface& surface_;
|
||||
|
||||
const dictionary coeffsDict_;
|
||||
|
||||
const scalar& defaultCellSize_;
|
||||
|
||||
//- If cell resizing is allowed, this is the factor of the old cell size
|
||||
// to get the new cell size
|
||||
scalar refinementFactor_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfaceCellSizeFunction");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
surfaceCellSizeFunction,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& surfaceCellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
),
|
||||
(surfaceCellSizeFunctionDict, surface, defaultCellSize)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
surfaceCellSizeFunction
|
||||
(
|
||||
const word& type,
|
||||
const dictionary& surfaceCellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
surfaceCellSizeFunction(const surfaceCellSizeFunction&) = delete;
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected surfaceCellSizeFunction
|
||||
static autoPtr<surfaceCellSizeFunction> New
|
||||
(
|
||||
const dictionary& surfaceCellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfaceCellSizeFunction();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Const access to the details dictionary
|
||||
inline const dictionary& coeffsDict() const
|
||||
{
|
||||
return coeffsDict_;
|
||||
}
|
||||
|
||||
virtual scalar interpolate
|
||||
(
|
||||
const point& pt,
|
||||
const label index
|
||||
) const = 0;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const surfaceCellSizeFunction&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,78 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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 "uniformValue.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(uniformValue, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
surfaceCellSizeFunction,
|
||||
uniformValue,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::uniformValue::uniformValue
|
||||
(
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
)
|
||||
:
|
||||
surfaceCellSizeFunction
|
||||
(
|
||||
typeName,
|
||||
cellSizeFunctionDict,
|
||||
surface,
|
||||
defaultCellSize
|
||||
),
|
||||
surfaceCellSize_
|
||||
(
|
||||
coeffsDict().lookup<scalar>("surfaceCellSizeCoeff")*defaultCellSize
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::uniformValue::interpolate
|
||||
(
|
||||
const point& pt,
|
||||
const label index
|
||||
) const
|
||||
{
|
||||
return surfaceCellSize_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,100 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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::uniformValue
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
uniformValue.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uniformValue_H
|
||||
#define uniformValue_H
|
||||
|
||||
#include "surfaceCellSizeFunction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uniformValue Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class uniformValue
|
||||
:
|
||||
public surfaceCellSizeFunction
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
scalar surfaceCellSize_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("uniformValue");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
uniformValue
|
||||
(
|
||||
const dictionary& cellSizeFunctionDict,
|
||||
const searchableSurface& surface,
|
||||
const scalar& defaultCellSize
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~uniformValue()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual scalar interpolate
|
||||
(
|
||||
const point& pt,
|
||||
const label index
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,65 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2022 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/>.
|
||||
|
||||
Typedefs
|
||||
CGALTriangulation3DKernel
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CGALTriangulation3DKernel_H
|
||||
#define CGALTriangulation3DKernel_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "CGAL/Delaunay_triangulation_3.h"
|
||||
|
||||
#ifdef CGAL_INEXACT
|
||||
|
||||
// Fast kernel using a double as the storage type but the triangulation may
|
||||
// fail. Adding robust circumcentre traits.
|
||||
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel baseK;
|
||||
|
||||
// #include "CGAL/Robust_circumcenter_traits_3.h"
|
||||
// typedef CGAL::Robust_circumcenter_traits_3<baseK> K;
|
||||
|
||||
#include "CGAL/Robust_weighted_circumcenter_filtered_traits_3.h"
|
||||
typedef CGAL::Robust_weighted_circumcenter_filtered_traits_3<baseK> K;
|
||||
|
||||
#else
|
||||
|
||||
// Very robust but expensive kernel
|
||||
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel baseK;
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,61 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
Typedefs
|
||||
CGALTriangulation3Ddefs
|
||||
|
||||
Description
|
||||
CGAL data structures used for 3D Delaunay meshing.
|
||||
|
||||
Define CGAL_INEXACT to use Exact_predicates_inexact_constructions kernel
|
||||
otherwise the more robust but much less efficient
|
||||
Exact_predicates_exact_constructions will be used.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CGALTriangulation3Ddefs_H
|
||||
#define CGALTriangulation3Ddefs_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "CGALTriangulation3DKernel.H"
|
||||
|
||||
#include "indexedVertex.H"
|
||||
#include "indexedCell.H"
|
||||
|
||||
typedef CGAL::indexedVertex<K> Vb;
|
||||
typedef CGAL::indexedCell<K> Cb;
|
||||
|
||||
typedef CGAL::Compact_location CompactLocator;
|
||||
typedef CGAL::Fast_location FastLocator;
|
||||
|
||||
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> Tds;
|
||||
typedef CGAL::Delaunay_triangulation_3<K, Tds, CompactLocator> Delaunay;
|
||||
typedef CGAL::Delaunay_triangulation_3<K, Tds, FastLocator> CellSizeDelaunay;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,578 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2022 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 "indexedVertexOps.H"
|
||||
#include "indexedCellOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::defaultCellSize() const
|
||||
{
|
||||
return foamyHexMeshControls().defaultCellSize();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::targetCellSize
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
return cellShapeControls().cellSize(pt);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::averageAnyCellSize
|
||||
(
|
||||
const Vertex_handle& vA,
|
||||
const Vertex_handle& vB
|
||||
) const
|
||||
{
|
||||
if
|
||||
(
|
||||
(!vA->internalOrBoundaryPoint() || vA->referred())
|
||||
&& (!vB->internalOrBoundaryPoint() || vB->referred())
|
||||
)
|
||||
{
|
||||
// There are no internalOrBoundaryPoints available, determine
|
||||
// size from scratch
|
||||
|
||||
// Geometric mean
|
||||
return sqrt
|
||||
(
|
||||
targetCellSize(topoint(vA->point()))
|
||||
*targetCellSize(topoint(vB->point()))
|
||||
);
|
||||
}
|
||||
else if (!vB->internalOrBoundaryPoint() || vB->referred())
|
||||
{
|
||||
return vA->targetCellSize();
|
||||
}
|
||||
else if (!vA->internalOrBoundaryPoint() || vA->referred())
|
||||
{
|
||||
return vB->targetCellSize();
|
||||
}
|
||||
|
||||
return CGAL::indexedVertexOps::averageCellSize(vA, vB);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::averageAnyCellSize
|
||||
(
|
||||
const Delaunay::Finite_facets_iterator& fit
|
||||
) const
|
||||
{
|
||||
// Arithmetic mean
|
||||
|
||||
scalar sizeSum = 0;
|
||||
|
||||
label nProducts = 0;
|
||||
|
||||
const Cell_handle c(fit->first);
|
||||
const label oppositeVertex = fit->second;
|
||||
|
||||
for (label i = 0; i < 3; i++)
|
||||
{
|
||||
Vertex_handle v = c->vertex(vertex_triple_index(oppositeVertex, i));
|
||||
|
||||
if (v->internalOrBoundaryPoint() && !v->referred())
|
||||
{
|
||||
|
||||
sizeSum += v->targetCellSize();
|
||||
|
||||
nProducts++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nProducts < 1)
|
||||
{
|
||||
// There are no internalOrBoundaryPoints available, determine
|
||||
// size from scratch
|
||||
|
||||
for (label i = 0; i < 3; i++)
|
||||
{
|
||||
Vertex_handle v = c->vertex(vertex_triple_index(oppositeVertex, i));
|
||||
|
||||
sizeSum += targetCellSize(topoint(v->point()));
|
||||
}
|
||||
|
||||
nProducts = 3;
|
||||
}
|
||||
|
||||
if (sizeSum < 0)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "sizeSum = " << sizeSum
|
||||
<< endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pow(sizeSum, (1.0/nProducts));
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::pointPairDistance
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
return targetCellSize(pt)*foamyHexMeshControls().pointPairDistanceCoeff();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::mixedFeaturePointDistance
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
return
|
||||
pointPairDistance(pt)
|
||||
*foamyHexMeshControls().mixedFeaturePointPPDistanceCoeff();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::featurePointExclusionDistanceSqr
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
return
|
||||
sqr
|
||||
(
|
||||
targetCellSize(pt)
|
||||
*foamyHexMeshControls().featurePointExclusionDistanceCoeff()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::featureEdgeExclusionDistanceSqr
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
return
|
||||
sqr
|
||||
(
|
||||
targetCellSize(pt)
|
||||
*foamyHexMeshControls().featureEdgeExclusionDistanceCoeff()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::surfacePtExclusionDistanceSqr
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
return
|
||||
sqr
|
||||
(
|
||||
targetCellSize(pt)
|
||||
*foamyHexMeshControls().surfacePtExclusionDistanceCoeff()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::surfaceSearchDistanceSqr
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
return
|
||||
sqr
|
||||
(
|
||||
targetCellSize(pt)
|
||||
*foamyHexMeshControls().surfaceSearchDistanceCoeff()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::conformalVoronoiMesh::maxSurfaceProtrusion
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
return
|
||||
targetCellSize(pt)
|
||||
*foamyHexMeshControls().maxSurfaceProtrusionCoeff();
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::conformalVoronoiMesh::createPointPair
|
||||
(
|
||||
const scalar ppDist,
|
||||
const Foam::point& surfPt,
|
||||
const vector& n,
|
||||
const bool ptPair,
|
||||
DynamicList<Vb>& pts
|
||||
) const
|
||||
{
|
||||
vector ppDistn = ppDist*n;
|
||||
|
||||
// const Foam::point internalPt = surfPt - ppDistn;
|
||||
// const Foam::point externalPt = surfPt + ppDistn;
|
||||
|
||||
// bool internalInside = geometryToConformTo_.inside(internalPt);
|
||||
// bool externalOutside = geometryToConformTo_.outside(externalPt);
|
||||
|
||||
// if (internalInside && externalOutside)
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
surfPt - ppDistn,
|
||||
vertexCount() + pts.size(),
|
||||
Vb::vtInternalSurface,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
surfPt + ppDistn,
|
||||
vertexCount() + pts.size(),
|
||||
Vb::vtExternalSurface,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
if (ptPair)
|
||||
{
|
||||
ptPairs_.addPointPair
|
||||
(
|
||||
pts[pts.size() - 2].index(),
|
||||
pts[pts.size() - 1].index() // external 0 -> slave
|
||||
);
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// Info<< "Warning: point pair not inside/outside" << nl
|
||||
// << " surfPt = " << surfPt << nl
|
||||
// << " internal = " << internalPt << " " << internalInside << nl
|
||||
// << " external = " << externalPt << " " << externalOutside
|
||||
// << endl;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
inline Foam::point Foam::conformalVoronoiMesh::perturbPoint
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
Foam::point perturbedPt(pt);
|
||||
|
||||
// vector delta(xR/ni, yR/nj, zR/nk);
|
||||
// scalar pert = randomPerturbationCoeff*cmptMin(delta);
|
||||
|
||||
scalar pert = 1e-12*defaultCellSize();
|
||||
|
||||
perturbedPt.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
perturbedPt.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
perturbedPt.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
|
||||
return perturbedPt;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::conformalVoronoiMesh::createBafflePointPair
|
||||
(
|
||||
const scalar ppDist,
|
||||
const Foam::point& surfPt,
|
||||
const vector& n,
|
||||
const bool ptPair,
|
||||
DynamicList<Vb>& pts
|
||||
) const
|
||||
{
|
||||
vector ppDistn = ppDist*n;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
surfPt - ppDistn,
|
||||
vertexCount() + pts.size(),
|
||||
Vb::vtInternalSurfaceBaffle,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
surfPt + ppDistn,
|
||||
vertexCount() + pts.size(),
|
||||
Vb::vtExternalSurfaceBaffle,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
if (ptPair)
|
||||
{
|
||||
ptPairs_.addPointPair
|
||||
(
|
||||
pts[pts.size() - 2].index(), // external 0 -> slave
|
||||
pts[pts.size() - 1].index()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::conformalVoronoiMesh::internalPointIsInside
|
||||
(
|
||||
const Foam::point& pt
|
||||
) const
|
||||
{
|
||||
if
|
||||
(
|
||||
!geometryToConformTo_.globalBounds().contains(pt)
|
||||
|| !geometryToConformTo_.inside(pt)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::conformalVoronoiMesh::isBoundaryDualFace
|
||||
(
|
||||
const Delaunay::Finite_edges_iterator& eit
|
||||
) const
|
||||
{
|
||||
Cell_handle c = eit->first;
|
||||
Vertex_handle vA = c->vertex(eit->second);
|
||||
Vertex_handle vB = c->vertex(eit->third);
|
||||
|
||||
// if (vA->internalBoundaryPoint() && vB->externalBoundaryPoint())
|
||||
// {
|
||||
// if (vA->index() == vB->index() - 1)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// else if (vA->externalBoundaryPoint() && vB->internalBoundaryPoint())
|
||||
// {
|
||||
// if (vA->index() == vB->index() + 1)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
|
||||
// A dual face on the boundary will result from one Dv inside and
|
||||
// one outside
|
||||
return
|
||||
(
|
||||
(
|
||||
(vA->internalOrBoundaryPoint() && !vA->referred())
|
||||
|| (vB->internalOrBoundaryPoint() && !vB->referred())
|
||||
)
|
||||
&& (
|
||||
!vA->internalOrBoundaryPoint()
|
||||
|| !vB->internalOrBoundaryPoint()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::List<bool> Foam::conformalVoronoiMesh::dualFaceBoundaryPoints
|
||||
(
|
||||
const Delaunay::Finite_edges_iterator& eit
|
||||
) const
|
||||
{
|
||||
Cell_circulator ccStart = incident_cells(*eit);
|
||||
Cell_circulator cc1 = ccStart;
|
||||
Cell_circulator cc2 = cc1;
|
||||
|
||||
// Advance the second circulator so that it always stays on the next
|
||||
// cell around the edge;
|
||||
cc2++;
|
||||
|
||||
DynamicList<bool> tmpFaceBoundaryPoints;
|
||||
|
||||
do
|
||||
{
|
||||
label cc1I = cc1->cellIndex();
|
||||
|
||||
label cc2I = cc2->cellIndex();
|
||||
|
||||
if (cc1I != cc2I)
|
||||
{
|
||||
if (cc1->boundaryDualVertex())
|
||||
{
|
||||
tmpFaceBoundaryPoints.append(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpFaceBoundaryPoints.append(false);
|
||||
}
|
||||
}
|
||||
|
||||
cc1++;
|
||||
|
||||
cc2++;
|
||||
|
||||
} while (cc1 != ccStart);
|
||||
|
||||
return Foam::move(tmpFaceBoundaryPoints);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached
|
||||
(
|
||||
const Delaunay::Finite_facets_iterator& fit
|
||||
) const
|
||||
{
|
||||
DynamicList<label> procsAttached(8);
|
||||
|
||||
const Cell_handle c1(fit->first);
|
||||
const label oppositeVertex = fit->second;
|
||||
const Cell_handle c2(c1->neighbor(oppositeVertex));
|
||||
|
||||
FixedList<label, 4> c1Procs(CGAL::indexedCellOps::processorsAttached(c1));
|
||||
|
||||
FixedList<label, 4> c2Procs(CGAL::indexedCellOps::processorsAttached(c2));
|
||||
|
||||
forAll(c1Procs, aPI)
|
||||
{
|
||||
if (findIndex(procsAttached, c1Procs[aPI] == -1))
|
||||
{
|
||||
procsAttached.append(c1Procs[aPI]);
|
||||
}
|
||||
|
||||
if (findIndex(procsAttached, c2Procs[aPI] == -1))
|
||||
{
|
||||
procsAttached.append(c2Procs[aPI]);
|
||||
}
|
||||
}
|
||||
|
||||
return List<label>(procsAttached);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::conformalVoronoiMesh::isParallelDualEdge
|
||||
(
|
||||
const Delaunay::Finite_facets_iterator& fit
|
||||
) const
|
||||
{
|
||||
const Cell_handle c1(fit->first);
|
||||
const label oppositeVertex = fit->second;
|
||||
|
||||
return
|
||||
(
|
||||
c1->vertex(vertex_triple_index(oppositeVertex, 0))->referred()
|
||||
|| c1->vertex(vertex_triple_index(oppositeVertex, 1))->referred()
|
||||
|| c1->vertex(vertex_triple_index(oppositeVertex, 2))->referred()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::conformalVoronoiMesh::isProcBoundaryEdge
|
||||
(
|
||||
const Delaunay::Finite_edges_iterator& eit
|
||||
) const
|
||||
{
|
||||
bool isProcBoundaryEdge = false;
|
||||
|
||||
Cell_handle c = eit->first;
|
||||
Vertex_handle vA = c->vertex(eit->second);
|
||||
Vertex_handle vB = c->vertex(eit->third);
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
(vA->referred() && !vB->referred())
|
||||
|| (vB->referred() && !vA->referred())
|
||||
)
|
||||
&& vA->internalOrBoundaryPoint()
|
||||
&& vB->internalOrBoundaryPoint()
|
||||
)
|
||||
{
|
||||
isProcBoundaryEdge = true;
|
||||
}
|
||||
|
||||
return isProcBoundaryEdge;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::Time& Foam::conformalVoronoiMesh::time() const
|
||||
{
|
||||
return runTime_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::searchableSurfaces&
|
||||
Foam::conformalVoronoiMesh::allGeometry() const
|
||||
{
|
||||
return allGeometry_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::conformationSurfaces&
|
||||
Foam::conformalVoronoiMesh::geometryToConformTo() const
|
||||
{
|
||||
return geometryToConformTo_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::backgroundMeshDecomposition&
|
||||
Foam::conformalVoronoiMesh::decomposition() const
|
||||
{
|
||||
if (!Pstream::parRun())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "The backgroundMeshDecomposition cannot be asked for in serial."
|
||||
<< exit(FatalError) << endl;
|
||||
}
|
||||
|
||||
return decomposition_();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::cellShapeControl&
|
||||
Foam::conformalVoronoiMesh::cellShapeControls() const
|
||||
{
|
||||
return cellShapeControl_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::cvControls&
|
||||
Foam::conformalVoronoiMesh::foamyHexMeshControls() const
|
||||
{
|
||||
return foamyHexMeshControls_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,148 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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 "conformalVoronoiMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Triangulation>
|
||||
bool Foam::conformalVoronoiMesh::distributeBackground(const Triangulation& mesh)
|
||||
{
|
||||
if (!Pstream::parRun())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Info<< nl << "Redistributing points" << endl;
|
||||
|
||||
timeCheck("Before distribute");
|
||||
|
||||
label iteration = 0;
|
||||
|
||||
scalar previousLoadUnbalance = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
scalar maxLoadUnbalance = mesh.calculateLoadUnbalance();
|
||||
|
||||
if
|
||||
(
|
||||
maxLoadUnbalance <= foamyHexMeshControls().maxLoadUnbalance()
|
||||
|| maxLoadUnbalance <= previousLoadUnbalance
|
||||
)
|
||||
{
|
||||
// If this is the first iteration, return false, if it was a
|
||||
// subsequent one, return true;
|
||||
return iteration != 0;
|
||||
}
|
||||
|
||||
previousLoadUnbalance = maxLoadUnbalance;
|
||||
|
||||
Info<< " Total number of vertices before redistribution "
|
||||
<< returnReduce(label(mesh.number_of_vertices()), sumOp<label>())
|
||||
<< endl;
|
||||
|
||||
const fvMesh& bMesh = decomposition_().mesh();
|
||||
|
||||
volScalarField cellWeights
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cellWeights",
|
||||
bMesh.time().name(),
|
||||
bMesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
bMesh,
|
||||
dimensionedScalar(dimless, 1e-2),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
meshSearch cellSearch(bMesh, polyMesh::FACE_PLANES);
|
||||
|
||||
labelList cellVertices(bMesh.nCells(), label(0));
|
||||
|
||||
for
|
||||
(
|
||||
typename Triangulation::Finite_vertices_iterator vit
|
||||
= mesh.finite_vertices_begin();
|
||||
vit != mesh.finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
// Only store real vertices that are not feature vertices
|
||||
if (vit->real() && !vit->featurePoint())
|
||||
{
|
||||
pointFromPoint v = topoint(vit->point());
|
||||
|
||||
label celli = cellSearch.findCell(v);
|
||||
|
||||
if (celli == -1)
|
||||
{
|
||||
// Pout<< "findCell conformalVoronoiMesh::distribute "
|
||||
// << "findCell "
|
||||
// << vit->type() << " "
|
||||
// << vit->index() << " "
|
||||
// << v << " "
|
||||
// << celli
|
||||
// << " find nearest celli ";
|
||||
|
||||
celli = cellSearch.findNearestCell(v);
|
||||
}
|
||||
|
||||
cellVertices[celli]++;
|
||||
}
|
||||
}
|
||||
|
||||
scalarField& cwi = cellWeights.primitiveFieldRef();
|
||||
|
||||
forAll(cellVertices, cI)
|
||||
{
|
||||
// Give a small but finite weight for empty cells. Some
|
||||
// decomposition methods have difficulty with integer overflows in
|
||||
// the sum of the normalised weight field.
|
||||
cwi[cI] = max(cellVertices[cI], 1e-2);
|
||||
}
|
||||
|
||||
autoPtr<polyDistributionMap> mapDist = decomposition_().distribute
|
||||
(
|
||||
cellWeights
|
||||
);
|
||||
|
||||
cellShapeControl_.shapeControlMesh().distribute(decomposition_);
|
||||
|
||||
distribute();
|
||||
|
||||
timeCheck("After distribute");
|
||||
|
||||
iteration++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,702 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2022 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 "conformalVoronoiMesh.H"
|
||||
#include "polyModifyFace.H"
|
||||
#include "polyModifyCell.H"
|
||||
#include "syncTools.H"
|
||||
#include "regionSplit.H"
|
||||
#include "surfaceZonesInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::conformalVoronoiMesh::calcNeighbourCellCentres
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const pointField& cellCentres,
|
||||
pointField& neiCc
|
||||
) const
|
||||
{
|
||||
label nBoundaryFaces = mesh.nFaces() - mesh.nInternalFaces();
|
||||
|
||||
if (neiCc.size() != nBoundaryFaces)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "nBoundaries:" << nBoundaryFaces
|
||||
<< " neiCc:" << neiCc.size()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
|
||||
const labelUList& faceCells = pp.faceCells();
|
||||
|
||||
label bFacei = pp.start() - mesh.nInternalFaces();
|
||||
|
||||
if (pp.coupled())
|
||||
{
|
||||
forAll(faceCells, i)
|
||||
{
|
||||
neiCc[bFacei] = cellCentres[faceCells[i]];
|
||||
bFacei++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Swap coupled boundaries. Apply separation to cc since is coordinate.
|
||||
syncTools::swapBoundaryFacePositions(mesh, neiCc);
|
||||
}
|
||||
|
||||
|
||||
void Foam::conformalVoronoiMesh::selectSeparatedCoupledFaces
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
boolList& selected
|
||||
) const
|
||||
{
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
if (isA<coupledPolyPatch>(patches[patchi]))
|
||||
{
|
||||
const coupledPolyPatch& cpp =
|
||||
refCast<const coupledPolyPatch>(patches[patchi]);
|
||||
|
||||
if (cpp.transform().transformsPosition())
|
||||
{
|
||||
forAll(cpp, i)
|
||||
{
|
||||
selected[cpp.start()+i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::conformalVoronoiMesh::findCellZoneInsideWalk
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& locationSurfaces, // indices of surfaces with inside point
|
||||
const labelList& faceToSurface, // per face index of named surface
|
||||
labelList& cellToSurface
|
||||
) const
|
||||
{
|
||||
// Analyse regions. Reuse regionsplit
|
||||
boolList blockedFace(mesh.nFaces());
|
||||
selectSeparatedCoupledFaces(mesh, blockedFace);
|
||||
|
||||
forAll(faceToSurface, facei)
|
||||
{
|
||||
if (faceToSurface[facei] == -1)
|
||||
{
|
||||
blockedFace[facei] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
blockedFace[facei] = true;
|
||||
}
|
||||
}
|
||||
// No need to sync since namedSurfaceIndex already is synced
|
||||
|
||||
// Set region per cell based on walking
|
||||
regionSplit cellRegion(mesh, blockedFace);
|
||||
blockedFace.clear();
|
||||
|
||||
|
||||
// Force calculation of face decomposition (used in findCell)
|
||||
(void)mesh.tetBasePtIs();
|
||||
|
||||
const PtrList<surfaceZonesInfo>& surfZones =
|
||||
geometryToConformTo().surfZones();
|
||||
|
||||
// For all locationSurface find the cell
|
||||
forAll(locationSurfaces, i)
|
||||
{
|
||||
label surfI = locationSurfaces[i];
|
||||
|
||||
const Foam::point& insidePoint = surfZones[surfI].zoneInsidePoint();
|
||||
|
||||
const word& surfName = geometryToConformTo().geometry().names()[surfI];
|
||||
|
||||
Info<< " For surface " << surfName
|
||||
<< " finding inside point " << insidePoint
|
||||
<< endl;
|
||||
|
||||
// Find the region containing the insidePoint
|
||||
label keepRegionI = -1;
|
||||
|
||||
label celli = mesh.findCell(insidePoint);
|
||||
|
||||
if (celli != -1)
|
||||
{
|
||||
keepRegionI = cellRegion[celli];
|
||||
}
|
||||
reduce(keepRegionI, maxOp<label>());
|
||||
|
||||
Info<< " For surface " << surfName
|
||||
<< " found point " << insidePoint << " in cell " << celli
|
||||
<< " in global region " << keepRegionI
|
||||
<< " out of " << cellRegion.nRegions() << " regions." << endl;
|
||||
|
||||
if (keepRegionI == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Point " << insidePoint
|
||||
<< " is not inside the mesh." << nl
|
||||
<< "Bounding box of the mesh:" << mesh.bounds()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Set all cells with this region
|
||||
forAll(cellRegion, celli)
|
||||
{
|
||||
if (cellRegion[celli] == keepRegionI)
|
||||
{
|
||||
if (cellToSurface[celli] == -2)
|
||||
{
|
||||
cellToSurface[celli] = surfI;
|
||||
}
|
||||
else if (cellToSurface[celli] != surfI)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Cell " << celli
|
||||
<< " at " << mesh.cellCentres()[celli]
|
||||
<< " is inside surface " << surfName
|
||||
<< " but already marked as being in zone "
|
||||
<< cellToSurface[celli] << endl
|
||||
<< "This can happen if your surfaces are not"
|
||||
<< " (sufficiently) closed."
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList Foam::conformalVoronoiMesh::calcCellZones
|
||||
(
|
||||
const pointField& cellCentres
|
||||
) const
|
||||
{
|
||||
labelList cellToSurface(cellCentres.size(), label(-1));
|
||||
|
||||
const PtrList<surfaceZonesInfo>& surfZones =
|
||||
geometryToConformTo().surfZones();
|
||||
|
||||
// Get list of closed surfaces
|
||||
labelList closedNamedSurfaces
|
||||
(
|
||||
surfaceZonesInfo::getAllClosedNamedSurfaces
|
||||
(
|
||||
surfZones,
|
||||
geometryToConformTo().geometry(),
|
||||
geometryToConformTo().surfaces()
|
||||
)
|
||||
);
|
||||
|
||||
forAll(closedNamedSurfaces, i)
|
||||
{
|
||||
label surfI = closedNamedSurfaces[i];
|
||||
|
||||
const searchableSurface& surface =
|
||||
allGeometry()[geometryToConformTo().surfaces()[surfI]];
|
||||
|
||||
const surfaceZonesInfo::areaSelectionAlgo selectionMethod =
|
||||
surfZones[surfI].zoneInside();
|
||||
|
||||
if
|
||||
(
|
||||
selectionMethod != surfaceZonesInfo::INSIDE
|
||||
&& selectionMethod != surfaceZonesInfo::OUTSIDE
|
||||
&& selectionMethod != surfaceZonesInfo::INSIDEPOINT
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Trying to use surface "
|
||||
<< surface.name()
|
||||
<< " which has non-geometric inside selection method "
|
||||
<< surfaceZonesInfo::areaSelectionAlgoNames[selectionMethod]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (surface.hasVolumeType())
|
||||
{
|
||||
List<volumeType> volType;
|
||||
surface.getVolumeType(cellCentres, volType);
|
||||
|
||||
bool selectInside = true;
|
||||
if (selectionMethod == surfaceZonesInfo::INSIDEPOINT)
|
||||
{
|
||||
List<volumeType> volTypeInsidePoint;
|
||||
surface.getVolumeType
|
||||
(
|
||||
pointField(1, surfZones[surfI].zoneInsidePoint()),
|
||||
volTypeInsidePoint
|
||||
);
|
||||
|
||||
if (volTypeInsidePoint[0] == volumeType::outside)
|
||||
{
|
||||
selectInside = false;
|
||||
}
|
||||
}
|
||||
else if (selectionMethod == surfaceZonesInfo::OUTSIDE)
|
||||
{
|
||||
selectInside = false;
|
||||
}
|
||||
|
||||
forAll(volType, pointi)
|
||||
{
|
||||
if (cellToSurface[pointi] == -1)
|
||||
{
|
||||
if
|
||||
(
|
||||
(
|
||||
volType[pointi] == volumeType::inside
|
||||
&& selectInside
|
||||
)
|
||||
|| (
|
||||
volType[pointi] == volumeType::outside
|
||||
&& !selectInside
|
||||
)
|
||||
)
|
||||
{
|
||||
cellToSurface[pointi] = surfI;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cellToSurface;
|
||||
}
|
||||
|
||||
|
||||
void Foam::conformalVoronoiMesh::calcFaceZones
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const pointField& cellCentres,
|
||||
const labelList& cellToSurface,
|
||||
labelList& faceToSurface,
|
||||
boolList& flipMap
|
||||
) const
|
||||
{
|
||||
faceToSurface.setSize(mesh.nFaces(), -1);
|
||||
flipMap.setSize(mesh.nFaces(), false);
|
||||
|
||||
const faceList& faces = mesh.faces();
|
||||
const labelList& faceOwner = mesh.faceOwner();
|
||||
const labelList& faceNeighbour = mesh.faceNeighbour();
|
||||
|
||||
labelList neiFaceOwner(mesh.nFaces() - mesh.nInternalFaces(), label(-1));
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
|
||||
const labelUList& faceCells = pp.faceCells();
|
||||
|
||||
label bFacei = pp.start() - mesh.nInternalFaces();
|
||||
|
||||
if (pp.coupled())
|
||||
{
|
||||
forAll(faceCells, i)
|
||||
{
|
||||
neiFaceOwner[bFacei] = cellToSurface[faceCells[i]];
|
||||
bFacei++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syncTools::swapBoundaryFaceList(mesh, neiFaceOwner);
|
||||
|
||||
forAll(faces, facei)
|
||||
{
|
||||
const label ownerSurfacei = cellToSurface[faceOwner[facei]];
|
||||
|
||||
if (faceToSurface[facei] >= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
const label neiSurfacei = cellToSurface[faceNeighbour[facei]];
|
||||
|
||||
if
|
||||
(
|
||||
(ownerSurfacei >= 0 || neiSurfacei >= 0)
|
||||
&& ownerSurfacei != neiSurfacei
|
||||
)
|
||||
{
|
||||
flipMap[facei] =
|
||||
(
|
||||
ownerSurfacei == max(ownerSurfacei, neiSurfacei)
|
||||
? false
|
||||
: true
|
||||
);
|
||||
|
||||
faceToSurface[facei] = max(ownerSurfacei, neiSurfacei);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label patchID = mesh.boundaryMesh().whichPatch(facei);
|
||||
|
||||
if (mesh.boundaryMesh()[patchID].coupled())
|
||||
{
|
||||
const label neiSurfacei =
|
||||
neiFaceOwner[facei - mesh.nInternalFaces()];
|
||||
|
||||
if
|
||||
(
|
||||
(ownerSurfacei >= 0 || neiSurfacei >= 0)
|
||||
&& ownerSurfacei != neiSurfacei
|
||||
)
|
||||
{
|
||||
flipMap[facei] =
|
||||
(
|
||||
ownerSurfacei == max(ownerSurfacei, neiSurfacei)
|
||||
? false
|
||||
: true
|
||||
);
|
||||
|
||||
faceToSurface[facei] = max(ownerSurfacei, neiSurfacei);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ownerSurfacei >= 0)
|
||||
{
|
||||
faceToSurface[facei] = ownerSurfacei;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const PtrList<surfaceZonesInfo>& surfZones =
|
||||
geometryToConformTo().surfZones();
|
||||
|
||||
labelList unclosedSurfaces
|
||||
(
|
||||
surfaceZonesInfo::getUnclosedNamedSurfaces
|
||||
(
|
||||
surfZones,
|
||||
geometryToConformTo().geometry(),
|
||||
geometryToConformTo().surfaces()
|
||||
)
|
||||
);
|
||||
|
||||
pointField neiCc(mesh.nFaces() - mesh.nInternalFaces());
|
||||
calcNeighbourCellCentres
|
||||
(
|
||||
mesh,
|
||||
cellCentres,
|
||||
neiCc
|
||||
);
|
||||
|
||||
// Use intersection of cellCentre connections
|
||||
forAll(faces, facei)
|
||||
{
|
||||
if (faceToSurface[facei] >= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
label patchID = mesh.boundaryMesh().whichPatch(facei);
|
||||
|
||||
const label own = faceOwner[facei];
|
||||
|
||||
List<pointIndexHit> surfHit;
|
||||
labelList hitSurface;
|
||||
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
const label nei = faceNeighbour[facei];
|
||||
|
||||
geometryToConformTo().findSurfaceAllIntersections
|
||||
(
|
||||
cellCentres[own],
|
||||
cellCentres[nei],
|
||||
surfHit,
|
||||
hitSurface
|
||||
);
|
||||
}
|
||||
else if (patchID != -1 && mesh.boundaryMesh()[patchID].coupled())
|
||||
{
|
||||
geometryToConformTo().findSurfaceAllIntersections
|
||||
(
|
||||
cellCentres[own],
|
||||
neiCc[facei - mesh.nInternalFaces()],
|
||||
surfHit,
|
||||
hitSurface
|
||||
);
|
||||
}
|
||||
|
||||
// If there are multiple intersections then do not add to
|
||||
// a faceZone
|
||||
if (surfHit.size() == 1 && surfHit[0].hit())
|
||||
{
|
||||
if (findIndex(unclosedSurfaces, hitSurface[0]) != -1)
|
||||
{
|
||||
vectorField norm;
|
||||
geometryToConformTo().getNormal
|
||||
(
|
||||
hitSurface[0],
|
||||
List<pointIndexHit>(1, surfHit[0]),
|
||||
norm
|
||||
);
|
||||
|
||||
vector fN = faces[facei].area(mesh.points());
|
||||
fN /= mag(fN) + small;
|
||||
|
||||
if ((norm[0] & fN) < 0)
|
||||
{
|
||||
flipMap[facei] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flipMap[facei] = false;
|
||||
}
|
||||
|
||||
faceToSurface[facei] = hitSurface[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// labelList neiCellSurface(mesh.nFaces()-mesh.nInternalFaces());
|
||||
//
|
||||
// forAll(patches, patchi)
|
||||
// {
|
||||
// const polyPatch& pp = patches[patchi];
|
||||
//
|
||||
// if (pp.coupled())
|
||||
// {
|
||||
// forAll(pp, i)
|
||||
// {
|
||||
// label facei = pp.start()+i;
|
||||
// label ownSurface = cellToSurface[faceOwner[facei]];
|
||||
// neiCellSurface[facei - mesh.nInternalFaces()] = ownSurface;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// syncTools::swapBoundaryFaceList(mesh, neiCellSurface);
|
||||
//
|
||||
// forAll(patches, patchi)
|
||||
// {
|
||||
// const polyPatch& pp = patches[patchi];
|
||||
//
|
||||
// if (pp.coupled())
|
||||
// {
|
||||
// forAll(pp, i)
|
||||
// {
|
||||
// label facei = pp.start()+i;
|
||||
// label ownSurface = cellToSurface[faceOwner[facei]];
|
||||
// label neiSurface =
|
||||
// neiCellSurface[facei-mesh.nInternalFaces()];
|
||||
//
|
||||
// if (faceToSurface[facei] == -1 && (ownSurface != neiSurface))
|
||||
// {
|
||||
// // Give face the max cell zone
|
||||
// faceToSurface[facei] = max(ownSurface, neiSurface);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Sync
|
||||
syncTools::syncFaceList(mesh, faceToSurface, maxEqOp<label>());
|
||||
}
|
||||
|
||||
|
||||
void Foam::conformalVoronoiMesh::addZones
|
||||
(
|
||||
polyMesh& mesh,
|
||||
const pointField& cellCentres
|
||||
) const
|
||||
{
|
||||
Info<< " Adding zones to mesh" << endl;
|
||||
|
||||
const PtrList<surfaceZonesInfo>& surfZones =
|
||||
geometryToConformTo().surfZones();
|
||||
|
||||
labelList cellToSurface(calcCellZones(cellCentres));
|
||||
|
||||
labelList faceToSurface;
|
||||
boolList flipMap;
|
||||
|
||||
calcFaceZones
|
||||
(
|
||||
mesh,
|
||||
cellCentres,
|
||||
cellToSurface,
|
||||
faceToSurface,
|
||||
flipMap
|
||||
);
|
||||
|
||||
labelList insidePointNamedSurfaces
|
||||
(
|
||||
surfaceZonesInfo::getInsidePointNamedSurfaces(surfZones)
|
||||
);
|
||||
|
||||
findCellZoneInsideWalk
|
||||
(
|
||||
mesh,
|
||||
insidePointNamedSurfaces,
|
||||
faceToSurface,
|
||||
cellToSurface
|
||||
);
|
||||
|
||||
labelList namedSurfaces(surfaceZonesInfo::getNamedSurfaces(surfZones));
|
||||
|
||||
forAll(namedSurfaces, i)
|
||||
{
|
||||
label surfI = namedSurfaces[i];
|
||||
|
||||
Info<< incrIndent << indent << "Surface : "
|
||||
<< geometryToConformTo().geometry().names()[surfI] << nl
|
||||
<< indent << " faceZone : "
|
||||
<< surfZones[surfI].faceZoneName() << nl
|
||||
<< indent << " cellZone : "
|
||||
<< surfZones[surfI].cellZoneName()
|
||||
<< decrIndent << endl;
|
||||
}
|
||||
|
||||
// Add zones to mesh
|
||||
labelList surfaceToFaceZone =
|
||||
surfaceZonesInfo::addFaceZonesToMesh
|
||||
(
|
||||
surfZones,
|
||||
namedSurfaces,
|
||||
mesh
|
||||
);
|
||||
|
||||
labelList surfaceToCellZone =
|
||||
surfaceZonesInfo::addCellZonesToMesh
|
||||
(
|
||||
surfZones,
|
||||
namedSurfaces,
|
||||
mesh
|
||||
);
|
||||
|
||||
// Topochange container
|
||||
polyTopoChange meshMod(mesh);
|
||||
|
||||
forAll(cellToSurface, celli)
|
||||
{
|
||||
label surfacei = cellToSurface[celli];
|
||||
|
||||
if (surfacei >= 0)
|
||||
{
|
||||
label zoneI = surfaceToCellZone[surfacei];
|
||||
|
||||
if (zoneI >= 0)
|
||||
{
|
||||
meshMod.setAction
|
||||
(
|
||||
polyModifyCell
|
||||
(
|
||||
celli,
|
||||
false, // removeFromZone
|
||||
zoneI
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const labelList& faceOwner = mesh.faceOwner();
|
||||
const labelList& faceNeighbour = mesh.faceNeighbour();
|
||||
|
||||
forAll(faceToSurface, facei)
|
||||
{
|
||||
label surfacei = faceToSurface[facei];
|
||||
|
||||
if (surfacei < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
label patchID = mesh.boundaryMesh().whichPatch(facei);
|
||||
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
label own = faceOwner[facei];
|
||||
label nei = faceNeighbour[facei];
|
||||
|
||||
meshMod.setAction
|
||||
(
|
||||
polyModifyFace
|
||||
(
|
||||
mesh.faces()[facei], // modified face
|
||||
facei, // label of face
|
||||
own, // owner
|
||||
nei, // neighbour
|
||||
false, // face flip
|
||||
-1, // patch for face
|
||||
false, // remove from zone
|
||||
surfaceToFaceZone[surfacei], // zone for face
|
||||
flipMap[facei] // face flip in zone
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (patchID != -1 && mesh.boundaryMesh()[patchID].coupled())
|
||||
{
|
||||
label own = faceOwner[facei];
|
||||
|
||||
meshMod.setAction
|
||||
(
|
||||
polyModifyFace
|
||||
(
|
||||
mesh.faces()[facei], // modified face
|
||||
facei, // label of face
|
||||
own, // owner
|
||||
-1, // neighbour
|
||||
false, // face flip
|
||||
patchID, // patch for face
|
||||
false, // remove from zone
|
||||
surfaceToFaceZone[surfacei], // zone for face
|
||||
flipMap[facei] // face flip in zone
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Change the mesh (no inflation, parallel sync)
|
||||
autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh, false, true);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,634 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-2022 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 "featurePointConformer.H"
|
||||
#include "cvControls.H"
|
||||
#include "conformationSurfaces.H"
|
||||
#include "conformalVoronoiMesh.H"
|
||||
#include "cellShapeControl.H"
|
||||
#include "DelaunayMeshTools.H"
|
||||
#include "ConstCirculator.H"
|
||||
#include "backgroundMeshDecomposition.H"
|
||||
#include "autoPtr.H"
|
||||
#include "distributionMap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(featurePointConformer, 0);
|
||||
}
|
||||
|
||||
const Foam::scalar Foam::featurePointConformer::tolParallel = 1e-3;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::featurePointConformer::sharedFaceNormal
|
||||
(
|
||||
const extendedFeatureEdgeMesh& feMesh,
|
||||
const label edgeI,
|
||||
const label nextEdgeI
|
||||
) const
|
||||
{
|
||||
const labelList& edgeInormals = feMesh.edgeNormals()[edgeI];
|
||||
const labelList& nextEdgeInormals = feMesh.edgeNormals()[nextEdgeI];
|
||||
|
||||
const vector& A1 = feMesh.normals()[edgeInormals[0]];
|
||||
const vector& A2 = feMesh.normals()[edgeInormals[1]];
|
||||
|
||||
const vector& B1 = feMesh.normals()[nextEdgeInormals[0]];
|
||||
const vector& B2 = feMesh.normals()[nextEdgeInormals[1]];
|
||||
|
||||
// Info<< " A1 = " << A1 << endl;
|
||||
// Info<< " A2 = " << A2 << endl;
|
||||
// Info<< " B1 = " << B1 << endl;
|
||||
// Info<< " B2 = " << B2 << endl;
|
||||
|
||||
const scalar A1B1 = mag((A1 & B1) - 1.0);
|
||||
const scalar A1B2 = mag((A1 & B2) - 1.0);
|
||||
const scalar A2B1 = mag((A2 & B1) - 1.0);
|
||||
const scalar A2B2 = mag((A2 & B2) - 1.0);
|
||||
|
||||
// Info<< " A1B1 = " << A1B1 << endl;
|
||||
// Info<< " A1B2 = " << A1B2 << endl;
|
||||
// Info<< " A2B1 = " << A2B1 << endl;
|
||||
// Info<< " A2B2 = " << A2B2 << endl;
|
||||
|
||||
if (A1B1 < A1B2 && A1B1 < A2B1 && A1B1 < A2B2)
|
||||
{
|
||||
return 0.5*(A1 + B1);
|
||||
}
|
||||
else if (A1B2 < A1B1 && A1B2 < A2B1 && A1B2 < A2B2)
|
||||
{
|
||||
return 0.5*(A1 + B2);
|
||||
}
|
||||
else if (A2B1 < A1B1 && A2B1 < A1B2 && A2B1 < A2B2)
|
||||
{
|
||||
return 0.5*(A2 + B1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.5*(A2 + B2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::featurePointConformer::getSign
|
||||
(
|
||||
const extendedFeatureEdgeMesh::edgeStatus eStatus
|
||||
) const
|
||||
{
|
||||
if (eStatus == extendedFeatureEdgeMesh::EXTERNAL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (eStatus == extendedFeatureEdgeMesh::INTERNAL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Foam::featurePointConformer::addMasterAndSlavePoints
|
||||
(
|
||||
const DynamicList<Foam::point>& masterPoints,
|
||||
const DynamicList<Foam::indexedVertexEnum::vertexType>& masterPointsTypes,
|
||||
const Map<DynamicList<autoPtr<plane>>>& masterPointReflections,
|
||||
DynamicList<Vb>& pts,
|
||||
const label ptI
|
||||
) const
|
||||
{
|
||||
typedef DynamicList<autoPtr<plane>> planeDynList;
|
||||
typedef Foam::indexedVertexEnum::vertexType vertexType;
|
||||
|
||||
forAll(masterPoints, pI)
|
||||
{
|
||||
// Append master to the list of points
|
||||
|
||||
const Foam::point& masterPt = masterPoints[pI];
|
||||
const vertexType masterType = masterPointsTypes[pI];
|
||||
|
||||
// Info<< " Master = " << masterPt << endl;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
masterPt,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
masterType,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
const label masterIndex = pts.last().index();
|
||||
|
||||
// meshTools::writeOBJ(strMasters, masterPt);
|
||||
|
||||
const planeDynList& masterPointPlanes = masterPointReflections[pI];
|
||||
|
||||
forAll(masterPointPlanes, planeI)
|
||||
{
|
||||
// Reflect master points in the planes and insert the slave points
|
||||
|
||||
const plane& reflPlane = masterPointPlanes[planeI]();
|
||||
|
||||
const Foam::point slavePt = reflPlane.mirror(masterPt);
|
||||
|
||||
// Info<< " Slave " << planeI << " = " << slavePt << endl;
|
||||
|
||||
const vertexType slaveType =
|
||||
(
|
||||
masterType == Vb::vtInternalFeaturePoint
|
||||
? Vb::vtExternalFeaturePoint // true
|
||||
: Vb::vtInternalFeaturePoint // false
|
||||
);
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
slavePt,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
slaveType,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
masterIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
|
||||
// meshTools::writeOBJ(strSlaves, slavePt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::featurePointConformer::createMasterAndSlavePoints
|
||||
(
|
||||
const extendedFeatureEdgeMesh& feMesh,
|
||||
const label ptI,
|
||||
DynamicList<Vb>& pts
|
||||
) const
|
||||
{
|
||||
typedef DynamicList<autoPtr<plane>> planeDynList;
|
||||
typedef indexedVertexEnum::vertexType vertexType;
|
||||
typedef extendedFeatureEdgeMesh::edgeStatus edgeStatus;
|
||||
|
||||
const Foam::point& featPt = feMesh.points()[ptI];
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
Pstream::parRun()
|
||||
&& !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt)
|
||||
)
|
||||
|| geometryToConformTo_.outside(featPt)
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const scalar ppDist = foamyHexMesh_.pointPairDistance(featPt);
|
||||
|
||||
// Maintain a list of master points and the planes to relect them in
|
||||
DynamicList<Foam::point> masterPoints;
|
||||
DynamicList<vertexType> masterPointsTypes;
|
||||
Map<planeDynList> masterPointReflections;
|
||||
|
||||
const labelList& featPtEdges = feMesh.featurePointEdges()[ptI];
|
||||
|
||||
pointFeatureEdgesTypes pointEdgeTypes(feMesh, ptI);
|
||||
|
||||
const List<extendedFeatureEdgeMesh::edgeStatus> allEdStat =
|
||||
pointEdgeTypes.calcPointFeatureEdgesTypes();
|
||||
|
||||
// Info<< nl << featPt << " " << pointEdgeTypes;
|
||||
|
||||
ConstCirculator<labelList> circ(featPtEdges);
|
||||
|
||||
// Loop around the edges of the feature point
|
||||
if (circ.size()) do
|
||||
{
|
||||
// const edgeStatus eStatusPrev = feMesh.getEdgeStatus(circ.prev());
|
||||
const edgeStatus eStatusCurr = feMesh.getEdgeStatus(circ());
|
||||
// const edgeStatus eStatusNext = feMesh.getEdgeStatus(circ.next());
|
||||
|
||||
// Info<< " Prev = "
|
||||
// << extendedFeatureEdgeMesh::edgeStatusNames_[eStatusPrev]
|
||||
// << " Curr = "
|
||||
// << extendedFeatureEdgeMesh::edgeStatusNames_[eStatusCurr]
|
||||
//// << " Next = "
|
||||
//// << extendedFeatureEdgeMesh::edgeStatusNames_[eStatusNext]
|
||||
// << endl;
|
||||
|
||||
// Get the direction in which to move the point in relation to the
|
||||
// feature point
|
||||
label sign = getSign(eStatusCurr);
|
||||
|
||||
const vector n = sharedFaceNormal(feMesh, circ(), circ.next());
|
||||
|
||||
const vector pointMotionDirection = sign*0.5*ppDist*n;
|
||||
|
||||
// Info<< " Shared face normal = " << n << endl;
|
||||
// Info<< " Direction to move point = " << pointMotionDirection
|
||||
// << endl;
|
||||
|
||||
if (masterPoints.empty())
|
||||
{
|
||||
// Initialise with the first master point
|
||||
Foam::point pt = featPt + pointMotionDirection;
|
||||
|
||||
planeDynList firstPlane;
|
||||
firstPlane.append(autoPtr<plane>(new plane(featPt, n)));
|
||||
|
||||
masterPoints.append(pt);
|
||||
|
||||
masterPointsTypes.append
|
||||
(
|
||||
sign == 1
|
||||
? Vb::vtExternalFeaturePoint // true
|
||||
: Vb::vtInternalFeaturePoint // false
|
||||
);
|
||||
|
||||
// Info<< " " << " " << firstPlane << endl;
|
||||
|
||||
// const Foam::point reflectedPoint = reflectPointInPlane
|
||||
// (
|
||||
// masterPoints.last(),
|
||||
// firstPlane.last()()
|
||||
// );
|
||||
|
||||
masterPointReflections.insert
|
||||
(
|
||||
masterPoints.size() - 1,
|
||||
firstPlane
|
||||
);
|
||||
}
|
||||
// else if
|
||||
// (
|
||||
// eStatusPrev == extendedFeatureEdgeMesh::INTERNAL
|
||||
// && eStatusCurr == extendedFeatureEdgeMesh::EXTERNAL
|
||||
// )
|
||||
// {
|
||||
// // Insert a new master point.
|
||||
// Foam::point pt = featPt + pointMotionDirection;
|
||||
//
|
||||
// planeDynList firstPlane;
|
||||
// firstPlane.append(autoPtr<plane>(new plane(featPt, n)));
|
||||
//
|
||||
// masterPoints.append(pt);
|
||||
//
|
||||
// masterPointsTypes.append
|
||||
// (
|
||||
// sign == 1
|
||||
// ? Vb::vtExternalFeaturePoint // true
|
||||
// : Vb::vtInternalFeaturePoint // false
|
||||
// );
|
||||
//
|
||||
// masterPointReflections.insert
|
||||
// (
|
||||
// masterPoints.size() - 1,
|
||||
// firstPlane
|
||||
// );
|
||||
// }
|
||||
// else if
|
||||
// (
|
||||
// eStatusPrev == extendedFeatureEdgeMesh::EXTERNAL
|
||||
// && eStatusCurr == extendedFeatureEdgeMesh::INTERNAL
|
||||
// )
|
||||
// {
|
||||
//
|
||||
// }
|
||||
else
|
||||
{
|
||||
// Just add this face contribution to the latest master point
|
||||
|
||||
masterPoints.last() += pointMotionDirection;
|
||||
|
||||
masterPointReflections[masterPoints.size() - 1].append
|
||||
(
|
||||
autoPtr<plane>(new plane(featPt, n))
|
||||
);
|
||||
}
|
||||
|
||||
} while (circ.circulate(CirculatorBase::direction::clockwise));
|
||||
|
||||
addMasterAndSlavePoints
|
||||
(
|
||||
masterPoints,
|
||||
masterPointsTypes,
|
||||
masterPointReflections,
|
||||
pts,
|
||||
ptI
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::featurePointConformer::createMixedFeaturePoints
|
||||
(
|
||||
DynamicList<Vb>& pts
|
||||
) const
|
||||
{
|
||||
if (foamyHexMeshControls_.mixedFeaturePointPPDistanceCoeff() < 0)
|
||||
{
|
||||
Info<< nl
|
||||
<< "Skipping specialised handling for mixed feature points" << endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const PtrList<extendedFeatureEdgeMesh>& feMeshes
|
||||
(
|
||||
geometryToConformTo_.features()
|
||||
);
|
||||
|
||||
forAll(feMeshes, i)
|
||||
{
|
||||
const extendedFeatureEdgeMesh& feMesh = feMeshes[i];
|
||||
const labelListList& pointsEdges = feMesh.pointEdges();
|
||||
const pointField& points = feMesh.points();
|
||||
|
||||
for
|
||||
(
|
||||
label ptI = feMesh.mixedStart();
|
||||
ptI < feMesh.nonFeatureStart();
|
||||
ptI++
|
||||
)
|
||||
{
|
||||
const Foam::point& featPt = points[ptI];
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::parRun()
|
||||
&& !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const labelList& pEds = pointsEdges[ptI];
|
||||
|
||||
pointFeatureEdgesTypes pFEdgeTypes(feMesh, ptI);
|
||||
|
||||
const List<extendedFeatureEdgeMesh::edgeStatus> allEdStat =
|
||||
pFEdgeTypes.calcPointFeatureEdgesTypes();
|
||||
|
||||
bool specialisedSuccess = false;
|
||||
|
||||
if (foamyHexMeshControls_.specialiseFeaturePoints())
|
||||
{
|
||||
specialisedSuccess =
|
||||
createSpecialisedFeaturePoint
|
||||
(
|
||||
feMesh, pEds, pFEdgeTypes, allEdStat, ptI, pts
|
||||
);
|
||||
}
|
||||
|
||||
if (!specialisedSuccess && foamyHexMeshControls_.edgeAiming())
|
||||
{
|
||||
// Specialisations available for some mixed feature points. For
|
||||
// non-specialised feature points, inserting mixed internal and
|
||||
// external edge groups at feature point.
|
||||
|
||||
// Skipping unsupported mixed feature point types
|
||||
// bool skipEdge = false;
|
||||
//
|
||||
// forAll(pEds, e)
|
||||
// {
|
||||
// const label edgeI = pEds[e];
|
||||
//
|
||||
// const extendedFeatureEdgeMesh::edgeStatus edStatus
|
||||
// = feMesh.getEdgeStatus(edgeI);
|
||||
//
|
||||
// if
|
||||
// (
|
||||
// edStatus == extendedFeatureEdgeMesh::OPEN
|
||||
// || edStatus == extendedFeatureEdgeMesh::MULTIPLE
|
||||
// )
|
||||
// {
|
||||
// Info<< "Edge type " << edStatus
|
||||
// << " found for mixed feature point " << ptI
|
||||
// << ". Not supported."
|
||||
// << endl;
|
||||
//
|
||||
// skipEdge = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (skipEdge)
|
||||
// {
|
||||
// Info<< "Skipping point " << ptI << nl << endl;
|
||||
//
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// createFeaturePoints(feMesh, ptI, pts, types);
|
||||
|
||||
const Foam::point& pt = points[ptI];
|
||||
|
||||
const scalar edgeGroupDistance =
|
||||
foamyHexMesh_.mixedFeaturePointDistance(pt);
|
||||
|
||||
forAll(pEds, e)
|
||||
{
|
||||
const label edgeI = pEds[e];
|
||||
|
||||
const Foam::point edgePt =
|
||||
pt + edgeGroupDistance*feMesh.edgeDirection(edgeI, ptI);
|
||||
|
||||
const pointIndexHit edgeHit(true, edgePt, edgeI);
|
||||
|
||||
foamyHexMesh_.createEdgePointGroup(feMesh, edgeHit, pts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::featurePointConformer::createFeaturePoints(DynamicList<Vb>& pts)
|
||||
{
|
||||
const PtrList<extendedFeatureEdgeMesh>& feMeshes
|
||||
(
|
||||
geometryToConformTo_.features()
|
||||
);
|
||||
|
||||
forAll(feMeshes, i)
|
||||
{
|
||||
const extendedFeatureEdgeMesh& feMesh(feMeshes[i]);
|
||||
|
||||
for
|
||||
(
|
||||
label ptI = feMesh.convexStart();
|
||||
ptI < feMesh.mixedStart();
|
||||
// ptI < feMesh.nonFeatureStart();
|
||||
ptI++
|
||||
)
|
||||
{
|
||||
createMasterAndSlavePoints(feMesh, ptI, pts);
|
||||
}
|
||||
|
||||
if (foamyHexMeshControls_.guardFeaturePoints())
|
||||
{
|
||||
for
|
||||
(
|
||||
// label ptI = feMesh.convexStart();
|
||||
label ptI = feMesh.mixedStart();
|
||||
ptI < feMesh.nonFeatureStart();
|
||||
ptI++
|
||||
)
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
feMesh.points()[ptI],
|
||||
Vb::vtConstrained
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::featurePointConformer::featurePointConformer
|
||||
(
|
||||
const conformalVoronoiMesh& foamyHexMesh
|
||||
)
|
||||
:
|
||||
foamyHexMesh_(foamyHexMesh),
|
||||
foamyHexMeshControls_(foamyHexMesh.foamyHexMeshControls()),
|
||||
geometryToConformTo_(foamyHexMesh.geometryToConformTo()),
|
||||
featurePointVertices_(),
|
||||
ftPtPairs_(foamyHexMesh)
|
||||
{
|
||||
Info<< nl
|
||||
<< "Conforming to feature points" << endl;
|
||||
|
||||
Info<< incrIndent
|
||||
<< indent << "Circulating edges is: "
|
||||
<< foamyHexMeshControls_.circulateEdges().asText() << nl
|
||||
<< indent << "Guarding feature points is: "
|
||||
<< foamyHexMeshControls_.guardFeaturePoints().asText() << nl
|
||||
<< indent << "Snapping to feature points is: "
|
||||
<< foamyHexMeshControls_.snapFeaturePoints().asText() << nl
|
||||
<< indent << "Specialising feature points is: "
|
||||
<< foamyHexMeshControls_.specialiseFeaturePoints().asText()
|
||||
<< decrIndent
|
||||
<< endl;
|
||||
|
||||
DynamicList<Vb> pts;
|
||||
|
||||
createFeaturePoints(pts);
|
||||
|
||||
createMixedFeaturePoints(pts);
|
||||
|
||||
// Points added using the createEdgePointGroup function will be labelled as
|
||||
// internal/external feature edges. Relabel them as feature points,
|
||||
// otherwise they are inserted as both feature points and surface points.
|
||||
forAll(pts, pI)
|
||||
{
|
||||
Vb& pt = pts[pI];
|
||||
|
||||
// if (pt.featureEdgePoint())
|
||||
{
|
||||
if (pt.internalBoundaryPoint())
|
||||
{
|
||||
pt.type() = Vb::vtInternalFeaturePoint;
|
||||
}
|
||||
else if (pt.externalBoundaryPoint())
|
||||
{
|
||||
pt.type() = Vb::vtExternalFeaturePoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foamyHexMeshControls_.objOutput())
|
||||
{
|
||||
DelaunayMeshTools::writeOBJ("featureVertices.obj", pts);
|
||||
}
|
||||
|
||||
featurePointVertices_.transfer(pts);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::featurePointConformer::~featurePointConformer()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::featurePointConformer::distribute
|
||||
(
|
||||
const backgroundMeshDecomposition& decomposition
|
||||
)
|
||||
{
|
||||
// Distribute points to their appropriate processor
|
||||
decomposition.distributePoints(featurePointVertices_);
|
||||
|
||||
// Update the processor indices of the points to the new processor number
|
||||
forAll(featurePointVertices_, vI)
|
||||
{
|
||||
featurePointVertices_[vI].procIndex() = Pstream::myProcNo();
|
||||
}
|
||||
|
||||
// Also update the feature point pairs
|
||||
}
|
||||
|
||||
|
||||
void Foam::featurePointConformer::reIndexPointPairs
|
||||
(
|
||||
const Map<label>& oldToNewIndices
|
||||
)
|
||||
{
|
||||
forAll(featurePointVertices_, vI)
|
||||
{
|
||||
const label currentIndex = featurePointVertices_[vI].index();
|
||||
|
||||
Map<label>::const_iterator newIndexIter =
|
||||
oldToNewIndices.find(currentIndex);
|
||||
|
||||
if (newIndexIter != oldToNewIndices.end())
|
||||
{
|
||||
featurePointVertices_[vI].index() = newIndexIter();
|
||||
}
|
||||
}
|
||||
|
||||
ftPtPairs_.reIndex(oldToNewIndices);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,200 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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::featurePointConformer
|
||||
|
||||
Description
|
||||
The Delaunay vertices required to conform to a feature point can be
|
||||
determined upon initialisation because the feature points are fixed and
|
||||
do not change throughout the meshing process.
|
||||
|
||||
SourceFiles
|
||||
featurePointConformerI.H
|
||||
featurePointConformer.C
|
||||
featurePointConformerSpecialisations.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef featurePointConformer_H
|
||||
#define featurePointConformer_H
|
||||
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
#include "vector.H"
|
||||
#include "DynamicList.H"
|
||||
#include "List.H"
|
||||
#include "extendedFeatureEdgeMesh.H"
|
||||
#include "pointPairs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class conformalVoronoiMesh;
|
||||
class cvControls;
|
||||
class conformationSurfaces;
|
||||
class pointFeatureEdgesTypes;
|
||||
class backgroundMeshDecomposition;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class featurePointConformer Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class featurePointConformer
|
||||
{
|
||||
// Static data
|
||||
|
||||
//- Tolerance within which two lines are said to be parallel.
|
||||
static const scalar tolParallel;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Reference to the mesher.
|
||||
const conformalVoronoiMesh& foamyHexMesh_;
|
||||
|
||||
//- Reference to the mesher controls.
|
||||
const cvControls& foamyHexMeshControls_;
|
||||
|
||||
//- Reference to the conformation surfaces.
|
||||
const conformationSurfaces& geometryToConformTo_;
|
||||
|
||||
//- Store the feature constraining points, to be reinserted after a
|
||||
// triangulation clear.
|
||||
List<Vb> featurePointVertices_;
|
||||
|
||||
//-
|
||||
mutable pointPairs<Delaunay> ftPtPairs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the shared face normal between two edges geometrically.
|
||||
vector sharedFaceNormal
|
||||
(
|
||||
const extendedFeatureEdgeMesh& feMesh,
|
||||
const label edgeI,
|
||||
const label nextEdgeI
|
||||
) const;
|
||||
|
||||
label getSign(const extendedFeatureEdgeMesh::edgeStatus eStatus) const;
|
||||
|
||||
bool createSpecialisedFeaturePoint
|
||||
(
|
||||
const extendedFeatureEdgeMesh& feMesh,
|
||||
const labelList& pEds,
|
||||
const pointFeatureEdgesTypes& pFEdgesTypes,
|
||||
const List<extendedFeatureEdgeMesh::edgeStatus>& allEdStat,
|
||||
const label ptI,
|
||||
DynamicList<Vb>& pts
|
||||
) const;
|
||||
|
||||
|
||||
void addMasterAndSlavePoints
|
||||
(
|
||||
const DynamicList<point>& masterPoints,
|
||||
const DynamicList<indexedVertexEnum::vertexType>& masterPointsTypes,
|
||||
const Map<DynamicList<autoPtr<plane>>>& masterPointReflections,
|
||||
DynamicList<Vb>& pts,
|
||||
const label ptI
|
||||
) const;
|
||||
|
||||
//- Helper function for conforming to feature points
|
||||
void createMasterAndSlavePoints
|
||||
(
|
||||
const extendedFeatureEdgeMesh& feMesh,
|
||||
const label ptI,
|
||||
DynamicList<Vb>& pts
|
||||
) const;
|
||||
|
||||
void createMixedFeaturePoints(DynamicList<Vb>& pts) const;
|
||||
|
||||
//- Create the points that will conform to the feature
|
||||
void createFeaturePoints(DynamicList<Vb>& pts);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("featurePointConformer");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
explicit featurePointConformer
|
||||
(
|
||||
const conformalVoronoiMesh& foamyHexMesh
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
featurePointConformer(const featurePointConformer&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
~featurePointConformer();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the feature point vertices for insertion into the
|
||||
// triangulation.
|
||||
inline const List<Vb>& featurePointVertices() const;
|
||||
|
||||
//- Return the feature point pair table
|
||||
inline const pointPairs<Delaunay>& featurePointPairs() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Distribute the feature point vertices according to the
|
||||
// supplied background mesh
|
||||
void distribute(const backgroundMeshDecomposition& decomposition);
|
||||
|
||||
//- Reindex the feature point pairs using the map.
|
||||
void reIndexPointPairs(const Map<label>& oldToNewIndices);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const featurePointConformer&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "featurePointConformerI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,38 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
const Foam::List<Vb>& Foam::featurePointConformer::featurePointVertices() const
|
||||
{
|
||||
return featurePointVertices_;
|
||||
}
|
||||
|
||||
const Foam::pointPairs<Delaunay>&
|
||||
Foam::featurePointConformer::featurePointPairs() const
|
||||
{
|
||||
return ftPtPairs_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,918 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "featurePointConformer.H"
|
||||
#include "vectorTools.H"
|
||||
#include "pointFeatureEdgesTypes.H"
|
||||
#include "conformalVoronoiMesh.H"
|
||||
#include "pointConversion.H"
|
||||
|
||||
using namespace Foam::vectorTools;
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::featurePointConformer::createSpecialisedFeaturePoint
|
||||
(
|
||||
const extendedFeatureEdgeMesh& feMesh,
|
||||
const labelList& pEds,
|
||||
const pointFeatureEdgesTypes& pFEdgesTypes,
|
||||
const List<extendedFeatureEdgeMesh::edgeStatus>& allEdStat,
|
||||
const label ptI,
|
||||
DynamicList<Vb>& pts
|
||||
) const
|
||||
{
|
||||
if
|
||||
(
|
||||
!pFEdgesTypes.found(extendedFeatureEdgeMesh::EXTERNAL)
|
||||
|| !pFEdgesTypes.found(extendedFeatureEdgeMesh::INTERNAL)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
pFEdgesTypes[extendedFeatureEdgeMesh::EXTERNAL] == 2
|
||||
&& pFEdgesTypes[extendedFeatureEdgeMesh::INTERNAL] == 1
|
||||
&& pEds.size() == 3
|
||||
)
|
||||
{
|
||||
if (debug) Info<< "nExternal == 2 && nInternal == 1" << endl;
|
||||
|
||||
const Foam::point& featPt = feMesh.points()[ptI];
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::parRun()
|
||||
&& !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const label initialNumOfPoints = pts.size();
|
||||
|
||||
const scalar ppDist = foamyHexMesh_.pointPairDistance(featPt);
|
||||
|
||||
const vectorField& normals = feMesh.normals();
|
||||
|
||||
const labelListList& edgeNormals = feMesh.edgeNormals();
|
||||
|
||||
label concaveEdgeI = -1;
|
||||
labelList convexEdgesI(2, label(-1));
|
||||
label nConvex = 0;
|
||||
|
||||
forAll(pEds, i)
|
||||
{
|
||||
const extendedFeatureEdgeMesh::edgeStatus& eS = allEdStat[i];
|
||||
|
||||
if (eS == extendedFeatureEdgeMesh::INTERNAL)
|
||||
{
|
||||
concaveEdgeI = pEds[i];
|
||||
}
|
||||
else if (eS == extendedFeatureEdgeMesh::EXTERNAL)
|
||||
{
|
||||
convexEdgesI[nConvex++] = pEds[i];
|
||||
}
|
||||
else if (eS == extendedFeatureEdgeMesh::FLAT)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Edge " << eS << " is flat"
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Edge " << eS << " not concave/convex"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
const vector& concaveEdgePlaneANormal =
|
||||
normals[edgeNormals[concaveEdgeI][0]];
|
||||
|
||||
const vector& concaveEdgePlaneBNormal =
|
||||
normals[edgeNormals[concaveEdgeI][1]];
|
||||
|
||||
// Intersect planes parallel to the concave edge planes offset
|
||||
// by ppDist and the plane defined by featPt and the edge vector.
|
||||
plane planeA
|
||||
(
|
||||
featPt + ppDist*concaveEdgePlaneANormal,
|
||||
concaveEdgePlaneANormal
|
||||
);
|
||||
|
||||
plane planeB
|
||||
(
|
||||
featPt + ppDist*concaveEdgePlaneBNormal,
|
||||
concaveEdgePlaneBNormal
|
||||
);
|
||||
|
||||
const vector& concaveEdgeDir = feMesh.edgeDirection
|
||||
(
|
||||
concaveEdgeI,
|
||||
ptI
|
||||
);
|
||||
|
||||
// Todo,needed later but want to get rid of this.
|
||||
const Foam::point concaveEdgeLocalFeatPt =
|
||||
featPt + ppDist*concaveEdgeDir;
|
||||
|
||||
// Finding the nearest point on the intersecting line to the edge
|
||||
// point. Floating point errors often occur using planePlaneIntersect
|
||||
|
||||
plane planeF(concaveEdgeLocalFeatPt, concaveEdgeDir);
|
||||
|
||||
const Foam::point concaveEdgeExternalPt = planeF.planePlaneIntersect
|
||||
(
|
||||
planeA,
|
||||
planeB
|
||||
);
|
||||
|
||||
// Redefine planes to be on the feature surfaces to project through
|
||||
|
||||
planeA = plane(featPt, concaveEdgePlaneANormal);
|
||||
|
||||
planeB = plane(featPt, concaveEdgePlaneBNormal);
|
||||
|
||||
const Foam::point internalPtA =
|
||||
concaveEdgeExternalPt
|
||||
- 2.0*planeA.distance(concaveEdgeExternalPt)
|
||||
*concaveEdgePlaneANormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
internalPtA,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtInternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
const label internalPtAIndex(pts.last().index());
|
||||
|
||||
const Foam::point internalPtB =
|
||||
concaveEdgeExternalPt
|
||||
- 2.0*planeB.distance(concaveEdgeExternalPt)
|
||||
*concaveEdgePlaneBNormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
internalPtB,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtInternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
const label internalPtBIndex(pts.last().index());
|
||||
|
||||
// Add the external points
|
||||
|
||||
Foam::point externalPtD;
|
||||
Foam::point externalPtE;
|
||||
|
||||
vector convexEdgePlaneCNormal(Zero);
|
||||
vector convexEdgePlaneDNormal(Zero);
|
||||
|
||||
const labelList& concaveEdgeNormals = edgeNormals[concaveEdgeI];
|
||||
const labelList& convexEdgeANormals = edgeNormals[convexEdgesI[0]];
|
||||
const labelList& convexEdgeBNormals = edgeNormals[convexEdgesI[1]];
|
||||
|
||||
forAll(concaveEdgeNormals, edgeNormalI)
|
||||
{
|
||||
bool convexEdgeA = false;
|
||||
bool convexEdgeB = false;
|
||||
|
||||
forAll(convexEdgeANormals, edgeAnormalI)
|
||||
{
|
||||
const vector& concaveNormal
|
||||
= normals[concaveEdgeNormals[edgeNormalI]];
|
||||
const vector& convexNormal
|
||||
= normals[convexEdgeANormals[edgeAnormalI]];
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Angle between vectors = "
|
||||
<< degAngleBetween(concaveNormal, convexNormal) << endl;
|
||||
}
|
||||
|
||||
// Need a looser tolerance, because sometimes adjacent triangles
|
||||
// on the same surface will be slightly out of alignment.
|
||||
if (areParallel(concaveNormal, convexNormal, tolParallel))
|
||||
{
|
||||
convexEdgeA = true;
|
||||
}
|
||||
}
|
||||
|
||||
forAll(convexEdgeBNormals, edgeBnormalI)
|
||||
{
|
||||
const vector& concaveNormal
|
||||
= normals[concaveEdgeNormals[edgeNormalI]];
|
||||
const vector& convexNormal
|
||||
= normals[convexEdgeBNormals[edgeBnormalI]];
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Angle between vectors = "
|
||||
<< degAngleBetween(concaveNormal, convexNormal) << endl;
|
||||
}
|
||||
|
||||
// Need a looser tolerance, because sometimes adjacent triangles
|
||||
// on the same surface will be slightly out of alignment.
|
||||
if (areParallel(concaveNormal, convexNormal, tolParallel))
|
||||
{
|
||||
convexEdgeB = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((convexEdgeA && convexEdgeB) || (!convexEdgeA && !convexEdgeB))
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Both or neither of the convex edges share the concave "
|
||||
<< "edge's normal."
|
||||
<< " convexEdgeA = " << convexEdgeA
|
||||
<< " convexEdgeB = " << convexEdgeB
|
||||
<< endl;
|
||||
|
||||
// Remove points that have just been added before returning
|
||||
for (label i = 0; i < 2; ++i)
|
||||
{
|
||||
pts.remove();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (convexEdgeA)
|
||||
{
|
||||
forAll(convexEdgeANormals, edgeAnormalI)
|
||||
{
|
||||
const vector& concaveNormal
|
||||
= normals[concaveEdgeNormals[edgeNormalI]];
|
||||
const vector& convexNormal
|
||||
= normals[convexEdgeANormals[edgeAnormalI]];
|
||||
|
||||
if
|
||||
(
|
||||
!areParallel(concaveNormal, convexNormal, tolParallel)
|
||||
)
|
||||
{
|
||||
convexEdgePlaneCNormal = convexNormal;
|
||||
|
||||
plane planeC(featPt, convexEdgePlaneCNormal);
|
||||
|
||||
externalPtD =
|
||||
internalPtA
|
||||
+ 2.0*planeC.distance(internalPtA)
|
||||
*convexEdgePlaneCNormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
externalPtD,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtExternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtAIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (convexEdgeB)
|
||||
{
|
||||
forAll(convexEdgeBNormals, edgeBnormalI)
|
||||
{
|
||||
const vector& concaveNormal
|
||||
= normals[concaveEdgeNormals[edgeNormalI]];
|
||||
const vector& convexNormal
|
||||
= normals[convexEdgeBNormals[edgeBnormalI]];
|
||||
|
||||
if
|
||||
(
|
||||
!areParallel(concaveNormal, convexNormal, tolParallel)
|
||||
)
|
||||
{
|
||||
convexEdgePlaneDNormal = convexNormal;
|
||||
|
||||
plane planned(featPt, convexEdgePlaneDNormal);
|
||||
|
||||
externalPtE =
|
||||
internalPtB
|
||||
+ 2.0*planned.distance(internalPtB)
|
||||
*convexEdgePlaneDNormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
externalPtE,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtExternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtBIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
concaveEdgeExternalPt,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtExternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtBIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtAIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
|
||||
const label concaveEdgeExternalPtIndex(pts.last().index());
|
||||
|
||||
const scalar totalAngle = radToDeg
|
||||
(
|
||||
constant::mathematical::pi
|
||||
+ radAngleBetween(concaveEdgePlaneANormal, concaveEdgePlaneBNormal)
|
||||
);
|
||||
|
||||
if (totalAngle > foamyHexMeshControls_.maxQuadAngle())
|
||||
{
|
||||
// Add additional mitreing points
|
||||
// scalar angleSign = 1.0;
|
||||
|
||||
|
||||
vector convexEdgesPlaneNormal =
|
||||
0.5*(convexEdgePlaneCNormal + convexEdgePlaneDNormal);
|
||||
|
||||
plane planeM(featPt, convexEdgesPlaneNormal);
|
||||
|
||||
// if
|
||||
// (
|
||||
// geometryToConformTo_.outside
|
||||
// (
|
||||
// featPt - convexEdgesPlaneNormal*ppDist
|
||||
// )
|
||||
// )
|
||||
// {
|
||||
// angleSign = -1.0;
|
||||
// }
|
||||
|
||||
// scalar phi =
|
||||
// angleSign*acos(concaveEdgeDir & -convexEdgesPlaneNormal);
|
||||
//
|
||||
// scalar guard =
|
||||
// (
|
||||
// 1.0 + sin(phi)*ppDist/mag
|
||||
// (
|
||||
// concaveEdgeLocalFeatPt - concaveEdgeExternalPt
|
||||
// )
|
||||
// )/cos(phi) - 1.0;
|
||||
|
||||
const Foam::point internalPtF =
|
||||
concaveEdgeExternalPt
|
||||
//+ (2.0 + guard)*(concaveEdgeLocalFeatPt - concaveEdgeExternalPt);
|
||||
+ 2.0*(concaveEdgeLocalFeatPt - concaveEdgeExternalPt);
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
internalPtF,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtInternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
const label internalPtFIndex(pts.last().index());
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
concaveEdgeExternalPtIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
|
||||
const Foam::point externalPtG =
|
||||
internalPtF
|
||||
+ 2.0*planeM.distance(internalPtF)*convexEdgesPlaneNormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
externalPtG,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtExternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtFIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
for (label ptI = initialNumOfPoints; ptI < pts.size(); ++ptI)
|
||||
{
|
||||
Info<< "Point " << ptI << " : ";
|
||||
meshTools::writeOBJ(Info, topoint(pts[ptI].point()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if
|
||||
(
|
||||
pFEdgesTypes[extendedFeatureEdgeMesh::EXTERNAL] == 1
|
||||
&& pFEdgesTypes[extendedFeatureEdgeMesh::INTERNAL] == 2
|
||||
&& pEds.size() == 3
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "nExternal == 1 && nInternal == 2" << endl;
|
||||
}
|
||||
|
||||
const Foam::point& featPt = feMesh.points()[ptI];
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::parRun()
|
||||
&& !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const label initialNumOfPoints = pts.size();
|
||||
|
||||
const scalar ppDist = foamyHexMesh_.pointPairDistance(featPt);
|
||||
|
||||
const vectorField& normals = feMesh.normals();
|
||||
|
||||
const labelListList& edgeNormals = feMesh.edgeNormals();
|
||||
|
||||
label convexEdgeI = -1;
|
||||
labelList concaveEdgesI(2, label(-1));
|
||||
label nConcave = 0;
|
||||
|
||||
forAll(pEds, i)
|
||||
{
|
||||
const extendedFeatureEdgeMesh::edgeStatus& eS = allEdStat[i];
|
||||
|
||||
if (eS == extendedFeatureEdgeMesh::EXTERNAL)
|
||||
{
|
||||
convexEdgeI = pEds[i];
|
||||
}
|
||||
else if (eS == extendedFeatureEdgeMesh::INTERNAL)
|
||||
{
|
||||
concaveEdgesI[nConcave++] = pEds[i];
|
||||
}
|
||||
else if (eS == extendedFeatureEdgeMesh::FLAT)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Edge " << eS << " is flat"
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Edge " << eS << " not concave/convex"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
const vector& convexEdgePlaneANormal =
|
||||
normals[edgeNormals[convexEdgeI][0]];
|
||||
|
||||
const vector& convexEdgePlaneBNormal =
|
||||
normals[edgeNormals[convexEdgeI][1]];
|
||||
|
||||
// Intersect planes parallel to the concave edge planes offset
|
||||
// by ppDist and the plane defined by featPt and the edge vector.
|
||||
plane planeA
|
||||
(
|
||||
featPt - ppDist*convexEdgePlaneANormal,
|
||||
convexEdgePlaneANormal
|
||||
);
|
||||
|
||||
plane planeB
|
||||
(
|
||||
featPt - ppDist*convexEdgePlaneBNormal,
|
||||
convexEdgePlaneBNormal
|
||||
);
|
||||
|
||||
const vector& convexEdgeDir = feMesh.edgeDirection
|
||||
(
|
||||
convexEdgeI,
|
||||
ptI
|
||||
);
|
||||
|
||||
// Todo,needed later but want to get rid of this.
|
||||
const Foam::point convexEdgeLocalFeatPt =
|
||||
featPt + ppDist*convexEdgeDir;
|
||||
|
||||
// Finding the nearest point on the intersecting line to the edge
|
||||
// point. Floating point errors often occur using planePlaneIntersect
|
||||
|
||||
plane planeF(convexEdgeLocalFeatPt, convexEdgeDir);
|
||||
|
||||
const Foam::point convexEdgeExternalPt = planeF.planePlaneIntersect
|
||||
(
|
||||
planeA,
|
||||
planeB
|
||||
);
|
||||
|
||||
// Redefine planes to be on the feature surfaces to project through
|
||||
|
||||
planeA = plane(featPt, convexEdgePlaneANormal);
|
||||
|
||||
planeB = plane(featPt, convexEdgePlaneBNormal);
|
||||
|
||||
const Foam::point internalPtA =
|
||||
convexEdgeExternalPt
|
||||
+ 2.0*planeA.distance(convexEdgeExternalPt)
|
||||
*convexEdgePlaneANormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
internalPtA,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtExternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
const label internalPtAIndex(pts.last().index());
|
||||
|
||||
const Foam::point internalPtB =
|
||||
convexEdgeExternalPt
|
||||
+ 2.0*planeB.distance(convexEdgeExternalPt)
|
||||
*convexEdgePlaneBNormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
internalPtB,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtExternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
const label internalPtBIndex(pts.last().index());
|
||||
|
||||
// Add the internal points
|
||||
|
||||
Foam::point externalPtD;
|
||||
Foam::point externalPtE;
|
||||
|
||||
vector concaveEdgePlaneCNormal(Zero);
|
||||
vector concaveEdgePlaneDNormal(Zero);
|
||||
|
||||
const labelList& convexEdgeNormals = edgeNormals[convexEdgeI];
|
||||
const labelList& concaveEdgeANormals = edgeNormals[concaveEdgesI[0]];
|
||||
const labelList& concaveEdgeBNormals = edgeNormals[concaveEdgesI[1]];
|
||||
|
||||
forAll(convexEdgeNormals, edgeNormalI)
|
||||
{
|
||||
bool concaveEdgeA = false;
|
||||
bool concaveEdgeB = false;
|
||||
|
||||
forAll(concaveEdgeANormals, edgeAnormalI)
|
||||
{
|
||||
const vector& convexNormal
|
||||
= normals[convexEdgeNormals[edgeNormalI]];
|
||||
const vector& concaveNormal
|
||||
= normals[concaveEdgeANormals[edgeAnormalI]];
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Angle between vectors = "
|
||||
<< degAngleBetween(convexNormal, concaveNormal) << endl;
|
||||
}
|
||||
|
||||
// Need a looser tolerance, because sometimes adjacent triangles
|
||||
// on the same surface will be slightly out of alignment.
|
||||
if (areParallel(convexNormal, concaveNormal, tolParallel))
|
||||
{
|
||||
concaveEdgeA = true;
|
||||
}
|
||||
}
|
||||
|
||||
forAll(concaveEdgeBNormals, edgeBnormalI)
|
||||
{
|
||||
const vector& convexNormal
|
||||
= normals[convexEdgeNormals[edgeNormalI]];
|
||||
const vector& concaveNormal
|
||||
= normals[concaveEdgeBNormals[edgeBnormalI]];
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Angle between vectors = "
|
||||
<< degAngleBetween(convexNormal, concaveNormal) << endl;
|
||||
}
|
||||
|
||||
// Need a looser tolerance, because sometimes adjacent triangles
|
||||
// on the same surface will be slightly out of alignment.
|
||||
if (areParallel(convexNormal, concaveNormal, tolParallel))
|
||||
{
|
||||
concaveEdgeB = true;
|
||||
}
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
(concaveEdgeA && concaveEdgeB)
|
||||
|| (!concaveEdgeA && !concaveEdgeB)
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Both or neither of the concave edges share the convex "
|
||||
<< "edge's normal."
|
||||
<< " concaveEdgeA = " << concaveEdgeA
|
||||
<< " concaveEdgeB = " << concaveEdgeB
|
||||
<< endl;
|
||||
|
||||
// Remove points that have just been added before returning
|
||||
for (label i = 0; i < 2; ++i)
|
||||
{
|
||||
pts.remove();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (concaveEdgeA)
|
||||
{
|
||||
forAll(concaveEdgeANormals, edgeAnormalI)
|
||||
{
|
||||
const vector& convexNormal
|
||||
= normals[convexEdgeNormals[edgeNormalI]];
|
||||
const vector& concaveNormal
|
||||
= normals[concaveEdgeANormals[edgeAnormalI]];
|
||||
|
||||
if
|
||||
(
|
||||
!areParallel(convexNormal, concaveNormal, tolParallel)
|
||||
)
|
||||
{
|
||||
concaveEdgePlaneCNormal = concaveNormal;
|
||||
|
||||
plane planeC(featPt, concaveEdgePlaneCNormal);
|
||||
|
||||
externalPtD =
|
||||
internalPtA
|
||||
- 2.0*planeC.distance(internalPtA)
|
||||
*concaveEdgePlaneCNormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
externalPtD,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtInternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtAIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (concaveEdgeB)
|
||||
{
|
||||
forAll(concaveEdgeBNormals, edgeBnormalI)
|
||||
{
|
||||
const vector& convexNormal
|
||||
= normals[convexEdgeNormals[edgeNormalI]];
|
||||
const vector& concaveNormal
|
||||
= normals[concaveEdgeBNormals[edgeBnormalI]];
|
||||
|
||||
if
|
||||
(
|
||||
!areParallel(convexNormal, concaveNormal, tolParallel)
|
||||
)
|
||||
{
|
||||
concaveEdgePlaneDNormal = concaveNormal;
|
||||
|
||||
plane planned(featPt, concaveEdgePlaneDNormal);
|
||||
|
||||
externalPtE =
|
||||
internalPtB
|
||||
- 2.0*planned.distance(internalPtB)
|
||||
*concaveEdgePlaneDNormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
externalPtE,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtInternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtBIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
convexEdgeExternalPt,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtInternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtBIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
internalPtAIndex,
|
||||
pts.last().index()
|
||||
);
|
||||
|
||||
const scalar totalAngle = radToDeg
|
||||
(
|
||||
constant::mathematical::pi
|
||||
+ radAngleBetween(convexEdgePlaneANormal, convexEdgePlaneBNormal)
|
||||
);
|
||||
|
||||
if (totalAngle > foamyHexMeshControls_.maxQuadAngle())
|
||||
{
|
||||
// Add additional mitreing points
|
||||
// scalar angleSign = 1.0;
|
||||
|
||||
|
||||
vector convexEdgesPlaneNormal =
|
||||
0.5*(concaveEdgePlaneCNormal + concaveEdgePlaneDNormal);
|
||||
|
||||
plane planeM(featPt, convexEdgesPlaneNormal);
|
||||
|
||||
// if
|
||||
// (
|
||||
// geometryToConformTo_.outside
|
||||
// (
|
||||
// featPt - convexEdgesPlaneNormal*ppDist
|
||||
// )
|
||||
// )
|
||||
// {
|
||||
// angleSign = -1.0;
|
||||
// }
|
||||
|
||||
// scalar phi =
|
||||
// angleSign*acos(concaveEdgeDir & -convexEdgesPlaneNormal);
|
||||
//
|
||||
// scalar guard =
|
||||
// (
|
||||
// 1.0 + sin(phi)*ppDist/mag
|
||||
// (
|
||||
// concaveEdgeLocalFeatPt - concaveEdgeExternalPt
|
||||
// )
|
||||
// )/cos(phi) - 1.0;
|
||||
|
||||
const Foam::point internalPtF =
|
||||
convexEdgeExternalPt
|
||||
//+ (2.0 + guard)*(concaveEdgeLocalFeatPt - concaveEdgeExternalPt);
|
||||
+ 2.0*(convexEdgeLocalFeatPt - convexEdgeExternalPt);
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
internalPtF,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtExternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
pts[pts.size() - 2].index(),
|
||||
pts.last().index()
|
||||
);
|
||||
|
||||
const Foam::point externalPtG =
|
||||
internalPtF
|
||||
- 2.0*planeM.distance(internalPtF)*convexEdgesPlaneNormal;
|
||||
|
||||
pts.append
|
||||
(
|
||||
Vb
|
||||
(
|
||||
externalPtG,
|
||||
foamyHexMesh_.vertexCount() + pts.size(),
|
||||
Vb::vtInternalFeaturePoint,
|
||||
Pstream::myProcNo()
|
||||
)
|
||||
);
|
||||
|
||||
ftPtPairs_.addPointPair
|
||||
(
|
||||
pts[pts.size() - 2].index(),
|
||||
pts.last().index()
|
||||
);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
for (label ptI = initialNumOfPoints; ptI < pts.size(); ++ptI)
|
||||
{
|
||||
Info<< "Point " << ptI << " "
|
||||
<< indexedVertexEnum::vertexTypeNames_[pts[ptI].type()]
|
||||
<< " : ";
|
||||
|
||||
meshTools::writeOBJ(Info, topoint(pts[ptI].point()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,101 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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 "pointFeatureEdgesTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointFeatureEdgesTypes::pointFeatureEdgesTypes
|
||||
(
|
||||
const extendedFeatureEdgeMesh& feMesh,
|
||||
const label pointLabel
|
||||
)
|
||||
:
|
||||
HashTable<label, extendedFeatureEdgeMesh::edgeStatus>(),
|
||||
feMesh_(feMesh),
|
||||
pointLabel_(pointLabel)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointFeatureEdgesTypes::~pointFeatureEdgesTypes()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::List<Foam::extendedFeatureEdgeMesh::edgeStatus>
|
||||
Foam::pointFeatureEdgesTypes::calcPointFeatureEdgesTypes()
|
||||
{
|
||||
const labelList& pEds = feMesh_.pointEdges()[pointLabel_];
|
||||
|
||||
List<extendedFeatureEdgeMesh::edgeStatus> allEdStat(pEds.size());
|
||||
|
||||
forAll(pEds, i)
|
||||
{
|
||||
label edgeI = pEds[i];
|
||||
|
||||
extendedFeatureEdgeMesh::edgeStatus& eS = allEdStat[i];
|
||||
|
||||
eS = feMesh_.getEdgeStatus(edgeI);
|
||||
|
||||
this->operator()(eS)++;
|
||||
}
|
||||
|
||||
return allEdStat;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const pointFeatureEdgesTypes& p
|
||||
)
|
||||
{
|
||||
os << "Point = " << p.pointLabel_ << endl;
|
||||
|
||||
for
|
||||
(
|
||||
HashTable<label, extendedFeatureEdgeMesh::edgeStatus>
|
||||
::const_iterator iter = p.cbegin();
|
||||
iter != p.cend();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
os << " "
|
||||
<< extendedFeatureEdgeMesh::edgeStatusNames_[iter.key()]
|
||||
<< " = "
|
||||
<< iter()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,113 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 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::pointFeatureEdgesTypes
|
||||
|
||||
Description
|
||||
Holds information on the types of feature edges attached to feature points.
|
||||
|
||||
SourceFiles
|
||||
pointFeatureEdgesTypes.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pointFeatureEdgesTypes_H
|
||||
#define pointFeatureEdgesTypes_H
|
||||
|
||||
#include "HashTable.H"
|
||||
#include "extendedFeatureEdgeMesh.H"
|
||||
#include "List.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class pointFeatureEdgesTypes;
|
||||
|
||||
Ostream& operator<<(Ostream&, const pointFeatureEdgesTypes&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pointFeatureEdgesTypes Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Hold the types of feature edges attached to the point.
|
||||
class pointFeatureEdgesTypes
|
||||
:
|
||||
public HashTable<label, extendedFeatureEdgeMesh::edgeStatus>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to the feature edge mesh
|
||||
const extendedFeatureEdgeMesh& feMesh_;
|
||||
|
||||
//- Label of the point
|
||||
label pointLabel_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
pointFeatureEdgesTypes
|
||||
(
|
||||
const extendedFeatureEdgeMesh& feMesh,
|
||||
const label pointLabel
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~pointFeatureEdgesTypes();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Fill the pointFeatureEdgesType class with the types of feature
|
||||
// edges that are attached to the point.
|
||||
List<extendedFeatureEdgeMesh::edgeStatus> calcPointFeatureEdgesTypes();
|
||||
|
||||
|
||||
// Info
|
||||
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const pointFeatureEdgesTypes& p
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,89 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "indexedCell.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
|
||||
|
||||
template<class Gt, class Cb>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const InfoProxy<CGAL::indexedCell<Gt, Cb>>& p
|
||||
)
|
||||
{
|
||||
const CGAL::indexedCell<Gt, Cb>& iv = p.t_;
|
||||
|
||||
os << "Cell: ";
|
||||
|
||||
if (iv.index_ == CGAL::indexedCell<Gt, Cb>::ctFar)
|
||||
{
|
||||
os << "far";
|
||||
}
|
||||
else if (iv.index_ >= 0)
|
||||
{
|
||||
os << iv.index_;
|
||||
}
|
||||
else if (iv.index_ == CGAL::indexedCell<Gt, Cb>::ctInternal)
|
||||
{
|
||||
os << "internal";
|
||||
}
|
||||
else if (iv.index_ == CGAL::indexedCell<Gt, Cb>::ctSurface)
|
||||
{
|
||||
os << "surface";
|
||||
}
|
||||
else if (iv.index_ == CGAL::indexedCell<Gt, Cb>::ctFeatureEdge)
|
||||
{
|
||||
os << "featureEdge";
|
||||
}
|
||||
else if (iv.index_ == CGAL::indexedCell<Gt, Cb>::ctFeaturePoint)
|
||||
{
|
||||
os << "featurePoint";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "unassigned";
|
||||
}
|
||||
|
||||
if (iv.parallelDualVertex())
|
||||
{
|
||||
os << " (processor)";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " (local)";
|
||||
}
|
||||
|
||||
os << " filterCount: " << iv.filterCount_ << nl;
|
||||
os << " " << iv.vertex(0)->info();
|
||||
os << " " << iv.vertex(1)->info();
|
||||
os << " " << iv.vertex(2)->info();
|
||||
os << " " << iv.vertex(3)->info();
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,276 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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
|
||||
CGAL::indexedCell
|
||||
|
||||
Description
|
||||
An indexed form of CGAL::Triangulation_cell_base_3<K> used to keep
|
||||
track of the Delaunay cells (tets) in the tessellation.
|
||||
|
||||
SourceFiles
|
||||
indexedCellI.H
|
||||
indexedCell.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef indexedCell_H
|
||||
#define indexedCell_H
|
||||
|
||||
#include "CGAL/Triangulation_3.h"
|
||||
#include "CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h"
|
||||
#include "indexedVertex.H"
|
||||
#include "List.H"
|
||||
#include "globalIndex.H"
|
||||
#include "Pstream.H"
|
||||
#include "Swap.H"
|
||||
#include "InfoProxy.H"
|
||||
#include "tetCell.H"
|
||||
#include "typeInfo.H"
|
||||
#include "vectorTools.H"
|
||||
#include "indexedCellEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
template<class Gt, class Cb> class indexedCell;
|
||||
}
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
class Ostream;
|
||||
template<class Gt, class Cb> Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const Foam::InfoProxy<CGAL::indexedCell<Gt, Cb>>&
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class indexedCell Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template
|
||||
<
|
||||
class Gt,
|
||||
class Cb=CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3<Gt>
|
||||
>
|
||||
class indexedCell
|
||||
:
|
||||
public Foam::indexedCellEnum,
|
||||
public Cb
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- The index for this Delaunay tetrahedral cell. Type information is
|
||||
//- Also carried:
|
||||
|
||||
// ctFar : the dual point of this cell does not form part of the
|
||||
// internal or boundary of the dual mesh
|
||||
// >=0 : the (local) index of an internal or boundary dual point,
|
||||
// not on a processor face
|
||||
// < 0 && > ctFar : the (global) index of a dual point on a processor
|
||||
// face
|
||||
|
||||
Foam::label index_;
|
||||
|
||||
//- The number of times that this Delaunay cell has been limited
|
||||
// during filtering
|
||||
int filterCount_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Same as globallyOrderedCellVertices but without sorting
|
||||
Foam::tetCell unsortedVertexGlobalIndices
|
||||
(
|
||||
const Foam::globalIndex& globalDelaunayVertexIndices
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
typedef typename Cb::Triangulation_data_structure Tds;
|
||||
typedef typename Cb::Vertex_handle Vertex_handle;
|
||||
typedef typename Cb::Cell_handle Cell_handle;
|
||||
|
||||
template<class TDS2>
|
||||
struct Rebind_TDS
|
||||
{
|
||||
typedef typename Cb::template Rebind_TDS<TDS2>::Other Cb2;
|
||||
typedef indexedCell<Gt, Cb2> Other;
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
inline indexedCell();
|
||||
|
||||
inline indexedCell
|
||||
(
|
||||
Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Vertex_handle v3
|
||||
);
|
||||
|
||||
inline indexedCell
|
||||
(
|
||||
Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Vertex_handle v3,
|
||||
Cell_handle n0,
|
||||
Cell_handle n1,
|
||||
Cell_handle n2,
|
||||
Cell_handle n3
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
inline Foam::label& cellIndex();
|
||||
|
||||
inline Foam::label cellIndex() const;
|
||||
|
||||
#ifdef CGAL_INEXACT
|
||||
inline const Foam::point& dual();
|
||||
#else
|
||||
inline const Foam::point dual();
|
||||
#endif
|
||||
|
||||
inline bool unassigned() const;
|
||||
|
||||
inline int& filterCount();
|
||||
|
||||
inline int filterCount() const;
|
||||
|
||||
//- Is the Delaunay cell real, i.e. any real vertex
|
||||
inline bool real() const;
|
||||
|
||||
//- Does the Delaunay cell have a far point
|
||||
inline bool hasFarPoint() const;
|
||||
|
||||
//- Does the Delaunay cell have a referred point
|
||||
inline bool hasReferredPoint() const;
|
||||
|
||||
//- Does the Delaunay cell have a feature point
|
||||
inline bool hasFeaturePoint() const;
|
||||
|
||||
//- Does the Delaunay cell have a seed point
|
||||
inline bool hasSeedPoint() const;
|
||||
|
||||
inline bool hasInternalPoint() const;
|
||||
inline bool hasBoundaryPoint() const;
|
||||
|
||||
inline bool hasConstrainedPoint() const;
|
||||
|
||||
//- Does the Dual vertex form part of a processor patch
|
||||
inline bool parallelDualVertex() const;
|
||||
|
||||
inline Foam::label vertexLowestProc() const;
|
||||
|
||||
//- Using the globalIndex object, return a list of four (sorted) global
|
||||
// Delaunay vertex indices that uniquely identify this tet in parallel
|
||||
inline Foam::tetCell vertexGlobalIndices
|
||||
(
|
||||
const Foam::globalIndex& globalDelaunayVertexIndices
|
||||
) const;
|
||||
|
||||
//- Using the globalIndex object, return a list of four vertices with
|
||||
// so that the cell has a consistent orientation in parallel.
|
||||
inline Foam::FixedList<Foam::label, 4> globallyOrderedCellVertices
|
||||
(
|
||||
const Foam::globalIndex& globalDelaunayVertexIndices
|
||||
) const;
|
||||
|
||||
//- Is the Delaunay cell part of the final dual mesh, i.e. any vertex
|
||||
// form part of the internal or boundary definition
|
||||
inline bool internalOrBoundaryDualVertex() const;
|
||||
|
||||
//- Is the Delaunay cell real or referred (or mixed), i.e. all vertices
|
||||
// form part of the real or referred internal or boundary definition
|
||||
inline bool anyInternalOrBoundaryDualVertex() const;
|
||||
|
||||
//- A dual vertex on the boundary will result from a Delaunay cell with
|
||||
// least one Delaunay vertex outside and at least one inside
|
||||
inline bool boundaryDualVertex() const;
|
||||
|
||||
inline bool baffleSurfaceDualVertex() const;
|
||||
|
||||
inline bool baffleEdgeDualVertex() const;
|
||||
|
||||
//- A dual vertex on a feature edge will result from this Delaunay cell
|
||||
inline bool featureEdgeDualVertex() const;
|
||||
|
||||
//- A dual vertex on a feature point will result from this Delaunay cell
|
||||
inline bool featurePointDualVertex() const;
|
||||
|
||||
inline bool nearProcBoundary() const;
|
||||
|
||||
inline bool potentialCoplanarCell() const;
|
||||
|
||||
inline bool featurePointExternalCell() const;
|
||||
inline bool featurePointInternalCell() const;
|
||||
|
||||
|
||||
// Info
|
||||
|
||||
//- Return info proxy.
|
||||
// Used to print indexedCell information to a stream
|
||||
Foam::InfoProxy<indexedCell<Gt, Cb>> info() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend Foam::Ostream& Foam::operator<< <Gt, Cb>
|
||||
(
|
||||
Foam::Ostream&,
|
||||
const Foam::InfoProxy<indexedCell<Gt, Cb>>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "indexedCellI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "indexedCell.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,128 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "plane.H"
|
||||
#include "tetPointRef.H"
|
||||
#include "pointConversion.H"
|
||||
#include "CGALTriangulation3DKernel.H"
|
||||
|
||||
|
||||
template<class Cell>
|
||||
Foam::scalar Foam::foamyHexMeshChecks::coplanarTet
|
||||
(
|
||||
Cell& c,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
tetPointRef tet
|
||||
(
|
||||
topoint(c->vertex(0)->point()),
|
||||
topoint(c->vertex(1)->point()),
|
||||
topoint(c->vertex(2)->point()),
|
||||
topoint(c->vertex(3)->point())
|
||||
);
|
||||
|
||||
const scalar quality = tet.quality();
|
||||
|
||||
if (quality < tol)
|
||||
{
|
||||
return quality;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
// plane triPlane
|
||||
// (
|
||||
// topoint(c->vertex(0)->point()),
|
||||
// topoint(c->vertex(1)->point()),
|
||||
// topoint(c->vertex(2)->point())
|
||||
// );
|
||||
//
|
||||
// const scalar distance = triPlane.distance(topoint(c->vertex(3)->point()));
|
||||
//
|
||||
// // Check if the four points are roughly coplanar. If they are then we
|
||||
// // cannot calculate the circumcentre. Better test might be the volume
|
||||
// // of the tet.
|
||||
// if (distance < tol)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// return distance;
|
||||
}
|
||||
|
||||
|
||||
template<class Cell>
|
||||
bool Foam::foamyHexMeshChecks::closePoints
|
||||
(
|
||||
Cell& c,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
for (label v = 0; v < 4; ++v)
|
||||
{
|
||||
for (label vA = v + 1; vA < 4; ++vA)
|
||||
{
|
||||
if
|
||||
(
|
||||
mag
|
||||
(
|
||||
topoint(c->vertex(v)->point())
|
||||
- topoint(c->vertex(vA)->point())
|
||||
)
|
||||
< tol
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Cell>
|
||||
bool Foam::foamyHexMeshChecks::smallVolume
|
||||
(
|
||||
Cell& c,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
CGAL::Tetrahedron_3<baseK> tet
|
||||
(
|
||||
c->vertex(0)->point(),
|
||||
c->vertex(1)->point(),
|
||||
c->vertex(2)->point(),
|
||||
c->vertex(3)->point()
|
||||
);
|
||||
|
||||
if (tet.volume() < tol)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef indexedCellChecks_H
|
||||
#define indexedCellChecks_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace foamyHexMeshChecks
|
||||
{
|
||||
|
||||
template<class Cell>
|
||||
scalar coplanarTet
|
||||
(
|
||||
Cell& c,
|
||||
const scalar tol = 1e-12
|
||||
);
|
||||
|
||||
template<class Cell>
|
||||
bool closePoints
|
||||
(
|
||||
Cell& c,
|
||||
const scalar tol = 1e-12
|
||||
);
|
||||
|
||||
template<class Cell>
|
||||
bool smallVolume
|
||||
(
|
||||
Cell& c,
|
||||
const scalar tol = 0.0
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamyHexMeshChecks
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "indexedCellChecks.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,46 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "indexedCellEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
const char*
|
||||
Foam::NamedEnum<Foam::indexedCellEnum::cellTypes, 6>::names[] =
|
||||
{
|
||||
"Unassigned",
|
||||
"Internal",
|
||||
"Surface",
|
||||
"FeatureEdge",
|
||||
"FeaturePoint",
|
||||
"Far"
|
||||
};
|
||||
|
||||
const Foam::NamedEnum<Foam::indexedCellEnum::cellTypes, 6>
|
||||
cellTypesNames_;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,80 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
Class
|
||||
Foam::indexedCellEnum
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
indexedCellEnum.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef indexedCellEnum_H
|
||||
#define indexedCellEnum_H
|
||||
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class indexedCellEnum
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
enum cellTypes
|
||||
{
|
||||
ctUnassigned = INT_MIN,
|
||||
ctFar = INT_MIN + 1,
|
||||
ctInternal = INT_MIN + 2,
|
||||
ctSurface = INT_MIN + 3,
|
||||
ctFeatureEdge = INT_MIN + 4,
|
||||
ctFeaturePoint = INT_MIN + 5
|
||||
};
|
||||
|
||||
static const Foam::NamedEnum<cellTypes, 6> cellTypesNames_;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
inline bool contiguous<indexedCellEnum>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,763 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Gt, class Cb>
|
||||
Foam::tetCell CGAL::indexedCell<Gt, Cb>::unsortedVertexGlobalIndices
|
||||
(
|
||||
const Foam::globalIndex& globalDelaunayVertexIndices
|
||||
) const
|
||||
{
|
||||
Foam::tetCell tVGI;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Vertex_handle v = this->vertex(i);
|
||||
|
||||
// Finding the global index of each Delaunay vertex
|
||||
tVGI[i] = globalDelaunayVertexIndices.toGlobal
|
||||
(
|
||||
Foam::Pstream::myProcNo(),
|
||||
v->index()
|
||||
);
|
||||
}
|
||||
|
||||
return tVGI;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Gt, class Cb>
|
||||
CGAL::indexedCell<Gt, Cb>::indexedCell()
|
||||
:
|
||||
Cb(),
|
||||
index_(ctUnassigned),
|
||||
filterCount_(0)
|
||||
{}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
CGAL::indexedCell<Gt, Cb>::indexedCell
|
||||
(
|
||||
Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3
|
||||
)
|
||||
:
|
||||
Cb(v0, v1, v2, v3),
|
||||
index_(ctUnassigned),
|
||||
filterCount_(0)
|
||||
{}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
CGAL::indexedCell<Gt, Cb>::indexedCell
|
||||
(
|
||||
Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Vertex_handle v3,
|
||||
Cell_handle n0,
|
||||
Cell_handle n1,
|
||||
Cell_handle n2,
|
||||
Cell_handle n3
|
||||
)
|
||||
:
|
||||
Cb(v0, v1, v2, v3, n0, n1, n2, n3),
|
||||
index_(ctUnassigned),
|
||||
filterCount_(0)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Gt, class Cb>
|
||||
Foam::label& CGAL::indexedCell<Gt, Cb>::cellIndex()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
Foam::label CGAL::indexedCell<Gt, Cb>::cellIndex() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CGAL_INEXACT
|
||||
|
||||
template<class Gt, class Cb>
|
||||
const Foam::point& CGAL::indexedCell<Gt, Cb>::dual()
|
||||
{
|
||||
return reinterpret_cast<const Foam::point&>(this->circumcenter());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class Gt, class Cb>
|
||||
const Foam::point CGAL::indexedCell<Gt, Cb>::dual()
|
||||
{
|
||||
const typename Gt::Point_3& P = this->circumcenter();
|
||||
|
||||
return Foam::point
|
||||
(
|
||||
CGAL::to_double(P.x()),
|
||||
CGAL::to_double(P.y()),
|
||||
CGAL::to_double(P.z())
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::unassigned() const
|
||||
{
|
||||
return index_ == ctUnassigned;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline int& CGAL::indexedCell<Gt, Cb>::filterCount()
|
||||
{
|
||||
return filterCount_;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline int CGAL::indexedCell<Gt, Cb>::filterCount() const
|
||||
{
|
||||
return filterCount_;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::real() const
|
||||
{
|
||||
return
|
||||
(
|
||||
(
|
||||
this->vertex(0)->real()
|
||||
|| this->vertex(1)->real()
|
||||
|| this->vertex(2)->real()
|
||||
|| this->vertex(3)->real()
|
||||
)
|
||||
&&
|
||||
!(
|
||||
this->vertex(0)->farPoint()
|
||||
|| this->vertex(1)->farPoint()
|
||||
|| this->vertex(2)->farPoint()
|
||||
|| this->vertex(3)->farPoint()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::hasFarPoint() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->farPoint()
|
||||
|| this->vertex(1)->farPoint()
|
||||
|| this->vertex(2)->farPoint()
|
||||
|| this->vertex(3)->farPoint()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::hasReferredPoint() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->referred()
|
||||
|| this->vertex(1)->referred()
|
||||
|| this->vertex(2)->referred()
|
||||
|| this->vertex(3)->referred()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::hasFeaturePoint() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->featurePoint()
|
||||
|| this->vertex(1)->featurePoint()
|
||||
|| this->vertex(2)->featurePoint()
|
||||
|| this->vertex(3)->featurePoint()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::hasSeedPoint() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->seedPoint()
|
||||
|| this->vertex(1)->seedPoint()
|
||||
|| this->vertex(2)->seedPoint()
|
||||
|| this->vertex(3)->seedPoint()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::hasInternalPoint() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->internalPoint()
|
||||
|| this->vertex(1)->internalPoint()
|
||||
|| this->vertex(2)->internalPoint()
|
||||
|| this->vertex(3)->internalPoint()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::hasBoundaryPoint() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->boundaryPoint()
|
||||
|| this->vertex(1)->boundaryPoint()
|
||||
|| this->vertex(2)->boundaryPoint()
|
||||
|| this->vertex(3)->boundaryPoint()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::hasConstrainedPoint() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->constrained()
|
||||
|| this->vertex(1)->constrained()
|
||||
|| this->vertex(2)->constrained()
|
||||
|| this->vertex(3)->constrained()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::parallelDualVertex() const
|
||||
{
|
||||
return
|
||||
(
|
||||
!this->hasFarPoint()
|
||||
&&
|
||||
(
|
||||
this->vertex(0)->referred()
|
||||
|| this->vertex(1)->referred()
|
||||
|| this->vertex(2)->referred()
|
||||
|| this->vertex(3)->referred()
|
||||
)
|
||||
&&
|
||||
(
|
||||
this->vertex(0)->real()
|
||||
|| this->vertex(1)->real()
|
||||
|| this->vertex(2)->real()
|
||||
|| this->vertex(3)->real()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline Foam::label CGAL::indexedCell<Gt, Cb>::vertexLowestProc() const
|
||||
{
|
||||
Foam::label lowestProc = -1;
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (this->vertex(i)->referred())
|
||||
{
|
||||
lowestProc = min(lowestProc, this->vertex(i)->procIndex());
|
||||
}
|
||||
}
|
||||
|
||||
return lowestProc;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline Foam::tetCell CGAL::indexedCell<Gt, Cb>::vertexGlobalIndices
|
||||
(
|
||||
const Foam::globalIndex& globalDelaunayVertexIndices
|
||||
) const
|
||||
{
|
||||
// tetVertexGlobalIndices
|
||||
Foam::tetCell tVGI
|
||||
= unsortedVertexGlobalIndices(globalDelaunayVertexIndices);
|
||||
|
||||
// bubble sort
|
||||
for (int i = 0; i < tVGI.size(); i++)
|
||||
{
|
||||
for (int j = tVGI.size() - 1 ; j > i; j--)
|
||||
{
|
||||
if (tVGI[j - 1] > tVGI[j])
|
||||
{
|
||||
Foam::Swap(tVGI[j - 1], tVGI[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tVGI;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline Foam::FixedList<Foam::label, 4>
|
||||
CGAL::indexedCell<Gt, Cb>::globallyOrderedCellVertices
|
||||
(
|
||||
const Foam::globalIndex& globalDelaunayVertexIndices
|
||||
) const
|
||||
{
|
||||
// tetVertexGlobalIndices
|
||||
Foam::tetCell tVGI
|
||||
= unsortedVertexGlobalIndices(globalDelaunayVertexIndices);
|
||||
|
||||
Foam::FixedList<Foam::label, 4> vertexMap(Foam::identity(4));
|
||||
|
||||
// bubble sort
|
||||
for (int i = 0; i < tVGI.size(); i++)
|
||||
{
|
||||
for (int j = tVGI.size() - 1 ; j > i; j--)
|
||||
{
|
||||
if (tVGI[j - 1] > tVGI[j])
|
||||
{
|
||||
Foam::Swap(tVGI[j - 1], tVGI[j]);
|
||||
Foam::Swap(vertexMap[j - 1], vertexMap[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
tVGI[i] = vertexMap[i];
|
||||
}
|
||||
|
||||
return tVGI;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::internalOrBoundaryDualVertex() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->internalOrBoundaryPoint()
|
||||
|| this->vertex(1)->internalOrBoundaryPoint()
|
||||
|| this->vertex(2)->internalOrBoundaryPoint()
|
||||
|| this->vertex(3)->internalOrBoundaryPoint()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::anyInternalOrBoundaryDualVertex() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->internalOrBoundaryPoint()
|
||||
|| this->vertex(0)->externalBoundaryPoint()
|
||||
|| this->vertex(1)->internalOrBoundaryPoint()
|
||||
|| this->vertex(1)->externalBoundaryPoint()
|
||||
|| this->vertex(2)->internalOrBoundaryPoint()
|
||||
|| this->vertex(2)->externalBoundaryPoint()
|
||||
|| this->vertex(3)->internalOrBoundaryPoint()
|
||||
|| this->vertex(3)->externalBoundaryPoint()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::boundaryDualVertex() const
|
||||
{
|
||||
// return
|
||||
// (
|
||||
// this->vertex(0)->boundaryPoint()
|
||||
// && this->vertex(1)->boundaryPoint()
|
||||
// && this->vertex(2)->boundaryPoint()
|
||||
// && this->vertex(3)->boundaryPoint()
|
||||
// );
|
||||
|
||||
return
|
||||
(
|
||||
(
|
||||
this->vertex(0)->internalBoundaryPoint()
|
||||
|| this->vertex(1)->internalBoundaryPoint()
|
||||
|| this->vertex(2)->internalBoundaryPoint()
|
||||
|| this->vertex(3)->internalBoundaryPoint()
|
||||
)
|
||||
&& (
|
||||
this->vertex(0)->externalBoundaryPoint()
|
||||
|| this->vertex(1)->externalBoundaryPoint()
|
||||
|| this->vertex(2)->externalBoundaryPoint()
|
||||
|| this->vertex(3)->externalBoundaryPoint()
|
||||
)
|
||||
);
|
||||
|
||||
// Foam::label nBoundaryPoints = 0;
|
||||
//
|
||||
// for (Foam::label i = 0; i < 4; ++i)
|
||||
// {
|
||||
// Vertex_handle v = this->vertex(i);
|
||||
//
|
||||
// if (v->boundaryPoint())
|
||||
// {
|
||||
// nBoundaryPoints++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return (nBoundaryPoints > 1);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::baffleSurfaceDualVertex() const
|
||||
{
|
||||
return
|
||||
(
|
||||
(
|
||||
this->vertex(0)->internalBaffleSurfacePoint()
|
||||
|| this->vertex(1)->internalBaffleSurfacePoint()
|
||||
|| this->vertex(2)->internalBaffleSurfacePoint()
|
||||
|| this->vertex(3)->internalBaffleSurfacePoint()
|
||||
)
|
||||
&& (
|
||||
this->vertex(0)->externalBaffleSurfacePoint()
|
||||
|| this->vertex(1)->externalBaffleSurfacePoint()
|
||||
|| this->vertex(2)->externalBaffleSurfacePoint()
|
||||
|| this->vertex(3)->externalBaffleSurfacePoint()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::baffleEdgeDualVertex() const
|
||||
{
|
||||
return
|
||||
(
|
||||
(
|
||||
this->vertex(0)->internalBaffleEdgePoint()
|
||||
|| this->vertex(1)->internalBaffleEdgePoint()
|
||||
|| this->vertex(2)->internalBaffleEdgePoint()
|
||||
|| this->vertex(3)->internalBaffleEdgePoint()
|
||||
)
|
||||
&& (
|
||||
this->vertex(0)->externalBaffleEdgePoint()
|
||||
|| this->vertex(1)->externalBaffleEdgePoint()
|
||||
|| this->vertex(2)->externalBaffleEdgePoint()
|
||||
|| this->vertex(3)->externalBaffleEdgePoint()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::featureEdgeDualVertex() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->featureEdgePoint()
|
||||
&& this->vertex(1)->featureEdgePoint()
|
||||
&& this->vertex(2)->featureEdgePoint()
|
||||
&& this->vertex(3)->featureEdgePoint()
|
||||
);
|
||||
// (
|
||||
// this->vertex(0)->featureEdgePoint()
|
||||
// || this->vertex(1)->featureEdgePoint()
|
||||
// || this->vertex(2)->featureEdgePoint()
|
||||
// || this->vertex(3)->featureEdgePoint()
|
||||
// )
|
||||
// && (
|
||||
// (
|
||||
// this->vertex(0)->featureEdgePoint()
|
||||
// || this->vertex(0)->featurePoint()
|
||||
// )
|
||||
// && (
|
||||
// this->vertex(1)->featureEdgePoint()
|
||||
// || this->vertex(1)->featurePoint()
|
||||
// )
|
||||
// && (
|
||||
// this->vertex(2)->featureEdgePoint()
|
||||
// || this->vertex(2)->featurePoint()
|
||||
// )
|
||||
// && (
|
||||
// this->vertex(3)->featureEdgePoint()
|
||||
// || this->vertex(3)->featurePoint()
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::featurePointDualVertex() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->featurePoint()
|
||||
&& this->vertex(1)->featurePoint()
|
||||
&& this->vertex(2)->featurePoint()
|
||||
&& this->vertex(3)->featurePoint()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::nearProcBoundary() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->nearProcBoundary()
|
||||
|| this->vertex(1)->nearProcBoundary()
|
||||
|| this->vertex(2)->nearProcBoundary()
|
||||
|| this->vertex(3)->nearProcBoundary()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::potentialCoplanarCell() const
|
||||
{
|
||||
Foam::label nMasters = 0;
|
||||
Foam::label nSlaves = 0;
|
||||
|
||||
Vertex_handle vM[2];
|
||||
Vertex_handle vS[2];
|
||||
|
||||
for (Foam::label i = 0; i < 4; ++i)
|
||||
{
|
||||
Vertex_handle v = this->vertex(i);
|
||||
|
||||
if (v->internalBoundaryPoint())
|
||||
{
|
||||
vM[nMasters] = v;
|
||||
nMasters++;
|
||||
}
|
||||
|
||||
if (v->externalBoundaryPoint())
|
||||
{
|
||||
vS[nSlaves] = v;
|
||||
nSlaves++;
|
||||
}
|
||||
}
|
||||
|
||||
Foam::label nPairs = 0;
|
||||
|
||||
if (nMasters == 2 && nSlaves == 2)
|
||||
{
|
||||
Foam::vector vp0(Foam::Zero);
|
||||
Foam::vector vp1(Foam::Zero);
|
||||
|
||||
if
|
||||
(
|
||||
vM[0]->type() == vS[0]->index()
|
||||
&& vM[0]->index() == vS[0]->type()
|
||||
)
|
||||
{
|
||||
vp0 = reinterpret_cast<const Foam::point&>(vM[0]->point())
|
||||
- reinterpret_cast<const Foam::point&>(vS[0]->point());
|
||||
nPairs++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
vM[0]->type() == vS[1]->index()
|
||||
&& vM[0]->index() == vS[1]->type()
|
||||
)
|
||||
{
|
||||
vp0 = reinterpret_cast<const Foam::point&>(vM[0]->point())
|
||||
- reinterpret_cast<const Foam::point&>(vS[1]->point());
|
||||
nPairs++;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
vM[1]->type() == vS[0]->index()
|
||||
&& vM[1]->index() == vS[0]->type()
|
||||
)
|
||||
{
|
||||
vp1 = reinterpret_cast<const Foam::point&>(vM[1]->point())
|
||||
- reinterpret_cast<const Foam::point&>(vS[0]->point());
|
||||
nPairs++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
vM[1]->type() == vS[1]->index()
|
||||
&& vM[1]->index() == vS[1]->type()
|
||||
)
|
||||
{
|
||||
vp1 = reinterpret_cast<const Foam::point&>(vM[1]->point())
|
||||
- reinterpret_cast<const Foam::point&>(vS[1]->point());
|
||||
nPairs++;
|
||||
}
|
||||
|
||||
if (nPairs == 2)
|
||||
{
|
||||
if (Foam::vectorTools::areParallel(vp0, vp1))
|
||||
{
|
||||
Foam::Pout<< "PARALLEL" << Foam::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::featurePointExternalCell() const
|
||||
{
|
||||
int featureVertex = -1;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (this->vertex(i)->constrained())
|
||||
{
|
||||
featureVertex = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Pick cell with a face attached to an infinite cell
|
||||
|
||||
if (featureVertex != -1)
|
||||
{
|
||||
Vertex_handle v1 =
|
||||
this->vertex(Tds::vertex_triple_index(featureVertex, 0));
|
||||
Vertex_handle v2 =
|
||||
this->vertex(Tds::vertex_triple_index(featureVertex, 1));
|
||||
Vertex_handle v3 =
|
||||
this->vertex(Tds::vertex_triple_index(featureVertex, 2));
|
||||
|
||||
if (v1->internalBoundaryPoint())
|
||||
{
|
||||
if
|
||||
(
|
||||
v2->externalBoundaryPoint()
|
||||
&& v3->externalBoundaryPoint()
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (v2->internalBoundaryPoint())
|
||||
{
|
||||
if
|
||||
(
|
||||
v1->externalBoundaryPoint()
|
||||
&& v3->externalBoundaryPoint()
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (v3->internalBoundaryPoint())
|
||||
{
|
||||
if
|
||||
(
|
||||
v1->externalBoundaryPoint()
|
||||
&& v2->externalBoundaryPoint()
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
inline bool CGAL::indexedCell<Gt, Cb>::featurePointInternalCell() const
|
||||
{
|
||||
int featureVertex = -1;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (this->vertex(i)->constrained())
|
||||
{
|
||||
featureVertex = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Pick cell with a face attached to an infinite cell
|
||||
|
||||
if (featureVertex != -1)
|
||||
{
|
||||
Vertex_handle v1 =
|
||||
this->vertex(Tds::vertex_triple_index(featureVertex, 0));
|
||||
Vertex_handle v2 =
|
||||
this->vertex(Tds::vertex_triple_index(featureVertex, 1));
|
||||
Vertex_handle v3 =
|
||||
this->vertex(Tds::vertex_triple_index(featureVertex, 2));
|
||||
|
||||
if (v1->externalBoundaryPoint())
|
||||
{
|
||||
if
|
||||
(
|
||||
v2->internalBoundaryPoint()
|
||||
&& v3->internalBoundaryPoint()
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (v2->externalBoundaryPoint())
|
||||
{
|
||||
if
|
||||
(
|
||||
v1->internalBoundaryPoint()
|
||||
&& v3->internalBoundaryPoint()
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (v3->externalBoundaryPoint())
|
||||
{
|
||||
if
|
||||
(
|
||||
v1->internalBoundaryPoint()
|
||||
&& v2->internalBoundaryPoint()
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,76 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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/>.
|
||||
|
||||
Namespace
|
||||
CGAL::indexedCellOps
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
indexedCellOpsTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef indexedCellOps_H
|
||||
#define indexedCellOps_H
|
||||
|
||||
#include "label.H"
|
||||
#include "FixedList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Namespace indexedCellOps Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
namespace indexedCellOps
|
||||
{
|
||||
|
||||
//- Does the Dual vertex form part of a processor patch
|
||||
template<class CellType>
|
||||
Foam::label dualVertexMasterProc(const CellType& c);
|
||||
|
||||
template<class CellType>
|
||||
Foam::FixedList<Foam::label, 4> processorsAttached(const CellType& c);
|
||||
|
||||
} // End namespace indexedCellOps
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "indexedCellOpsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,82 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2013-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 "indexedCellOps.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class CellType>
|
||||
Foam::label CGAL::indexedCellOps::dualVertexMasterProc(const CellType& c)
|
||||
{
|
||||
if (!c->parallelDualVertex())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// The master processor is the lowest numbered of the four on this tet.
|
||||
|
||||
int masterProc = Foam::Pstream::nProcs() + 1;
|
||||
|
||||
for (Foam::label vI = 0; vI < 4; ++vI)
|
||||
{
|
||||
if (c->vertex(vI)->referred())
|
||||
{
|
||||
masterProc = min(masterProc, c->vertex(vI)->procIndex());
|
||||
}
|
||||
else
|
||||
{
|
||||
masterProc = min(masterProc, Foam::Pstream::myProcNo());
|
||||
}
|
||||
}
|
||||
|
||||
return masterProc;
|
||||
}
|
||||
|
||||
|
||||
template<class CellType>
|
||||
Foam::FixedList<Foam::label, 4>
|
||||
CGAL::indexedCellOps::processorsAttached(const CellType& c)
|
||||
{
|
||||
Foam::FixedList<Foam::label, 4> procsAttached(Foam::Pstream::myProcNo());
|
||||
|
||||
if (!c->parallelDualVertex())
|
||||
{
|
||||
return procsAttached;
|
||||
}
|
||||
|
||||
for (Foam::label vI = 0; vI < 4; ++vI)
|
||||
{
|
||||
if (c->vertex(vI)->referred())
|
||||
{
|
||||
procsAttached[vI] = c->vertex(vI)->procIndex();
|
||||
}
|
||||
}
|
||||
|
||||
return procsAttached;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user