fvOption: Rationalize corrections

This commit is contained in:
Henry
2015-06-01 11:18:45 +01:00
parent bbbad9cfc0
commit 257d71ebf1
10 changed files with 139 additions and 156 deletions

View File

@ -55,7 +55,11 @@ $(generalConstraints)/explicitSetValue/explicitSetValue.C
derivedConstraints=constraints/derived
$(derivedConstraints)/fixedTemperatureConstraint/fixedTemperatureConstraint.C
$(derivedConstraints)/temperatureLimitsConstraint/temperatureLimitsConstraint.C
/* Corrections */
corrections/limitTemperature/limitTemperature.C
LIB = $(FOAM_LIBBIN)/libfvOptions

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "temperatureLimitsConstraint.H"
#include "limitTemperature.H"
#include "fvMesh.H"
#include "basicThermo.H"
#include "addToRunTimeSelectionTable.H"
@ -34,11 +34,11 @@ namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(temperatureLimitsConstraint, 0);
defineTypeNameAndDebug(limitTemperature, 0);
addToRunTimeSelectionTable
(
option,
temperatureLimitsConstraint,
limitTemperature,
dictionary
);
}
@ -46,7 +46,7 @@ namespace fv
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::temperatureLimitsConstraint::temperatureLimitsConstraint
Foam::fv::limitTemperature::limitTemperature
(
const word& name,
const word& modelType,
@ -65,13 +65,13 @@ Foam::fv::temperatureLimitsConstraint::temperatureLimitsConstraint
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fv::temperatureLimitsConstraint::alwaysApply() const
bool Foam::fv::limitTemperature::alwaysApply() const
{
return true;
}
void Foam::fv::temperatureLimitsConstraint::correct(volScalarField& he)
void Foam::fv::limitTemperature::correct(volScalarField& he)
{
const basicThermo& thermo =
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
@ -125,7 +125,7 @@ void Foam::fv::temperatureLimitsConstraint::correct(volScalarField& he)
}
bool Foam::fv::temperatureLimitsConstraint::read(const dictionary& dict)
bool Foam::fv::limitTemperature::read(const dictionary& dict)
{
if (cellSetOption::read(dict))
{

View File

@ -22,27 +22,27 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fv::temperatureLimitsConstraint
Foam::fv::limitTemperature
Description
Constraint for temperature to apply limits between minimum and maximum
Correction for temperature to apply limits between minimum and maximum
values
Constraint described by:
temperatureLimitsConstraintCoeffs
limitTemperatureCoeffs
{
minimum 200;
maximum 500;
}
SourceFiles
temperatureLimitsConstraint.C
limitTemperature.C
\*---------------------------------------------------------------------------*/
#ifndef temperatureLimitsConstraint_H
#define temperatureLimitsConstraint_H
#ifndef limitTemperature_H
#define limitTemperature_H
#include "cellSetOption.H"
@ -54,10 +54,10 @@ namespace fv
{
/*---------------------------------------------------------------------------*\
Class temperatureLimitsConstraint Declaration
Class limitTemperature Declaration
\*---------------------------------------------------------------------------*/
class temperatureLimitsConstraint
class limitTemperature
:
public cellSetOption
{
@ -78,22 +78,22 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
temperatureLimitsConstraint(const temperatureLimitsConstraint&);
limitTemperature(const limitTemperature&);
//- Disallow default bitwise assignment
void operator=(const temperatureLimitsConstraint&);
void operator=(const limitTemperature&);
public:
//- Runtime type information
TypeName("temperatureLimitsConstraint");
TypeName("limitTemperature");
// Constructors
//- Construct from components
temperatureLimitsConstraint
limitTemperature
(
const word& name,
const word& modelType,
@ -103,7 +103,7 @@ public:
//- Destructor
virtual ~temperatureLimitsConstraint()
virtual ~limitTemperature()
{}

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "fvOption.H"
#include "fvMatrices.H"
#include "volFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -65,8 +65,7 @@ Foam::fv::option::option
fieldNames_(),
applied_()
{
Info<< incrIndent << indent << "Source: " << name_ << endl;
Info<< decrIndent;
Info<< incrIndent << indent << "Source: " << name_ << endl << decrIndent;
}
@ -139,26 +138,6 @@ void Foam::fv::option::checkApplied() const
}
void Foam::fv::option::correct(volScalarField& fld)
{}
void Foam::fv::option::correct(volVectorField& fld)
{}
void Foam::fv::option::correct(volSphericalTensorField& fld)
{}
void Foam::fv::option::correct(volSymmTensorField& fld)
{}
void Foam::fv::option::correct(volTensorField& fld)
{}
void Foam::fv::option::addSup
(
fvMatrix<scalar>& eqn,
@ -332,4 +311,24 @@ void Foam::fv::option::constrain(fvMatrix<tensor>& eqn, const label fieldI)
{}
void Foam::fv::option::correct(volScalarField& field)
{}
void Foam::fv::option::correct(volVectorField& field)
{}
void Foam::fv::option::correct(volSphericalTensorField& field)
{}
void Foam::fv::option::correct(volSymmTensorField& field)
{}
void Foam::fv::option::correct(volTensorField& field)
{}
// ************************************************************************* //

View File

@ -230,55 +230,32 @@ public:
// Evaluation
// Correct
// Explicit and implicit sources
//- Scalar
virtual void correct(volScalarField& fld);
//- Vector
virtual void correct(volVectorField& fld);
//- Spherical tensor
virtual void correct(volSphericalTensorField& fld);
//- Symmetric tensor
virtual void correct(volSymmTensorField& fld);
//- Tensor
virtual void correct(volTensorField& fld);
// Add explicit and implicit contributions
//- Scalar
virtual void addSup
(
fvMatrix<scalar>& eqn,
const label fieldI
);
//- Vector
virtual void addSup
(
fvMatrix<vector>& eqn,
const label fieldI
);
//- Spherical tensor
virtual void addSup
(
fvMatrix<symmTensor>& eqn,
const label fieldI
);
//- Symmetric tensor
virtual void addSup
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
);
//- Tensor
virtual void addSup
(
fvMatrix<tensor>& eqn,
@ -286,9 +263,8 @@ public:
);
// Add explicit and implicit contributions to compressible equations
// Explicit and implicit sources for compressible equations
//- Scalar
virtual void addSup
(
const volScalarField& rho,
@ -296,7 +272,6 @@ public:
const label fieldI
);
//- Vector
virtual void addSup
(
const volScalarField& rho,
@ -304,7 +279,6 @@ public:
const label fieldI
);
//- Spherical tensor
virtual void addSup
(
const volScalarField& rho,
@ -312,7 +286,6 @@ public:
const label fieldI
);
//- Symmetric tensor
virtual void addSup
(
const volScalarField& rho,
@ -320,7 +293,6 @@ public:
const label fieldI
);
//- Tensor
virtual void addSup
(
const volScalarField& rho,
@ -329,9 +301,8 @@ public:
);
// Add explicit and implicit contributions to phase equations
// Explicit and implicit sources for phase equations
//- Scalar
virtual void addSup
(
const volScalarField& alpha,
@ -340,7 +311,6 @@ public:
const label fieldI
);
//- Vector
virtual void addSup
(
const volScalarField& alpha,
@ -349,7 +319,6 @@ public:
const label fieldI
);
//- Spherical tensor
virtual void addSup
(
const volScalarField& alpha,
@ -358,7 +327,6 @@ public:
const label fieldI
);
//- Symmetric tensor
virtual void addSup
(
const volScalarField& alpha,
@ -367,7 +335,6 @@ public:
const label fieldI
);
//- Tensor
virtual void addSup
(
const volScalarField& alpha,
@ -379,35 +346,30 @@ public:
// Constraints
//- Scalar
virtual void constrain
(
fvMatrix<scalar>& eqn,
const label fieldI
);
//- Vector
virtual void constrain
(
fvMatrix<vector>& eqn,
const label fieldI
);
//- Spherical tensor
virtual void constrain
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
);
//- Symmetric tensor
virtual void constrain
(
fvMatrix<symmTensor>& eqn,
const label fieldI
);
//- Tensor
virtual void constrain
(
fvMatrix<tensor>& eqn,
@ -415,6 +377,15 @@ public:
);
// Correction
virtual void correct(volScalarField& field);
virtual void correct(volVectorField& field);
virtual void correct(volSphericalTensorField& field);
virtual void correct(volSymmTensorField& field);
virtual void correct(volTensorField& field);
// IO
//- Write the source header information

View File

@ -32,13 +32,13 @@ SourceFile
\*---------------------------------------------------------------------------*/
#ifndef optionList_H
#define optionList_H
#ifndef fvOptionList_H
#define fvOptionList_H
#include "fvOption.H"
#include "PtrList.H"
#include "GeometricField.H"
#include "fvPatchField.H"
#include "fvOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,10 +119,6 @@ public:
//- Reset the source list
void reset(const dictionary& dict);
//- Correct
template<class Type>
void correct(GeometricField<Type, fvPatchField, volMesh>& fld);
// Sources
@ -130,14 +126,14 @@ public:
template<class Type>
tmp<fvMatrix<Type> > operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld
GeometricField<Type, fvPatchField, volMesh>& field
);
//- Return source for equation with specified name
template<class Type>
tmp<fvMatrix<Type> > operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld,
GeometricField<Type, fvPatchField, volMesh>& field,
const word& fieldName
);
@ -146,7 +142,7 @@ public:
tmp<fvMatrix<Type> > operator()
(
const volScalarField& rho,
GeometricField<Type, fvPatchField, volMesh>& fld
GeometricField<Type, fvPatchField, volMesh>& field
);
//- Return source for equation with specified name
@ -154,7 +150,7 @@ public:
tmp<fvMatrix<Type> > operator()
(
const volScalarField& rho,
GeometricField<Type, fvPatchField, volMesh>& fld,
GeometricField<Type, fvPatchField, volMesh>& field,
const word& fieldName
);
@ -164,7 +160,7 @@ public:
(
const volScalarField& alpha,
const volScalarField& rho,
GeometricField<Type, fvPatchField, volMesh>& fld
GeometricField<Type, fvPatchField, volMesh>& field
);
//- Return source for equation with specified name
@ -173,7 +169,7 @@ public:
(
const volScalarField& alpha,
const volScalarField& rho,
GeometricField<Type, fvPatchField, volMesh>& fld,
GeometricField<Type, fvPatchField, volMesh>& field,
const word& fieldName
);
@ -185,6 +181,13 @@ public:
void constrain(fvMatrix<Type>& eqn);
// Correction
//- Apply correction to field
template<class Type>
void correct(GeometricField<Type, fvPatchField, volMesh>& field);
// IO
//- Read dictionary

View File

@ -26,60 +26,27 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::fv::optionList::correct
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld
GeometricField<Type, fvPatchField, volMesh>& field
)
{
const word& fieldName = fld.name();
forAll(*this, i)
{
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
if (fieldI != -1)
{
source.setApplied(fieldI);
if (source.isActive())
{
if (debug)
{
Info<< "Correcting source " << source.name()
<< " for field " << fieldName << endl;
}
source.correct(fld);
}
}
}
return this->operator()(field, field.name());
}
template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld
)
{
return this->operator()(fld, fld.name());
}
template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld,
GeometricField<Type, fvPatchField, volMesh>& field,
const word& fieldName
)
{
checkApplied();
const dimensionSet ds = fld.dimensions()/dimTime*dimVolume;
const dimensionSet ds = field.dimensions()/dimTime*dimVolume;
tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(fld, ds));
tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx();
forAll(*this, i)
@ -113,10 +80,10 @@ template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
const volScalarField& rho,
GeometricField<Type, fvPatchField, volMesh>& fld
GeometricField<Type, fvPatchField, volMesh>& field
)
{
return this->operator()(rho, fld, fld.name());
return this->operator()(rho, field, field.name());
}
@ -124,15 +91,18 @@ template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
const volScalarField& rho,
GeometricField<Type, fvPatchField, volMesh>& fld,
GeometricField<Type, fvPatchField, volMesh>& field,
const word& fieldName
)
{
checkApplied();
const dimensionSet ds = rho.dimensions()*fld.dimensions()/dimTime*dimVolume;
const dimensionSet ds
(
rho.dimensions()*field.dimensions()/dimTime*dimVolume
);
tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(fld, ds));
tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx();
forAll(*this, i)
@ -167,10 +137,10 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
const volScalarField& alpha,
const volScalarField& rho,
GeometricField<Type, fvPatchField, volMesh>& fld
GeometricField<Type, fvPatchField, volMesh>& field
)
{
return this->operator()(alpha, rho, fld, fld.name());
return this->operator()(alpha, rho, field, field.name());
}
@ -179,16 +149,19 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
const volScalarField& alpha,
const volScalarField& rho,
GeometricField<Type, fvPatchField, volMesh>& fld,
GeometricField<Type, fvPatchField, volMesh>& field,
const word& fieldName
)
{
checkApplied();
const dimensionSet ds =
alpha.dimensions()*rho.dimensions()*fld.dimensions()/dimTime*dimVolume;
const dimensionSet ds
(
alpha.dimensions()*rho.dimensions()*field.dimensions()
/dimTime*dimVolume
);
tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(fld, ds));
tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx();
forAll(*this, i)
@ -248,4 +221,37 @@ void Foam::fv::optionList::constrain(fvMatrix<Type>& eqn)
}
template<class Type>
void Foam::fv::optionList::correct
(
GeometricField<Type, fvPatchField, volMesh>& field
)
{
const word& fieldName = field.name();
forAll(*this, i)
{
option& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
if (fieldI != -1)
{
source.setApplied(fieldI);
if (source.isActive())
{
if (debug)
{
Info<< "Correcting source " << source.name()
<< " for field " << fieldName << endl;
}
source.correct(field);
}
}
}
}
// ************************************************************************* //

