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_),
87 cellOwners_ = patch.faceCells();
92 for (
const face&
f : patch)
94 nTris +=
f.nTriangles();
97 DynamicList<labelledTri> dynTriFace(nTris);
98 DynamicList<face> tris(8);
102 const face&
f = patch[facei];
107 for (
const auto& t : tris)
109 dynTriFace.emplace_back(t[0], t[1], t[2], facei);
114 triFace_.transfer(dynTriFace);
123 triCumulativeMagSf_.resize_nocopy(triFace_.size()+1);
125 auto iter = triCumulativeMagSf_.begin();
128 scalar patchArea = 0;
132 for (
const auto& t : triFace_)
134 patchArea += t.mag(
points);
138 sumTriMagSf_.resize_nocopy(numProc+1);
143 slice[myProci] = patchArea;
148 for (label i = 1; i < sumTriMagSf_.size(); ++i)
150 sumTriMagSf_[i] += sumTriMagSf_[i-1];
164 const scalar fraction01,
177 const label proci =
whichProc(fraction01);
181 const scalar areaFraction = fraction01*
patchArea_;
205 const scalar a = rnd.
position(scalar(0.1), scalar(0.5));
206 const vector& pc =
mesh.cellCentres()[cellOwner];
213 mesh.findTetFacePt(cellOwner, position, tetFacei, tetPti);
216 if (tetFacei == -1 ||tetPti == -1)
218 mesh.findCellFacePt(position, cellOwner, tetFacei, tetPti);
223 if (tetFacei == -1 ||tetPti == -1)
235 for (label teti=1; teti<cellTetIs.
size()-1; teti++)
239 + cellTetIs[teti].tet(
mesh).mag()/V[cellOwner];
241 cTetVFrac.
last() = 1;
244 const scalar volFrac = rnd.
sample01<scalar>();
248 if (cTetVFrac[vfI] > volFrac)
254 position = cellTetIs[teti].tet(
mesh).randomPoint(rnd);
255 tetFacei = cellTetIs[teti].face();
256 tetPti = cellTetIs[teti].tetPt();
285 scalar fraction01 = rnd.globalSample01<scalar>();
287 return setPositionAndCell
302 const scalar areaFraction = fraction01*patchArea_;
307 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.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
SubList< scalar > subList
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual communication.
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()
Access last element of the list, position [size()-1].
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
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.
A traits class, which is primarily used for primitives and vector-space.
const word patchName_
Patch name.
const label patchId_
Patch ID.
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.
scalarList triCumulativeMagSf_
Cumulative triangle area per triangle face (processor-local).
label whichProc(const scalar fraction01) const
Return the processor that has the location specified by the fraction.
scalar patchArea_
Patch area - total across all processors.
vectorList patchNormal_
Patch face normal directions.
scalarList sumTriMagSf_
Cumulative area fractions per processor.
labelList cellOwners_
List of cell labels corresponding to injector positions.
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.
List< labelledTri > triFace_
The polyPatch faces as triangles, the index of each corresponds to the undecomposed patch face index.
static List< tetIndices > cellTetIndices(const polyMesh &mesh, label cI)
Return the tet decomposition of the given cell, see.
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
vector point
Point is a vector.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< scalar > scalarList
List of scalar.
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.