44 patchName_(patchName),
51 triCumulativeMagSf_(),
57 <<
"Requested patch " <<
patchName_ <<
" not found" <<
nl 58 <<
"Available patches are: " <<
mesh.boundaryMesh().names() <<
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();
108 triToFace.append(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];
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];
185 const point pf(tri.randomPoint(rnd));
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];
213 const List<tetIndices> cellTetIs =
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();
276 scalar fraction01 = rnd.globalSample01<scalar>();
278 return setPositionAndCell
293 const scalar areaFraction = fraction01*patchArea_;
298 if (areaFraction >= sumTriMagSf_[i])
List< scalar > scalarList
List of scalar.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
const word patchName_
Patch name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
label whichProc(const scalar fraction01) const
Return the processor that has the location specified by the fraction.
constexpr char nl
The newline '\n' character (0x0a)
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
patchInjectionBase(const polyMesh &mesh, const word &patchName)
Construct from mesh and patch name.
virtual void updateMesh(const polyMesh &mesh)
Update patch geometry and derived info for injection 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...
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
static List< tetIndices > cellTetIndices(const polyMesh &mesh, label cI)
Return the tet decomposition of the given cell, see.
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
Type sample01()
Return a sample whose components lie in the range [0,1].
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A triangular face using a FixedList of labels corresponding to mesh vertices.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
Inter-processor communications stream.
const label patchId_
Patch ID.
const vectorField & cellCentres() const
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
T & last()
Access last element of the list, position [size()-1].
vector point
Point is a vector.
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.
Mesh data needed to do the Finite Volume discretisation.
const std::string patch
OpenFOAM patch number as a std::string.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
triangle< point, const point & > triPointRef
A triangle using referred points.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
Mesh consisting of general polyhedral cells.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
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)