mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: cvMesh: Improve parallel algorithm
Add functions to indexedCell and indexedVertex to calculate duals and work out whether cell or vertex is near a processor boundary. Add functions to seed and remove far points around the processor boundary.
This commit is contained in:
@ -240,9 +240,9 @@ void Foam::conformalVoronoiMesh::insertPoints
|
||||
{
|
||||
label preDistributionSize(points.size());
|
||||
|
||||
DynamicList<Foam::point> transferPoints(points.size()/2);
|
||||
DynamicList<Foam::point> transferPoints;
|
||||
|
||||
DynamicList<Point> pointsOnProcessor(points.size()/2);
|
||||
DynamicList<Point> pointsOnProcessor;
|
||||
|
||||
for
|
||||
(
|
||||
@ -277,12 +277,16 @@ void Foam::conformalVoronoiMesh::insertPoints
|
||||
decomposition_().distributePoints(transferPoints)
|
||||
);
|
||||
|
||||
const label oldSize = points.size();
|
||||
|
||||
points.setSize(oldSize + transferPoints.size());
|
||||
|
||||
forAll(transferPoints, tPI)
|
||||
{
|
||||
points.append(toPoint(transferPoints[tPI]));
|
||||
points[tPI + oldSize] = toPoint(transferPoints[tPI]);
|
||||
}
|
||||
|
||||
label sizeChange = preDistributionSize - label(points.size());
|
||||
label sizeChange = preDistributionSize - points.size();
|
||||
|
||||
// if (mag(sizeChange) > 0)
|
||||
// {
|
||||
@ -417,7 +421,6 @@ void Foam::conformalVoronoiMesh::insertPoints
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
rangeInsertWithInfo
|
||||
(
|
||||
pts.begin(),
|
||||
@ -1246,6 +1249,8 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
|
||||
// better balance the surface conformation load.
|
||||
distributeBackground();
|
||||
|
||||
// conformToSurface();
|
||||
|
||||
buildSurfaceConformation(rmCoarse);
|
||||
|
||||
// The introduction of the surface conformation may have distorted the
|
||||
@ -1313,7 +1318,7 @@ void Foam::conformalVoronoiMesh::move()
|
||||
{
|
||||
cit->cellIndex() = dualVertI;
|
||||
|
||||
dualVertices[dualVertI] = topoint(dual(cit));
|
||||
dualVertices[dualVertI] = cit->dual();
|
||||
|
||||
dualVertI++;
|
||||
}
|
||||
@ -1511,7 +1516,6 @@ void Foam::conformalVoronoiMesh::move()
|
||||
(
|
||||
toPoint(0.5*(dVA + dVB))
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
else if
|
||||
@ -1671,9 +1675,57 @@ void Foam::conformalVoronoiMesh::move()
|
||||
|
||||
insertPoints(pointsToInsert);
|
||||
|
||||
// Remove internal points that have been inserted outside the surface.
|
||||
label internalPtIsOutside = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->internalPoint())
|
||||
{
|
||||
bool inside
|
||||
= geometryToConformTo_.inside(topoint(vit->point()));
|
||||
|
||||
if (!inside)
|
||||
{
|
||||
remove(vit);
|
||||
internalPtIsOutside++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< " " << internalPtIsOutside
|
||||
<< " internal points were inserted outside the domain. "
|
||||
<< "They have been removed." << endl;
|
||||
|
||||
// Fix points that have not been significantly displaced
|
||||
// for
|
||||
// (
|
||||
// Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
// vit != finite_vertices_end();
|
||||
// ++vit
|
||||
// )
|
||||
// {
|
||||
// if (vit->internalPoint())
|
||||
// {
|
||||
// if
|
||||
// (
|
||||
// mag(displacementAccumulator[vit->index()])
|
||||
// < 0.1*targetCellSize(topoint(vit->point()))
|
||||
// )
|
||||
// {
|
||||
// vit->setVertexFixed();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (cvMeshControls().objOutput() && runTime_.outputTime())
|
||||
{
|
||||
writePoints("points_" + runTime_.timeName() + ".obj", false);
|
||||
writePoints("points_" + runTime_.timeName() + ".obj", true);
|
||||
}
|
||||
|
||||
timeCheck("Internal points inserted");
|
||||
|
||||
@ -48,7 +48,6 @@ SourceFiles
|
||||
#define CGAL_INEXACT
|
||||
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
#include <CGAL/Spatial_sort_traits_adapter_3.h>
|
||||
#include "uint.H"
|
||||
#include "ulong.H"
|
||||
#include "searchableSurfaces.H"
|
||||
@ -595,6 +594,12 @@ private:
|
||||
Foam::point& b
|
||||
) const;
|
||||
|
||||
label removeProcessorBoundarySeeds(bool reinsertBoundPts);
|
||||
|
||||
void seedProcessorBoundarySurfaces(bool seedProcessors);
|
||||
|
||||
label numberOfUnusedReferredPoints() const;
|
||||
|
||||
//- Build the parallelInterfaces of the mesh
|
||||
void buildParallelInterface
|
||||
(
|
||||
@ -1240,7 +1245,7 @@ public:
|
||||
Traits_for_spatial_sort<Triangulation>()
|
||||
);
|
||||
|
||||
typename Triangulation::Cell_handle hint;
|
||||
typename Triangulation::Vertex_handle hint;
|
||||
|
||||
for
|
||||
(
|
||||
@ -1250,16 +1255,9 @@ public:
|
||||
++p
|
||||
)
|
||||
{
|
||||
typename Triangulation::Locate_type lt;
|
||||
typename Triangulation::Cell_handle c;
|
||||
label li, lj;
|
||||
|
||||
c = T.locate(*(p->first), lt, li, lj, hint);
|
||||
|
||||
const size_t checkInsertion = T.number_of_vertices();
|
||||
|
||||
typename Triangulation::Vertex_handle v
|
||||
= T.insert(*(p->first), lt, c, li, lj);
|
||||
hint = T.insert(*(p->first), hint);
|
||||
|
||||
if (checkInsertion != T.number_of_vertices() - 1)
|
||||
{
|
||||
@ -1278,12 +1276,11 @@ public:
|
||||
// type directly (note that this routine never gets
|
||||
// called for referredPoints so type will never be
|
||||
// -procI
|
||||
type += T.number_of_vertices() - 1;
|
||||
type += checkInsertion;
|
||||
}
|
||||
|
||||
v->index() = indices[oldIndex]
|
||||
+ T.number_of_vertices() - 1;
|
||||
v->type() = type;
|
||||
hint->index() = indices[oldIndex] + checkInsertion;
|
||||
hint->type() = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1890,7 +1890,7 @@ void Foam::conformalVoronoiMesh::indexDualVertices
|
||||
{
|
||||
cit->cellIndex() = dualVertI;
|
||||
|
||||
pts[dualVertI] = topoint(dual(cit));
|
||||
pts[dualVertI] = cit->dual();
|
||||
|
||||
if
|
||||
(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -125,7 +125,7 @@ void Foam::conformalVoronoiMesh::drawDelaunayCell
|
||||
os << "# cell index: " << label(c->cellIndex()) << endl;
|
||||
|
||||
os << "# circumradius "
|
||||
<< mag(topoint(dual(c)) - topoint(c->vertex(0)->point()))
|
||||
<< mag(c->dual() - topoint(c->vertex(0)->point()))
|
||||
<< endl;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
@ -144,7 +144,7 @@ void Foam::conformalVoronoiMesh::drawDelaunayCell
|
||||
|
||||
os << "# cicumcentre " << endl;
|
||||
|
||||
meshTools::writeOBJ(os, topoint(dual(c)));
|
||||
meshTools::writeOBJ(os, c->dual());
|
||||
|
||||
os << "l " << 1 + offset << " " << 5 + offset << endl;
|
||||
}
|
||||
@ -167,7 +167,7 @@ void Foam::conformalVoronoiMesh::writePoints
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!internalOnly || vit->internalOrBoundaryPoint())
|
||||
if (!internalOnly || vit->internalPoint())
|
||||
{
|
||||
meshTools::writeOBJ(str, topoint(vit->point()));
|
||||
}
|
||||
@ -241,7 +241,7 @@ void Foam::conformalVoronoiMesh::writeProcessorInterface
|
||||
{
|
||||
if (!cit->farCell())
|
||||
{
|
||||
points[cit->cellIndex()] = topoint(dual(cit));
|
||||
points[cit->cellIndex()] = cit->dual();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ SourceFiles
|
||||
#include "Swap.H"
|
||||
#include "InfoProxy.H"
|
||||
#include "tetCell.H"
|
||||
#include "typeInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -154,6 +155,8 @@ public:
|
||||
|
||||
inline int cellIndex() const;
|
||||
|
||||
inline const Foam::point& dual();
|
||||
|
||||
inline bool farCell() const;
|
||||
|
||||
inline int& filterCount();
|
||||
@ -163,6 +166,11 @@ public:
|
||||
//- 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;
|
||||
|
||||
inline bool hasInternalPoint() const;
|
||||
|
||||
//- Does the Dual vertex form part of a processor patch
|
||||
inline bool parallelDualVertex() const;
|
||||
|
||||
@ -190,6 +198,8 @@ public:
|
||||
// least one Delaunay vertex outside and at least one inside
|
||||
inline bool boundaryDualVertex() const;
|
||||
|
||||
inline bool nearProcBoundary() const;
|
||||
|
||||
|
||||
// Info
|
||||
|
||||
|
||||
@ -86,6 +86,24 @@ int CGAL::indexedCell<Gt, Cb>::cellIndex() const
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
const Foam::point& CGAL::indexedCell<Gt, Cb>::dual()
|
||||
{
|
||||
#ifdef CGAL_INEXACT
|
||||
return reinterpret_cast<const Foam::point&>(this->circumcenter());
|
||||
#else
|
||||
const typename Gt::Point_3& P = this->circumcenter();
|
||||
|
||||
return
|
||||
(
|
||||
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>::farCell() const
|
||||
{
|
||||
@ -112,10 +130,45 @@ 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)->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>::hasInternalPoint() const
|
||||
{
|
||||
return
|
||||
(
|
||||
this->vertex(0)->internalPoint()
|
||||
|| this->vertex(1)->internalPoint()
|
||||
|| this->vertex(2)->internalPoint()
|
||||
|| this->vertex(3)->internalPoint()
|
||||
);
|
||||
}
|
||||
|
||||
@ -285,4 +338,17 @@ inline bool CGAL::indexedCell<Gt, Cb>::boundaryDualVertex() const
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -29,7 +29,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "indexedVertex.H"
|
||||
//#include "conformalVoronoiMesh.H"
|
||||
#include "point.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
|
||||
|
||||
@ -45,6 +45,7 @@ SourceFiles
|
||||
#include <CGAL/Triangulation_3.h>
|
||||
#include "tensor.H"
|
||||
#include "InfoProxy.H"
|
||||
#include "point.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -101,6 +102,8 @@ class indexedVertex
|
||||
//- Specify whether the vertex is fixed or movable.
|
||||
bool vertexFixed_;
|
||||
|
||||
bool nearProcBoundary_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -198,6 +201,12 @@ public:
|
||||
//- Set the point to be near the boundary
|
||||
inline void setNearBoundary();
|
||||
|
||||
//- Is point internal and near a proc boundary
|
||||
inline bool nearProcBoundary() const;
|
||||
|
||||
//- Set the point to be near a proc boundary
|
||||
inline void setNearProcBoundary();
|
||||
|
||||
//- Either master or slave of pointPair.
|
||||
inline bool pairPoint() const;
|
||||
|
||||
@ -227,7 +236,7 @@ public:
|
||||
inline bool isVertexFixed() const;
|
||||
|
||||
//- Fix the vertex so that it can't be moved
|
||||
inline void setVertexFixed() const;
|
||||
inline void setVertexFixed();
|
||||
|
||||
// inline void operator=(const Delaunay::Finite_vertices_iterator vit)
|
||||
// {
|
||||
|
||||
@ -38,7 +38,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex()
|
||||
type_(vtInternal),
|
||||
alignment_(),
|
||||
targetCellSize_(0.0),
|
||||
vertexFixed_(false)
|
||||
vertexFixed_(false),
|
||||
nearProcBoundary_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -50,7 +51,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(const Point& p)
|
||||
type_(vtInternal),
|
||||
alignment_(),
|
||||
targetCellSize_(0.0),
|
||||
vertexFixed_(false)
|
||||
vertexFixed_(false),
|
||||
nearProcBoundary_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -67,7 +69,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex
|
||||
type_(type),
|
||||
alignment_(),
|
||||
targetCellSize_(0.0),
|
||||
vertexFixed_(false)
|
||||
vertexFixed_(false),
|
||||
nearProcBoundary_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -79,7 +82,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(const Point& p, Cell_handle f)
|
||||
type_(vtInternal),
|
||||
alignment_(),
|
||||
targetCellSize_(0.0),
|
||||
vertexFixed_(false)
|
||||
vertexFixed_(false),
|
||||
nearProcBoundary_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -91,7 +95,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(Cell_handle f)
|
||||
type_(vtInternal),
|
||||
alignment_(),
|
||||
targetCellSize_(0.0),
|
||||
vertexFixed_(false)
|
||||
vertexFixed_(false),
|
||||
nearProcBoundary_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -251,6 +256,20 @@ inline void CGAL::indexedVertex<Gt, Vb>::setNearBoundary()
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Vb>
|
||||
inline bool CGAL::indexedVertex<Gt, Vb>::nearProcBoundary() const
|
||||
{
|
||||
return nearProcBoundary_;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Vb>
|
||||
inline void CGAL::indexedVertex<Gt, Vb>::setNearProcBoundary()
|
||||
{
|
||||
nearProcBoundary_ = true;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Vb>
|
||||
inline bool CGAL::indexedVertex<Gt, Vb>::pairPoint() const
|
||||
{
|
||||
@ -331,7 +350,7 @@ inline bool CGAL::indexedVertex<Gt, Vb>::isVertexFixed() const
|
||||
|
||||
|
||||
template<class Gt, class Vb>
|
||||
inline void CGAL::indexedVertex<Gt, Vb>::setVertexFixed() const
|
||||
inline void CGAL::indexedVertex<Gt, Vb>::setVertexFixed()
|
||||
{
|
||||
vertexFixed_ = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user