View File

@ -169,7 +169,7 @@ void Foam::fv::rotorDiskSource::writeField
if (mesh_.time().outputTime() || writeNow)
{
tmp<fieldType> tfld
tmp<fieldType> tfield
(
new fieldType
(
@ -186,7 +186,7 @@ void Foam::fv::rotorDiskSource::writeField
)
);
Field<Type>& fld = tfld().internalField();
Field<Type>& field = tfield().internalField();
if (cells_.size() != values.size())
{
@ -197,10 +197,10 @@ void Foam::fv::rotorDiskSource::writeField
forAll(cells_, i)
{
const label cellI = cells_[i];
fld[cellI] = values[i];
field[cellI] = values[i];
}
tfld().write();
tfield().write();
}
}

View File

@ -149,7 +149,7 @@ Foam::fv::option& Foam::fv::CodedSource<Type>::redirectFvOption() const
template<class Type>
void Foam::fv::CodedSource<Type>::correct
(
GeometricField<Type, fvPatchField, volMesh>& fld
GeometricField<Type, fvPatchField, volMesh>& field
)
{
if (debug)
@ -159,7 +159,7 @@ void Foam::fv::CodedSource<Type>::correct
}
updateLibrary(redirectType_);
redirectFvOption().correct(fld);
redirectFvOption().correct(field);
}

View File

@ -31,7 +31,7 @@ Description
codeCorrect
(
GeometricField<Type, fvPatchField, volMesh>& fld
GeometricField<Type, fvPatchField, volMesh>& field
)
codeAddSup
@ -47,7 +47,7 @@ Description
)
where :
fld is the field in fieldNames
field is the field in fieldNames
eqn is the fvMatrix
\heading Source usage