53 void Foam::sampledSets::boundaryRandom::calcSamples
55 DynamicList<point>& samplingPositions,
56 DynamicList<label>& samplingSegments,
57 DynamicList<label>& samplingCells,
58 DynamicList<label>& samplingFaces
62 const labelList patchIDs(
mesh().boundaryMesh().patchSet(patches_).toc());
65 DynamicList<label> triFaces, triTetPts;
72 const face&
f = patch[patchFacei];
73 const label facei = patchFacei + patch.start();
75 for (
label tetPti = 1; tetPti <
f.size() - 1; ++ tetPti)
77 triFaces.append(facei);
78 triTetPts.append(tetPti);
87 const tetIndices tetIs
89 mesh().faceOwner()[triFaces[trii]],
94 trisFraction[trii + 1] =
95 trisFraction[trii] + tetIs.faceTri(
mesh()).mag();
106 procsFraction[proci + 1] = procsFraction[proci] + procsArea[proci];
112 trisFraction /= trisFraction.last();
115 if (procsFraction.last() != 0)
117 procsFraction /= procsFraction.last();
121 randomGenerator
rndGen(261782,
true);
123 for (
label i = 0; i < nPoints_; ++ i)
128 const scalar rProc =
rndGen.scalar01();
129 const scalar rTri =
rndGen.scalar01();
132 if (procsFraction[proci] < rProc && rProc <= procsFraction[proci + 1])
135 while (rTri > trisFraction[trii + 1])
140 const tetIndices tetIs
142 mesh().faceOwner()[triFaces[trii]],
150 (1 - rootSmall)*r2D.a(),
151 (1 - rootSmall)*r2D.b(),
152 (1 - rootSmall)*r2D.c()
155 samplingPositions.append(tetIs.tet(
mesh()).barycentricToPoint(r3D));
156 samplingSegments.append(i);
157 samplingCells.append(tetIs.cell());
158 samplingFaces.append(tetIs.face());
164 void Foam::sampledSets::boundaryRandom::genSamples()
166 DynamicList<point> samplingPositions;
167 DynamicList<label> samplingSegments;
168 DynamicList<label> samplingCells;
169 DynamicList<label> samplingFaces;
179 samplingPositions.shrink();
180 samplingSegments.shrink();
181 samplingCells.shrink();
182 samplingFaces.shrink();
205 patches_(
dict.lookup(
"patches")),
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
const polyMesh & mesh() const
Access the mesh.
Random samples within patches.
boundaryRandom(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
virtual ~boundaryRandom()
Destructor.
Set of sets to sample. Call sampledSets.write() to sample&write files.
A class for handling words, derived from string.
defineTypeNameAndDebug(arcUniform, 0)
addToRunTimeSelectionTable(sampledSet, arcUniform, word)
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
word name(const bool)
Return a word representation of a bool.
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
barycentric2D barycentric2D01(randomGenerator &rndGen)
Generate a random barycentric coordinate within the unit triangle.
randomGenerator rndGen(653213)