mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Updated explicit source to semi-implicit source
This commit is contained in:
@ -3,7 +3,7 @@ basicSource/basicSourceIO.C
|
||||
basicSource/basicSourceList.C
|
||||
basicSource/IObasicSourceList.C
|
||||
|
||||
general/explicitSource/explicitSource.C
|
||||
general/semiImplicitSource/semiImplicitSource.C
|
||||
general/explicitSetValue/explicitSetValue.C
|
||||
general/codedSource/codedSource.C
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,15 +23,16 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ExplicitSource.H"
|
||||
#include "SemiImplicitSource.H"
|
||||
#include "fvMesh.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "DimensionedField.H"
|
||||
#include "fvmSup.H"
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::wordList Foam::ExplicitSource<Type>::
|
||||
const Foam::wordList Foam::SemiImplicitSource<Type>::
|
||||
volumeModeTypeNames_
|
||||
(
|
||||
IStringStream("(absolute specific)")()
|
||||
@ -41,8 +42,8 @@ volumeModeTypeNames_
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
typename Foam::ExplicitSource<Type>::volumeModeType
|
||||
Foam::ExplicitSource<Type>::wordToVolumeModeType
|
||||
typename Foam::SemiImplicitSource<Type>::volumeModeType
|
||||
Foam::SemiImplicitSource<Type>::wordToVolumeModeType
|
||||
(
|
||||
const word& vmtName
|
||||
) const
|
||||
@ -57,8 +58,8 @@ Foam::ExplicitSource<Type>::wordToVolumeModeType
|
||||
|
||||
FatalErrorIn
|
||||
(
|
||||
"ExplicitSource<Type>::volumeModeType"
|
||||
"ExplicitSource<Type>::wordToVolumeModeType(const word&)"
|
||||
"SemiImplicitSource<Type>::volumeModeType"
|
||||
"SemiImplicitSource<Type>::wordToVolumeModeType(const word&)"
|
||||
) << "Unknown volumeMode type " << vmtName
|
||||
<< ". Valid volumeMode types are:" << nl << volumeModeTypeNames_
|
||||
<< exit(FatalError);
|
||||
@ -68,7 +69,7 @@ Foam::ExplicitSource<Type>::wordToVolumeModeType
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::word Foam::ExplicitSource<Type>::volumeModeTypeToWord
|
||||
Foam::word Foam::SemiImplicitSource<Type>::volumeModeTypeToWord
|
||||
(
|
||||
const volumeModeType& vmtType
|
||||
) const
|
||||
@ -85,7 +86,7 @@ Foam::word Foam::ExplicitSource<Type>::volumeModeTypeToWord
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
|
||||
void Foam::SemiImplicitSource<Type>::setFieldData(const dictionary& dict)
|
||||
{
|
||||
fieldNames_.setSize(dict.toc().size());
|
||||
injectionRate_.setSize(fieldNames_.size());
|
||||
@ -111,7 +112,7 @@ void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::ExplicitSource<Type>::ExplicitSource
|
||||
Foam::SemiImplicitSource<Type>::SemiImplicitSource
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
@ -131,7 +132,7 @@ Foam::ExplicitSource<Type>::ExplicitSource
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::ExplicitSource<Type>::addSup
|
||||
void Foam::SemiImplicitSource<Type>::addSup
|
||||
(
|
||||
fvMatrix<Type>& eqn,
|
||||
const label fieldI
|
||||
@ -139,15 +140,17 @@ void Foam::ExplicitSource<Type>::addSup
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "ExplicitSource<"<< pTraits<Type>::typeName
|
||||
Info<< "SemiImplicitSource<" << pTraits<Type>::typeName
|
||||
<< ">::addSup for source " << name_ << endl;
|
||||
}
|
||||
|
||||
const GeometricField<Type, fvPatchField, volMesh>& psi = eqn.psi();
|
||||
|
||||
DimensionedField<Type, volMesh> Su
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name_ + fieldNames_[fieldI] + "Sup",
|
||||
name_ + fieldNames_[fieldI] + "Su",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
@ -163,9 +166,31 @@ void Foam::ExplicitSource<Type>::addSup
|
||||
false
|
||||
);
|
||||
|
||||
UIndirectList<Type>(Su, cells_) = injectionRate_[fieldI]/VDash_;
|
||||
UIndirectList<Type>(Su, cells_) = injectionRate_[fieldI].first()/VDash_;
|
||||
|
||||
eqn += Su;
|
||||
DimensionedField<scalar, volMesh> Sp
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name_ + fieldNames_[fieldI] + "Sp",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensioned<scalar>
|
||||
(
|
||||
"zero",
|
||||
Su.dimensions()/psi.dimensions(),
|
||||
0.0
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
UIndirectList<scalar>(Sp, cells_) = injectionRate_[fieldI].second()/VDash_;
|
||||
|
||||
eqn += Su + fvm::Sp(Sp, psi);
|
||||
}
|
||||
|
||||
|
||||
@ -22,21 +22,33 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ExplicitSource
|
||||
Foam::SemiImplicitSource
|
||||
|
||||
Description
|
||||
Explicit source
|
||||
Semi-implicit source, described using an input dictionary. The injection
|
||||
rate coefficients are specified as pairs of Su-Sp coefficients, i.e.
|
||||
|
||||
Sources described by:
|
||||
\f[
|
||||
S(x) = S_u + S_p x
|
||||
\f]
|
||||
|
||||
where
|
||||
\vartable
|
||||
S(x) | net source for field 'x'
|
||||
S_u | explicit source contribution
|
||||
S_p | linearised implicit contribution
|
||||
\endvartable
|
||||
|
||||
Example of the source specification:
|
||||
|
||||
\verbatim
|
||||
<Type>ExplicitSourceCoeffs
|
||||
<Type>SemiImplicitSourceCoeffs
|
||||
{
|
||||
volumeMode absolute; // specific
|
||||
injectionRate
|
||||
injectionRateSuSp
|
||||
{
|
||||
k 30.7;
|
||||
epsilon 1.5;
|
||||
k (30.7 0);
|
||||
epsilon (1.5 0);
|
||||
}
|
||||
}
|
||||
\verbatim
|
||||
@ -49,12 +61,12 @@ SeeAlso
|
||||
Foam::basicSource
|
||||
|
||||
SourceFiles
|
||||
ExplicitSource.C
|
||||
SemiImplicitSource.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ExplicitSource_H
|
||||
#define ExplicitSource_H
|
||||
#ifndef SemiImplicitSource_H
|
||||
#define SemiImplicitSource_H
|
||||
|
||||
#include "Tuple2.H"
|
||||
#include "basicSource.H"
|
||||
@ -69,7 +81,7 @@ namespace Foam
|
||||
class fvMesh;
|
||||
|
||||
template<class Type>
|
||||
class ExplicitSource;
|
||||
class SemiImplicitSource;
|
||||
|
||||
// Forward declaration of friend functions
|
||||
|
||||
@ -77,15 +89,15 @@ template<class Type>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const ExplicitSource<Type>&
|
||||
const SemiImplicitSource<Type>&
|
||||
);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ExplicitSource Declaration
|
||||
Class SemiImplicitSource Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class ExplicitSource
|
||||
class SemiImplicitSource
|
||||
:
|
||||
public basicSource
|
||||
{
|
||||
@ -115,7 +127,7 @@ protected:
|
||||
scalar VDash_;
|
||||
|
||||
//- Source field values
|
||||
List<Type> injectionRate_;
|
||||
List<Tuple2<Type, scalar> > injectionRate_;
|
||||
|
||||
|
||||
// Protected functions
|
||||
@ -133,13 +145,13 @@ protected:
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("ExplicitSource");
|
||||
TypeName("SemiImplicitSource");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ExplicitSource
|
||||
SemiImplicitSource
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
@ -156,7 +168,7 @@ public:
|
||||
inline const volumeModeType& volumeMode() const;
|
||||
|
||||
//- Return const access to the source field values
|
||||
inline const List<Type>& injectionRate() const;
|
||||
inline const List<Tuple2<Type, scalar> >& injectionRate() const;
|
||||
|
||||
|
||||
// Edit
|
||||
@ -165,7 +177,7 @@ public:
|
||||
inline volumeModeType& volumeMode();
|
||||
|
||||
//- Return access to the source field values
|
||||
inline List<Type>& injectionRate();
|
||||
inline List<Tuple2<Type, scalar> >& injectionRate();
|
||||
|
||||
|
||||
// Evaluation
|
||||
@ -191,13 +203,13 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ExplicitSource.C"
|
||||
# include "ExplicitSourceIO.C"
|
||||
# include "SemiImplicitSource.C"
|
||||
# include "SemiImplicitSourceIO.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "ExplicitSourceI.H"
|
||||
#include "SemiImplicitSourceI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,35 +23,37 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ExplicitSource.H"
|
||||
#include "SemiImplicitSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline const typename Foam::ExplicitSource<Type>::volumeModeType&
|
||||
Foam::ExplicitSource<Type>::volumeMode() const
|
||||
inline const typename Foam::SemiImplicitSource<Type>::volumeModeType&
|
||||
Foam::SemiImplicitSource<Type>::volumeMode() const
|
||||
{
|
||||
return volumeMode_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline const Foam::List<Type>& Foam::ExplicitSource<Type>::injectionRate() const
|
||||
inline const Foam::List<Foam::Tuple2<Type, Foam::scalar> >&
|
||||
Foam::SemiImplicitSource<Type>::injectionRate() const
|
||||
{
|
||||
return injectionRate_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline typename Foam::ExplicitSource<Type>::volumeModeType&
|
||||
Foam::ExplicitSource<Type>::volumeMode()
|
||||
inline typename Foam::SemiImplicitSource<Type>::volumeModeType&
|
||||
Foam::SemiImplicitSource<Type>::volumeMode()
|
||||
{
|
||||
return volumeMode_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::List<Type>& Foam::ExplicitSource<Type>::injectionRate()
|
||||
inline Foam::List<Foam::Tuple2<Type,
|
||||
Foam::scalar> >& Foam::SemiImplicitSource<Type>::injectionRate()
|
||||
{
|
||||
return injectionRate_;
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,12 +23,12 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ExplicitSource.H"
|
||||
#include "SemiImplicitSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::ExplicitSource<Type>::writeData(Ostream& os) const
|
||||
void Foam::SemiImplicitSource<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
os << indent << name_ << endl;
|
||||
dict_.write(os);
|
||||
@ -36,12 +36,12 @@ void Foam::ExplicitSource<Type>::writeData(Ostream& os) const
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::ExplicitSource<Type>::read(const dictionary& dict)
|
||||
bool Foam::SemiImplicitSource<Type>::read(const dictionary& dict)
|
||||
{
|
||||
if (basicSource::read(dict))
|
||||
{
|
||||
volumeMode_ = wordToVolumeModeType(coeffs_.lookup("volumeMode"));
|
||||
setFieldData(coeffs_.subDict("injectionRate"));
|
||||
setFieldData(coeffs_.subDict("injectionRateSuSp"));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,17 +24,17 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "makeBasicSource.H"
|
||||
#include "ExplicitSource.H"
|
||||
#include "SemiImplicitSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeBasicSource(ExplicitSource, scalar);
|
||||
makeBasicSource(ExplicitSource, vector);
|
||||
makeBasicSource(ExplicitSource, sphericalTensor);
|
||||
makeBasicSource(ExplicitSource, symmTensor);
|
||||
makeBasicSource(ExplicitSource, tensor);
|
||||
makeBasicSource(SemiImplicitSource, scalar);
|
||||
makeBasicSource(SemiImplicitSource, vector);
|
||||
makeBasicSource(SemiImplicitSource, sphericalTensor);
|
||||
makeBasicSource(SemiImplicitSource, symmTensor);
|
||||
makeBasicSource(SemiImplicitSource, tensor);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user