From 39aeb1d8f62d68b992b9ff78996e4d899f711c1c Mon Sep 17 00:00:00 2001 From: andy <andy> Date: Fri, 26 Oct 2012 09:46:16 +0100 Subject: [PATCH] ENH: Updated explicit source to semi-implicit source --- src/fieldSources/Make/files | 2 +- .../SemiImplicitSource.C} | 55 +++++++++++++----- .../SemiImplicitSource.H} | 56 +++++++++++-------- .../SemiImplicitSourceI.H} | 18 +++--- .../SemiImplicitSourceIO.C} | 10 ++-- .../semiImplicitSource.C} | 14 ++--- 6 files changed, 97 insertions(+), 58 deletions(-) rename src/fieldSources/general/{explicitSource/ExplicitSource.C => semiImplicitSource/SemiImplicitSource.C} (71%) rename src/fieldSources/general/{explicitSource/ExplicitSource.H => semiImplicitSource/SemiImplicitSource.H} (78%) rename src/fieldSources/general/{explicitSource/ExplicitSourceI.H => semiImplicitSource/SemiImplicitSourceI.H} (72%) rename src/fieldSources/general/{explicitSource/ExplicitSourceIO.C => semiImplicitSource/SemiImplicitSourceIO.C} (83%) rename src/fieldSources/general/{explicitSource/explicitSource.C => semiImplicitSource/semiImplicitSource.C} (78%) diff --git a/src/fieldSources/Make/files b/src/fieldSources/Make/files index 41fecea8008..11f91ff58ad 100644 --- a/src/fieldSources/Make/files +++ b/src/fieldSources/Make/files @@ -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 diff --git a/src/fieldSources/general/explicitSource/ExplicitSource.C b/src/fieldSources/general/semiImplicitSource/SemiImplicitSource.C similarity index 71% rename from src/fieldSources/general/explicitSource/ExplicitSource.C rename to src/fieldSources/general/semiImplicitSource/SemiImplicitSource.C index 64ed783cb93..2e556eaf01c 100644 --- a/src/fieldSources/general/explicitSource/ExplicitSource.C +++ b/src/fieldSources/general/semiImplicitSource/SemiImplicitSource.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_; + + 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; + eqn += Su + fvm::Sp(Sp, psi); } diff --git a/src/fieldSources/general/explicitSource/ExplicitSource.H b/src/fieldSources/general/semiImplicitSource/SemiImplicitSource.H similarity index 78% rename from src/fieldSources/general/explicitSource/ExplicitSource.H rename to src/fieldSources/general/semiImplicitSource/SemiImplicitSource.H index 30a18dd5d39..94a174034b2 100644 --- a/src/fieldSources/general/explicitSource/ExplicitSource.H +++ b/src/fieldSources/general/semiImplicitSource/SemiImplicitSource.H @@ -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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/fieldSources/general/explicitSource/ExplicitSourceI.H b/src/fieldSources/general/semiImplicitSource/SemiImplicitSourceI.H similarity index 72% rename from src/fieldSources/general/explicitSource/ExplicitSourceI.H rename to src/fieldSources/general/semiImplicitSource/SemiImplicitSourceI.H index e3f4b8aa63b..eb352de08a3 100644 --- a/src/fieldSources/general/explicitSource/ExplicitSourceI.H +++ b/src/fieldSources/general/semiImplicitSource/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_; } diff --git a/src/fieldSources/general/explicitSource/ExplicitSourceIO.C b/src/fieldSources/general/semiImplicitSource/SemiImplicitSourceIO.C similarity index 83% rename from src/fieldSources/general/explicitSource/ExplicitSourceIO.C rename to src/fieldSources/general/semiImplicitSource/SemiImplicitSourceIO.C index f2abe69cbd6..6b91798be64 100644 --- a/src/fieldSources/general/explicitSource/ExplicitSourceIO.C +++ b/src/fieldSources/general/semiImplicitSource/SemiImplicitSourceIO.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,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; } diff --git a/src/fieldSources/general/explicitSource/explicitSource.C b/src/fieldSources/general/semiImplicitSource/semiImplicitSource.C similarity index 78% rename from src/fieldSources/general/explicitSource/explicitSource.C rename to src/fieldSources/general/semiImplicitSource/semiImplicitSource.C index 338a4220593..e3b294fa59d 100644 --- a/src/fieldSources/general/explicitSource/explicitSource.C +++ b/src/fieldSources/general/semiImplicitSource/semiImplicitSource.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 @@ -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); } -- GitLab