35 template<
class CloudType>
46 particleFluxAccumulators_()
52 forAll(cloud.mesh().boundaryMesh(),
p)
54 const polyPatch& patch = cloud.mesh().boundaryMesh()[
p];
56 if (isType<polyPatch>(patch))
62 patches_.transfer(patches);
66 this->coeffDict().subDict(
"numberDensities")
72 particleFluxAccumulators_.
setSize(patches_.size());
76 const polyPatch& patch = cloud.mesh().boundaryMesh()[patches_[
p]];
85 moleculeTypeIds_.
setSize(molecules.size());
87 numberDensities_.setSize(molecules.size());
92 numberDensitiesDict.
lookup<scalar>(molecules[i]);
94 moleculeTypeIds_[i] =
findIndex(cloud.typeIdList(), molecules[i]);
96 if (moleculeTypeIds_[i] == -1)
99 <<
"typeId " << molecules[i] <<
"not defined in cloud." <<
nl 104 numberDensities_ /= cloud.nParticle();
111 template<
class CloudType>
118 template<
class CloudType>
133 pFA[facei].
setSize(patch.size(), 0);
139 template<
class CloudType>
146 const scalar deltaT =
mesh.time().deltaTValue();
152 label particlesInserted = 0;
154 const volScalarField::Boundary& boundaryT
159 const volVectorField::Boundary& boundaryU
179 label typeId = moleculeTypeIds_[i];
181 scalar mass = cloud.
constProps(typeId).mass();
183 if (
min(boundaryT[patchi]) < small)
186 <<
"Zero boundary temperature detected, check boundaryT " 187 <<
"condition." <<
nl 217 exp(-
sqr(sCosTheta)) + sqrtPi*sCosTheta*(1 +
erf(sCosTheta))
227 const face&
f = patch[pFI];
231 label celli =
mesh.faceOwner()[globalFaceIndex];
247 scalar previousCumulativeSum = 0.0;
255 + previousCumulativeSum;
257 previousCumulativeSum = cTriAFracs[triI];
262 cTriAFracs.
last() = 1.0;
279 scalar faceTemperature = boundaryT[
patchi][pFI];
285 scalar& faceAccumulator = pFA[i][pFI];
292 if ((faceAccumulator - nI) >
rndGen.scalar01())
297 faceAccumulator -= nI;
299 label typeId = moleculeTypeIds_[i];
301 scalar mass = cloud.
constProps(typeId).mass();
303 for (
label i = 0; i < nI; i++)
308 scalar triSelection =
rndGen.scalar01();
311 label selectedTriI = -1;
317 if (cTriAFracs[triI] >= triSelection)
325 const tetIndices& faceTetIs = faceTets[selectedTriI];
331 scalar mostProbableSpeed
340 scalar sCosTheta = (faceVelocity &
n)/mostProbableSpeed;
343 scalar uNormProbCoeffA =
344 sCosTheta +
sqrt(
sqr(sCosTheta) + 2.0);
346 scalar uNormProbCoeffB =
350 + sCosTheta*(sCosTheta -
sqrt(
sqr(sCosTheta) + 2.0))
354 scalar randomScaling = 3.0;
358 randomScaling =
mag(sCosTheta) + 1;
366 scalar uNormalThermal;
372 randomScaling*(2.0*
rndGen.scalar01() - 1);
374 uNormal = uNormalThermal + sCosTheta;
382 P = 2.0*uNormal/uNormProbCoeffA
383 *
exp(uNormProbCoeffB -
sqr(uNormalThermal));
386 }
while (P <
rndGen.scalar01());
392 +
rndGen.scalarNormal()*t2
394 + (t1 & faceVelocity)*t1
395 + (t2 & faceVelocity)*t2
396 + mostProbableSpeed*uNormal*n;
401 cloud.
constProps(typeId).internalDegreesOfFreedom()
414 Info<<
" Particles inserted = " 415 << particlesInserted <<
endl;
const volScalarField & boundaryT() const
Return macroscopic temperature.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A face is a list of labels corresponding to mesh vertices.
scalar mag() const
Return scalar magnitude.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the face for.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Templated inflow boundary model class.
void size(const label)
Override size to be inconsistent with allocated storage.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void autoMap(const mapPolyMesh &)
Remap the particles to the correct cells following mesh change.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
wordList toc() const
Return the table of contents.
virtual void inflow()
Introduce particles.
FreeStream(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
dimensionedScalar exp(const dimensionedScalar &ds)
const volVectorField & boundaryU() const
Return macroscopic velocity.
Random & rndGen()
Return references to the random object.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
errorManip< error > abort(error &err)
scalar maxwellianMostProbableSpeed(scalar temperature, scalar mass) const
Most probable speed.
scalar equipartitionInternalEnergy(scalar temperature, direction internalDegreesOfFreedom)
Generate a random internal energy, sampled from the.
const vectorField::subField faceAreas() const
Return face areas.
dimensionedScalar erf(const dimensionedScalar &ds)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void addNewParcel(const vector &position, const label celli, const vector &U, const scalar Ei, const label typeId)
Add new parcel.
const fvMesh & mesh() const
Return references to the mesh.
void setSize(const label)
Reset size of List.
const scalarField::subField magFaceAreas() const
Return face area magnitudes.
const dimensionedScalar k
Boltzmann constant.
label start() const
Return start label of this patch in the polyMesh face list.
Point randomPoint(Random &rndGen) const
Return a random point on the triangle from a uniform.
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
T & last()
Return the last element of the list.
virtual ~FreeStream()
Destructor.
Templated base class for dsmc cloud.
const List< typename ParcelType::constantProperties > & constProps() const
Return all of the constant properties.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
static List< tetIndices > faceTetIndices(const polyMesh &mesh, label fI, label cI)
Return the tet decomposition of the given face, with.
const vectorField::subField faceCentres() const
Return face centres.