Files
OpenFOAM-12/src/finiteVolume/cfdTools/general/fvModels/fvModel.C
Will Bainbridge 171101d1e5 fvModels: Specify source property values in field files
When an fvModel source introduces fluid into a simulation it should also
create a corresponding source term for all properties transported into
the domain by that injection. The source is, effectively, an alternative
form of inlet boundary, on which all transported properties need an
inlet value specified.

These values are now specified in the property field files. The
following is an example of a 0/U file in which the velocity of fluid
introduced by a fvModel source called "injection1" is set to a fixed
value of (-1 0 0):

    dimensions      [0 1 -1 0 0 0 0];

    internalField   uniform (0 0 0);

    boundaryField
    {
        #includeEtc "caseDicts/setConstraintTypes"

        wall
        {
            type            noSlip;
        }

        atmosphere
        {
            type            pressureInletOutletVelocity;
            value           $internalField;
        }
    }

    // *** NEW ***
    sources
    {
        injection1
        {
            type            uniformFixedValue;
            uniformValue    (-1 0 0);
        }
    }

And the following entry in the 0/k file specifies the turbulent kinetic
energy introduced as a fraction of the mean flow kinetic energy:

    sources
    {
        injection1
        {
            type            turbulentIntensityKineticEnergy;
            intensity       0.05;
        }
    }

The specification is directly analogous to boundary conditions. The
conditions are run-time selectable and can be concisely implemented.
They can access each other and be inter-dependent (e.g., the above,
where turbulent kinetic energy depends on velocity). The syntax keeps
field data localised and makes the source model (e.g., massSource,
volumeSource, ...) specification independent from what other models and
fields are present in the simulation. The 'fieldValues' entry previously
required by source models is now no longer required.

If source values need specifying and no source condition has been
supplied in the relevant field file then an error will be generated.
This error is similar to that generated for missing boundary conditions.
This replaces the behaviour where sources such as these would introduce
a value of zero, either silently or with a warning. This is now
considered unacceptable. Zero might be a tolerable default for certain
fields (U, k), but is wholly inappropriate for others (T, epsilon, rho).

This change additionally makes it possible to inject fluid into a
multicomponent solver with a specified temperature. Previously, it was
not possible to do this as there was no means of evaluating the energy
of fluid with the injected composition.
2023-10-12 11:24:27 +01:00

214 lines
4.9 KiB
C++

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021-2023 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fvModel.H"
#include "volFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(fvModel, 0);
defineRunTimeSelectionTable(fvModel, dictionary);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::fvModel::addSupType
(
const VolField<Type>& field,
fvMatrix<Type>& eqn
) const
{}
template<class Type>
void Foam::fvModel::addSupType
(
const volScalarField& rho,
const VolField<Type>& field,
fvMatrix<Type>& eqn
) const
{}
template<class Type>
void Foam::fvModel::addSupType
(
const volScalarField& alpha,
const volScalarField& rho,
const VolField<Type>& field,
fvMatrix<Type>& eqn
) const
{}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fvModel::fvModel
(
const word& name,
const word& modelType,
const fvMesh& mesh,
const dictionary& dict
)
:
name_(name),
modelType_(modelType),
mesh_(mesh),
dict_(dict),
coeffs_(dict.optionalSubDict(modelType + "Coeffs"))
{
Info<< incrIndent << indent << "Name: " << name_
<< endl << decrIndent;
}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::fvModel> Foam::fvModel::New
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
)
{
const word modelType(dict.lookup("type"));
Info<< indent
<< "Selecting finite volume model type " << modelType << endl;
if
(
!dictionaryConstructorTablePtr_
|| dictionaryConstructorTablePtr_->find(modelType)
== dictionaryConstructorTablePtr_->end()
)
{
if
(
!libs.open
(
dict,
"libs",
dictionaryConstructorTablePtr_
)
)
{
libs.open("lib" + modelType.remove(':') + ".so", false);
}
if (!dictionaryConstructorTablePtr_)
{
FatalErrorInFunction
<< "Unknown model type "
<< modelType << nl << nl
<< "Table of fvModels is empty"
<< exit(FatalError);
}
}
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalIOErrorInFunction(dict)
<< "Unknown fvModel " << modelType << nl << nl
<< "Valid fvModels are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
return autoPtr<fvModel>
(
cstrIter()(name, modelType, mesh, dict)
);
}
Foam::fvModel::~fvModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::wordList Foam::fvModel::addSupFields() const
{
return wordList::null();
}
bool Foam::fvModel::addsSupToField(const word& fieldName) const
{
return findIndex(addSupFields(), fieldName) != -1;
}
Foam::scalar Foam::fvModel::maxDeltaT() const
{
return vGreat;
}
void Foam::fvModel::addSup(fvMatrix<scalar>& eqn) const
{}
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_FIELD_SUP, fvModel)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP, fvModel)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP, fvModel)
void Foam::fvModel::preUpdateMesh()
{}
void Foam::fvModel::correct()
{}
bool Foam::fvModel::read(const dictionary& dict)
{
coeffs_ = dict.optionalSubDict(modelType_ + "Coeffs");
return true;
}
bool Foam::fvModel::write(const bool write) const
{
return true;
}
// ************************************************************************* //