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();
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"
372 if (this->vertexCount())
381 IOobject::READ_IF_PRESENT,
386 if (
mesh.nPoints() == this->vertexCount())
399 if (
io.typeHeaderOk<pointScalarField>(
true))
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()
436 <<
abort(FatalError);
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 =
540 DistributedDelaunayMesh<CellSizeDelaunay>::distribute
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++;
637 autoPtr<polyMesh>
meshPtr = DelaunayMesh<CellSizeDelaunay>::createMesh
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);
CGAL::Delaunay_triangulation_3< K, Tds, FastLocator > CellSizeDelaunay
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
void reset()
Clear the entire triangulation.
void append(const T &val)
Append an element at the end of the list.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static word timeName(const scalar t, const int precision=precision_)
T & first()
Return the first element of the list.
void size(const label n)
Older name for setAddressableSize.
static bool & parRun() noexcept
Test if this a parallel run.
A bounding box defined in terms of min/max extrema points.
tmp< pointField > cellCentres() const
Get the centres of all the tets.
static word meshSubDir
Return the mesh sub-directory name (usually "cellShapeControlMesh")
label estimateCellCount(const autoPtr< backgroundMeshDecomposition > &decomposition) const
CellSizeDelaunay::Cell_handle Cell_handle
void barycentricCoords(const Foam::point &pt, barycentric &bary, Cell_handle &ch) const
Calculate and return the barycentric coordinates for.
CellSizeDelaunay::Vertex_handle Vertex_handle
tensorField dumpAlignments() const
void writeTriangulation()
void distribute(const backgroundMeshDecomposition &decomposition)
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
const Time & time() const
Return the top-level database.
int myProcNo() const noexcept
Return processor number.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
const dimensionedScalar c
Speed of light in a vacuum.
const wordList volume
Standard volume field types (scalar, vector, tensor, etc)
IOField< triad > triadIOField
triadField with IO.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Pair< label > labelPair
A pair of labels.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
tetrahedron< point, const point & > tetPointRef
A tetrahedron using referred points.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
List< label > labelList
A List of labels.
PointFrompoint toPoint(const Foam::point &p)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
pointFromPoint topoint(const Point &P)
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
A List of scalars.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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....
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.