43 { equilibriumModelType::LANGMUIR,
"Langmuir" }
53 { kineticModelType::PseudoFirstOrder,
"PseudoFirstOrder" }
60 Foam::speciesSorptionFvPatchScalarField::calcMoleFractions()
const 63 auto& Mole = tMole.ref();
72 const PtrList<volScalarField>&
Y =
thermo.composition().Y();
78 const label speciesId =
84 thermo.composition().W(speciesId)
91 const label
cellId = faceCells[i];
98 <<
"Thermo type is not 'rhoReactionThermo'. " <<
nl 99 <<
"This BC is designed to operate with a rho based thermo." 108 Foam::speciesSorptionFvPatchScalarField::field
110 const word& fieldName,
111 const dimensionSet& dim
114 const fvMesh&
mesh = this->internalField().mesh();
149 parent_bctype(
p, iF),
150 equilibriumModel_(equilibriumModelType::LANGMUIR),
151 kinematicModel_(kineticModelType::PseudoFirstOrder),
152 allowDesorption_(true),
153 thicknessPtr_(nullptr),
171 parent_bctype(
p, iF,
dict),
172 equilibriumModel_(equilibriumModelTypeNames.
get(
"equilibriumModel",
dict)),
173 kinematicModel_(kinematicModelTypeNames.
get(
"kinematicModel",
dict)),
174 allowDesorption_(
dict.getOrDefault<bool>(
"allowDesorption", true)),
179 rhoS_(
dict.
get<scalar>(
"rhoS")),
180 pName_(
dict.getOrDefault<
word>(
"p",
"p")),
193 const this_bctype& ptf,
195 const DimensionedField<scalar, volMesh>& iF,
196 const fvPatchFieldMapper& mapper
199 parent_bctype(ptf,
p, iF, mapper),
200 equilibriumModel_(ptf.equilibriumModel_),
201 kinematicModel_(ptf.kinematicModel_),
202 allowDesorption_(ptf.allowDesorption_),
203 thicknessPtr_(ptf.thicknessPtr_.clone(
patch().
patch())),
209 dfldp_(ptf.dfldp_, mapper),
210 mass_(ptf.mass_, mapper)
216 const this_bctype& ptf,
220 parent_bctype(ptf, iF),
221 equilibriumModel_(ptf.equilibriumModel_),
222 kinematicModel_(ptf.kinematicModel_),
223 allowDesorption_(ptf.allowDesorption_),
224 thicknessPtr_(ptf.thicknessPtr_.clone(
patch().
patch())),
242 this->parent_bctype::autoMap(m);
249 thicknessPtr_->autoMap(m);
260 this->parent_bctype::rmap(ptf, addr);
262 const auto& tiptf = refCast<const this_bctype>(ptf);
264 dfldp_.rmap(tiptf.dfldp_, addr);
265 mass_.rmap(tiptf.mass_, addr);
267 if (thicknessPtr_ && tiptf.thicknessPtr_)
269 thicknessPtr_->rmap(tiptf.thicknessPtr_(), addr);
277 const auto&
thermo = db().lookupObject<rhoReactionThermo>
282 const label speciesId =
287 const scalar t = db().time().timeOutputValue();
300 const label faceCelli = this->
patch().faceCells()[facei];
301 Vol[facei] = this->internalField().mesh().V()[faceCelli];
312 Info<<
" Patch mass rate min/max [kg/m3/sec]: " 337 switch (equilibriumModel_)
339 case equilibriumModelType::LANGMUIR:
342 tmp<scalarField> tco = calcMoleFractions();
346 cEq = max_*(kl_*tco()*
pp/(1 + kl_*tco()*
pp));
356 switch (kinematicModel_)
358 case kineticModelType::PseudoFirstOrder:
360 dfldp_ = kabs_*(cEq - mass_);
366 if (!allowDesorption_)
368 dfldp_.clamp_min(scalar(0));
372 const scalar dt = db().time().deltaTValue();
374 mass_ =
max(mass_, scalar(0));
379 "adsorbedMass" + this->internalField().
name(),
381 ).boundaryFieldRef()[
patch().index()];
389 Info<<
" Absorption rate min/max [mol/kg/sec]: " 393 this->parent_bctype::updateCoeffs();
403 "equilibriumModel", equilibriumModelTypeNames[equilibriumModel_]
407 "kinematicModel", kinematicModelTypeNames[kinematicModel_]
411 thicknessPtr_->writeData(os);
413 os.writeEntry(
"kabs", kabs_);
414 os.writeEntry(
"kl", kl_);
415 os.writeEntry(
"max", max_);
416 os.writeEntry(
"rhoS", rhoS_);
417 os.writeEntryIfDifferent<
bool>
424 dfldp_.writeEntry(
"dfldp", os);
425 mass_.writeEntry(
"mass", os);
426 os.writeEntryIfDifferent<word>(
"p",
"p", pName_);
439 speciesSorptionFvPatchScalarField
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
word dictName() const
The local dictionary name (final part of scoped name)
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const objectRegistry & db() const
The associated objectRegistry.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const fvPatch & patch() const noexcept
Return the patch.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
virtual void write(Ostream &) const
Write.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
equilibriumModelType
Options for the equilibrum model.
const speciesTable & species() const
Return the table of species.
bool store()
Register object with its registry and transfer ownership to the registry.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
speciesSorptionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
const Time & time() const
Return the top-level database.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
psiReactionThermo & thermo
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
kineticModelType
Options for the kinematic model.
fvPatchField< scalar > fvPatchScalarField
constexpr T & get(FixedList< T, N > &list) noexcept
virtual void write(Ostream &) const
Write.
A class for handling words, derived from Foam::string.
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual const labelUList & faceCells() const
Return faceCells.
A FieldMapper for finite-volume patch fields.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
label size() const noexcept
The number of elements in the container.
int debug
Static debugging option.
const dimensionSet dimMoles(0, 0, 0, 0, 1, 0, 0)
static const Enum< equilibriumModelType > equilibriumModelTypeNames
Names for equilibriumModelType.
tmp< scalarField > mass() const
Access to mass.
const dimensionedScalar h
Planck constant.
static const Enum< kineticModelType > kinematicModelTypeNames
Names for kineticModelType.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
PtrList< volScalarField > & Y
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Automatically write from objectRegistry::writeObject()
const DimensionedField< scalar, volMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual basicSpecieMixture & composition()=0
Return the composition of the multi-component mixture.
virtual void operator=(const UList< Type > &)
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
List< label > labelList
A List of labels.
A class for managing temporary objects.
virtual scalar W(const label speciei) const =0
Molecular weight of the given specie [kg/kmol].
virtual tmp< scalarField > patchSource() const
Source of cells next to the patch.
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Request registration (bool: true)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)