223 CellSizeDelaunay::Finite_vertices_iterator vit =
224 finite_vertices_begin();
225 vit != finite_vertices_end();
229 std::list<Vertex_handle> verts;
230 adjacent_vertices(vit, std::back_inserter(verts));
232 bool removePt =
true;
235 std::list<Vertex_handle>::iterator aVit = verts.begin();
240 Vertex_handle avh = *aVit;
243 mag(avh->targetCellSize() - vit->targetCellSize())
244 /
max(vit->targetCellSize(), 1
e-6);
265 tmp<pointField> tcellCentres(
new pointField(number_of_finite_cells()));
271 CellSizeDelaunay::Finite_cells_iterator c = finite_cells_begin();
272 c != finite_cells_end();
276 if (c->hasFarPoint())
286 CGAL::centroid<baseK>
288 c->vertex(0)->point(),
289 c->vertex(1)->point(),
290 c->vertex(2)->point(),
291 c->vertex(3)->point()
295 cellCentres[count++] = centre;
298 cellCentres.resize(count);
308 "refinementTriangulation_" 315 Info<<
"Write refinementTriangulation" <<
endl;
319 CellSizeDelaunay::Finite_edges_iterator
e = finite_edges_begin();
320 e != finite_edges_end();
324 Cell_handle c =
e->first;
325 Vertex_handle vA = c->vertex(
e->second);
326 Vertex_handle vB = c->vertex(
e->third);
329 if (vA->farPoint() || vB->farPoint())
335 if (vA->referred() && vB->referred())
348 Info<<
" Triangulation is valid" <<
endl;
353 <<
"Triangulation is not valid" 370 if (this->vertexCount())
384 if (mesh.nPoints() == this->vertexCount())
406 mesh.time().timeName(),
417 sizes.size() == this->vertexCount()
418 && alignments.size() == this->vertexCount()
423 Finite_vertices_iterator vit = finite_vertices_begin();
424 vit != finite_vertices_end();
428 vit->targetCellSize() = sizes[vit->index()];
429 vit->alignment() = alignments[vit->index()];
435 <<
"Cell size point field is not the same size as the " 463 if (dimension() > 2 && !is_infinite(ch))
469 topoint(ch->vertex(0)->point()),
470 topoint(ch->vertex(1)->point()),
471 topoint(ch->vertex(2)->point()),
472 topoint(ch->vertex(3)->point())
475 bary = tet.pointToBarycentric(pt);
482 DynamicList<Foam::point> pts(number_of_vertices());
486 Finite_vertices_iterator vit = finite_vertices_begin();
487 vit != finite_vertices_end();
493 pts.append(
topoint(vit->point()));
505 const backgroundMeshDecomposition& decomposition
508 DynamicList<Foam::point>
points(number_of_vertices());
509 DynamicList<scalar> sizes(number_of_vertices());
510 DynamicList<tensor> alignments(number_of_vertices());
512 DynamicList<Vb> farPts(8);
516 Finite_vertices_iterator vit = finite_vertices_begin();
517 vit != finite_vertices_end();
524 sizes.append(vit->targetCellSize());
525 alignments.append(vit->alignment());
527 else if (vit->farPoint())
540 farPts.last().targetCellSize() = vit->targetCellSize();
541 farPts.last().alignment() = vit->alignment();
545 autoPtr<mapDistribute> mapDist =
552 mapDist().distribute(sizes);
553 mapDist().distribute(alignments);
560 DynamicList<Vb> verticesToInsert(
points.size());
565 verticesToInsert.append(farPts[ptI]);
571 verticesToInsert.append
582 verticesToInsert.last().targetCellSize() = sizes[pI];
583 verticesToInsert.last().alignment() = alignments[pI];
586 Info<<
nl <<
" Inserting distributed background tessellation..." <<
endl;
588 this->rangeInsertWithInfo
590 verticesToInsert.begin(),
591 verticesToInsert.end(),
595 sync(decomposition.procBounds());
597 Info<<
" Total number of vertices after redistribution " 609 Finite_vertices_iterator vit = finite_vertices_begin();
610 vit != finite_vertices_end();
614 alignmentsTmp[count++] = vit->alignment();
617 return alignmentsTmp;
623 Info<<
"Writing " << meshSubDir <<
endl;
629 Finite_cells_iterator cit = finite_cells_begin();
630 cit != finite_cells_end();
634 if (!cit->hasFarPoint() && !is_infinite(cit))
636 cit->cellIndex() = cellCount++;
649 const polyMesh& mesh =
meshPtr();
656 mesh.time().timeName(),
671 mesh.time().timeName(),
685 Finite_vertices_iterator vit = finite_vertices_begin();
686 vit != finite_vertices_end();
690 if (!vit->farPoint())
693 sizes[vertexMap[
labelPair(vit->index(), vit->procIndex())]] =
694 vit->targetCellSize();
696 alignments[vertexMap[
labelPair(vit->index(), vit->procIndex())]] =
733 const autoPtr<backgroundMeshDecomposition>& decomposition
738 scalar cellCount = 0;
742 Finite_cells_iterator cit = finite_cells_begin();
743 cit != finite_cells_end();
747 if (!cit->hasFarPoint() && !is_infinite(cit))
750 CGAL::Tetrahedron_3<baseK> tet
752 cit->vertex(0)->point(),
753 cit->vertex(1)->point(),
754 cit->vertex(2)->point(),
755 cit->vertex(3)->point()
763 && !decomposition().positionOnThisProcessor(centre)
769 scalar volume = CGAL::to_double(tet.volume());
771 scalar averagedPointCellSize = 0;
775 for (
label vI = 0; vI < 4; ++vI)
777 averagedPointCellSize += cit->vertex(vI)->targetCellSize();
781 averagedPointCellSize /= 4;
797 cellCount += volume/
pow(averagedPointCellSize, 3);
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
void writeTriangulation()
tetrahedron< point, const point & > tetPointRef
#define forAll(list, i)
Loop across all elements in list.
~cellShapeControlMesh()
Destructor.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
pointFromPoint topoint(const Point &P)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
tmp< pointField > cellCentres() const
Get the centres of all the tets.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
HashTable< label, labelPair, FixedList< label, 2 >::Hash<> > labelTolabelPairHashTable
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool distribute(const boundBox &bb)
void barycentricCoords(const Foam::point &pt, barycentric &bary, Cell_handle &ch) const
Calculate and return the barycentric coordinates for.
A bounding box defined in terms of the points at its extremities.
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
const dimensionedScalar c
Speed of light in a vacuum.
tensorField dumpAlignments() const
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
A List of scalars.
void reset()
Clear the entire triangulation.
Pair< label > labelPair
Label pair.
PointFrompoint toPoint(const Foam::point &p)
List< label > labelList
A List of labels.
void distribute(const backgroundMeshDecomposition &decomposition)
errorManip< error > abort(error &err)
cellShapeControlMesh(const Time &runTime)
defineTypeNameAndDebug(combustionModel, 0)
static pointMesh & New(polyMesh &mesh)
word name(const complex &)
Return a string representation of a complex.
CGAL::Delaunay_triangulation_3< K, Tds, FastLocator > CellSizeDelaunay
static word meshSubDir
Return the mesh sub-directory name (usually "cellShapeControlMesh")
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
CellSizeDelaunay::Cell_handle Cell_handle
static bool & parRun()
Is this a parallel run?
dimensioned< scalar > mag(const dimensioned< Type > &)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const doubleScalar e
Elementary charge.
label estimateCellCount(const autoPtr< backgroundMeshDecomposition > &decomposition) const
A class for managing temporary objects.
IOField< triad > triadIOField
triadField with IO.
autoPtr< polyMesh > createMesh(const fileName &name, labelTolabelPairHashTable &vertexMap, labelList &cellMap, const bool writeDelaunayData=true) const
Create an fvMesh from the triangulation.