43 void Foam::fv::phaseChange::readCoeffs(
const dictionary&
dict)
45 energySemiImplicit_ =
dict.lookup<
bool>(
"energySemiImplicit");
51 const ThermoRefPair<multicomponentThermo>& mcThermos =
52 thermos().thermos<multicomponentThermo>();
54 List<labelPair> result(species().size(),
labelPair(-1, -1));
58 if (mcThermos.valid()[i])
62 result[mDoti][i] = mcThermos[i].species()[species()[mDoti]];
79 const bool haveSpecie =
dict.found(
"specie");
81 if (required && !haveSpecie)
101 const bool haveSpecie =
dict.found(
"specie");
102 const bool haveSpecies =
dict.found(
"species");
104 if (haveSpecie && haveSpecies)
107 <<
"Both keywords specie and species "
108 <<
" are defined in dictionary " <<
dict.name()
112 if (required && !haveSpecie && !haveSpecies)
115 <<
"Neither keywords specie nor species "
116 <<
" are defined in dictionary " <<
dict.name()
131 if (species() != readSpecie(
dict,
false))
134 <<
"Cannot change the specie of a " <<
type() <<
" model "
142 if (species() != readSpecies(
dict,
false))
145 <<
"Cannot change the species of a " <<
type() <<
" model "
154 const word& modelType,
168 if (mcThermos.
valid()[i])
172 specieis_[mDoti][i] = mcThermos[i].species()[species[mDoti]];
181 if (mcThermos.
either() && species_.empty())
184 <<
"Mixture transfer specified by model " <<
name <<
" of type "
185 << modelType <<
" for two phases " << phaseNames().first()
186 <<
" and " << phaseNames().second() <<
" but ";
190 <<
"both phases have"
192 <<
"phase " << phaseNames()[mcThermos.
valid().
second()] <<
" has";
200 if (!mcThermos.
either() && species_.size())
203 <<
"Specie transfer specified by model " <<
name
204 <<
" of type " << modelType <<
" for two pure phases "
205 << phaseNames().first() <<
" and " << phaseNames().second()
210 if (!mcThermos.
both() && species_.size() > 1)
213 <<
"Multi-specie transfer specified by model " <<
name
214 <<
" of type " << modelType <<
" for phases "
215 << phaseNames().first() <<
" and " << phaseNames().second()
216 <<
" but phase " << phaseNames()[mcThermos.
valid().
first()]
224 setSpecies(
name(),
type(), species);
230 if (this->species() != species)
233 <<
"Cannot change the species of a " <<
type() <<
" model "
241 for (
label i = 0; i < 2; ++ i)
243 if (isA<fluidThermo>(thermos()[i]))
245 return refCast<const fluidThermo>(thermos()[i]).p();
267 tvf->internalFieldRef() = tvif();
268 tvf->correctBoundaryConditions();
294 const word& modelType,
301 thermos_(
mesh, phaseNames()),
305 energySemiImplicit_(false)
318 const bool firstRequired,
319 const bool secondRequired
325 {firstRequired, secondRequired},
335 const bool firstRequired,
336 const bool secondRequired
342 {firstRequired, secondRequired},
352 const bool firstRequired,
353 const bool secondRequired
359 {firstRequired, secondRequired},
361 "fluid-multicomponent"
368 static const labelPair noSpecieis(-1, -1);
372 if (species().empty())
376 else if (species().size() == 1)
383 <<
"Requested mixture/single-specie indices from multi-specie "
388 return specieis_[mDoti];
414 : mDot[i] < 0 ? T2[i]
428 return kappa2/(kappa1 + kappa2);
437 return L(this->Tchange(), mDoti);
450 const labelPair specieis = this->specieis(mDoti);
456 for (
label j = 0; j < 2; ++ j)
460 ? thermos()[j].ha(
p, Tchange)
461 : mcThermos[j].hai(specieis[j],
p, Tchange);
479 const labelPair specieis = this->specieis(mDoti);
485 for (
label j = 0; j < 2; ++ j)
489 ? thermos()[j].ha(Tchange,
patchi)
490 : mcThermos[j].hai(specieis[j],
p, Tchange);
500 if (species().empty())
503 <<
"Mixture phase change rate not defined by model of type "
517 tmDot.
ref() += mDot(mDoti);
534 if (mDoti == 0 && species().size() == 1)
539 if (species().size() > 1)
542 <<
"Specie phase change rate not defined by model of type "
558 const label i = index(phaseNames(),
alpha.group());
565 if (index(heNames(), heOrYi.
name()) != -1)
572 label mDoti = species().empty() ? -1 : 0;
573 mDoti < species().size();
577 const labelPair specieis = this->specieis(mDoti);
586 ? thermos()[i].hs(
p, tTchange())
587 : mcThermos[i].hsi(specieis[i],
p, tTchange())
591 if (energySemiImplicit_)
593 eqn += -
fvm::SuSp(-
s*tmDot(), heOrYi) -
s*tmDot()*heOrYi;
598 (i == 0 ? 1 - Lfraction() : Lfraction())
600 *L(tTchange(), mDoti);
608 if (mcThermos.
valid()[i] && mcThermos[i].containsSpecie(specieName))
611 if (!species().found(specieName))
return;
614 eqn +=
s*mDot(species()[specieName]);
628 readCoeffs(coeffs(
dict));
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Mesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
tmp< DimensionedField< Type, GeoMesh, Field > > T() const
Return the field transpose (only defined for second rank tensors)
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
static word member(const word &name)
Return member (name without the extension)
const word & name() const
Return name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
const Type & second() const
Return second.
const Type & first() const
Return first.
Class containing a pair of thermo references. Handles down-casting to more specific thermo types by c...
const Pair< bool > & valid() const
Access the validity flags.
bool either() const
Return if either validity flag is set.
ThermoRefPair< OtherThermoType > thermos() const
Cast to a different thermo type, with error checking.
bool both() const
Return if both validity flags are set.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Base-class for multi-component fluid thermodynamic properties.
Base-class for fluid thermodynamic properties.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Mesh data needed to do the Finite Volume discretisation.
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
const word & name() const
Return const access to the source name.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Base class for mass transfers between phases.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Base class for phase change models.
void reReadSpecies(const dictionary &dict) const
Re-read the names of the transferring species.
const labelPair & specieis(const label mDoti=-1) const
Return the indices of the transferring specie in the two.
wordList readSpecie(const dictionary &dict, const bool required) const
Read the names of the transferring specie.
const ThermoRefPair< multicomponentThermo > multicomponentThermos(const bool, const bool) const
Return the multicomponent thermo references.
virtual tmp< DimensionedField< scalar, volMesh > > Lfraction() const
Return the fraction of the latent heat that is transferred into.
const ThermoRefPair< fluidThermo > fluidThermos(const bool, const bool) const
Return the fluid thermo references.
void reReadSpecie(const dictionary &dict) const
Re-read the names of the transferring specie.
wordList readSpecies(const dictionary &dict, const bool required) const
Read the names of the transferring species.
static tmp< DimensionedField< scalar, volMesh > > vfToVif(const tmp< volScalarField > &tvf)
Remove the boundary field from the given geometric field.
virtual tmp< DimensionedField< scalar, volMesh > > mDot() const
Return the total phase change rate.
virtual bool read(const dictionary &dict)
Read source dictionary.
void addSup(const volScalarField &alpha, const volScalarField &rho, const volScalarField &heOrYi, fvMatrix< scalar > &eqn) const
Override the energy equation to add the phase change heat, or.
void setSpecies(const word &name, const word &modelType, const wordList &species)
Set the names of the transferring species.
const ThermoRefPair< fluidMulticomponentThermo > fluidMulticomponentThermos(const bool, const bool) const
Return the fluid multicomponent thermo references.
void reSetSpecies(const wordList &species)
Re-set the names of the transferring species.
tmp< DimensionedField< scalar, volMesh > > L(const label mDoti=-1) const
Return the latent heat.
const hashedWordList & species() const
Return the names of the transferring species. Empty if neither.
const volScalarField & p() const
Access the pressure field.
virtual tmp< DimensionedField< scalar, volMesh > > Tchange() const
Return the temperature at which the phases are considered to be.
phaseChange(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict, const wordList &species)
Construct from explicit source name and mesh.
static tmp< volScalarField > vifToVf(const tmp< DimensionedField< scalar, volMesh >> &tvif)
Add a boundary field to the given internal field.
Base-class for multi-component thermodynamic properties.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
A class for managing temporary objects.
T * ptr() const
Return tmp pointer for reuse.
void clear() const
If object pointer points to valid object:
T & ref() const
Return non-const reference or generate a fatal error.
A class for handling words, derived from string.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
defineTypeNameAndDebug(bound, 0)
tmp< fvMatrix< Type > > SuSp(const volScalarField::Internal &, const VolField< Type > &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
A List of words.
Pair< label > labelPair
Label pair.
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
labelList second(const UList< labelPair > &p)
const dimensionSet dimTemperature
labelList first(const UList< labelPair > &p)
const dimensionSet dimTime
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
const dimensionSet dimDensity
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.