compressibleVoF,compressibleMultiphaseVoF: Apply fvConstraints to the pressure
Replaces the hard-coded pMin.
This commit is contained in:
@ -77,13 +77,6 @@ Foam::solvers::compressibleMultiphaseVoF::compressibleMultiphaseVoF
|
||||
false
|
||||
),
|
||||
|
||||
pMin
|
||||
(
|
||||
"pMin",
|
||||
dimPressure,
|
||||
mixture
|
||||
),
|
||||
|
||||
K("K", 0.5*magSqr(U)),
|
||||
|
||||
momentumTransport_
|
||||
|
||||
@ -94,9 +94,6 @@ protected:
|
||||
//- Pressure reference
|
||||
Foam::pressureReference pressureReference_;
|
||||
|
||||
//- Minimum pressure
|
||||
dimensionedScalar pMin;
|
||||
|
||||
|
||||
// Kinematic properties
|
||||
|
||||
|
||||
@ -141,7 +141,8 @@ void Foam::solvers::compressibleMultiphaseVoF::pressureCorrector()
|
||||
|
||||
phi = phiHbyA + p_rghEqnIncomp.flux();
|
||||
|
||||
p = max(p_rgh + mixture.rho()*buoyancy.gh, pMin);
|
||||
p = p_rgh + rho*buoyancy.gh;
|
||||
fvConstraints().constrain(p);
|
||||
p_rgh = p - rho*buoyancy.gh;
|
||||
p_rgh.correctBoundaryConditions();
|
||||
|
||||
|
||||
@ -79,13 +79,6 @@ Foam::solvers::compressibleVoF::compressibleVoF(fvMesh& mesh)
|
||||
false
|
||||
),
|
||||
|
||||
pMin
|
||||
(
|
||||
"pMin",
|
||||
dimPressure,
|
||||
mixture_
|
||||
),
|
||||
|
||||
alphaRhoPhi1
|
||||
(
|
||||
IOobject::groupName("alphaRhoPhi", alpha1.group()),
|
||||
|
||||
@ -101,9 +101,6 @@ protected:
|
||||
//- Pressure reference
|
||||
Foam::pressureReference pressureReference_;
|
||||
|
||||
//- Minimum pressure
|
||||
dimensionedScalar pMin;
|
||||
|
||||
|
||||
// Kinematic properties
|
||||
|
||||
|
||||
@ -200,8 +200,9 @@ void Foam::solvers::compressibleVoF::pressureCorrector()
|
||||
|
||||
phi = phiHbyA + p_rghEqnIncomp.flux();
|
||||
|
||||
p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*buoyancy.gh, pMin);
|
||||
p_rgh = p - (alpha1*rho1 + alpha2*rho2)*buoyancy.gh;
|
||||
p = p_rgh + rho*buoyancy.gh;
|
||||
fvConstraints().constrain(p);
|
||||
p_rgh = p - rho*buoyancy.gh;
|
||||
p_rgh.correctBoundaryConditions();
|
||||
|
||||
U = HbyA
|
||||
|
||||
121
src/fvConstraints/bound/boundConstraint.C
Normal file
121
src/fvConstraints/bound/boundConstraint.C
Normal file
@ -0,0 +1,121 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 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 "boundConstraint.H"
|
||||
#include "volFields.H"
|
||||
#include "bound.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
defineTypeNameAndDebug(bound, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
fvConstraint,
|
||||
bound,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fv::bound::readCoeffs()
|
||||
{
|
||||
fieldName_ = coeffs().lookup<word>("field");
|
||||
min_ = coeffs().lookup<scalar>("min");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fv::bound::bound
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const fvMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvConstraint(name, modelType, mesh, dict),
|
||||
fieldName_(word::null),
|
||||
min_(0)
|
||||
{
|
||||
readCoeffs();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wordList Foam::fv::bound::constrainedFields() const
|
||||
{
|
||||
return wordList(1, fieldName_);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fv::bound::constrain(volScalarField& f) const
|
||||
{
|
||||
return Foam::bound(f, dimensionedScalar(f.dimensions(), min_));
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fv::bound::movePoints()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fv::bound::topoChange(const polyTopoChangeMap&)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::fv::bound::mapMesh(const polyMeshMap&)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::fv::bound::distribute(const polyDistributionMap&)
|
||||
{}
|
||||
|
||||
|
||||
bool Foam::fv::bound::read(const dictionary& dict)
|
||||
{
|
||||
if (fvConstraint::read(dict))
|
||||
{
|
||||
readCoeffs();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
153
src/fvConstraints/bound/boundConstraint.H
Normal file
153
src/fvConstraints/bound/boundConstraint.H
Normal file
@ -0,0 +1,153 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 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::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
|
||||
|
||||
SourceFiles
|
||||
bound.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef boundConstraint_H
|
||||
#define boundConstraint_H
|
||||
|
||||
#include "fvConstraint.H"
|
||||
#include "dimensionedScalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class bound Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class bound
|
||||
:
|
||||
public fvConstraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Field name
|
||||
word fieldName_;
|
||||
|
||||
//- Minimum value
|
||||
scalar min_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Non-virtual read
|
||||
void readCoeffs();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("bound");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
bound
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const fvMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
bound(const bound&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~bound()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the list of fields constrained by the fvConstraint
|
||||
virtual wordList constrainedFields() const;
|
||||
|
||||
//- Constrain the pressure field
|
||||
virtual bool constrain(volScalarField& p) 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 bound&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fv
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
241
src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.C
Normal file
241
src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.C
Normal file
@ -0,0 +1,241 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
195
src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.H
Normal file
195
src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.H
Normal file
@ -0,0 +1,195 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
// ************************************************************************* //
|
||||
183
src/fvConstraints/fixedValue/fixedValueConstraint.C
Normal file
183
src/fvConstraints/fixedValue/fixedValueConstraint.C
Normal file
@ -0,0 +1,183 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
156
src/fvConstraints/fixedValue/fixedValueConstraint.H
Normal file
156
src/fvConstraints/fixedValue/fixedValueConstraint.H
Normal file
@ -0,0 +1,156 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (water oil mercury air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigmas
|
||||
(
|
||||
(air water) 0.07
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object fvConstraints;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
boundp
|
||||
{
|
||||
type bound;
|
||||
|
||||
field p;
|
||||
min 100;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (liquid air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigma 0.0309;
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (liquid air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigma 0.0309;
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (water air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigma
|
||||
{
|
||||
type liquidProperties;
|
||||
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (water air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigma
|
||||
{
|
||||
type liquidProperties;
|
||||
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (water air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigma 0.07;
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (liquid air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigma 0.0309;
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
format ascii;
|
||||
format binary;
|
||||
class volScalarField;
|
||||
location "0";
|
||||
object T.air;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
format ascii;
|
||||
format binary;
|
||||
class volScalarField;
|
||||
location "0";
|
||||
object T.water;
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object fvConstraints;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
boundp
|
||||
{
|
||||
type bound;
|
||||
|
||||
field p;
|
||||
min 100;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (water air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigma
|
||||
{
|
||||
type liquidProperties;
|
||||
|
||||
@ -16,8 +16,6 @@ FoamFile
|
||||
|
||||
phases (liquid air);
|
||||
|
||||
pMin 10000;
|
||||
|
||||
sigma 0.0309;
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user