diff --git a/applications/solvers/modules/compressibleMultiphaseVoF/compressibleMultiphaseVoF.C b/applications/solvers/modules/compressibleMultiphaseVoF/compressibleMultiphaseVoF.C
index 00cdaa7e09..a15dbeee35 100644
--- a/applications/solvers/modules/compressibleMultiphaseVoF/compressibleMultiphaseVoF.C
+++ b/applications/solvers/modules/compressibleMultiphaseVoF/compressibleMultiphaseVoF.C
@@ -77,13 +77,6 @@ Foam::solvers::compressibleMultiphaseVoF::compressibleMultiphaseVoF
false
),
- pMin
- (
- "pMin",
- dimPressure,
- mixture
- ),
-
K("K", 0.5*magSqr(U)),
momentumTransport_
diff --git a/applications/solvers/modules/compressibleMultiphaseVoF/compressibleMultiphaseVoF.H b/applications/solvers/modules/compressibleMultiphaseVoF/compressibleMultiphaseVoF.H
index 3e1a9a759d..c7c7afc815 100644
--- a/applications/solvers/modules/compressibleMultiphaseVoF/compressibleMultiphaseVoF.H
+++ b/applications/solvers/modules/compressibleMultiphaseVoF/compressibleMultiphaseVoF.H
@@ -94,9 +94,6 @@ protected:
//- Pressure reference
Foam::pressureReference pressureReference_;
- //- Minimum pressure
- dimensionedScalar pMin;
-
// Kinematic properties
diff --git a/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C b/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C
index ee305af28a..1fc468fc51 100644
--- a/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C
+++ b/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C
@@ -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();
diff --git a/applications/solvers/modules/compressibleVoF/compressibleVoF.C b/applications/solvers/modules/compressibleVoF/compressibleVoF.C
index 54e1c4c878..31e1f24ad6 100644
--- a/applications/solvers/modules/compressibleVoF/compressibleVoF.C
+++ b/applications/solvers/modules/compressibleVoF/compressibleVoF.C
@@ -79,13 +79,6 @@ Foam::solvers::compressibleVoF::compressibleVoF(fvMesh& mesh)
false
),
- pMin
- (
- "pMin",
- dimPressure,
- mixture_
- ),
-
alphaRhoPhi1
(
IOobject::groupName("alphaRhoPhi", alpha1.group()),
diff --git a/applications/solvers/modules/compressibleVoF/compressibleVoF.H b/applications/solvers/modules/compressibleVoF/compressibleVoF.H
index 81237d84b4..f364515505 100644
--- a/applications/solvers/modules/compressibleVoF/compressibleVoF.H
+++ b/applications/solvers/modules/compressibleVoF/compressibleVoF.H
@@ -101,9 +101,6 @@ protected:
//- Pressure reference
Foam::pressureReference pressureReference_;
- //- Minimum pressure
- dimensionedScalar pMin;
-
// Kinematic properties
diff --git a/applications/solvers/modules/compressibleVoF/pressureCorrector.C b/applications/solvers/modules/compressibleVoF/pressureCorrector.C
index 945f45f1c2..1c6e151434 100644
--- a/applications/solvers/modules/compressibleVoF/pressureCorrector.C
+++ b/applications/solvers/modules/compressibleVoF/pressureCorrector.C
@@ -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
diff --git a/src/fvConstraints/bound/boundConstraint.C b/src/fvConstraints/bound/boundConstraint.C
new file mode 100644
index 0000000000..f1a691cf3c
--- /dev/null
+++ b/src/fvConstraints/bound/boundConstraint.C
@@ -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 .
+
+\*---------------------------------------------------------------------------*/
+
+#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("field");
+ min_ = coeffs().lookup("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;
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/fvConstraints/bound/boundConstraint.H b/src/fvConstraints/bound/boundConstraint.H
new file mode 100644
index 0000000000..1a858d4fad
--- /dev/null
+++ b/src/fvConstraints/bound/boundConstraint.H
@@ -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 .
+
+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
+
+// ************************************************************************* //
diff --git a/src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.C b/src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.C
new file mode 100644
index 0000000000..87183fefbe
--- /dev/null
+++ b/src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.C
@@ -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 .
+
+\*---------------------------------------------------------------------------*/
+
+#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::
+ names[] =
+ {
+ "uniform",
+ "lookup"
+ };
+}
+
+const Foam::NamedEnum
+ 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::New("temperature", coeffs()).ptr()
+ );
+ break;
+ }
+ case temperatureMode::lookup:
+ {
+ TName_ = coeffs().lookupOrDefault("T", "T");
+ break;
+ }
+ }
+
+ phaseName_ = coeffs().lookupOrDefault("phase", word::null);
+
+ fraction_ =
+ coeffs().found("fraction")
+ ? Function1::New("fraction", coeffs())
+ : autoPtr>();
+}
+
+
+// * * * * * * * * * * * * * * * * 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
+ (
+ IOobject::groupName(physicalProperties::typeName, phaseName_)
+ );
+
+ return wordList(1, thermo.he().name());
+}
+
+
+bool Foam::fv::fixedTemperatureConstraint::constrain
+(
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ const labelUList cells = set_.cells();
+
+ const basicThermo& thermo =
+ mesh().lookupObject
+ (
+ 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(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;
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.H b/src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.H
new file mode 100644
index 0000000000..75c6bbae8e
--- /dev/null
+++ b/src/fvConstraints/fixedTemperature/fixedTemperatureConstraint.H
@@ -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 .
+
+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 modeNames_;
+
+
+private:
+
+ // Private Data
+
+ //- The set of cells the fvConstraint applies to
+ fvCellSet set_;
+
+ //- Operation mode
+ temperatureMode mode_;
+
+ //- Uniform temperature [K]
+ autoPtr> 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> 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& 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
+
+// ************************************************************************* //
diff --git a/src/fvConstraints/fixedValue/fixedValueConstraint.C b/src/fvConstraints/fixedValue/fixedValueConstraint.C
new file mode 100644
index 0000000000..646bc2efea
--- /dev/null
+++ b/src/fvConstraints/fixedValue/fixedValueConstraint.C
@@ -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 .
+
+\*---------------------------------------------------------------------------*/
+
+#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::New("fraction", coeffs())
+ : autoPtr>();
+}
+
+
+template
+bool Foam::fv::fixedValueConstraint::constrainType
+(
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ const scalar t = mesh().time().userTimeValue();
+
+ const List values
+ (
+ set_.nCells(),
+ fieldValues_[fieldName]->value(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;
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/fvConstraints/fixedValue/fixedValueConstraint.H b/src/fvConstraints/fixedValue/fixedValueConstraint.H
new file mode 100644
index 0000000000..d4e1f4a635
--- /dev/null
+++ b/src/fvConstraints/fixedValue/fixedValueConstraint.H
@@ -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 .
+
+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 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> fraction_;
+
+
+ // Private Member Functions
+
+ //- Non-virtual read
+ void readCoeffs();
+
+ //- Set value on a field
+ template
+ inline bool constrainType
+ (
+ fvMatrix& 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
+
+// ************************************************************************* //
diff --git a/tutorials/modules/compressibleMultiphaseVoF/damBreak4phaseLaminar/constant/phaseProperties b/tutorials/modules/compressibleMultiphaseVoF/damBreak4phaseLaminar/constant/phaseProperties
index 5099b5e264..fae27f9c0a 100644
--- a/tutorials/modules/compressibleMultiphaseVoF/damBreak4phaseLaminar/constant/phaseProperties
+++ b/tutorials/modules/compressibleMultiphaseVoF/damBreak4phaseLaminar/constant/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (water oil mercury air);
-pMin 10000;
-
sigmas
(
(air water) 0.07
diff --git a/tutorials/modules/compressibleVoF/ballValve/system/fvConstraints b/tutorials/modules/compressibleVoF/ballValve/system/fvConstraints
new file mode 100644
index 0000000000..7acfe0048f
--- /dev/null
+++ b/tutorials/modules/compressibleVoF/ballValve/system/fvConstraints
@@ -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;
+}
+
+// ************************************************************************* //
diff --git a/tutorials/modules/compressibleVoF/climbingRod/constant/phaseProperties b/tutorials/modules/compressibleVoF/climbingRod/constant/phaseProperties
index a5b25fc891..d039745bae 100644
--- a/tutorials/modules/compressibleVoF/climbingRod/constant/phaseProperties
+++ b/tutorials/modules/compressibleVoF/climbingRod/constant/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (liquid air);
-pMin 10000;
-
sigma 0.0309;
// ************************************************************************* //
diff --git a/tutorials/modules/compressibleVoF/cylinder/constant/phaseProperties b/tutorials/modules/compressibleVoF/cylinder/constant/phaseProperties
index a5b25fc891..d039745bae 100644
--- a/tutorials/modules/compressibleVoF/cylinder/constant/phaseProperties
+++ b/tutorials/modules/compressibleVoF/cylinder/constant/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (liquid air);
-pMin 10000;
-
sigma 0.0309;
// ************************************************************************* //
diff --git a/tutorials/modules/compressibleVoF/damBreak/constant/phaseProperties b/tutorials/modules/compressibleVoF/damBreak/constant/phaseProperties
index 9fbac45d1f..1249d39c10 100644
--- a/tutorials/modules/compressibleVoF/damBreak/constant/phaseProperties
+++ b/tutorials/modules/compressibleVoF/damBreak/constant/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (water air);
-pMin 10000;
-
sigma
{
type liquidProperties;
diff --git a/tutorials/modules/compressibleVoF/depthCharge2D/constant/phaseProperties b/tutorials/modules/compressibleVoF/depthCharge2D/constant/phaseProperties
index f109c1b045..46a697f5b2 100644
--- a/tutorials/modules/compressibleVoF/depthCharge2D/constant/phaseProperties
+++ b/tutorials/modules/compressibleVoF/depthCharge2D/constant/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (water air);
-pMin 10000;
-
sigma
{
type liquidProperties;
diff --git a/tutorials/modules/compressibleVoF/depthCharge3D/constant/phaseProperties b/tutorials/modules/compressibleVoF/depthCharge3D/constant/phaseProperties
index 257245b92f..6883065eff 100644
--- a/tutorials/modules/compressibleVoF/depthCharge3D/constant/phaseProperties
+++ b/tutorials/modules/compressibleVoF/depthCharge3D/constant/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (water air);
-pMin 10000;
-
sigma 0.07;
// ************************************************************************* //
diff --git a/tutorials/modules/compressibleVoF/plateFilm/constant/phaseProperties b/tutorials/modules/compressibleVoF/plateFilm/constant/phaseProperties
index d1d9770ced..b7fbb877fa 100644
--- a/tutorials/modules/compressibleVoF/plateFilm/constant/phaseProperties
+++ b/tutorials/modules/compressibleVoF/plateFilm/constant/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (liquid air);
-pMin 10000;
-
sigma 0.0309;
// ************************************************************************* //
diff --git a/tutorials/modules/compressibleVoF/sloshingTank2D/0/T.air b/tutorials/modules/compressibleVoF/sloshingTank2D/0/T.air
index ded1f502b3..03c52bb671 100644
--- a/tutorials/modules/compressibleVoF/sloshingTank2D/0/T.air
+++ b/tutorials/modules/compressibleVoF/sloshingTank2D/0/T.air
@@ -7,7 +7,7 @@
\*---------------------------------------------------------------------------*/
FoamFile
{
- format ascii;
+ format binary;
class volScalarField;
location "0";
object T.air;
diff --git a/tutorials/modules/compressibleVoF/sloshingTank2D/0/T.water b/tutorials/modules/compressibleVoF/sloshingTank2D/0/T.water
index 0a19521000..a9f129624e 100644
--- a/tutorials/modules/compressibleVoF/sloshingTank2D/0/T.water
+++ b/tutorials/modules/compressibleVoF/sloshingTank2D/0/T.water
@@ -7,7 +7,7 @@
\*---------------------------------------------------------------------------*/
FoamFile
{
- format ascii;
+ format binary;
class volScalarField;
location "0";
object T.water;
diff --git a/tutorials/modules/compressibleVoF/sloshingTank2D/system/fvConstraints b/tutorials/modules/compressibleVoF/sloshingTank2D/system/fvConstraints
new file mode 100644
index 0000000000..7acfe0048f
--- /dev/null
+++ b/tutorials/modules/compressibleVoF/sloshingTank2D/system/fvConstraints
@@ -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;
+}
+
+// ************************************************************************* //
diff --git a/tutorials/modules/multiRegion/CHT/VoFcoolingCylinder2D/constant/fluid/phaseProperties b/tutorials/modules/multiRegion/CHT/VoFcoolingCylinder2D/constant/fluid/phaseProperties
index f109c1b045..46a697f5b2 100644
--- a/tutorials/modules/multiRegion/CHT/VoFcoolingCylinder2D/constant/fluid/phaseProperties
+++ b/tutorials/modules/multiRegion/CHT/VoFcoolingCylinder2D/constant/fluid/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (water air);
-pMin 10000;
-
sigma
{
type liquidProperties;
diff --git a/tutorials/modules/multiRegion/film/VoFToFilm/constant/VoF/phaseProperties b/tutorials/modules/multiRegion/film/VoFToFilm/constant/VoF/phaseProperties
index d1d9770ced..b7fbb877fa 100644
--- a/tutorials/modules/multiRegion/film/VoFToFilm/constant/VoF/phaseProperties
+++ b/tutorials/modules/multiRegion/film/VoFToFilm/constant/VoF/phaseProperties
@@ -16,8 +16,6 @@ FoamFile
phases (liquid air);
-pMin 10000;
-
sigma 0.0309;
// ************************************************************************* //