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())
385 if (mesh.nPoints() == this->vertexCount())
407 mesh.time().timeName(),
418 sizes.size() == this->vertexCount()
419 && alignments.size() == this->vertexCount()
424 Finite_vertices_iterator vit = finite_vertices_begin();
425 vit != finite_vertices_end();
429 vit->targetCellSize() = sizes[vit->index()];
430 vit->alignment() = alignments[vit->index()];
436 <<
"Cell size point field is not the same size as the " 464 if (dimension() > 2 && !is_infinite(ch))
470 topoint(ch->vertex(0)->point()),
471 topoint(ch->vertex(1)->point()),
472 topoint(ch->vertex(2)->point()),
473 topoint(ch->vertex(3)->point())
476 bary = tet.pointToBarycentric(pt);
483 DynamicList<Foam::point> pts(number_of_vertices());
487 Finite_vertices_iterator vit = finite_vertices_begin();
488 vit != finite_vertices_end();
494 pts.append(
topoint(vit->point()));
506 const backgroundMeshDecomposition& decomposition
509 DynamicList<Foam::point>
points(number_of_vertices());
510 DynamicList<scalar> sizes(number_of_vertices());
511 DynamicList<tensor> alignments(number_of_vertices());
513 DynamicList<Vb> farPts(8);
517 Finite_vertices_iterator vit = finite_vertices_begin();
518 vit != finite_vertices_end();
525 sizes.append(vit->targetCellSize());
526 alignments.append(vit->alignment());
528 else if (vit->farPoint())
541 farPts.last().targetCellSize() = vit->targetCellSize();
542 farPts.last().alignment() = vit->alignment();
546 autoPtr<distributionMap> mapDist =
553 mapDist().distribute(sizes);
554 mapDist().distribute(alignments);
561 DynamicList<Vb> verticesToInsert(
points.size());
566 verticesToInsert.append(farPts[ptI]);
572 verticesToInsert.append
583 verticesToInsert.last().targetCellSize() = sizes[pI];
584 verticesToInsert.last().alignment() = alignments[pI];
587 Info<<
nl <<
" Inserting distributed background tessellation..." <<
endl;
589 this->rangeInsertWithInfo
591 verticesToInsert.begin(),
592 verticesToInsert.end(),
596 sync(decomposition.procBounds());
598 Info<<
" Total number of vertices after redistribution " 610 Finite_vertices_iterator vit = finite_vertices_begin();
611 vit != finite_vertices_end();
615 alignmentsTmp[count++] = vit->alignment();
618 return alignmentsTmp;
624 Info<<
"Writing " << meshSubDir <<
endl;
630 Finite_cells_iterator cit = finite_cells_begin();
631 cit != finite_cells_end();
635 if (!cit->hasFarPoint() && !is_infinite(cit))
637 cit->cellIndex() = cellCount++;
650 const polyMesh& mesh =
meshPtr();
657 mesh.time().timeName(),
672 mesh.time().timeName(),
686 Finite_vertices_iterator vit = finite_vertices_begin();
687 vit != finite_vertices_end();
691 if (!vit->farPoint())
694 sizes[vertexMap[
labelPair(vit->index(), vit->procIndex())]] =
695 vit->targetCellSize();
697 alignments[vertexMap[
labelPair(vit->index(), vit->procIndex())]] =
734 const autoPtr<backgroundMeshDecomposition>& decomposition
739 scalar cellCount = 0;
743 Finite_cells_iterator cit = finite_cells_begin();
744 cit != finite_cells_end();
748 if (!cit->hasFarPoint() && !is_infinite(cit))
751 CGAL::Tetrahedron_3<baseK> tet
753 cit->vertex(0)->point(),
754 cit->vertex(1)->point(),
755 cit->vertex(2)->point(),
756 cit->vertex(3)->point()
764 && !decomposition().positionOnThisProcessor(centre)
770 scalar volume = CGAL::to_double(tet.volume());
772 scalar averagedPointCellSize = 0;
776 for (
label vI = 0; vI < 4; ++vI)
778 averagedPointCellSize += cit->vertex(vI)->targetCellSize();
782 averagedPointCellSize /= 4;
798 cellCount += volume/
pow(averagedPointCellSize, 3);
void writeTriangulation()
tetrahedron< point, const point & > tetPointRef
#define forAll(list, i)
Loop across all elements in list.
~cellShapeControlMesh()
Destructor.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > 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)
#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)
Holds information (coordinate and normal) regarding nearest wall point.
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)
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
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.