fv::bound: New fvConstraint to bound a scalar field where it is below the specified minimum
Class
Foam::fv::bound
Description
Bound the specified scalar field where it is below the specified minimum.
Where the field is unbounded it is set to the maximum of the average of
the neighbouring cell values and the specified minimum.
Usage
Example usage:
\verbatim
limitp
{
type bound;
field p;
min 100;
}
\endverbatim
This commit is contained in:
@ -184,7 +184,7 @@ qZeta::qZeta
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
sqrt(bound(k_, kMin_)),
|
||||
sqrt(max(k_, kMin_)),
|
||||
k_.boundaryField().types()
|
||||
),
|
||||
|
||||
@ -198,7 +198,7 @@ qZeta::qZeta
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
bound(epsilon_, epsilonMin_)/(2.0*q_),
|
||||
max(epsilon_, epsilonMin_)/(2.0*q_),
|
||||
epsilon_.boundaryField().types()
|
||||
)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,17 +24,15 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "bound.H"
|
||||
#include "volFields.H"
|
||||
#include "fvcAverage.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::volScalarField&
|
||||
Foam::bound(volScalarField& vsf, const dimensionedScalar& lowerBound)
|
||||
bool Foam::bound(volScalarField& vsf, const dimensionedScalar& min)
|
||||
{
|
||||
const scalar minVsf = min(vsf).value();
|
||||
const scalar minVsf = Foam::min(vsf).value();
|
||||
|
||||
if (minVsf < lowerBound.value())
|
||||
if (minVsf < min.value())
|
||||
{
|
||||
Info<< "bounding " << vsf.name()
|
||||
<< ", min: " << minVsf
|
||||
@ -47,16 +45,20 @@ Foam::bound(volScalarField& vsf, const dimensionedScalar& lowerBound)
|
||||
max
|
||||
(
|
||||
vsf.primitiveField(),
|
||||
fvc::average(max(vsf, lowerBound))().primitiveField()
|
||||
* pos0(-vsf.primitiveField())
|
||||
fvc::average(max(vsf, min))().primitiveField()
|
||||
*pos0(-vsf.primitiveField())
|
||||
),
|
||||
lowerBound.value()
|
||||
min.value()
|
||||
);
|
||||
|
||||
vsf.boundaryFieldRef() = max(vsf.boundaryField(), lowerBound.value());
|
||||
}
|
||||
vsf.boundaryFieldRef() = max(vsf.boundaryField(), min.value());
|
||||
|
||||
return vsf;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,10 +25,12 @@ InNamespace
|
||||
Foam
|
||||
|
||||
Description
|
||||
Bound the given scalar field if it has gone unbounded.
|
||||
Bound the given scalar field where it is below the specified minimum.
|
||||
|
||||
Used extensively in RAS and LES turbulence models, but also of use
|
||||
within solvers.
|
||||
Where the field is unbounded it is set to the maximum of the average of
|
||||
the neighbouring cell values and the specified minimum.
|
||||
|
||||
Used extensively in RAS and LES turbulence models to bound k, epsilon etc.
|
||||
|
||||
SourceFiles
|
||||
bound.C
|
||||
@ -48,10 +50,8 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Bound the given scalar field if it has gone unbounded.
|
||||
// Return the bounded field.
|
||||
// Used extensively in RAS and LES turbulence models.
|
||||
volScalarField& bound(volScalarField&, const dimensionedScalar& lowerBound);
|
||||
//- Bound the given scalar field where it is below the specified min value
|
||||
bool bound(volScalarField&, const dimensionedScalar& min);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
fixedValueConstraint/fixedValueConstraint.C
|
||||
fixedTemperatureConstraint/fixedTemperatureConstraint.C
|
||||
fixedValue/fixedValueConstraint.C
|
||||
fixedTemperature/fixedTemperatureConstraint.C
|
||||
limitTemperature/limitTemperature.C
|
||||
limitPressure/limitPressure.C
|
||||
limitMag/limitMag.C
|
||||
bound/boundConstraint.C
|
||||
meanVelocityForce/meanVelocityForce.C
|
||||
meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C
|
||||
|
||||
|
||||
@ -1,241 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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 "fixedTemperatureConstraint.H"
|
||||
#include "fvMesh.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "basicThermo.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
defineTypeNameAndDebug(fixedTemperatureConstraint, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
fvConstraint,
|
||||
fixedTemperatureConstraint,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<fv::fixedTemperatureConstraint::temperatureMode, 2>::
|
||||
names[] =
|
||||
{
|
||||
"uniform",
|
||||
"lookup"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::fv::fixedTemperatureConstraint::temperatureMode, 2>
|
||||
Foam::fv::fixedTemperatureConstraint::modeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fv::fixedTemperatureConstraint::readCoeffs()
|
||||
{
|
||||
mode_ = modeNames_.read(coeffs().lookup("mode"));
|
||||
|
||||
switch (mode_)
|
||||
{
|
||||
case temperatureMode::uniform:
|
||||
{
|
||||
TValue_.reset
|
||||
(
|
||||
Function1<scalar>::New("temperature", coeffs()).ptr()
|
||||
);
|
||||
break;
|
||||
}
|
||||
case temperatureMode::lookup:
|
||||
{
|
||||
TName_ = coeffs().lookupOrDefault<word>("T", "T");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
phaseName_ = coeffs().lookupOrDefault<word>("phase", word::null);
|
||||
|
||||
fraction_ =
|
||||
coeffs().found("fraction")
|
||||
? Function1<scalar>::New("fraction", coeffs())
|
||||
: autoPtr<Function1<scalar>>();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const fvMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvConstraint(name, modelType, mesh, dict),
|
||||
set_(mesh, coeffs()),
|
||||
mode_(temperatureMode::uniform),
|
||||
TValue_(nullptr),
|
||||
TName_(word::null),
|
||||
phaseName_(word::null)
|
||||
{
|
||||
readCoeffs();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wordList Foam::fv::fixedTemperatureConstraint::constrainedFields() const
|
||||
{
|
||||
const basicThermo& thermo =
|
||||
mesh().lookupObject<basicThermo>
|
||||
(
|
||||
IOobject::groupName(physicalProperties::typeName, phaseName_)
|
||||
);
|
||||
|
||||
return wordList(1, thermo.he().name());
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fv::fixedTemperatureConstraint::constrain
|
||||
(
|
||||
fvMatrix<scalar>& eqn,
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
const labelUList cells = set_.cells();
|
||||
|
||||
const basicThermo& thermo =
|
||||
mesh().lookupObject<basicThermo>
|
||||
(
|
||||
IOobject::groupName(physicalProperties::typeName, phaseName_)
|
||||
);
|
||||
|
||||
const scalar t = mesh().time().userTimeValue();
|
||||
|
||||
switch (mode_)
|
||||
{
|
||||
case temperatureMode::uniform:
|
||||
{
|
||||
const scalarField Tuni(cells.size(), TValue_->value(t));
|
||||
const scalarField heuni(thermo.he(Tuni, cells));
|
||||
|
||||
if (fraction_.valid())
|
||||
{
|
||||
eqn.setValues
|
||||
(
|
||||
cells,
|
||||
heuni,
|
||||
scalarList(cells.size(), fraction_->value(t))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
eqn.setValues(cells, heuni);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case temperatureMode::lookup:
|
||||
{
|
||||
const volScalarField& T =
|
||||
mesh().lookupObject<volScalarField>(TName_);
|
||||
const scalarField Tlkp(T, cells);
|
||||
const scalarField helkp(thermo.he(Tlkp, cells));
|
||||
|
||||
if (fraction_.valid())
|
||||
{
|
||||
eqn.setValues
|
||||
(
|
||||
cells,
|
||||
helkp,
|
||||
scalarList(cells.size(), fraction_->value(t))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
eqn.setValues(cells, helkp);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return cells.size();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fv::fixedTemperatureConstraint::movePoints()
|
||||
{
|
||||
set_.movePoints();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::fixedTemperatureConstraint::topoChange
|
||||
(
|
||||
const polyTopoChangeMap& map
|
||||
)
|
||||
{
|
||||
set_.topoChange(map);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::fixedTemperatureConstraint::mapMesh(const polyMeshMap& map)
|
||||
{
|
||||
set_.mapMesh(map);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::fixedTemperatureConstraint::distribute
|
||||
(
|
||||
const polyDistributionMap& map
|
||||
)
|
||||
{
|
||||
set_.distribute(map);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fv::fixedTemperatureConstraint::read(const dictionary& dict)
|
||||
{
|
||||
if (fvConstraint::read(dict))
|
||||
{
|
||||
set_.read(coeffs());
|
||||
readCoeffs();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,195 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-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/>.
|
||||
|
||||
Class
|
||||
Foam::fv::fixedTemperatureConstraint
|
||||
|
||||
Description
|
||||
Fixed temperature equation constraint
|
||||
|
||||
Usage
|
||||
\verbatim
|
||||
fixedTemperature
|
||||
{
|
||||
type fixedTemperatureConstraint;
|
||||
|
||||
select all;
|
||||
|
||||
phase gas; // Optional phase name
|
||||
|
||||
// Uniform temperature constraint
|
||||
mode uniform;
|
||||
temperature constant 500; // Uniform temperature
|
||||
|
||||
// // Looked-up field temperature constraint
|
||||
// T T; // Temperature field name
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note:
|
||||
The 'uniform' option allows the use of a time-varying uniform
|
||||
temperature by means of the Function1 type.
|
||||
|
||||
SourceFiles
|
||||
fixedTemperatureConstraint.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fixedTemperatureConstraint_H
|
||||
#define fixedTemperatureConstraint_H
|
||||
|
||||
#include "fvConstraint.H"
|
||||
#include "fvCellSet.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fixedTemperatureConstraint Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fixedTemperatureConstraint
|
||||
:
|
||||
public fvConstraint
|
||||
{
|
||||
public:
|
||||
|
||||
//- Temperature mode
|
||||
enum class temperatureMode
|
||||
{
|
||||
uniform,
|
||||
lookup
|
||||
};
|
||||
|
||||
//- String representation of mode enums
|
||||
static const NamedEnum<temperatureMode, 2> modeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- The set of cells the fvConstraint applies to
|
||||
fvCellSet set_;
|
||||
|
||||
//- Operation mode
|
||||
temperatureMode mode_;
|
||||
|
||||
//- Uniform temperature [K]
|
||||
autoPtr<Function1<scalar>> TValue_;
|
||||
|
||||
//- Temperature field name
|
||||
word TName_;
|
||||
|
||||
//- Optional phase name
|
||||
word phaseName_;
|
||||
|
||||
//- Fraction of the constraint to apply. Facilitates ramping, or
|
||||
// pulsing, or deactivation after a time. Should take a value between
|
||||
// 0 and 1. Defaults to 1 (i.e., apply all of the constraint).
|
||||
autoPtr<Function1<scalar>> fraction_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Non-virtual read
|
||||
void readCoeffs();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fixedTemperatureConstraint");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fixedTemperatureConstraint
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const fvMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
fixedTemperatureConstraint(const fixedTemperatureConstraint&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fixedTemperatureConstraint()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the list of fields constrained by the fvConstraint
|
||||
virtual wordList constrainedFields() const;
|
||||
|
||||
//- Constrain energy equation to fix the temperature
|
||||
virtual bool constrain
|
||||
(
|
||||
fvMatrix<scalar>& eqn,
|
||||
const word& fieldName
|
||||
) const;
|
||||
|
||||
//- Update for mesh motion
|
||||
virtual bool movePoints();
|
||||
|
||||
//- Update topology using the given map
|
||||
virtual void topoChange(const polyTopoChangeMap&);
|
||||
|
||||
//- Update from another mesh using the given map
|
||||
virtual void mapMesh(const polyMeshMap&);
|
||||
|
||||
//- Redistribute or update using the given distribution map
|
||||
virtual void distribute(const polyDistributionMap&);
|
||||
|
||||
//- Read dictionary
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fixedTemperatureConstraint&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fv
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,183 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-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 "fixedValueConstraint.H"
|
||||
#include "fvMesh.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "fvcSurfaceIntegrate.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
defineTypeNameAndDebug(fixedValueConstraint, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
fvConstraint,
|
||||
fixedValueConstraint,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fv::fixedValueConstraint::readCoeffs()
|
||||
{
|
||||
fieldValues_.clear();
|
||||
forAllConstIter(dictionary, coeffs().subDict("fieldValues"), iter)
|
||||
{
|
||||
fieldValues_.set
|
||||
(
|
||||
iter().keyword(),
|
||||
new unknownTypeFunction1
|
||||
(
|
||||
iter().keyword(),
|
||||
coeffs().subDict("fieldValues")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
fraction_ =
|
||||
coeffs().found("fraction")
|
||||
? Function1<scalar>::New("fraction", coeffs())
|
||||
: autoPtr<Function1<scalar>>();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::fv::fixedValueConstraint::constrainType
|
||||
(
|
||||
fvMatrix<Type>& eqn,
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
const scalar t = mesh().time().userTimeValue();
|
||||
|
||||
const List<Type> values
|
||||
(
|
||||
set_.nCells(),
|
||||
fieldValues_[fieldName]->value<Type>(t)
|
||||
);
|
||||
|
||||
if (fraction_.valid())
|
||||
{
|
||||
eqn.setValues
|
||||
(
|
||||
set_.cells(),
|
||||
values,
|
||||
scalarList(set_.nCells(), fraction_->value(t))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
eqn.setValues(set_.cells(), values);
|
||||
}
|
||||
|
||||
return set_.nCells();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fv::fixedValueConstraint::fixedValueConstraint
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const fvMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvConstraint(name, modelType, mesh, dict),
|
||||
set_(mesh, coeffs())
|
||||
{
|
||||
readCoeffs();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wordList Foam::fv::fixedValueConstraint::constrainedFields() const
|
||||
{
|
||||
return fieldValues_.toc();
|
||||
}
|
||||
|
||||
|
||||
FOR_ALL_FIELD_TYPES
|
||||
(
|
||||
IMPLEMENT_FV_CONSTRAINT_CONSTRAIN,
|
||||
fv::fixedValueConstraint
|
||||
);
|
||||
|
||||
|
||||
bool Foam::fv::fixedValueConstraint::movePoints()
|
||||
{
|
||||
set_.movePoints();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::fixedValueConstraint::topoChange(const polyTopoChangeMap& map)
|
||||
{
|
||||
set_.topoChange(map);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::fixedValueConstraint::mapMesh(const polyMeshMap& map)
|
||||
{
|
||||
set_.mapMesh(map);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::fixedValueConstraint::distribute
|
||||
(
|
||||
const polyDistributionMap& map
|
||||
)
|
||||
{
|
||||
set_.distribute(map);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fv::fixedValueConstraint::read(const dictionary& dict)
|
||||
{
|
||||
if (fvConstraint::read(dict))
|
||||
{
|
||||
set_.read(coeffs());
|
||||
readCoeffs();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,156 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-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/>.
|
||||
|
||||
Class
|
||||
Foam::fv::fixedValueConstraint
|
||||
|
||||
Description
|
||||
Constrain the field values within a specified region.
|
||||
|
||||
Usage
|
||||
For example to set the turbulence properties within a porous region:
|
||||
\verbatim
|
||||
porosityTurbulence
|
||||
{
|
||||
type fixedValueConstraint;
|
||||
|
||||
select cellZone;
|
||||
cellZone porosity;
|
||||
|
||||
fieldValues
|
||||
{
|
||||
k 1;
|
||||
epsilon 150;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
fixedValueConstraint.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fixedValueConstraint_H
|
||||
#define fixedValueConstraint_H
|
||||
|
||||
#include "fvConstraint.H"
|
||||
#include "fvCellSet.H"
|
||||
#include "unknownTypeFunction1.H"
|
||||
#include "HashPtrTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fixedValueConstraint Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fixedValueConstraint
|
||||
:
|
||||
public fvConstraint
|
||||
{
|
||||
// Private Member Data
|
||||
|
||||
//- The set of cells the fvConstraint applies to
|
||||
fvCellSet set_;
|
||||
|
||||
//- Field values
|
||||
HashPtrTable<unknownTypeFunction1> fieldValues_;
|
||||
|
||||
//- Fraction of the constraint to apply. Facilitates ramping, or
|
||||
// pulsing, or deactivation after a time. Should take a value between
|
||||
// 0 and 1. Defaults to 1 (i.e., apply all of the constraint).
|
||||
autoPtr<Function1<scalar>> fraction_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Non-virtual read
|
||||
void readCoeffs();
|
||||
|
||||
//- Set value on a field
|
||||
template<class Type>
|
||||
inline bool constrainType
|
||||
(
|
||||
fvMatrix<Type>& eqn,
|
||||
const word& fieldName
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fixedValueConstraint");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fixedValueConstraint
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const fvMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the list of fields constrained by the fvConstraint
|
||||
virtual wordList constrainedFields() const;
|
||||
|
||||
//- Add a constraint to an equation
|
||||
FOR_ALL_FIELD_TYPES(DEFINE_FV_CONSTRAINT_CONSTRAIN);
|
||||
|
||||
//- Update for mesh motion
|
||||
virtual bool movePoints();
|
||||
|
||||
//- Update topology using the given map
|
||||
virtual void topoChange(const polyTopoChangeMap&);
|
||||
|
||||
//- Update from another mesh using the given map
|
||||
virtual void mapMesh(const polyMeshMap&);
|
||||
|
||||
//- Redistribute or update using the given distribution map
|
||||
virtual void distribute(const polyDistributionMap&);
|
||||
|
||||
//- Read source dictionary
|
||||
virtual bool read(const dictionary& dict);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fv
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -237,7 +237,6 @@ void Foam::fv::limitPressure::distribute(const polyDistributionMap&)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
bool Foam::fv::limitPressure::read(const dictionary& dict)
|
||||
{
|
||||
if (fvConstraint::read(dict))
|
||||
|
||||
Reference in New Issue
Block a user