222 CellSizeDelaunay::Finite_vertices_iterator vit =
223 finite_vertices_begin();
224 vit != finite_vertices_end();
228 std::list<Vertex_handle> verts;
229 adjacent_vertices(vit, std::back_inserter(verts));
231 bool removePt =
true;
234 std::list<Vertex_handle>::iterator aVit = verts.begin();
239 Vertex_handle avh = *aVit;
242 mag(avh->targetCellSize() - vit->targetCellSize())
243 /
max(vit->targetCellSize(), 1
e-6);
264 tmp<pointField> tcellCentres(
new pointField(number_of_finite_cells()));
270 CellSizeDelaunay::Finite_cells_iterator c = finite_cells_begin();
271 c != finite_cells_end();
275 if (c->hasFarPoint())
285 CGAL::centroid<baseK>
287 c->vertex(0)->point(),
288 c->vertex(1)->point(),
289 c->vertex(2)->point(),
290 c->vertex(3)->point()
294 cellCentres[count++] = centre;
297 cellCentres.resize(count);
307 "refinementTriangulation_" 314 Info<<
"Write refinementTriangulation" <<
endl;
318 CellSizeDelaunay::Finite_edges_iterator
e = finite_edges_begin();
319 e != finite_edges_end();
323 Cell_handle c =
e->first;
324 Vertex_handle vA = c->vertex(
e->second);
325 Vertex_handle vB = c->vertex(
e->third);
328 if (vA->farPoint() || vB->farPoint())
334 if (vA->referred() && vB->referred())
347 Info<<
" Triangulation is valid" <<
endl;
352 <<
"Triangulation is not valid" 360 Foam::cellShapeControlMesh::cellShapeControlMesh(
const Time& runTime)
368 defaultCellSize_(0.0)
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 tet.barycentric(pt, bary);
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()
#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)
const double e
Elementary charge.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
autoPtr< polyMesh > createMesh(const fileName &name, labelTolabelPairHashTable &vertexMap, labelList &cellMap, const bool writeDelaunayData=true) const
Create an fvMesh from the triangulation.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
tetrahedron< point, const point & > tetPointRef
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)
A bounding box defined in terms of the points at its extremities.
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
static const pointMesh & New(const polyMesh &mesh)
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
A List of scalars.
void barycentricCoords(const Foam::point &pt, scalarList &bary, Cell_handle &ch) const
Calculate and return the barycentric coordinates for.
void reset()
Clear the entire triangulation.
Pair< label > labelPair
Label pair.
label estimateCellCount(const autoPtr< backgroundMeshDecomposition > &decomposition) const
PointFrompoint toPoint(const Foam::point &p)
List< label > labelList
A List of labels.
void distribute(const backgroundMeshDecomposition &decomposition)
errorManip< error > abort(error &err)
tensorField dumpAlignments() const
defineTypeNameAndDebug(combustionModel, 0)
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?
const dimensionedScalar c
Speed of light in a vacuum.
dimensioned< scalar > mag(const dimensioned< Type > &)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A class for managing temporary objects.
IOField< triad > triadIOField
triadField with IO.