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());
93 numberDensitiesDict.
lookup(molecules[i])
96 moleculeTypeIds_[i] =
findIndex(cloud.typeIdList(), molecules[i]);
98 if (moleculeTypeIds_[i] == -1)
101 <<
"typeId " << molecules[i] <<
"not defined in cloud." <<
nl 106 numberDensities_ /= cloud.nParticle();
113 template<
class CloudType>
120 template<
class CloudType>
135 pFA[facei].
setSize(patch.size(), 0);
141 template<
class CloudType>
148 const scalar deltaT =
mesh.time().deltaTValue();
154 label particlesInserted = 0;
156 const volScalarField::Boundary& boundaryT
161 const volVectorField::Boundary& boundaryU
181 label typeId = moleculeTypeIds_[i];
183 scalar mass = cloud.
constProps(typeId).mass();
185 if (
min(boundaryT[patchi]) < small)
188 <<
"Zero boundary temperature detected, check boundaryT " 189 <<
"condition." <<
nl 219 exp(-
sqr(sCosTheta)) + sqrtPi*sCosTheta*(1 +
erf(sCosTheta))
229 const face&
f = patch[pFI];
233 label celli =
mesh.faceOwner()[globalFaceIndex];
249 scalar previousCummulativeSum = 0.0;
257 + previousCummulativeSum;
259 previousCummulativeSum = cTriAFracs[triI];
264 cTriAFracs.
last() = 1.0;
281 scalar faceTemperature = boundaryT[
patchi][pFI];
287 scalar& faceAccumulator = pFA[i][pFI];
294 if ((faceAccumulator - nI) >
rndGen.scalar01())
299 faceAccumulator -= nI;
301 label typeId = moleculeTypeIds_[i];
303 scalar mass = cloud.
constProps(typeId).mass();
305 for (
label i = 0; i < nI; i++)
310 scalar triSelection =
rndGen.scalar01();
313 label selectedTriI = -1;
319 if (cTriAFracs[triI] >= triSelection)
327 const tetIndices& faceTetIs = faceTets[selectedTriI];
333 scalar mostProbableSpeed
342 scalar sCosTheta = (faceVelocity &
n)/mostProbableSpeed;
345 scalar uNormProbCoeffA =
346 sCosTheta +
sqrt(
sqr(sCosTheta) + 2.0);
348 scalar uNormProbCoeffB =
352 + sCosTheta*(sCosTheta -
sqrt(
sqr(sCosTheta) + 2.0))
356 scalar randomScaling = 3.0;
360 randomScaling =
mag(sCosTheta) + 1;
368 scalar uNormalThermal;
374 randomScaling*(2.0*
rndGen.scalar01() - 1);
376 uNormal = uNormalThermal + sCosTheta;
384 P = 2.0*uNormal/uNormProbCoeffA
385 *
exp(uNormProbCoeffB -
sqr(uNormalThermal));
388 }
while (P <
rndGen.scalar01());
394 +
rndGen.scalarNormal()*t2
396 + (t1 & faceVelocity)*t1
397 + (t2 & faceVelocity)*t2
398 + mostProbableSpeed*uNormal*n;
403 cloud.
constProps(typeId).internalDegreesOfFreedom()
416 Info<<
" Particles inserted = " 417 << 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.
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...
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
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 normals.
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.
const dimensionedScalar k
Boltzmann constant.
void setSize(const label)
Reset size of List.
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.