Go to the documentation of this file.
44 patchName_(patchName),
45 patchId_(
mesh.boundaryMesh().findPatchID(patchName_)),
51 triCumulativeMagSf_(),
52 sumTriMagSf_(Pstream::nProcs() + 1,
Zero)
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);
116 sumTriMagSf_[i] = 0.0;
124 for (label i = 1; i < triMagSf.size(); i++)
126 triMagSf[i] += triMagSf[i-1];
131 triToFace_.transfer(triToFace);
132 triCumulativeMagSf_.transfer(triMagSf);
135 for (label i = 1; i < sumTriMagSf_.size(); i++)
137 sumTriMagSf_[i] += sumTriMagSf_[i-1];
141 patchArea_ =
sum(magSf);
142 patchNormal_ =
patch.faceAreas()/magSf;
150 const scalar fraction01,
160 if (cellOwners_.size() > 0)
163 const label proci = whichProc(fraction01);
167 const scalar areaFraction = fraction01*patchArea_;
171 scalar offset = sumTriMagSf_[proci];
174 if (areaFraction > triCumulativeMagSf_[i] + offset)
182 facei = triToFace_[trii];
183 cellOwner = cellOwners_[facei];
188 const face& tf = triFace_[trii];
193 const scalar a = rnd.
position(scalar(0.1), scalar(0.5));
196 mag((pf - pc) & patchNormal_[facei])*patchNormal_[facei];
204 if (tetFacei == -1 ||tetPti == -1)
211 if (tetFacei == -1 ||tetPti == -1)
214 cellOwner = cellOwners_[facei];
223 for (label teti=1; teti<cellTetIs.size()-1; teti++)
227 + cellTetIs[teti].tet(
mesh).mag()/V[cellOwner];
229 cTetVFrac.last() = 1;
232 const scalar volFrac = rnd.
sample01<scalar>();
236 if (cTetVFrac[vfI] > volFrac)
242 position = cellTetIs[teti].tet(
mesh).randomPoint(rnd);
243 tetFacei = cellTetIs[teti].face();
244 tetPti = cellTetIs[teti].tetPt();
283 return setPositionAndCell
298 const scalar areaFraction = fraction01*patchArea_;
303 if (areaFraction >= sumTriMagSf_[i])
Type globalSample01()
Return a sample whose components lie in the range [0,1].
A class for handling words, derived from Foam::string.
Point randomPoint(Random &rndGen) const
Return a random point on the triangle from a uniform.
static constexpr const zero Zero
Global zero (0)
Type sample01()
Return a sample whose components lie in the range [0,1].
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
A triangle primitive used to calculate face normals and swept volumes.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
patchInjectionBase(const polyMesh &mesh, const word &patchName)
Construct from mesh and patch name.
A patch is a list of labels that address the faces in the global face list.
virtual void updateMesh(const polyMesh &mesh)
Update patch geometry and derived info for injection locations.
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.
label whichProc(const scalar fraction01) const
Return the processor that has the location specified by the fraction.
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
Mesh data needed to do the Finite Volume discretisation.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
const vectorField & cellCentres() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
A triangular face using a FixedList of labels corresponding to mesh vertices.
Type position(const Type &start, const Type &end)
Return a sample on the interval [start,end].
const std::string patch
OpenFOAM patch number as a std::string.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A traits class, which is primarily used for primitives.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
static List< tetIndices > cellTetIndices(const polyMesh &mesh, label cI)
Return the tet decomposition of the given cell, see.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
A face is a list of labels corresponding to mesh vertices.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.