53 void Foam::sampledSets::boundaryRandom::calcSamples
55 DynamicList<point>& samplingPts,
56 DynamicList<label>& samplingCells,
57 DynamicList<label>& samplingFaces,
58 DynamicList<label>& samplingSegments,
59 DynamicList<scalar>& samplingCurveDist
63 const labelList patchIDs(
mesh().boundaryMesh().patchSet(patches_).toc());
66 DynamicList<label> triFaces, triTetPts;
69 const polyPatch& patch =
mesh().boundaryMesh()[patchIDs[
patchi]];
73 const face& f = patch[patchFacei];
74 const label facei = patchFacei + patch.start();
76 for (
label tetPti = 1; tetPti < f.size() - 1; ++ tetPti)
78 triFaces.append(facei);
79 triTetPts.append(tetPti);
88 const tetIndices tetIs
90 mesh().faceOwner()[triFaces[trii]],
95 trisFraction[trii + 1] =
96 trisFraction[trii] + tetIs.faceTri(
mesh()).mag();
107 procsFraction[proci + 1] = procsFraction[proci] + procsArea[proci];
113 trisFraction /= trisFraction.last();
116 if (procsFraction.last() != 0)
118 procsFraction /= procsFraction.last();
124 for (
label i = 0; i < nPoints_; ++ i)
129 const scalar rProc =
rndGen.scalar01();
130 const scalar rTri =
rndGen.scalar01();
133 if (procsFraction[proci] < rProc && rProc <= procsFraction[proci + 1])
136 while (rTri > trisFraction[trii + 1])
141 const tetIndices tetIs
143 mesh().faceOwner()[triFaces[trii]],
151 (1 - rootSmall)*r2D.a(),
152 (1 - rootSmall)*r2D.b(),
153 (1 - rootSmall)*r2D.c()
156 samplingPts.append(tetIs.tet(mesh()).barycentricToPoint(r3D));
157 samplingCells.append(tetIs.cell());
158 samplingFaces.append(tetIs.face());
159 samplingSegments.append(0);
160 samplingCurveDist.append(scalar(i));
166 void Foam::sampledSets::boundaryRandom::genSamples()
169 DynamicList<point> samplingPts;
170 DynamicList<label> samplingCells;
171 DynamicList<label> samplingFaces;
172 DynamicList<label> samplingSegments;
173 DynamicList<scalar> samplingCurveDist;
184 samplingPts.shrink();
185 samplingCells.shrink();
186 samplingFaces.shrink();
187 samplingSegments.shrink();
188 samplingCurveDist.shrink();
212 patches_(dict.
lookup(
"patches")),
barycentric2D barycentric2D01(Random &rndGen)
Generate a random barycentric coordinate within the unit triangle.
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)
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
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.
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.
addToRunTimeSelectionTable(sampledSet, arcUniform, word)
static label nProcs(const label communicator=0)
Number of processes in parallel run.
virtual bool write()
Sample and write.
boundaryRandom(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
Mesh consisting of general polyhedral cells.
defineTypeNameAndDebug(arcUniform, 0)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.