From b6f91de72c0e142b187fd8cb647e9747fe696aeb Mon Sep 17 00:00:00 2001 From: Jakub Knir Date: Tue, 7 Apr 2020 15:57:52 +0100 Subject: [PATCH] semiImplicitSource: Made operable on multiple different types The scalarSemiImplicitSource, vectorSemiImplicitSource, etc..., fvOptions have been replaced by a single semiImplicitSource fvOption. This allows sources to be specified for multiple fields regardless of type. For example: massSource { type semiImplicitSource; timeStart 1; duration 500; selectionMode points; points ( (0.075 0.2 0.05) ); volumeMode absolute; sources { thermo:rho.steam { explicit 1.0e-3; // kg/s implicit 0; } U.steam { explicit (0 1e-1 0); // kg*m/s^2 implicit 0; } h.steam { explicit 3700; // kg*m^2/s^3 implicit 0; } } } --- .../templates/system/solid/fvOptions | 18 +- .../semiImplicitSource/SemiImplicitSource.C | 231 ----------- .../semiImplicitSource/SemiImplicitSource.H | 218 ----------- .../semiImplicitSource/semiImplicitSource.C | 367 +++++++++++++++++- .../semiImplicitSource/semiImplicitSource.H | 309 +++++++++++++++ .../drift/constant/fvOptions | 16 +- .../negativeDrift/constant/fvOptions | 18 +- .../templates/system/solid/fvOptions | 4 +- .../heatedDuct/constant/heater/fvOptions | 2 +- .../reverseBurner/constant/gas/fvOptions | 2 +- .../planarPoiseuille/constant/fvOptions | 2 +- .../filter/constant/fvOptions | 31 +- .../laminar/bed/constant/fvOptions | 24 +- .../laminar/injection/constant/fvOptions | 48 +-- .../laminar/steamInjection/constant/fvOptions | 48 +-- .../laminar/injection/constant/fvOptions | 48 +-- 16 files changed, 774 insertions(+), 612 deletions(-) delete mode 100644 src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C delete mode 100644 src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.H create mode 100644 src/fvOptions/sources/general/semiImplicitSource/semiImplicitSource.H diff --git a/etc/templates/singleFluidCHT/templates/system/solid/fvOptions b/etc/templates/singleFluidCHT/templates/system/solid/fvOptions index 94e9ae6528..1804841850 100644 --- a/etc/templates/singleFluidCHT/templates/system/solid/fvOptions +++ b/etc/templates/singleFluidCHT/templates/system/solid/fvOptions @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class dictionary; - object porousZone; + object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -27,7 +27,7 @@ fixedTemperature fixedPower { - type scalarSemiImplicitSource; + type semiImplicitSource; active no; selectionMode all; @@ -35,10 +35,18 @@ fixedPower power 100; // Set power (W) - injectionRateSuSp + sources { - e ($power 0); - h ($power 0); + e + { + explicit $power; + implicit 0; + } + h + { + explicit $power; + implicit 0; + } } } diff --git a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C b/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C deleted file mode 100644 index 49c7cf3cff..0000000000 --- a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C +++ /dev/null @@ -1,231 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "SemiImplicitSource.H" -#include "fvMesh.H" -#include "fvMatrices.H" -#include "fvmSup.H" - -// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // - -template -const Foam::wordList Foam::fv::SemiImplicitSource::volumeModeTypeNames_ -( - IStringStream("(absolute specific)")() -); - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -template -typename Foam::fv::SemiImplicitSource::volumeModeType -Foam::fv::SemiImplicitSource::wordToVolumeModeType -( - const word& vmtName -) const -{ - forAll(volumeModeTypeNames_, i) - { - if (vmtName == volumeModeTypeNames_[i]) - { - return volumeModeType(i); - } - } - - FatalErrorInFunction - << "Unknown volumeMode type " << vmtName - << ". Valid volumeMode types are:" << nl << volumeModeTypeNames_ - << exit(FatalError); - - return volumeModeType(0); -} - - -template -Foam::word Foam::fv::SemiImplicitSource::volumeModeTypeToWord -( - const volumeModeType& vmtType -) const -{ - if (vmtType > volumeModeTypeNames_.size()) - { - return "UNKNOWN"; - } - else - { - return volumeModeTypeNames_[vmtType]; - } -} - - -template -void Foam::fv::SemiImplicitSource::setFieldData(const dictionary& dict) -{ - fieldNames_.setSize(dict.size()); - Su_.setSize(fieldNames_.size()); - Sp_.setSize(fieldNames_.size()); - - applied_.setSize(fieldNames_.size(), false); - - label i = 0; - forAllConstIter(dictionary, dict, iter) - { - fieldNames_[i] = iter().keyword(); - const dictionary& fieldSubDict(iter().dict()); - Su_.set(i, Function1::New("explicit", fieldSubDict)); - Sp_.set(i, Function1::New("implicit", fieldSubDict)); - i++; - } - - // Set volume normalisation - if (volumeMode_ == vmAbsolute) - { - VDash_ = V_; - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::fv::SemiImplicitSource::SemiImplicitSource -( - const word& name, - const word& modelType, - const dictionary& dict, - const fvMesh& mesh -) -: - cellSetOption(name, modelType, dict, mesh), - volumeMode_(vmAbsolute), - VDash_(1) -{ - read(dict); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::fv::SemiImplicitSource::addSup -( - fvMatrix& eqn, - const label fieldi -) -{ - if (debug) - { - Info<< "SemiImplicitSource<" << pTraits::typeName - << ">::addSup for source " << name_ << endl; - } - - const scalar t = mesh_.time().value(); - - const GeometricField& psi = eqn.psi(); - - typename GeometricField::Internal Su - ( - IOobject - ( - name_ + fieldNames_[fieldi] + "Su", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensioned - ( - "zero", - eqn.dimensions()/dimVolume, - Zero - ), - false - ); - - UIndirectList(Su, cells_) = Su_[fieldi].value(t)/VDash_; - - volScalarField::Internal Sp - ( - IOobject - ( - name_ + fieldNames_[fieldi] + "Sp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensioned - ( - "zero", - Su.dimensions()/psi.dimensions(), - 0 - ), - false - ); - - UIndirectList(Sp, cells_) = Sp_[fieldi].value(t)/VDash_; - - eqn += Su + fvm::SuSp(Sp, psi); -} - - -template -void Foam::fv::SemiImplicitSource::addSup -( - const volScalarField& rho, - fvMatrix& eqn, - const label fieldi -) -{ - if (debug) - { - Info<< "SemiImplicitSource<" << pTraits::typeName - << ">::addSup for source " << name_ << endl; - } - - return this->addSup(eqn, fieldi); -} - - -template -bool Foam::fv::SemiImplicitSource::read(const dictionary& dict) -{ - if (cellSetOption::read(dict)) - { - volumeMode_ = wordToVolumeModeType(coeffs_.lookup("volumeMode")); - setFieldData(coeffs_.subDict("sources")); - - return true; - } - else - { - return false; - } -} - - -// ************************************************************************* // diff --git a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.H b/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.H deleted file mode 100644 index e02a505052..0000000000 --- a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.H +++ /dev/null @@ -1,218 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::fv::SemiImplicitSource - -Description - Semi-implicit source, described using an input dictionary. The injection - rate coefficients are specified as pairs of Su-Sp coefficients, i.e. - - \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 tabulated heat source specification for internal energy: - \verbatim - volumeMode absolute; // specific - sources - { - e - { - explicit table ((0 0) (1.5 $power)); - implicit 0; - } - } - \endverbatim - - Example coded heat source specification for enthalpy: - \verbatim - volumeMode absolute; // specific - sources - { - h - { - explicit - { - type coded; - name heatInjection; - code - #{ - // Power amplitude - const scalar powerAmplitude = 1000; - - // x is the current time - return mag(powerAmplitude*sin(x)); - #}; - } - implicit 0; - } - } - \endverbatim - - Valid options for the \c volumeMode entry include: - - absolute: values are given as \ - - specific: values are given as \/m3 - -See also - Foam::fvOption - -SourceFiles - SemiImplicitSource.C - -\*---------------------------------------------------------------------------*/ - -#ifndef SemiImplicitSource_H -#define SemiImplicitSource_H - -#include "cellSetOption.H" -#include "Function1.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace fv -{ - -/*---------------------------------------------------------------------------*\ - Class SemiImplicitSource Declaration -\*---------------------------------------------------------------------------*/ - -template -class SemiImplicitSource -: - public cellSetOption -{ -public: - - // Public data - - //- Enumeration for volume types - enum volumeModeType - { - vmAbsolute, - vmSpecific - }; - - -private: - - // Private member data - - //- Word list of volume mode type names - static const wordList volumeModeTypeNames_; - - //- Volume mode - volumeModeType volumeMode_; - - //- Volume normalisation - scalar VDash_; - - //- Explicit source functions for the fields - PtrList> Su_; - - //- Implicit source functions for the fields - PtrList> Sp_; - - - // Private member functions - - //- Helper function to convert from a word to a volumeModeType - volumeModeType wordToVolumeModeType(const word& vtName) const; - - //- Helper function to convert from a volumeModeType to a word - word volumeModeTypeToWord(const volumeModeType& vtType) const; - - //- Set the local field data - void setFieldData(const dictionary& dict); - - -public: - - //- Runtime type information - TypeName("SemiImplicitSource"); - - - // Constructors - - //- Construct from components - SemiImplicitSource - ( - const word& name, - const word& modelType, - const dictionary& dict, - const fvMesh& mesh - ); - - - // Member Functions - - // Evaluation - - //- Add explicit contribution to equation - virtual void addSup - ( - fvMatrix& eqn, - const label fieldi - ); - - //- Add explicit contribution to compressible equation - virtual void addSup - ( - const volScalarField& rho, - fvMatrix& eqn, - const label fieldi - ); - - - // IO - - //- Read source dictionary - virtual bool read(const dictionary& dict); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "SemiImplicitSource.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/fvOptions/sources/general/semiImplicitSource/semiImplicitSource.C b/src/fvOptions/sources/general/semiImplicitSource/semiImplicitSource.C index 3a70600739..f8d263f6d7 100644 --- a/src/fvOptions/sources/general/semiImplicitSource/semiImplicitSource.C +++ b/src/fvOptions/sources/general/semiImplicitSource/semiImplicitSource.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,16 +23,365 @@ License \*---------------------------------------------------------------------------*/ -#include "makeFvOption.H" -#include "SemiImplicitSource.H" +#include "semiImplicitSource.H" +#include "fvMesh.H" +#include "fvMatrices.H" +#include "fvmSup.H" +#include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -makeFvOption(SemiImplicitSource, scalar); -makeFvOption(SemiImplicitSource, vector); -makeFvOption(SemiImplicitSource, sphericalTensor); -makeFvOption(SemiImplicitSource, symmTensor); -makeFvOption(SemiImplicitSource, tensor); +namespace Foam +{ + namespace fv + { + defineTypeNameAndDebug(semiImplicitSource, 0); + addToRunTimeSelectionTable + ( + cellSetOption, + semiImplicitSource, + dictionary + ); + } + + template<> + const char* NamedEnum::names[] = + { + "absolute", + "specific" + }; +} + +const Foam::NamedEnum + Foam::fv::semiImplicitSource::volumeModeNames_; + + +// * * * * * * * * * * * ** Private Member Functions ** * * * * * * * * * * // + +template +void Foam::fv::semiImplicitSource::addSupType +( + fvMatrix& eqn, + const label fieldi +) +{ + if (debug) + { + Info<< "semiImplicitSource<" << pTraits::typeName + << ">::addSup for source " << name_ << endl; + } + + const scalar t = mesh_.time().value(); + + const GeometricField& psi = eqn.psi(); + + typename GeometricField::Internal Su + ( + IOobject + ( + name_ + fieldNames_[fieldi] + "Su", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensioned + ( + "zero", + eqn.dimensions()/dimVolume, + Zero + ), + false + ); + + // Explicit source function for the field + autoPtr> SuFun1 + ( + Function1::New("explicit", fieldDicts_[fieldi]) + ); + UIndirectList(Su, cells_) = SuFun1->value(t)/VDash_; + + volScalarField::Internal Sp + ( + IOobject + ( + name_ + fieldNames_[fieldi] + "Sp", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensioned + ( + "zero", + Su.dimensions()/psi.dimensions(), + 0 + ), + false + ); + + // Implicit source function for the field + autoPtr> SpFun1 + ( + Function1::New("implicit", fieldDicts_[fieldi]) + ); + UIndirectList(Sp, cells_) = SpFun1->value(t)/VDash_; + + eqn += Su + fvm::SuSp(Sp, psi); +} + + +template +void Foam::fv::semiImplicitSource::addSupType +( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + if (debug) + { + Info<< "semiImplicitSource<" << pTraits::typeName + << ">::addSup for source " << name_ << endl; + } + + return this->addSup(eqn, fieldi); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fv::semiImplicitSource::semiImplicitSource +( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh +) +: + cellSetOption(name, modelType, dict, mesh), + volumeMode_(volumeMode::absolute), + VDash_(1) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fv::semiImplicitSource::~semiImplicitSource() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fv::semiImplicitSource::addSup +( + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +void Foam::fv::semiImplicitSource::addSup +( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSupType(eqn, fieldi); +} + + +bool Foam::fv::semiImplicitSource::read(const dictionary& dict) +{ + if (cellSetOption::read(dict)) + { + volumeMode_ = volumeModeNames_.read(coeffs_.lookup("volumeMode")); + + const dictionary& sources = coeffs_.subDict("sources"); + + // Number of the fields with source term + const label nFields = sources.size(); + + // Names of the field + fieldNames_.setSize(nFields); + + // Field dicts + fieldDicts_.setSize(nFields); + + label i = 0; + forAllConstIter(dictionary, sources, iter) + { + fieldNames_[i] = iter().keyword(); + fieldDicts_[i] = iter().dict(); + i++; + } + + // Set volume normalisation + if (volumeMode_ == volumeMode::absolute) + { + VDash_ = V_; + } + + applied_.setSize(nFields, false); + + return true; + } + else + { + return false; + } +} // ************************************************************************* // diff --git a/src/fvOptions/sources/general/semiImplicitSource/semiImplicitSource.H b/src/fvOptions/sources/general/semiImplicitSource/semiImplicitSource.H new file mode 100644 index 0000000000..e95a8dd424 --- /dev/null +++ b/src/fvOptions/sources/general/semiImplicitSource/semiImplicitSource.H @@ -0,0 +1,309 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::fv::semiImplicitSource + +Description + Semi-implicit source, described using an input dictionary. The injection + rate coefficients are specified as pairs of Su-Sp coefficients, i.e. + + \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 tabulated heat source specification for internal energy: + \verbatim + volumeMode absolute; // specific + sources + { + e + { + explicit table ((0 0) (1.5 $power)); + implicit 0; + } + } + \endverbatim + + Example coded heat source specification for enthalpy: + \verbatim + volumeMode absolute; // specific + sources + { + h + { + explicit + { + type coded; + name heatInjection; + code + #{ + // Power amplitude + const scalar powerAmplitude = 1000; + + // x is the current time + return mag(powerAmplitude*sin(x)); + #}; + } + implicit 0; + } + } + \endverbatim + + Valid options for the \c volumeMode entry include: + - absolute: values are given as \ + - specific: values are given as \/m3 + +See also + Foam::fvOption + +SourceFiles + semiImplicitSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef semiImplicitSource_H +#define semiImplicitSource_H + +#include "cellSetOption.H" +#include "Function1.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + +/*---------------------------------------------------------------------------*\ + Class semiImplicitSource Declaration +\*---------------------------------------------------------------------------*/ + +class semiImplicitSource +: + public cellSetOption +{ +public: + + // Public data + + //- Enumeration for volume types + enum class volumeMode + { + absolute, + specific + }; + + //- Property type names + static const NamedEnum volumeModeNames_; + + +private: + + // Private member data + + //- Volume mode + volumeMode volumeMode_; + + //- Volume normalisation + scalar VDash_; + + //- Explicit/Implicit source dicts + List fieldDicts_; + + + // Private member functions + + //- Add divergence terms to an equation + template + void addSupType(fvMatrix&, const label); + + //- Add divergence terms to an equation + template + void addSupType(const volScalarField&, fvMatrix&, const label); + + +public: + + //- Runtime type information + TypeName("semiImplicitSource"); + + + // Constructors + + //- Construct from components + semiImplicitSource + ( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh + ); + + //- Destructor + virtual ~semiImplicitSource(); + + + // Member Functions + + // Evaluation + + // Explicit and implicit sources + + virtual void addSup + ( + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + fvMatrix& eqn, + const label fieldi + ); + + + // Explicit and implicit sources for compressible equations + + virtual void addSup + ( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + + // Explicit and implicit sources for phase equations + + virtual void addSup + ( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + virtual void addSup + ( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + + // IO + + //- Read source dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv +} // End namespace Foam + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalance/drift/constant/fvOptions b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalance/drift/constant/fvOptions index 0a4c60bcca..17fa68d831 100644 --- a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalance/drift/constant/fvOptions +++ b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalance/drift/constant/fvOptions @@ -19,15 +19,23 @@ options { massSource { - type scalarSemiImplicitSource; + type semiImplicitSource; selectionMode all; volumeMode specific; - injectionRateSuSp + sources { - thermo:rho.air (0.024535 0);// kg/s/m³ - thermo:rho.water (-24.535 0); // kg/s/m³ + thermo:rho.air + { + explicit 0.024535; // kg/s/m^3 + implicit 0; + } + thermo:rho.water + { + explicit -24.535; // kg/s/m^3 + implicit 0; + } } } } diff --git a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalance/negativeDrift/constant/fvOptions b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalance/negativeDrift/constant/fvOptions index a20163b5c6..a3f0e47716 100644 --- a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalance/negativeDrift/constant/fvOptions +++ b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalance/negativeDrift/constant/fvOptions @@ -17,17 +17,25 @@ FoamFile options { - massSource1 + massSource { - type scalarSemiImplicitSource; + type semiImplicitSource; selectionMode all; volumeMode specific; - injectionRateSuSp + sources { - thermo:rho.air (-0.0258575 0); // kg/s/m³ - thermo:rho.water (25.8575 0); // kg/s/m³ + thermo:rho.air + { + explicit -0.0258575; // kg/s/m^3 + implicit 0; + } + thermo:rho.water + { + explicit 25.8575; // kg/s/m^3 + implicit 0; + } } } } diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/coolingSphere/templates/system/solid/fvOptions b/tutorials/heatTransfer/chtMultiRegionFoam/coolingSphere/templates/system/solid/fvOptions index 542f61bda7..4d7f4e8c8e 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/coolingSphere/templates/system/solid/fvOptions +++ b/tutorials/heatTransfer/chtMultiRegionFoam/coolingSphere/templates/system/solid/fvOptions @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class dictionary; - object porousZone; + object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -27,7 +27,7 @@ fixedTemperature fixedPower { - type scalarSemiImplicitSource; + type semiImplicitSource; active no; selectionMode all; diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/constant/heater/fvOptions b/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/constant/heater/fvOptions index 104f6b1d82..38b9a6aaf8 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/constant/heater/fvOptions +++ b/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/constant/heater/fvOptions @@ -19,7 +19,7 @@ options { energySource { - type scalarSemiImplicitSource; + type semiImplicitSource; timeStart 0; duration 1e6; diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/reverseBurner/constant/gas/fvOptions b/tutorials/heatTransfer/chtMultiRegionFoam/reverseBurner/constant/gas/fvOptions index d331546156..45592dc58e 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/reverseBurner/constant/gas/fvOptions +++ b/tutorials/heatTransfer/chtMultiRegionFoam/reverseBurner/constant/gas/fvOptions @@ -19,7 +19,7 @@ options { energySource { - type scalarSemiImplicitSource; + type semiImplicitSource; timeStart 0; duration 1; diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/constant/fvOptions b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/constant/fvOptions index 892c7636f5..31c9ff48b3 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/constant/fvOptions +++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/constant/fvOptions @@ -17,7 +17,7 @@ FoamFile momentumSource { - type vectorSemiImplicitSource; + type semiImplicitSource; timeStart 0.0; duration 1000; diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/constant/fvOptions b/tutorials/lagrangian/reactingParcelFoam/filter/constant/fvOptions index 1ca0b9e560..4c9a8d6cc2 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/constant/fvOptions +++ b/tutorials/lagrangian/reactingParcelFoam/filter/constant/fvOptions @@ -44,9 +44,9 @@ filter1 } -massSource1 +massSource { - type scalarSemiImplicitSource; + type semiImplicitSource; timeStart 0.2; duration 2.0; @@ -66,9 +66,9 @@ massSource1 implicit 0; } - H2O + U { - explicit 1e-4; // kg/s + explicit (0 0.005 0); implicit 0; } @@ -77,29 +77,10 @@ massSource1 explicit 10; implicit 0; } - } -} - -momentumSource1 -{ - type vectorSemiImplicitSource; - - timeStart 0.2; - duration 2.0; - selectionMode points; - points - ( - (2.75 0.5 0) - ); - - volumeMode absolute; - - sources - { - U + H2O { - explicit (0 0.005 0); + explicit 1e-4; // kg/s implicit 0; } } diff --git a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/bed/constant/fvOptions b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/bed/constant/fvOptions index 2bf46cbaf5..e5f8536c42 100644 --- a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/bed/constant/fvOptions +++ b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/bed/constant/fvOptions @@ -15,24 +15,20 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -injector1 -{ - timeStart 0; - duration 1e6; - selectionMode points; - points - ( - (0.075 0.925 0.05) - ); -} - options { - massSource1 + massSource { - type scalarSemiImplicitSource; + type semiImplicitSource; - $injector1; + timeStart 0; + duration 1e6; + + selectionMode points; + points + ( + (0.075 0.925 0.05) + ); volumeMode absolute; diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/injection/constant/fvOptions b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/injection/constant/fvOptions index 835e36c4de..e2f5395324 100644 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/injection/constant/fvOptions +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/injection/constant/fvOptions @@ -15,24 +15,20 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -injector1 -{ - timeStart 0.1; - duration 5; - selectionMode points; - points - ( - (0.075 0.2 0.05) - ); -} - options { - massSource1 + massSource { - type scalarSemiImplicitSource; + type semiImplicitSource; - $injector1; + timeStart 0.1; + duration 5; + + selectionMode points; + points + ( + (0.075 0.2 0.05) + ); volumeMode absolute; @@ -44,6 +40,12 @@ options implicit 0; } + U.air + { + explicit (0 -1e-2 0); // kg*m/s^2 + implicit 0; + } + e.air { explicit 500; // kg*m^2/s^3 @@ -51,24 +53,6 @@ options } } } - - momentumSource1 - { - type vectorSemiImplicitSource; - - $injector1; - - volumeMode absolute; - - sources - { - U.air - { - explicit (0 -1e-2 0); // kg*m/s^2 - implicit 0; // kg*m/s^2 - } - } - } } diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/steamInjection/constant/fvOptions b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/steamInjection/constant/fvOptions index 37bf4931b1..c87fdda012 100644 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/steamInjection/constant/fvOptions +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/steamInjection/constant/fvOptions @@ -15,24 +15,20 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -injector1 -{ - timeStart 1; - duration 500; - selectionMode points; - points - ( - (0.075 0.2 0.05) - ); -} - options { - massSource1 + massSource { - type scalarSemiImplicitSource; + type semiImplicitSource; - $injector1; + timeStart 1; + duration 500; + + selectionMode points; + points + ( + (0.075 0.2 0.05) + ); volumeMode absolute; @@ -44,29 +40,17 @@ options implicit 0; } - h.steam - { - explicit 3700; // kg*m^2/s^3 - implicit 0; - } - } - } - - momentumSource1 - { - type vectorSemiImplicitSource; - - $injector1; - - volumeMode absolute; - - sources - { U.steam { explicit (0 1e-1 0); // kg*m/s^2 implicit 0; } + + h.steam + { + explicit 3700; // kg*m^2/s^3 + implicit 0; + } } } diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/constant/fvOptions b/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/constant/fvOptions index 835e36c4de..e2f5395324 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/constant/fvOptions +++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/constant/fvOptions @@ -15,24 +15,20 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -injector1 -{ - timeStart 0.1; - duration 5; - selectionMode points; - points - ( - (0.075 0.2 0.05) - ); -} - options { - massSource1 + massSource { - type scalarSemiImplicitSource; + type semiImplicitSource; - $injector1; + timeStart 0.1; + duration 5; + + selectionMode points; + points + ( + (0.075 0.2 0.05) + ); volumeMode absolute; @@ -44,6 +40,12 @@ options implicit 0; } + U.air + { + explicit (0 -1e-2 0); // kg*m/s^2 + implicit 0; + } + e.air { explicit 500; // kg*m^2/s^3 @@ -51,24 +53,6 @@ options } } } - - momentumSource1 - { - type vectorSemiImplicitSource; - - $injector1; - - volumeMode absolute; - - sources - { - U.air - { - explicit (0 -1e-2 0); // kg*m/s^2 - implicit 0; // kg*m/s^2 - } - } - } }