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/basicSourceList.C
|
||||||
basicSource/IObasicSourceList.C
|
basicSource/IObasicSourceList.C
|
||||||
|
|
||||||
general/explicitSource/explicitSource.C
|
general/semiImplicitSource/semiImplicitSource.C
|
||||||
general/explicitSetValue/explicitSetValue.C
|
general/explicitSetValue/explicitSetValue.C
|
||||||
general/codedSource/codedSource.C
|
general/codedSource/codedSource.C
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,15 +23,16 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ExplicitSource.H"
|
#include "SemiImplicitSource.H"
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "fvMatrices.H"
|
#include "fvMatrices.H"
|
||||||
#include "DimensionedField.H"
|
#include "DimensionedField.H"
|
||||||
|
#include "fvmSup.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
const Foam::wordList Foam::ExplicitSource<Type>::
|
const Foam::wordList Foam::SemiImplicitSource<Type>::
|
||||||
volumeModeTypeNames_
|
volumeModeTypeNames_
|
||||||
(
|
(
|
||||||
IStringStream("(absolute specific)")()
|
IStringStream("(absolute specific)")()
|
||||||
@ -41,8 +42,8 @@ volumeModeTypeNames_
|
|||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
typename Foam::ExplicitSource<Type>::volumeModeType
|
typename Foam::SemiImplicitSource<Type>::volumeModeType
|
||||||
Foam::ExplicitSource<Type>::wordToVolumeModeType
|
Foam::SemiImplicitSource<Type>::wordToVolumeModeType
|
||||||
(
|
(
|
||||||
const word& vmtName
|
const word& vmtName
|
||||||
) const
|
) const
|
||||||
@ -57,8 +58,8 @@ Foam::ExplicitSource<Type>::wordToVolumeModeType
|
|||||||
|
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"ExplicitSource<Type>::volumeModeType"
|
"SemiImplicitSource<Type>::volumeModeType"
|
||||||
"ExplicitSource<Type>::wordToVolumeModeType(const word&)"
|
"SemiImplicitSource<Type>::wordToVolumeModeType(const word&)"
|
||||||
) << "Unknown volumeMode type " << vmtName
|
) << "Unknown volumeMode type " << vmtName
|
||||||
<< ". Valid volumeMode types are:" << nl << volumeModeTypeNames_
|
<< ". Valid volumeMode types are:" << nl << volumeModeTypeNames_
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -68,7 +69,7 @@ Foam::ExplicitSource<Type>::wordToVolumeModeType
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::word Foam::ExplicitSource<Type>::volumeModeTypeToWord
|
Foam::word Foam::SemiImplicitSource<Type>::volumeModeTypeToWord
|
||||||
(
|
(
|
||||||
const volumeModeType& vmtType
|
const volumeModeType& vmtType
|
||||||
) const
|
) const
|
||||||
@ -85,7 +86,7 @@ Foam::word Foam::ExplicitSource<Type>::volumeModeTypeToWord
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
|
void Foam::SemiImplicitSource<Type>::setFieldData(const dictionary& dict)
|
||||||
{
|
{
|
||||||
fieldNames_.setSize(dict.toc().size());
|
fieldNames_.setSize(dict.toc().size());
|
||||||
injectionRate_.setSize(fieldNames_.size());
|
injectionRate_.setSize(fieldNames_.size());
|
||||||
@ -111,7 +112,7 @@ void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
|
|||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::ExplicitSource<Type>::ExplicitSource
|
Foam::SemiImplicitSource<Type>::SemiImplicitSource
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const word& modelType,
|
const word& modelType,
|
||||||
@ -131,7 +132,7 @@ Foam::ExplicitSource<Type>::ExplicitSource
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::ExplicitSource<Type>::addSup
|
void Foam::SemiImplicitSource<Type>::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<Type>& eqn,
|
fvMatrix<Type>& eqn,
|
||||||
const label fieldI
|
const label fieldI
|
||||||
@ -139,15 +140,17 @@ void Foam::ExplicitSource<Type>::addSup
|
|||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "ExplicitSource<"<< pTraits<Type>::typeName
|
Info<< "SemiImplicitSource<" << pTraits<Type>::typeName
|
||||||
<< ">::addSup for source " << name_ << endl;
|
<< ">::addSup for source " << name_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& psi = eqn.psi();
|
||||||
|
|
||||||
DimensionedField<Type, volMesh> Su
|
DimensionedField<Type, volMesh> Su
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name_ + fieldNames_[fieldI] + "Sup",
|
name_ + fieldNames_[fieldI] + "Su",
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
@ -163,9 +166,31 @@ void Foam::ExplicitSource<Type>::addSup
|
|||||||
false
|
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/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::ExplicitSource
|
Foam::SemiImplicitSource
|
||||||
|
|
||||||
Description
|
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
|
\verbatim
|
||||||
<Type>ExplicitSourceCoeffs
|
<Type>SemiImplicitSourceCoeffs
|
||||||
{
|
{
|
||||||
volumeMode absolute; // specific
|
volumeMode absolute; // specific
|
||||||
injectionRate
|
injectionRateSuSp
|
||||||
{
|
{
|
||||||
k 30.7;
|
k (30.7 0);
|
||||||
epsilon 1.5;
|
epsilon (1.5 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\verbatim
|
\verbatim
|
||||||
@ -49,12 +61,12 @@ SeeAlso
|
|||||||
Foam::basicSource
|
Foam::basicSource
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
ExplicitSource.C
|
SemiImplicitSource.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef ExplicitSource_H
|
#ifndef SemiImplicitSource_H
|
||||||
#define ExplicitSource_H
|
#define SemiImplicitSource_H
|
||||||
|
|
||||||
#include "Tuple2.H"
|
#include "Tuple2.H"
|
||||||
#include "basicSource.H"
|
#include "basicSource.H"
|
||||||
@ -69,7 +81,7 @@ namespace Foam
|
|||||||
class fvMesh;
|
class fvMesh;
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
class ExplicitSource;
|
class SemiImplicitSource;
|
||||||
|
|
||||||
// Forward declaration of friend functions
|
// Forward declaration of friend functions
|
||||||
|
|
||||||
@ -77,15 +89,15 @@ template<class Type>
|
|||||||
Ostream& operator<<
|
Ostream& operator<<
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const ExplicitSource<Type>&
|
const SemiImplicitSource<Type>&
|
||||||
);
|
);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class ExplicitSource Declaration
|
Class SemiImplicitSource Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
class ExplicitSource
|
class SemiImplicitSource
|
||||||
:
|
:
|
||||||
public basicSource
|
public basicSource
|
||||||
{
|
{
|
||||||
@ -115,7 +127,7 @@ protected:
|
|||||||
scalar VDash_;
|
scalar VDash_;
|
||||||
|
|
||||||
//- Source field values
|
//- Source field values
|
||||||
List<Type> injectionRate_;
|
List<Tuple2<Type, scalar> > injectionRate_;
|
||||||
|
|
||||||
|
|
||||||
// Protected functions
|
// Protected functions
|
||||||
@ -133,13 +145,13 @@ protected:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("ExplicitSource");
|
TypeName("SemiImplicitSource");
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
ExplicitSource
|
SemiImplicitSource
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const word& modelType,
|
const word& modelType,
|
||||||
@ -156,7 +168,7 @@ public:
|
|||||||
inline const volumeModeType& volumeMode() const;
|
inline const volumeModeType& volumeMode() const;
|
||||||
|
|
||||||
//- Return const access to the source field values
|
//- Return const access to the source field values
|
||||||
inline const List<Type>& injectionRate() const;
|
inline const List<Tuple2<Type, scalar> >& injectionRate() const;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
@ -165,7 +177,7 @@ public:
|
|||||||
inline volumeModeType& volumeMode();
|
inline volumeModeType& volumeMode();
|
||||||
|
|
||||||
//- Return access to the source field values
|
//- Return access to the source field values
|
||||||
inline List<Type>& injectionRate();
|
inline List<Tuple2<Type, scalar> >& injectionRate();
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
@ -191,13 +203,13 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
# include "ExplicitSource.C"
|
# include "SemiImplicitSource.C"
|
||||||
# include "ExplicitSourceIO.C"
|
# include "SemiImplicitSourceIO.C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#include "ExplicitSourceI.H"
|
#include "SemiImplicitSourceI.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,35 +23,37 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ExplicitSource.H"
|
#include "SemiImplicitSource.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
inline const typename Foam::ExplicitSource<Type>::volumeModeType&
|
inline const typename Foam::SemiImplicitSource<Type>::volumeModeType&
|
||||||
Foam::ExplicitSource<Type>::volumeMode() const
|
Foam::SemiImplicitSource<Type>::volumeMode() const
|
||||||
{
|
{
|
||||||
return volumeMode_;
|
return volumeMode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
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_;
|
return injectionRate_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
inline typename Foam::ExplicitSource<Type>::volumeModeType&
|
inline typename Foam::SemiImplicitSource<Type>::volumeModeType&
|
||||||
Foam::ExplicitSource<Type>::volumeMode()
|
Foam::SemiImplicitSource<Type>::volumeMode()
|
||||||
{
|
{
|
||||||
return volumeMode_;
|
return volumeMode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
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_;
|
return injectionRate_;
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,12 +23,12 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ExplicitSource.H"
|
#include "SemiImplicitSource.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::ExplicitSource<Type>::writeData(Ostream& os) const
|
void Foam::SemiImplicitSource<Type>::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << indent << name_ << endl;
|
os << indent << name_ << endl;
|
||||||
dict_.write(os);
|
dict_.write(os);
|
||||||
@ -36,12 +36,12 @@ void Foam::ExplicitSource<Type>::writeData(Ostream& os) const
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool Foam::ExplicitSource<Type>::read(const dictionary& dict)
|
bool Foam::SemiImplicitSource<Type>::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
if (basicSource::read(dict))
|
if (basicSource::read(dict))
|
||||||
{
|
{
|
||||||
volumeMode_ = wordToVolumeModeType(coeffs_.lookup("volumeMode"));
|
volumeMode_ = wordToVolumeModeType(coeffs_.lookup("volumeMode"));
|
||||||
setFieldData(coeffs_.subDict("injectionRate"));
|
setFieldData(coeffs_.subDict("injectionRateSuSp"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -24,17 +24,17 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "makeBasicSource.H"
|
#include "makeBasicSource.H"
|
||||||
#include "ExplicitSource.H"
|
#include "SemiImplicitSource.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
makeBasicSource(ExplicitSource, scalar);
|
makeBasicSource(SemiImplicitSource, scalar);
|
||||||
makeBasicSource(ExplicitSource, vector);
|
makeBasicSource(SemiImplicitSource, vector);
|
||||||
makeBasicSource(ExplicitSource, sphericalTensor);
|
makeBasicSource(SemiImplicitSource, sphericalTensor);
|
||||||
makeBasicSource(ExplicitSource, symmTensor);
|
makeBasicSource(SemiImplicitSource, symmTensor);
|
||||||
makeBasicSource(ExplicitSource, tensor);
|
makeBasicSource(SemiImplicitSource, tensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user