33 bool Foam::triangulatedPatch::randomPoint
54 for (label i = 0; i < triWght_.
size() - 1; ++i)
56 if (
c > triWght_[i] &&
c <= triWght_[i+1])
65 const face& tf = triFace_[trii];
68 result = tri.randomPoint(rnd);
69 facei = triToFace_[trii];
75 const point& cc =
mesh.cellCentres()[celli];
79 result -= perturbTol_*
n*
mag(
n & (cc - result));
94 const scalar perturbTol
98 perturbTol_(perturbTol),
110 const word& patchName,
111 const scalar perturbTol
120 void Foam::triangulatedPatch::update()
125 DynamicList<label> triToFace(2*patch_.size());
126 DynamicList<face>
triFace(2*patch_.size());
127 DynamicList<scalar> triWght(2*patch_.size());
128 DynamicList<face> tris(8);
131 triWght.push_back(0);
135 const face&
f = patch_[facei];
140 for (
const auto& t : tris)
144 triWght.push_back(t.mag(
points));
152 for (label i = 1; i < procSumWght.size(); ++i)
155 procSumWght[i] += procSumWght[i-1];
164 triWght[i] += triWght[i-1];
168 triWght[i] += offset;
172 const scalar sumWght = procSumWght.back();
173 for (scalar& w : triWght)
180 triToFace_.transfer(triToFace);
181 triWght_.transfer(triWght);
193 const scalar
c = rnd.
position<scalar>(triWght_.front(), triWght_.back());
195 return randomPoint(rnd,
c, 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< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
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 int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
void push_back(const T &val)
Append an element at the end of the list.
#define forAll(list, i)
Loop across all elements in list.
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.
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.
void clear()
Clear the list, i.e. set size to zero.
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.
A triangular face using a FixedList of labels corresponding to mesh vertices.
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...
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.
triangle< point, const point & > triPointRef
A triangle using referred points.
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.
Type position(const Type &start, const Type &end)
Return a sample on the interval [start,end].
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
After completion all processors have the same data.
static constexpr const zero Zero
Global zero (0)