Skip to content
Snippets Groups Projects
Commit 9f53fdcc authored by Kutalmış Berçin's avatar Kutalmış Berçin Committed by Andrew Heather
Browse files

DOC: moleFractions: improve header-file doc and style consistency

INT: moleFractions: add phaseName support
parent bb07945a
Branches
Tags
1 merge request!393ENH: BilgerMixtureFraction: New function object
......@@ -5,7 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -31,10 +32,13 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ThermoType>
void Foam::moleFractions<ThermoType>::calculateMoleFractions()
void Foam::moleFractions<ThermoType>::calcMoleFractions()
{
const ThermoType& thermo =
mesh_.lookupObject<ThermoType>(basicThermo::dictName);
const auto& thermo =
mesh_.lookupObject<ThermoType>
(
IOobject::groupName(basicThermo::dictName, phaseName_)
);
const PtrList<volScalarField>& Y = thermo.composition().Y();
......@@ -44,7 +48,6 @@ void Foam::moleFractions<ThermoType>::calculateMoleFractions()
{
const dimensionedScalar Wi
(
"W",
dimMass/dimMoles,
thermo.composition().W(i)
);
......@@ -64,14 +67,19 @@ Foam::moleFractions<ThermoType>::moleFractions
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict)
fvMeshFunctionObject(name, runTime, dict),
phaseName_(dict.getOrDefault<word>("phase", word::null))
{
const ThermoType* thermo =
mesh_.findObject<ThermoType>(basicThermo::dictName);
const word dictName
(
IOobject::groupName(basicThermo::dictName, phaseName_)
);
if (thermo)
if (mesh_.foundObject<ThermoType>(dictName))
{
const PtrList<volScalarField>& Y = thermo->composition().Y();
const auto& thermo = mesh_.lookupObject<ThermoType>(dictName);
const PtrList<volScalarField>& Y = thermo.composition().Y();
X_.setSize(Y.size());
......@@ -96,10 +104,19 @@ Foam::moleFractions<ThermoType>::moleFractions
);
}
calculateMoleFractions();
calcMoleFractions();
}
else
{
if (phaseName_ != word::null)
{
FatalErrorInFunction
<< "Cannot find thermodynamics model of type "
<< ThermoType::typeName
<< " for phase " << phaseName_
<< exit(FatalError);
}
FatalErrorInFunction
<< "Cannot find thermodynamics model of type "
<< ThermoType::typeName
......@@ -108,13 +125,6 @@ Foam::moleFractions<ThermoType>::moleFractions
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ThermoType>
Foam::moleFractions<ThermoType>::~moleFractions()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ThermoType>
......@@ -123,21 +133,23 @@ bool Foam::moleFractions<ThermoType>::read
const dictionary& dict
)
{
return true;
}
if (functionObjects::fvMeshFunctionObject::read(dict))
{
phaseName_ = dict.getOrDefault<word>("phase", word::null);
return true;
}
template<class ThermoType>
bool Foam::moleFractions<ThermoType>::execute()
{
calculateMoleFractions();
return true;
return false;
}
template<class ThermoType>
bool Foam::moleFractions<ThermoType>::write()
bool Foam::moleFractions<ThermoType>::execute()
{
calcMoleFractions();
return true;
}
......
......@@ -5,7 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -30,34 +31,67 @@ Group
grpThermophysicalFunctionObjects
Description
This function object calculates mole-fraction fields from the mass-fraction
fields of the psi/rhoReactionThermo and caches them for output and further
post-processing.
The names of the mole-fraction fields are obtained from the corresponding
mass-fraction fields prepended by "X_"
Example of function object specification:
Calculates mole-fraction fields from the mass-fraction
fields of the psi/rhoReactionThermo and caches them
for output and further post-processing.
The names of the mole-fraction fields are obtained from
the corresponding mass-fraction fields prepended by "X_".
Operands:
\table
Operand | Type | Location
input | - | -
output file | - | -
output field | volScalarField | $FOAM_CASE/\<time\>/\<outField\>
\endtable
Usage
Minimal example by using \c system/controlDict.functions:
\verbatim
moleFractions
moleFractions1
{
type psiReactionThermoMoleFractions;
}
\endverbatim
or
\verbatim
moleFractions
{
type rhoReactionThermoMoleFractions;
// Conditional mandatory entries (unmodifiable)
// Either of the below depending on
// the thermodynamics package used in the solver.
// Option-1
type psiReactionThermoMoleFractions;
// Option-2
type rhoReactionThermoMoleFractions;
// Mandatory entries (unmodifiable)
libs (fieldFunctionObjects);
// Optional entries (runtime modifiable)
phase <phaseName>;
// Optional (inherited) entries
...
}
\endverbatim
depending on the thermodynamics package used in the solver.
where the entries mean:
\table
Property | Description | Type | Reqd | Dflt
type | Type name: psiReactionThermoMoleFractions or <!--
--> rhoReactionThermoMoleFractions | word | yes | -
libs | Library name: fieldFunctionObjects | word | yes | -
phase | Name of phase (e.g. "gas") | word | no | ""
\endtable
The inherited entries are elaborated in:
- \link functionObject.H \endlink
Usage by the \c postProcess utility is not available.
See also
Foam::functionObjects::fvMeshFunctionObject
SourceFiles
moleFractions.C
moleFractionsFunctionObjects.C
\*---------------------------------------------------------------------------*/
......@@ -81,22 +115,19 @@ class moleFractions
:
public functionObjects::fvMeshFunctionObject
{
// Private data
// Private Data
//- Species mole fractions
PtrList<volScalarField> X_;
//- Name of phase
word phaseName_;
// Private Member Functions
//- Calculate the mole fraction fields
virtual void calculateMoleFractions();
//- No copy construct
moleFractions(const moleFractions&) = delete;
//- No copy assignment
void operator=(const moleFractions&) = delete;
virtual void calcMoleFractions();
public:
......@@ -115,21 +146,30 @@ public:
const dictionary& dict
);
//- No copy construct
moleFractions(const moleFractions&) = delete;
//- No copy assignment
void operator=(const moleFractions&) = delete;
//- Destructor
virtual ~moleFractions();
virtual ~moleFractions() = default;
// Member Functions
//- Read the moleFractions data
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict);
//- Calculate the mole-fraction fields
virtual bool execute();
//- The mole-fraction fields auto-write
virtual bool write();
//- The mole-fraction fields auto-write - no-op
virtual bool write()
{
return true;
}
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment