44 patchName_(patchName),
51 triCumulativeMagSf_(),
52 sumTriMagSf_(
Pstream::nProcs() + 1, Zero)
57 <<
"Requested patch " <<
patchName_ <<
" not found" <<
nl
68 patchName_(pib.patchName_),
69 patchId_(pib.patchId_),
70 patchArea_(pib.patchArea_),
71 patchNormal_(pib.patchNormal_),
72 cellOwners_(pib.cellOwners_),
73 triFace_(pib.triFace_),
74 triToFace_(pib.triToFace_),
75 triCumulativeMagSf_(pib.triCumulativeMagSf_),
76 sumTriMagSf_(pib.sumTriMagSf_)
88 cellOwners_ = patch.faceCells();
101 const face&
f = patch[facei];
119 for (label i = 1; i < triMagSf.
size(); i++)
121 triMagSf[i] += triMagSf[i-1];
126 triToFace_.transfer(triToFace);
127 triCumulativeMagSf_.transfer(triMagSf);
130 for (label i = 1; i < sumTriMagSf_.size(); i++)
132 sumTriMagSf_[i] += sumTriMagSf_[i-1];
136 patchArea_ =
sum(magSf);
137 patchNormal_ = patch.faceAreas()/magSf;
145 const scalar fraction01,
155 if (cellOwners_.size() > 0)
158 const label proci = whichProc(fraction01);
162 const scalar areaFraction = fraction01*patchArea_;
166 scalar offset = sumTriMagSf_[proci];
169 if (areaFraction > triCumulativeMagSf_[i] + offset)
177 facei = triToFace_[trii];
178 cellOwner = cellOwners_[facei];
183 const face& tf = triFace_[trii];
188 const scalar a = rnd.
position(scalar(0.1), scalar(0.5));
191 mag((pf - pc) & patchNormal_[facei])*patchNormal_[facei];
199 if (tetFacei == -1 ||tetPti == -1)
206 if (tetFacei == -1 ||tetPti == -1)
209 cellOwner = cellOwners_[facei];
218 for (label teti=1; teti<cellTetIs.
size()-1; teti++)
222 + cellTetIs[teti].tet(
mesh).mag()/V[cellOwner];
224 cTetVFrac.
last() = 1;
227 const scalar volFrac = rnd.
sample01<scalar>();
231 if (cTetVFrac[vfI] > volFrac)
237 position = cellTetIs[teti].tet(
mesh).randomPoint(rnd);
238 tetFacei = cellTetIs[teti].face();
239 tetPti = cellTetIs[teti].tetPt();
278 return setPositionAndCell
293 const scalar areaFraction = fraction01*patchArea_;
298 if (areaFraction >= sumTriMagSf_[i])
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void transfer(List< T > &list)
Transfer contents of the argument List into this.
void append(const T &val)
Copy append an element to the end of this list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Inter-processor communications stream.
static void listCombineAllGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
After completion all processors have the same data.
Type position(const Type &start, const Type &end)
Return a sample on the interval [start,end].
Type sample01()
Return a sample whose components lie in the range [0,1].
Type globalSample01()
Return a sample whose components lie in the range [0,1].
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A face is a list of labels corresponding to mesh vertices.
Mesh data needed to do the Finite Volume discretisation.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
void updateMesh()
Update for new mesh topology.
A traits class, which is primarily used for primitives.
const word patchName_
Patch name.
const label patchId_
Patch ID.
virtual void updateMesh(const polyMesh &mesh)
Update patch geometry and derived info for injection locations.
label whichProc(const scalar fraction01) const
Return the processor that has the location specified by the fraction.
label setPositionAndCell(const fvMesh &mesh, const scalar fraction01, Random &rnd, vector &position, label &cellOwner, label &tetFacei, label &tetPti)
Set the injection position and owner cell, tetFace and tetPt.
wordList names() const
Return a list of patch names.
static List< tetIndices > cellTetIndices(const polyMesh &mesh, label cI)
Return the tet decomposition of the given cell, see.
Mesh consisting of general polyhedral cells.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
A patch is a list of labels that address the faces in the global face list.
const vectorField & cellCentres() const
int myProcNo() const noexcept
Return processor number.
A triangular face using a FixedList of labels corresponding to mesh vertices.
A triangle primitive used to calculate face normals and swept volumes.
Point randomPoint(Random &rndGen) const
Return a random point on the triangle from a uniform.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
static constexpr const zero Zero
Global zero (0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.