219 CellSizeDelaunay::Finite_vertices_iterator vit =
220 finite_vertices_begin();
221 vit != finite_vertices_end();
225 std::list<Vertex_handle> verts;
226 adjacent_vertices(vit, std::back_inserter(verts));
228 bool removePt =
true;
231 std::list<Vertex_handle>::iterator aVit = verts.begin();
239 mag(avh->targetCellSize() - vit->targetCellSize())
240 /
max(vit->targetCellSize(), 1
e-6);
261 tmp<pointField> tcellCentres(
new pointField(number_of_finite_cells()));
267 CellSizeDelaunay::Finite_cells_iterator
c = finite_cells_begin();
268 c != finite_cells_end();
272 if (
c->hasFarPoint())
282 CGAL::centroid<baseK>
284 c->vertex(0)->point(),
285 c->vertex(1)->point(),
286 c->vertex(2)->point(),
287 c->vertex(3)->point()
291 cellCentres[
count++] = centre;
294 cellCentres.resize(
count);
304 "refinementTriangulation_" 311 Info<<
"Write refinementTriangulation" <<
endl;
315 CellSizeDelaunay::Finite_edges_iterator
e = finite_edges_begin();
316 e != finite_edges_end();
320 Cell_handle
c =
e->first;
321 Vertex_handle vA =
c->vertex(
e->second);
322 Vertex_handle vB =
c->vertex(
e->third);
325 if (vA->farPoint() || vB->farPoint())
331 if (vA->referred() && vB->referred())
344 Info<<
" Triangulation is valid" <<
endl;
349 <<
"Triangulation is not valid" 357 Foam::cellShapeControlMesh::cellShapeControlMesh(
const Time&
runTime)
366 if (this->vertexCount())
380 if (
mesh.nPoints() == this->vertexCount())
402 mesh.time().timeName(),
411 if (alignments.size() == this->vertexCount())
415 Finite_vertices_iterator vit = finite_vertices_begin();
416 vit != finite_vertices_end();
420 vit->targetCellSize() = sizes[vit->index()];
421 vit->alignment() = alignments[vit->index()];
427 <<
"Cell alignments point field " << alignments.size()
428 <<
" is not the same size as the number of vertices" 429 <<
" in the mesh " << this->vertexCount()
451 if (dimension() > 2 && !is_infinite(ch))
457 topoint(ch->vertex(0)->point()),
458 topoint(ch->vertex(1)->point()),
459 topoint(ch->vertex(2)->point()),
460 topoint(ch->vertex(3)->point())
463 bary = tet.pointToBarycentric(pt);
470 DynamicList<Foam::point>
pts(number_of_vertices());
474 Finite_vertices_iterator vit = finite_vertices_begin();
475 vit != finite_vertices_end();
493 const backgroundMeshDecomposition& decomposition
496 DynamicList<Foam::point>
points(number_of_vertices());
497 DynamicList<scalar> sizes(number_of_vertices());
498 DynamicList<tensor> alignments(number_of_vertices());
500 DynamicList<Vb> farPts(8);
504 Finite_vertices_iterator vit = finite_vertices_begin();
505 vit != finite_vertices_end();
512 sizes.append(vit->targetCellSize());
513 alignments.append(vit->alignment());
515 else if (vit->farPoint())
528 farPts.last().targetCellSize() = vit->targetCellSize();
529 farPts.last().alignment() = vit->alignment();
533 autoPtr<mapDistribute> mapDist =
540 mapDist().distribute(sizes);
541 mapDist().distribute(alignments);
548 DynamicList<Vb> verticesToInsert(
points.
size());
553 verticesToInsert.append(farPts[ptI]);
559 verticesToInsert.append
570 verticesToInsert.last().targetCellSize() = sizes[pI];
571 verticesToInsert.last().alignment() = alignments[pI];
574 Info<<
nl <<
" Inserting distributed background tessellation..." <<
endl;
576 this->rangeInsertWithInfo
578 verticesToInsert.begin(),
579 verticesToInsert.end(),
583 sync(decomposition.procBounds());
585 Info<<
" Total number of vertices after redistribution " 597 Finite_vertices_iterator vit = finite_vertices_begin();
598 vit != finite_vertices_end();
602 alignmentsTmp[
count++] = vit->alignment();
605 return alignmentsTmp;
611 Info<<
"Writing " << meshSubDir <<
endl;
617 Finite_cells_iterator cit = finite_cells_begin();
618 cit != finite_cells_end();
622 if (!cit->hasFarPoint() && !is_infinite(cit))
624 cit->cellIndex() = cellCount++;
673 Finite_vertices_iterator vit = finite_vertices_begin();
674 vit != finite_vertices_end();
678 if (!vit->farPoint())
681 sizes[vertexMap[
labelPair(vit->index(), vit->procIndex())]] =
682 vit->targetCellSize();
684 alignments[vertexMap[
labelPair(vit->index(), vit->procIndex())]] =
721 const autoPtr<backgroundMeshDecomposition>& decomposition
726 scalar cellCount = 0;
730 Finite_cells_iterator cit = finite_cells_begin();
731 cit != finite_cells_end();
735 if (!cit->hasFarPoint() && !is_infinite(cit))
738 CGAL::Tetrahedron_3<baseK> tet
740 cit->vertex(0)->point(),
741 cit->vertex(1)->point(),
742 cit->vertex(2)->point(),
743 cit->vertex(3)->point()
751 && !decomposition().positionOnThisProcessor(centre)
757 scalar
volume = CGAL::to_double(tet.volume());
759 scalar averagedPointCellSize = 0;
763 for (label vI = 0; vI < 4; ++vI)
765 averagedPointCellSize += cit->vertex(vI)->targetCellSize();
769 averagedPointCellSize /= 4;
785 cellCount +=
volume/
pow(averagedPointCellSize, 3);
List< scalar > scalarList
List of scalar.
void writeTriangulation()
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
autoPtr< polyMesh > createMesh(const fileName &name, labelPairLookup &vertexMap, labelList &cellMap, const bool writeDelaunayData=true) const
Create an fvMesh from the triangulation.
void size(const label n)
Older name for setAddressableSize.
pointFromPoint topoint(const Point &P)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
tmp< pointField > cellCentres() const
Get the centres of all the tets.
tetrahedron< point, const point & > tetPointRef
A tetrahedron using referred points.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
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 min/max extrema points.
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
Ignore writing from objectRegistry::writeObject()
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
const Time & time() const
Return the top-level database.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
tensorField dumpAlignments() const
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
#define forAll(list, i)
Loop across all elements in list.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
A class for handling words, derived from Foam::string.
Reading is optional [identical to LAZY_READ].
void reset()
Clear the entire triangulation.
PointFrompoint toPoint(const Foam::point &p)
void distribute(const backgroundMeshDecomposition &decomposition)
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
errorManip< error > abort(error &err)
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
const wordList volume
Standard volume field types (scalar, vector, tensor, etc)
IOField< triad > triadIOField
IO for a Field of triad.
CellSizeDelaunay::Vertex_handle Vertex_handle
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Pair< label > labelPair
A pair of labels.
defineTypeNameAndDebug(combustionModel, 0)
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
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionedScalar c
Speed of light in a vacuum.
Automatically write from objectRegistry::writeObject()
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...
messageStream Info
Information stream (stdout output on master, null elsewhere)
label estimateCellCount(const autoPtr< backgroundMeshDecomposition > &decomposition) const
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Do not request registration (bool: false)
static constexpr const zero Zero
Global zero (0)