mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: SemiImplicitSource: allow Function1 for Su,Sp. Fixes #1750.
This commit is contained in:
@ -30,6 +30,7 @@ License
|
||||
#include "fvMesh.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "fvmSup.H"
|
||||
#include "Constant.H"
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -53,14 +54,46 @@ void Foam::fv::SemiImplicitSource<Type>::setFieldData(const dictionary& dict)
|
||||
label count = dict.size();
|
||||
|
||||
fieldNames_.resize(count);
|
||||
injectionRate_.resize(count);
|
||||
Su_.resize(count);
|
||||
Sp_.resize(count);
|
||||
|
||||
applied_.resize(count, false);
|
||||
|
||||
count = 0;
|
||||
for (const entry& dEntry : dict)
|
||||
{
|
||||
fieldNames_[count] = dEntry.keyword();
|
||||
dEntry.readEntry(injectionRate_[count]);
|
||||
|
||||
if (!dEntry.isDict())
|
||||
{
|
||||
Tuple2<Type, scalar> injectionRate;
|
||||
dEntry.readEntry(injectionRate);
|
||||
|
||||
Su_.set
|
||||
(
|
||||
count,
|
||||
new Function1Types::Constant<Type>
|
||||
(
|
||||
"Su",
|
||||
injectionRate.first()
|
||||
)
|
||||
);
|
||||
Sp_.set
|
||||
(
|
||||
count,
|
||||
new Function1Types::Constant<scalar>
|
||||
(
|
||||
"Sp",
|
||||
injectionRate.second()
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
const dictionary& Sdict = dEntry.dict();
|
||||
Su_.set(count, Function1<Type>::New("Su", Sdict));
|
||||
Sp_.set(count, Function1<scalar>::New("Sp", Sdict));
|
||||
}
|
||||
|
||||
++count;
|
||||
}
|
||||
@ -86,8 +119,7 @@ Foam::fv::SemiImplicitSource<Type>::SemiImplicitSource
|
||||
:
|
||||
cellSetOption(name, modelType, dict, mesh),
|
||||
volumeMode_(vmAbsolute),
|
||||
VDash_(1.0),
|
||||
injectionRate_()
|
||||
VDash_(1.0)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -125,7 +157,9 @@ void Foam::fv::SemiImplicitSource<Type>::addSup
|
||||
false
|
||||
);
|
||||
|
||||
UIndirectList<Type>(Su, cells_) = injectionRate_[fieldi].first()/VDash_;
|
||||
const scalar tmVal = mesh_.time().timeOutputValue();
|
||||
|
||||
UIndirectList<Type>(Su, cells_) = Su_[fieldi].value(tmVal)/VDash_;
|
||||
|
||||
volScalarField::Internal Sp
|
||||
(
|
||||
@ -142,7 +176,7 @@ void Foam::fv::SemiImplicitSource<Type>::addSup
|
||||
false
|
||||
);
|
||||
|
||||
UIndirectList<scalar>(Sp, cells_) = injectionRate_[fieldi].second()/VDash_;
|
||||
UIndirectList<scalar>(Sp, cells_) = Sp_[fieldi].value(tmVal)/VDash_;
|
||||
|
||||
eqn += Su + fvm::SuSp(Sp, psi);
|
||||
}
|
||||
@ -166,7 +200,6 @@ void Foam::fv::SemiImplicitSource<Type>::addSup
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::fv::SemiImplicitSource<Type>::read(const dictionary& dict)
|
||||
{
|
||||
|
||||
@ -60,6 +60,31 @@ Description
|
||||
- absolute: values are given as \<quantity\>
|
||||
- specific: values are given as \<quantity\>/m3
|
||||
|
||||
The injectionRate can also be specified as a Function1 by having
|
||||
dictionaries for the field entries instead:
|
||||
|
||||
\verbatim
|
||||
injectionRateSuSp
|
||||
{
|
||||
k
|
||||
{
|
||||
// Time-ramp from 0 to 30.7 at time 5
|
||||
Su table
|
||||
(
|
||||
(0 0.0)
|
||||
(5 30.7)
|
||||
);
|
||||
Sp 0.0;
|
||||
}
|
||||
epsilon
|
||||
{
|
||||
Su 1.5;
|
||||
Sp 0.0;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
See also
|
||||
Foam::fvOption
|
||||
|
||||
@ -74,6 +99,7 @@ SourceFiles
|
||||
#include "Tuple2.H"
|
||||
#include "cellSetOption.H"
|
||||
#include "Enum.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -128,7 +154,8 @@ protected:
|
||||
scalar VDash_;
|
||||
|
||||
//- Source field values
|
||||
List<Tuple2<Type, scalar>> injectionRate_;
|
||||
PtrList<Function1<Type>> Su_;
|
||||
PtrList<Function1<scalar>> Sp_;
|
||||
|
||||
|
||||
// Protected functions
|
||||
@ -162,18 +189,12 @@ public:
|
||||
//- Return const access to the volume mode
|
||||
inline const volumeModeType& volumeMode() const;
|
||||
|
||||
//- Return const access to the source field values
|
||||
inline const List<Tuple2<Type, scalar>>& injectionRate() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return access to the volume mode
|
||||
inline volumeModeType& volumeMode();
|
||||
|
||||
//- Return access to the source field values
|
||||
inline List<Tuple2<Type, scalar>>& injectionRate();
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
|
||||
@ -37,14 +37,6 @@ Foam::fv::SemiImplicitSource<Type>::volumeMode() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline const Foam::List<Foam::Tuple2<Type, Foam::scalar>>&
|
||||
Foam::fv::SemiImplicitSource<Type>::injectionRate() const
|
||||
{
|
||||
return injectionRate_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline typename Foam::fv::SemiImplicitSource<Type>::volumeModeType&
|
||||
Foam::fv::SemiImplicitSource<Type>::volumeMode()
|
||||
@ -53,12 +45,4 @@ Foam::fv::SemiImplicitSource<Type>::volumeMode()
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::List<Foam::Tuple2<Type,
|
||||
Foam::scalar>>& Foam::fv::SemiImplicitSource<Type>::injectionRate()
|
||||
{
|
||||
return injectionRate_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user