52 void Foam::sampledSets::boundaryRandom::calcSamples
54 DynamicList<point>& samplingPts,
55 DynamicList<label>& samplingCells,
56 DynamicList<label>& samplingFaces,
57 DynamicList<label>& samplingSegments,
58 DynamicList<scalar>& samplingCurveDist
62 List<DynamicList<face>> trisDyn(patches_.size());
63 List<DynamicList<label>> trisFaceiDyn(patches_.size());
66 const polyPatch& patch =
mesh().boundaryMesh()[
patchi];
70 const face& f = patch[patchFacei];
71 const label facei = patchFacei + patch.start();
73 DynamicList<face> faceTris(f.nTriangles());
74 f.triangles(patch.points(), faceTris);
76 trisDyn[
patchi].append(faceTris);
81 List<faceList> tris(patches_.size());
82 List<labelList> trisFacei(patches_.size());
85 tris[
patchi].transfer(trisDyn[patchi]);
86 trisFacei[
patchi].transfer(trisFaceiDyn[patchi]);
90 List<scalarField> trisFraction(patches_.size());
93 const polyPatch& patch =
mesh().boundaryMesh()[
patchi];
97 forAll(tris[patchi], patchTrii)
99 trisFraction[
patchi][patchTrii + 1] =
100 trisFraction[
patchi][patchTrii]
101 + tris[
patchi][patchTrii].mag(points);
105 scalarField patchesFraction(patches_.size() + 1, 0);
108 patchesFraction[patchi + 1] =
119 procsFraction[proci + 1] = procsFraction[proci] + procsArea[proci];
122 bool anyTris =
false;
125 if (tris[patchi].
size())
134 patchesFraction /= patchesFraction.last();
137 procsFraction /= procsFraction.last();
142 for (
label i = 0; i < nPoints_; ++ i)
147 const scalar rProc =
rndGen.scalar01();
148 const scalar rPatch =
rndGen.scalar01();
149 const scalar rTri =
rndGen.scalar01();
152 if (procsFraction[proci] < rProc && rProc <= procsFraction[proci + 1])
155 while (rPatch > patchesFraction[patchi + 1])
161 while (rTri > trisFraction[patchi][trii + 1])
166 const polyPatch& patch =
mesh().boundaryMesh()[
patchi];
168 const face& tf = tris[
patchi][trii];
169 const triPointRef tt(points[tf[0]], points[tf[1]], points[tf[2]]);
171 samplingPts.append(tt.barycentricToPoint(r));
172 samplingCells.append(
mesh().faceOwner()[trisFacei[patchi][trii]]);
173 samplingFaces.append(trisFacei[patchi][trii]);
174 samplingSegments.append(0);
175 samplingCurveDist.append(scalar(i));
181 void Foam::sampledSets::boundaryRandom::genSamples()
184 DynamicList<point> samplingPts;
185 DynamicList<label> samplingCells;
186 DynamicList<label> samplingFaces;
187 DynamicList<label> samplingSegments;
188 DynamicList<scalar> samplingCurveDist;
199 samplingPts.shrink();
200 samplingCells.shrink();
201 samplingFaces.shrink();
202 samplingSegments.shrink();
203 samplingCurveDist.shrink();
barycentric2D barycentric2D01(Random &rndGen)
Generate a random barycentric coordinate within the unit triangle.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
A list of keyword definitions, which are a keyword followed by any number of values (e...
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch IDs corresponding to the given names.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
virtual ~boundaryRandom()
Destructor.
Macros for easy insertion into run-time selection tables.
vectorField pointField
pointField is a vectorField.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
A class for handling words, derived from string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< label > labelList
A List of labels.
label readLabel(Istream &is)
addToRunTimeSelectionTable(sampledSet, arcUniform, word)
label size() const
Return the number of elements in the UPtrList.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
virtual bool write()
Sample and write.
triangle< point, const point & > triPointRef
boundaryRandom(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
Mesh consisting of general polyhedral cells.
List< wordRe > wordReList
A List of wordRe (word or regular expression)
defineTypeNameAndDebug(arcUniform, 0)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.