Go to the documentation of this file.
225 CellSizeDelaunay::Finite_vertices_iterator vit =
226 finite_vertices_begin();
227 vit != finite_vertices_end();
231 std::list<Vertex_handle> verts;
232 adjacent_vertices(vit, std::back_inserter(verts));
234 bool removePt =
true;
237 std::list<Vertex_handle>::iterator aVit = verts.begin();
245 mag(avh->targetCellSize() - vit->targetCellSize())
246 /
max(vit->targetCellSize(), 1
e-6);
267 tmp<pointField> tcellCentres(
new pointField(number_of_finite_cells()));
273 CellSizeDelaunay::Finite_cells_iterator
c = finite_cells_begin();
274 c != finite_cells_end();
278 if (
c->hasFarPoint())
288 CGAL::centroid<baseK>
290 c->vertex(0)->point(),
291 c->vertex(1)->point(),
292 c->vertex(2)->point(),
293 c->vertex(3)->point()
297 cellCentres[
count++] = centre;
300 cellCentres.resize(
count);
310 "refinementTriangulation_"
317 Info<<
"Write refinementTriangulation" <<
endl;
321 CellSizeDelaunay::Finite_edges_iterator
e = finite_edges_begin();
322 e != finite_edges_end();
326 Cell_handle
c =
e->first;
327 Vertex_handle vA =
c->vertex(
e->second);
328 Vertex_handle vB =
c->vertex(
e->third);
331 if (vA->farPoint() || vB->farPoint())
337 if (vA->referred() && vB->referred())
350 Info<<
" Triangulation is valid" <<
endl;
355 <<
"Triangulation is not valid"
363 Foam::cellShapeControlMesh::cellShapeControlMesh(
const Time&
runTime)
372 if (this->vertexCount())
386 if (
mesh.nPoints() == this->vertexCount())
408 mesh.time().timeName(),
417 if (alignments.size() == this->vertexCount())
421 Finite_vertices_iterator vit = finite_vertices_begin();
422 vit != finite_vertices_end();
426 vit->targetCellSize() = sizes[vit->index()];
427 vit->alignment() = alignments[vit->index()];
433 <<
"Cell alignments point field " << alignments.size()
434 <<
" is not the same size as the number of vertices"
435 <<
" in the mesh " << this->vertexCount()
457 if (dimension() > 2 && !is_infinite(ch))
463 topoint(ch->vertex(0)->point()),
464 topoint(ch->vertex(1)->point()),
465 topoint(ch->vertex(2)->point()),
466 topoint(ch->vertex(3)->point())
469 bary = tet.pointToBarycentric(pt);
476 DynamicList<Foam::point> pts(number_of_vertices());
480 Finite_vertices_iterator vit = finite_vertices_begin();
481 vit != finite_vertices_end();
487 pts.append(
topoint(vit->point()));
499 const backgroundMeshDecomposition& decomposition
502 DynamicList<Foam::point>
points(number_of_vertices());
503 DynamicList<scalar> sizes(number_of_vertices());
504 DynamicList<tensor> alignments(number_of_vertices());
506 DynamicList<Vb> farPts(8);
510 Finite_vertices_iterator vit = finite_vertices_begin();
511 vit != finite_vertices_end();
518 sizes.append(vit->targetCellSize());
519 alignments.append(vit->alignment());
521 else if (vit->farPoint())
534 farPts.last().targetCellSize() = vit->targetCellSize();
535 farPts.last().alignment() = vit->alignment();
539 autoPtr<mapDistribute> mapDist =
546 mapDist().distribute(sizes);
547 mapDist().distribute(alignments);
554 DynamicList<Vb> verticesToInsert(
points.size());
559 verticesToInsert.append(farPts[ptI]);
565 verticesToInsert.append
576 verticesToInsert.last().targetCellSize() = sizes[pI];
577 verticesToInsert.last().alignment() = alignments[pI];
580 Info<<
nl <<
" Inserting distributed background tessellation..." <<
endl;
582 this->rangeInsertWithInfo
584 verticesToInsert.begin(),
585 verticesToInsert.end(),
589 sync(decomposition.procBounds());
591 Info<<
" Total number of vertices after redistribution "
603 Finite_vertices_iterator vit = finite_vertices_begin();
604 vit != finite_vertices_end();
608 alignmentsTmp[
count++] = vit->alignment();
611 return alignmentsTmp;
617 Info<<
"Writing " << meshSubDir <<
endl;
623 Finite_cells_iterator cit = finite_cells_begin();
624 cit != finite_cells_end();
628 if (!cit->hasFarPoint() && !is_infinite(cit))
630 cit->cellIndex() = cellCount++;
679 Finite_vertices_iterator vit = finite_vertices_begin();
680 vit != finite_vertices_end();
684 if (!vit->farPoint())
687 sizes[vertexMap[
labelPair(vit->index(), vit->procIndex())]] =
688 vit->targetCellSize();
690 alignments[vertexMap[
labelPair(vit->index(), vit->procIndex())]] =
727 const autoPtr<backgroundMeshDecomposition>& decomposition
732 scalar cellCount = 0;
736 Finite_cells_iterator cit = finite_cells_begin();
737 cit != finite_cells_end();
741 if (!cit->hasFarPoint() && !is_infinite(cit))
744 CGAL::Tetrahedron_3<baseK> tet
746 cit->vertex(0)->point(),
747 cit->vertex(1)->point(),
748 cit->vertex(2)->point(),
749 cit->vertex(3)->point()
757 && !decomposition().positionOnThisProcessor(centre)
763 scalar
volume = CGAL::to_double(tet.volume());
765 scalar averagedPointCellSize = 0;
769 for (label vI = 0; vI < 4; ++vI)
771 averagedPointCellSize += cit->vertex(vI)->targetCellSize();
775 averagedPointCellSize /= 4;
791 cellCount +=
volume/
pow(averagedPointCellSize, 3);
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
A List of scalars.
Foam::autoPtr< Foam::fvMesh > meshPtr(nullptr)
tensorField dumpAlignments() const
A class for handling words, derived from Foam::string.
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
A class for managing temporary objects.
label estimateCellCount(const autoPtr< backgroundMeshDecomposition > &decomposition) const
static constexpr const zero Zero
Global zero (0)
autoPtr< polyMesh > createMesh(const fileName &name, labelPairLookup &vertexMap, labelList &cellMap, const bool writeDelaunayData=true) const
Create an fvMesh from the triangulation.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
static word timeName(const scalar t, const int precision=precision_)
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const wordList volume
Standard volume field types (scalar, vector, tensor, etc)
pointFromPoint topoint(const Point &P)
tetrahedron< point, const point & > tetPointRef
A tetrahedron using referred points.
#define forAll(list, i)
Loop across all elements in list.
Pair< label > labelPair
A pair of labels.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
void barycentricCoords(const Foam::point &pt, barycentric &bary, Cell_handle &ch) const
Calculate and return the barycentric coordinates for.
messageStream Info
Information stream (stdout output on master, null elsewhere)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
CellSizeDelaunay::Vertex_handle Vertex_handle
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
HashTable< label, labelPair, Foam::Hash< labelPair > > labelPairLookup
This is a Map of a labelPair to a label. Used for e.g. for face1, face2 to shared edge....
PointFrompoint toPoint(const Foam::point &p)
void distribute(const backgroundMeshDecomposition &decomposition)
errorManip< error > abort(error &err)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static word meshSubDir
Return the mesh sub-directory name (usually "cellShapeControlMesh")
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
bool distribute(const boundBox &bb)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
static bool & parRun() noexcept
Test if this a parallel run.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void writeTriangulation()
CellSizeDelaunay::Cell_handle Cell_handle
const dimensionedScalar e
Elementary charge.
A bounding box defined in terms of min/max extrema points.
const dimensionedScalar c
Speed of light in a vacuum.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const Time & time() const
Return the top-level database.
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
tmp< pointField > cellCentres() const
Get the centres of all the tets.
defineTypeNameAndDebug(combustionModel, 0)
IOField< triad > triadIOField
triadField with IO.
CGAL::Delaunay_triangulation_3< K, Tds, FastLocator > CellSizeDelaunay
void reset()
Clear the entire triangulation.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField