32 bool Foam::triangulatedPatch::randomPoint
55 for (label i = 0; i < triWght_.
size() - 1; ++i)
57 if (
c > triWght_[i] &&
c <= triWght_[i+1])
67 result = triFace_[trii].tri(
points).randomPoint(rnd);
68 facei = triFace_[trii].index();
74 const point& cc =
mesh.cellCentres()[celli];
78 result -= perturbTol_*
n*
mag(
n & (cc - result));
93 const scalar perturbTol
97 perturbTol_(perturbTol),
108 const word& patchName,
109 const scalar perturbTol
118 void Foam::triangulatedPatch::triangulate
121 List<labelledTri>& tris
128 for (
const face&
f :
pp)
130 nTris +=
f.nTriangles();
133 DynamicList<labelledTri> dynTris(nTris);
134 DynamicList<face> tfaces(8);
137 for (
const face&
f :
pp)
142 for (
const auto& t : tfaces)
149 tris.transfer(dynTris);
155 void Foam::triangulatedPatch::update()
160 triangulate(patch_, triFace_);
168 triWght_.resize_nocopy(triFace_.size()+1);
170 auto iter = triWght_.begin();
173 scalar patchArea = 0;
177 for (
const auto& t : triFace_)
179 patchArea += t.mag(
points);
188 slice[myProci] = patchArea;
193 for (label i = 1; i < procSumArea.size(); ++i)
195 procSumArea[i] += procSumArea[i-1];
198 const scalar offset = procSumArea[myProci];
199 const scalar totalArea = procSumArea.back();
202 for (scalar& w : triWght_)
204 w = (w + offset) / totalArea;
217 if (triWght_.empty())
225 const scalar
c = rnd.position<scalar>(triWght_.front(), triWght_.back());
227 return randomPoint(rnd,
c, result, facei, celli);
242 const bool ok = randomPoint(rnd,
c, result, facei, celli);
247 label proci = valid.find(
true);
254 return randomLocalPoint(rnd, result, facei, celli);
triangulatedPatch(const polyPatch &patch, const scalar perturbTol)
Constructors.
List< scalar > scalarList
List of scalar.
void size(const label n)
Older name for setAddressableSize.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
T & front()
Access first element of the list, position [0].
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
static List< T > listGatherValues(const T &localValue, const label communicator=worldComm)
Gather individual values into list locations.
static bool & parRun() noexcept
Test if this a parallel run.
SubList< scalar > subList
Declare type of subList.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
vectorField pointField
pointField is a vectorField.
Type sample01()
Return a sample whose components lie in the range [0,1].
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
const labelUList & faceCells() const
Return face-cell addressing.
const polyMesh & mesh() const noexcept
Return the mesh reference.
A class for handling words, derived from Foam::string.
bool randomLocalPoint(Random &rnd, point &result, label &facei, label &celli) const
Set a random point on the local patch.
bool randomGlobalPoint(Random &rnd, point &result, label &facei, label &celli) const
Set a global random point on the patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual linear/tree communicat...
Performs a triangulation of a patch to return randomised point locations.
vector point
Point is a vector.
const dimensionedScalar c
Speed of light in a vacuum.
const std::string patch
OpenFOAM patch number as a std::string.
T & back()
Access last element of the list, position [size()-1].
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())