diff --git a/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C b/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C
index 1fc468fc51..8454d54bb9 100644
--- a/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C
+++ b/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C
@@ -126,7 +126,13 @@ void Foam::solvers::compressibleMultiphaseVoF::pressureCorrector()
}
}
- solve(p_rghEqnComp + p_rghEqnIncomp);
+ {
+ fvScalarMatrix p_rghEqn(p_rghEqnComp + p_rghEqnIncomp);
+
+ fvConstraints().constrain(p_rghEqn);
+
+ p_rghEqn.solve();
+ }
if (pimple.finalNonOrthogonalIter())
{
diff --git a/applications/solvers/modules/compressibleVoF/pressureCorrector.C b/applications/solvers/modules/compressibleVoF/pressureCorrector.C
index 1c6e151434..7afcc224f2 100644
--- a/applications/solvers/modules/compressibleVoF/pressureCorrector.C
+++ b/applications/solvers/modules/compressibleVoF/pressureCorrector.C
@@ -185,10 +185,16 @@ void Foam::solvers::compressibleVoF::pressureCorrector()
== Sp_rgh
);
- solve
- (
- p_rghEqnComp1() + p_rghEqnComp2() + p_rghEqnIncomp
- );
+ {
+ fvScalarMatrix p_rghEqn
+ (
+ p_rghEqnComp1() + p_rghEqnComp2() + p_rghEqnIncomp
+ );
+
+ fvConstraints().constrain(p_rghEqn);
+
+ p_rghEqn.solve();
+ }
if (pimple.finalNonOrthogonalIter())
{
diff --git a/applications/solvers/modules/isothermalFluid/correctBuoyantPressure.C b/applications/solvers/modules/isothermalFluid/correctBuoyantPressure.C
index 3fcbc54234..536cadb784 100644
--- a/applications/solvers/modules/isothermalFluid/correctBuoyantPressure.C
+++ b/applications/solvers/modules/isothermalFluid/correctBuoyantPressure.C
@@ -159,6 +159,8 @@ void Foam::solvers::isothermalFluid::correctBuoyantPressure()
pressureReference.refValue()
);
+ fvConstraints().constrain(p_rghEqn);
+
p_rghEqn.solve();
}
}
@@ -195,6 +197,8 @@ void Foam::solvers::isothermalFluid::correctBuoyantPressure()
pressureReference.refValue()
);
+ fvConstraints().constrain(p_rghEqn);
+
p_rghEqn.solve();
}
}
diff --git a/applications/solvers/modules/isothermalFluid/correctPressure.C b/applications/solvers/modules/isothermalFluid/correctPressure.C
index 3d7ba71d1d..558ea4823e 100644
--- a/applications/solvers/modules/isothermalFluid/correctPressure.C
+++ b/applications/solvers/modules/isothermalFluid/correctPressure.C
@@ -146,6 +146,8 @@ void Foam::solvers::isothermalFluid::correctPressure()
pressureReference.refValue()
);
+ fvConstraints().constrain(pEqn);
+
pEqn.solve();
if (pimple.finalNonOrthogonalIter())
@@ -190,6 +192,8 @@ void Foam::solvers::isothermalFluid::correctPressure()
pressureReference.refValue()
);
+ fvConstraints().constrain(pEqn);
+
pEqn.solve();
if (pimple.finalNonOrthogonalIter())
diff --git a/applications/solvers/modules/multiphaseEuler/multiphaseEuler/cellPressureCorrector.C b/applications/solvers/modules/multiphaseEuler/multiphaseEuler/cellPressureCorrector.C
index 5f6a11137d..72e78dd61c 100644
--- a/applications/solvers/modules/multiphaseEuler/multiphaseEuler/cellPressureCorrector.C
+++ b/applications/solvers/modules/multiphaseEuler/multiphaseEuler/cellPressureCorrector.C
@@ -330,6 +330,8 @@ void Foam::solvers::multiphaseEuler::cellPressureCorrector()
);
}
+ fvConstraints().constrain(pEqn);
+
pEqn.solve();
}
diff --git a/applications/solvers/modules/multiphaseEuler/multiphaseEuler/facePressureCorrector.C b/applications/solvers/modules/multiphaseEuler/multiphaseEuler/facePressureCorrector.C
index e70bb9c816..86f25a8931 100644
--- a/applications/solvers/modules/multiphaseEuler/multiphaseEuler/facePressureCorrector.C
+++ b/applications/solvers/modules/multiphaseEuler/multiphaseEuler/facePressureCorrector.C
@@ -308,6 +308,8 @@ void Foam::solvers::multiphaseEuler::facePressureCorrector()
);
}
+ fvConstraints().constrain(pEqn);
+
pEqn.solve();
}
diff --git a/src/fvConstraints/Make/files b/src/fvConstraints/Make/files
index 7ba332a868..c1f91a76fc 100644
--- a/src/fvConstraints/Make/files
+++ b/src/fvConstraints/Make/files
@@ -6,5 +6,7 @@ limitMag/limitMag.C
bound/boundConstraint.C
meanVelocityForce/meanVelocityForce.C
meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C
+zeroDimensionalFixedPressure/zeroDimensionalFixedPressureConstraint.C
+zeroDimensionalFixedPressure/zeroDimensionalFixedPressureModel.C
LIB = $(FOAM_LIBBIN)/libfvConstraints
diff --git a/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureConstraint.C b/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureConstraint.C
new file mode 100644
index 0000000000..29c6b3cbe1
--- /dev/null
+++ b/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureConstraint.C
@@ -0,0 +1,308 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 "zeroDimensionalFixedPressureConstraint.H"
+#include "zeroDimensionalFixedPressureModel.H"
+#include "fvModels.H"
+#include "fvMatrix.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+ defineTypeNameAndDebug(zeroDimensionalFixedPressureConstraint, 0);
+ addToRunTimeSelectionTable
+ (
+ fvConstraint,
+ zeroDimensionalFixedPressureConstraint,
+ dictionary
+ );
+}
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+const Foam::fv::zeroDimensionalFixedPressureModel&
+Foam::fv::zeroDimensionalFixedPressureConstraint::model() const
+{
+ const fvModels& models = fvModels::New(mesh());
+
+ forAll(models, i)
+ {
+ if (isA(models[i]))
+ {
+ return refCast
+ (
+ models[i]
+ );
+ }
+ }
+
+ FatalErrorInFunction
+ << "The " << typeName << " fvConstraint requires a corresponding "
+ << zeroDimensionalFixedPressureModel::typeName << " fvModel"
+ << exit(FatalError);
+
+ return NullObjectRef();
+}
+
+
+template
+Foam::tmp
+Foam::fv::zeroDimensionalFixedPressureConstraint::massSource
+(
+ const AlphaFieldType& alpha,
+ const volScalarField::Internal& rho
+) const
+{
+ // Source does not exist yet. Return zero.
+ if (!sourcePtr_.valid())
+ {
+ return
+ volScalarField::Internal::New
+ (
+ typedName("source"),
+ mesh(),
+ dimensionedScalar(dimMass/dimVolume/dimTime, 0)
+ );
+ }
+
+ // Source for mass-based pressure equations
+ if (sourcePtr_->dimensions() == dimMass/dimVolume/dimTime)
+ {
+ return alpha*sourcePtr_();
+ }
+
+ // Source for volume-based pressure equations
+ if (sourcePtr_->dimensions() == dimless/dimTime)
+ {
+ return alpha*rho*sourcePtr_();
+ }
+
+ FatalErrorInFunction
+ << "Pressure equation dimensions not recognised"
+ << exit(FatalError);
+
+ return tmp(nullptr);
+}
+
+
+void Foam::fv::zeroDimensionalFixedPressureConstraint::readCoeffs()
+{
+ pName_ = coeffs().lookupOrDefault("p", "p");
+
+ rhoName_ = coeffs().lookupOrDefault("rho", "rho");
+
+ p_.reset(Function1::New("pressure", coeffs()).ptr());
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::fv::zeroDimensionalFixedPressureConstraint::
+zeroDimensionalFixedPressureConstraint
+(
+ const word& name,
+ const word& modelType,
+ const fvMesh& mesh,
+ const dictionary& dict
+)
+:
+ fvConstraint(name, modelType, mesh, dict),
+ pName_(word::null),
+ rhoName_(word::null),
+ p_(nullptr),
+ sourcePtr_(nullptr)
+{
+ if (mesh.nGeometricD() != 0)
+ {
+ FatalIOErrorInFunction(dict)
+ << "Zero-dimensional fvConstraint applied to a "
+ << mesh.nGeometricD() << "-dimensional mesh"
+ << exit(FatalIOError);
+ }
+
+ readCoeffs();
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::fv::zeroDimensionalFixedPressureConstraint::
+~zeroDimensionalFixedPressureConstraint()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+Foam::wordList
+Foam::fv::zeroDimensionalFixedPressureConstraint::constrainedFields() const
+{
+ return wordList(1, pName_);
+}
+
+
+const Foam::volScalarField::Internal&
+Foam::fv::zeroDimensionalFixedPressureConstraint::pEqnSource
+(
+ fvMatrix& pEqn
+) const
+{
+ // Ensure the corresponding fvModel exits
+ model();
+
+ // Construct the source if it does not yet exist
+ if (!sourcePtr_.valid())
+ {
+ sourcePtr_.set
+ (
+ new volScalarField::Internal
+ (
+ IOobject
+ (
+ typedName("source"),
+ mesh().time().timeName(),
+ mesh(),
+ IOobject::READ_IF_PRESENT,
+ IOobject::AUTO_WRITE
+ ),
+ mesh(),
+ dimensionedScalar(pEqn.dimensions()/dimVolume, 0)
+ )
+ );
+ }
+
+ return sourcePtr_();
+}
+
+
+Foam::tmp
+Foam::fv::zeroDimensionalFixedPressureConstraint::massSource
+(
+ const volScalarField::Internal& rho
+) const
+{
+ return massSource(geometricOneField(), rho);
+}
+
+
+Foam::tmp
+Foam::fv::zeroDimensionalFixedPressureConstraint::massSource
+(
+ const volScalarField::Internal& alpha,
+ const volScalarField::Internal& rho
+) const
+{
+ return massSource(alpha, rho);
+}
+
+
+bool Foam::fv::zeroDimensionalFixedPressureConstraint::constrain
+(
+ fvMatrix& pEqn,
+ const word& fieldName
+) const
+{
+ // Construct the source if it does not yet exist
+ pEqnSource(pEqn);
+
+ // Check the dimensions have not changed
+ sourcePtr_->dimensions() = pEqn.dimensions()/dimVolume;
+
+ // Remove the previous iteration's source from the pressure equation
+ pEqn += sourcePtr_();
+
+ // Set the source as the residual of the pressure equation when evaluated
+ // at the desired pressure
+ sourcePtr_() =
+ pEqn
+ & volScalarField::Internal::New
+ (
+ "p",
+ mesh(),
+ dimensionedScalar
+ (
+ dimPressure,
+ p_->value(mesh().time().userTimeValue())
+ )
+ );
+
+ // Add the source to the pressure equation to force the pressure towards
+ // the desired value
+ pEqn -= sourcePtr_();
+
+ return true;
+}
+
+
+bool Foam::fv::zeroDimensionalFixedPressureConstraint::movePoints()
+{
+ return true;
+}
+
+
+void Foam::fv::zeroDimensionalFixedPressureConstraint::topoChange
+(
+ const polyTopoChangeMap& map
+)
+{}
+
+
+void Foam::fv::zeroDimensionalFixedPressureConstraint::mapMesh
+(
+ const polyMeshMap& map
+)
+{}
+
+
+void Foam::fv::zeroDimensionalFixedPressureConstraint::distribute
+(
+ const polyDistributionMap& map
+)
+{}
+
+
+bool Foam::fv::zeroDimensionalFixedPressureConstraint::read
+(
+ const dictionary& dict
+)
+{
+ if (fvConstraint::read(dict))
+ {
+ readCoeffs();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureConstraint.H b/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureConstraint.H
new file mode 100644
index 0000000000..5f6906b3da
--- /dev/null
+++ b/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureConstraint.H
@@ -0,0 +1,220 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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::zeroDimensionalFixedPressureConstraint
+
+Description
+ Zero-dimensional fixed pressure constraint. Should be used in conjunction
+ with the zeroDimensionalFixedPressureModel.
+
+ This constraint and model facilitates specification of a constant or
+ time-varying pressure. It adds mass source terms proportional to the error
+ that remains when the pressure equation is evaluated at the desired
+ pressure. Iteration may be necessary to converge the constraint in the case
+ of non-linear equations of state.
+
+ Properties are added or removed with their current value. The model
+ therefore represents a uniform expansion or contraction in infinite space.
+
+Usage
+ Example usage:
+ \verbatim
+ {
+ type zeroDimensionalFixedPressure;
+
+ // Name of the pressure field, default = p
+ //p p;
+
+ // Name of the density field, default = rho
+ //rho rho;
+
+ // Pressure value
+ pressure 1e5;
+ }
+ \endverbatim
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef zeroDimensionalFixedPressureConstraint_H
+#define zeroDimensionalFixedPressureConstraint_H
+
+#include "fvConstraint.H"
+#include "Function1.H"
+#include "volFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+
+class zeroDimensionalFixedPressureModel;
+
+/*---------------------------------------------------------------------------*\
+ Class zeroDimensionalFixedPressureConstraint Declaration
+\*---------------------------------------------------------------------------*/
+
+class zeroDimensionalFixedPressureConstraint
+:
+ public fvConstraint
+{
+ // Private data
+
+ //- Pressure field name, default = p
+ word pName_;
+
+ //- Density field name, default = rho
+ word rhoName_;
+
+ //- The pressure value
+ autoPtr> p_;
+
+ //- The mass or volume source
+ mutable autoPtr sourcePtr_;
+
+
+ // Private member functions
+
+ //- Access the corresponding model
+ const zeroDimensionalFixedPressureModel& model() const;
+
+ //- Get the mass source
+ template
+ tmp massSource
+ (
+ const AlphaFieldType& alpha,
+ const volScalarField::Internal& rho
+ ) const;
+
+ //- Non-virtual read
+ void readCoeffs();
+
+
+public:
+
+ //- Runtime type information
+ TypeName("zeroDimensionalFixedPressure");
+
+
+ // Constructors
+
+ //- Construct from dictionary
+ zeroDimensionalFixedPressureConstraint
+ (
+ const word& name,
+ const word& modelType,
+ const fvMesh& mesh,
+ const dictionary& dict
+ );
+
+
+ //- Destructor
+ virtual ~zeroDimensionalFixedPressureConstraint();
+
+
+ // Member Functions
+
+ // Access
+
+ //- Pressure field name
+ inline const word& pName() const
+ {
+ return pName_;
+ }
+
+ //- Density field name
+ inline const word& rhoName() const
+ {
+ return rhoName_;
+ }
+
+
+ // Checks
+
+ //- Return the list of fields constrained by the fvConstraint
+ virtual wordList constrainedFields() const;
+
+
+ // Constraints
+
+ //- Return the mass or volume source for the pressure equation
+ const volScalarField::Internal& pEqnSource
+ (
+ fvMatrix& pEqn
+ ) const;
+
+ //- Return the mass source
+ tmp massSource
+ (
+ const volScalarField::Internal& rho
+ ) const;
+
+ //- Return the mass source for a given phase
+ tmp massSource
+ (
+ const volScalarField::Internal& alpha,
+ const volScalarField::Internal& rho
+ ) const;
+
+ //- Apply the constraint to the pressure equation
+ virtual bool constrain
+ (
+ fvMatrix& pEqn,
+ const word& fieldName
+ ) const;
+
+
+ // Mesh changes
+
+ //- 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&);
+
+
+ // IO
+
+ //- Read dictionary
+ virtual bool read(const dictionary& dict);
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace fv
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureModel.C b/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureModel.C
new file mode 100644
index 0000000000..47c94429ce
--- /dev/null
+++ b/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureModel.C
@@ -0,0 +1,292 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 "zeroDimensionalFixedPressureModel.H"
+#include "zeroDimensionalFixedPressureConstraint.H"
+#include "fvConstraints.H"
+#include "fvmSup.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+ defineTypeNameAndDebug(zeroDimensionalFixedPressureModel, 0);
+ addToRunTimeSelectionTable
+ (
+ fvModel,
+ zeroDimensionalFixedPressureModel,
+ dictionary
+ );
+}
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+const Foam::fv::zeroDimensionalFixedPressureConstraint&
+Foam::fv::zeroDimensionalFixedPressureModel::constraint() const
+{
+ const fvConstraints& constraints = fvConstraints::New(mesh());
+
+ forAll(constraints, i)
+ {
+ if (isA(constraints[i]))
+ {
+ return refCast
+ (
+ constraints[i]
+ );
+ }
+ }
+
+ FatalErrorInFunction
+ << "The " << typeName << " fvModel requires a corresponding "
+ << zeroDimensionalFixedPressureConstraint::typeName << " fvConstraint"
+ << exit(FatalError);
+
+ return NullObjectRef();
+}
+
+
+template
+void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
+(
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ FatalErrorInFunction
+ << "Cannot add a fixed pressure source to field " << fieldName
+ << " because this field's equation is not in mass-conservative form"
+ << exit(FatalError);
+}
+
+
+void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
+(
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ if (IOobject::member(fieldName) == constraint().rhoName())
+ {
+ eqn += constraint().massSource(eqn.psi()());
+ }
+ else
+ {
+ addSupType(eqn, fieldName); // error above
+ }
+}
+
+
+template
+void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
+(
+ const volScalarField& rho,
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ eqn -= fvm::SuSp(-constraint().massSource(rho()), eqn.psi());
+}
+
+
+void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
+(
+ const volScalarField& rho,
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ if (IOobject::member(fieldName) == constraint().rhoName())
+ {
+ if (IOobject::member(eqn.psi().name()) == constraint().pName())
+ {
+ eqn += constraint().pEqnSource(eqn);
+ }
+ else if (IOobject::member(eqn.psi().name()) == constraint().rhoName())
+ {
+ // Phase density equation. Argument names are misleading.
+ const volScalarField& alpha = rho;
+ const volScalarField& rho = eqn.psi();
+
+ eqn += constraint().massSource(alpha(), rho());
+ }
+ else
+ {
+ FatalErrorInFunction
+ << "Cannot add source for density field " << fieldName
+ << " into an equation for " << eqn.psi().name()
+ << exit(FatalError);
+ }
+ }
+ else
+ {
+ addSupType(rho, eqn, fieldName);
+ }
+}
+
+
+template
+void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
+(
+ const volScalarField& alpha,
+ const volScalarField& rho,
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ eqn -= fvm::SuSp(-constraint().massSource(alpha(), rho()), eqn.psi());
+}
+
+
+void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
+(
+ const volScalarField& alpha,
+ const volScalarField& rho,
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ if (IOobject::member(fieldName) == constraint().rhoName())
+ {
+ if (IOobject::member(eqn.psi().name()) == constraint().pName())
+ {
+ eqn += alpha*constraint().pEqnSource(eqn);
+ }
+ else if (IOobject::member(eqn.psi().name()) == constraint().rhoName())
+ {
+ FatalErrorInFunction
+ << "Cannot add source for density field " << fieldName
+ << " into a phase-conservative equation for "
+ << eqn.psi().name() << exit(FatalError);
+ }
+ else
+ {
+ FatalErrorInFunction
+ << "Cannot add source for density field " << fieldName
+ << " into an equation for " << eqn.psi().name()
+ << exit(FatalError);
+ }
+ }
+ else
+ {
+ addSupType(alpha, rho, eqn, fieldName);
+ }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::fv::zeroDimensionalFixedPressureModel::zeroDimensionalFixedPressureModel
+(
+ const word& name,
+ const word& modelType,
+ const fvMesh& mesh,
+ const dictionary& dict
+)
+:
+ fvModel(name, modelType, mesh, dict)
+{
+ if (mesh.nGeometricD() != 0)
+ {
+ FatalIOErrorInFunction(dict)
+ << "Zero-dimensional fvModel applied to a "
+ << mesh.nGeometricD() << "-dimensional mesh"
+ << exit(FatalIOError);
+ }
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::fv::zeroDimensionalFixedPressureModel::
+~zeroDimensionalFixedPressureModel()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+bool Foam::fv::zeroDimensionalFixedPressureModel::addsSupToField
+(
+ const word& fieldName
+) const
+{
+ return true;
+}
+
+
+FOR_ALL_FIELD_TYPES
+(
+ IMPLEMENT_FV_MODEL_ADD_SUP,
+ fv::zeroDimensionalFixedPressureModel
+);
+
+
+FOR_ALL_FIELD_TYPES
+(
+ IMPLEMENT_FV_MODEL_ADD_RHO_SUP,
+ fv::zeroDimensionalFixedPressureModel
+);
+
+
+FOR_ALL_FIELD_TYPES
+(
+ IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP,
+ fv::zeroDimensionalFixedPressureModel
+);
+
+
+bool Foam::fv::zeroDimensionalFixedPressureModel::movePoints()
+{
+ return true;
+}
+
+
+void Foam::fv::zeroDimensionalFixedPressureModel::topoChange
+(
+ const polyTopoChangeMap& map
+)
+{}
+
+
+void Foam::fv::zeroDimensionalFixedPressureModel::mapMesh
+(
+ const polyMeshMap& map
+)
+{}
+
+
+void Foam::fv::zeroDimensionalFixedPressureModel::distribute
+(
+ const polyDistributionMap& map
+)
+{}
+
+
+// ************************************************************************* //
diff --git a/src/fvModels/zeroDimensional/constraintSource/constraintSource.H b/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureModel.H
similarity index 64%
rename from src/fvModels/zeroDimensional/constraintSource/constraintSource.H
rename to src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureModel.H
index 90135a839f..c4ca2c7b24 100644
--- a/src/fvModels/zeroDimensional/constraintSource/constraintSource.H
+++ b/src/fvConstraints/zeroDimensionalFixedPressure/zeroDimensionalFixedPressureModel.H
@@ -22,17 +22,35 @@ License
along with OpenFOAM. If not, see .
Class
- Foam::fv::zeroDimensional::constraintSource
+ Foam::fv::zeroDimensionalFixedPressureModel
Description
- Base class for zero-dimensional constraint sources.
+ Zero-dimensional fixed pressure source. Should be used in conjunction
+ with the zeroDimensionalFixedPressureConstraint.
+
+ This constraint and model facilitates specification of a constant or
+ time-varying pressure. It adds mass source terms proportional to the error
+ that remains when the pressure equation is evaluated at the desired
+ pressure. Iteration may be necessary to converge the constraint in the case
+ of non-linear equations of state.
+
+ Properties are added or removed with their current value. The model
+ therefore represents a uniform expansion or contraction in infinite space.
+
+Usage
+ Example usage:
+ \verbatim
+ {
+ type zeroDimensionalFixedPressure;
+ }
+ \endverbatim
\*---------------------------------------------------------------------------*/
-#ifndef constraintSource_H
-#define constraintSource_H
+#ifndef zeroDimensionalFixedPressureModel_H
+#define zeroDimensionalFixedPressureModel_H
-#include "zeroDimensionalFvModel.H"
+#include "fvModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -40,23 +58,24 @@ namespace Foam
{
namespace fv
{
-namespace zeroDimensional
-{
+
+class zeroDimensionalFixedPressureConstraint;
/*---------------------------------------------------------------------------*\
- Class constraintSource Declaration
+ Class zeroDimensionalFixedPressureModel Declaration
\*---------------------------------------------------------------------------*/
-class constraintSource
+class zeroDimensionalFixedPressureModel
:
- public zeroDimensionalFvModel
+ public fvModel
{
// Private member functions
- // Sources
+ //- Access the corresponding constraint
+ const zeroDimensionalFixedPressureConstraint& constraint() const;
- //- Return the mass source
- virtual tmp dmdt() const = 0;
+
+ // Sources
//- Add a source term to an equation
template
@@ -92,17 +111,26 @@ class constraintSource
const word& fieldName
) const;
+ //- Add a source term to a scalar phase equation
+ void addSupType
+ (
+ const volScalarField& alpha,
+ const volScalarField& rho,
+ fvMatrix& eqn,
+ const word& fieldName
+ ) const;
+
public:
//- Runtime type information
- TypeName("constraintSource");
+ TypeName("zeroDimensionalFixedPressure");
// Constructors
//- Construct from dictionary
- constraintSource
+ zeroDimensionalFixedPressureModel
(
const word& name,
const word& modelType,
@@ -112,7 +140,7 @@ public:
//- Destructor
- virtual ~constraintSource();
+ virtual ~zeroDimensionalFixedPressureModel();
// Member Functions
@@ -123,10 +151,6 @@ public:
// field's transport equation
virtual bool addsSupToField(const word& fieldName) const;
- //- Return the list of fields for which the fvModel adds source term
- // to the transport equation
- virtual wordList addSupFields() const;
-
// Sources
@@ -138,12 +162,26 @@ public:
//- Add a source term to a phase equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP);
+
+
+ // Mesh changes
+
+ //- 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&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-} // End namespace zeroDimensional
} // End namespace fv
} // End namespace Foam
diff --git a/src/fvModels/Make/files b/src/fvModels/Make/files
index 099d5c55a7..c26d420284 100644
--- a/src/fvModels/Make/files
+++ b/src/fvModels/Make/files
@@ -25,8 +25,8 @@ derived/volumeFractionSource/volumeFractionSource.C
derived/solidEquilibriumEnergySource/solidEquilibriumEnergySource.C
derived/massSource/massSource.C
derived/heatSource/heatSource.C
-
derived/heatTransfer/heatTransfer.C
+derived/zeroDimensionalMassSource/zeroDimensionalMassSource.C
interRegion/interRegionModel/interRegionModel.C
interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C
@@ -40,10 +40,4 @@ derived/heatTransfer/heatTransferCoefficientModels/function1/function1.C
derived/heatTransfer/heatTransferCoefficientModels/function2/function2.C
derived/heatTransfer/heatTransferCoefficientModels/variable/variable.C
-zeroDimensional/zeroDimensionalFvModel/zeroDimensionalFvModel.C
-zeroDimensional/constraintSource/constraintSource.C
-zeroDimensional/densityConstraintSource/densityConstraintSource.C
-zeroDimensional/pressureConstraintSource/pressureConstraintSource.C
-zeroDimensional/zeroDimensionalMassSource/zeroDimensionalMassSource.C
-
LIB = $(FOAM_LIBBIN)/libfvModels
diff --git a/src/fvModels/zeroDimensional/zeroDimensionalMassSource/zeroDimensionalMassSource.C b/src/fvModels/derived/zeroDimensionalMassSource/zeroDimensionalMassSource.C
similarity index 100%
rename from src/fvModels/zeroDimensional/zeroDimensionalMassSource/zeroDimensionalMassSource.C
rename to src/fvModels/derived/zeroDimensionalMassSource/zeroDimensionalMassSource.C
diff --git a/src/fvModels/zeroDimensional/zeroDimensionalMassSource/zeroDimensionalMassSource.H b/src/fvModels/derived/zeroDimensionalMassSource/zeroDimensionalMassSource.H
similarity index 100%
rename from src/fvModels/zeroDimensional/zeroDimensionalMassSource/zeroDimensionalMassSource.H
rename to src/fvModels/derived/zeroDimensionalMassSource/zeroDimensionalMassSource.H
diff --git a/src/fvModels/zeroDimensional/constraintSource/constraintSource.C b/src/fvModels/zeroDimensional/constraintSource/constraintSource.C
deleted file mode 100644
index ab575e880e..0000000000
--- a/src/fvModels/zeroDimensional/constraintSource/constraintSource.C
+++ /dev/null
@@ -1,183 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / 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 "constraintSource.H"
-#include "fluidThermo.H"
-#include "fvModels.H"
-#include "fvMatrix.H"
-#include "fvmSup.H"
-#include "addToRunTimeSelectionTable.H"
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace fv
-{
-namespace zeroDimensional
-{
- defineTypeNameAndDebug(constraintSource, 0);
-}
-}
-}
-
-
-// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
-
-template
-void Foam::fv::zeroDimensional::constraintSource::addSupType
-(
- fvMatrix& eqn,
- const word& fieldName
-) const
-{
- FatalErrorInFunction
- << "Cannot add a constraint source to field " << fieldName
- << " because this field's equation is not in mass-conservative form"
- << exit(FatalError);
-}
-
-
-void Foam::fv::zeroDimensional::constraintSource::addSupType
-(
- fvMatrix& eqn,
- const word& fieldName
-) const
-{
- if (fieldName == "rho")
- {
- eqn += dmdt();
- }
- else
- {
- addSupType(eqn, fieldName);
- }
-}
-
-
-template
-void Foam::fv::zeroDimensional::constraintSource::addSupType
-(
- const volScalarField& rho,
- fvMatrix& eqn,
- const word& fieldName
-) const
-{
- eqn -= fvm::SuSp(-dmdt(), eqn.psi());
-}
-
-
-void Foam::fv::zeroDimensional::constraintSource::addSupType
-(
- const volScalarField& rho,
- fvMatrix& eqn,
- const word& fieldName
-) const
-{
- if (fieldName == "rho")
- {
- eqn += dmdt();
- }
- else
- {
- addSupType(rho, eqn, fieldName);
- }
-}
-
-
-template
-void Foam::fv::zeroDimensional::constraintSource::addSupType
-(
- const volScalarField& alpha,
- const volScalarField& rho,
- fvMatrix& eqn,
- const word& fieldName
-) const
-{
- FatalErrorInFunction
- << "Constraint sources do not support phase equations"
- << exit(FatalError);
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-Foam::fv::zeroDimensional::constraintSource::constraintSource
-(
- const word& name,
- const word& modelType,
- const fvMesh& mesh,
- const dictionary& dict
-)
-:
- zeroDimensionalFvModel(name, modelType, mesh, dict)
-{}
-
-
-// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
-
-Foam::fv::zeroDimensional::constraintSource::~constraintSource()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-
-bool Foam::fv::zeroDimensional::constraintSource::addsSupToField
-(
- const word& fieldName
-) const
-{
- return true;
-}
-
-
-Foam::wordList Foam::fv::zeroDimensional::constraintSource::addSupFields() const
-{
- return wordList(1, "rho");
-}
-
-
-FOR_ALL_FIELD_TYPES
-(
- IMPLEMENT_FV_MODEL_ADD_SUP,
- fv::zeroDimensional::constraintSource
-);
-
-
-FOR_ALL_FIELD_TYPES
-(
- IMPLEMENT_FV_MODEL_ADD_RHO_SUP,
- fv::zeroDimensional::constraintSource
-);
-
-
-FOR_ALL_FIELD_TYPES
-(
- IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP,
- fv::zeroDimensional::constraintSource
-);
-
-
-// ************************************************************************* //
diff --git a/src/fvModels/zeroDimensional/densityConstraintSource/densityConstraintSource.C b/src/fvModels/zeroDimensional/densityConstraintSource/densityConstraintSource.C
deleted file mode 100644
index 093a099201..0000000000
--- a/src/fvModels/zeroDimensional/densityConstraintSource/densityConstraintSource.C
+++ /dev/null
@@ -1,112 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / 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 "densityConstraintSource.H"
-#include "fluidThermo.H"
-#include "addToRunTimeSelectionTable.H"
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace fv
-{
-namespace zeroDimensional
-{
- defineTypeNameAndDebug(densityConstraintSource, 0);
- addToRunTimeSelectionTable(fvModel, densityConstraintSource, dictionary);
-}
-}
-}
-
-
-// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
-
-void Foam::fv::zeroDimensional::densityConstraintSource::readCoeffs()
-{
- rho_.reset(Function1::New("rho", coeffs()).ptr());
-}
-
-
-Foam::tmp
-Foam::fv::zeroDimensional::densityConstraintSource::dmdt() const
-{
- const fluidThermo& thermo =
- mesh().lookupObject(physicalProperties::typeName);
-
- const scalar t = mesh().time().userTimeValue();
- const dimensionedScalar& deltaT = mesh().time().deltaT();
-
- const dimensionedScalar rhoTarget(dimPressure, rho_->value(t));
-
- const volScalarField::Internal& rho = thermo.rho();
-
- return (rhoTarget - rho)/deltaT;
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-Foam::fv::zeroDimensional::densityConstraintSource::densityConstraintSource
-(
- const word& name,
- const word& modelType,
- const fvMesh& mesh,
- const dictionary& dict
-)
-:
- constraintSource(name, modelType, mesh, dict),
- rho_(nullptr)
-{
- readCoeffs();
-}
-
-
-// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
-
-Foam::fv::zeroDimensional::densityConstraintSource::~densityConstraintSource()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-
-bool Foam::fv::zeroDimensional::densityConstraintSource::read
-(
- const dictionary& dict
-)
-{
- if (fvModel::read(dict))
- {
- readCoeffs();
- return true;
- }
- else
- {
- return false;
- }
-}
-
-
-// ************************************************************************* //
diff --git a/src/fvModels/zeroDimensional/densityConstraintSource/densityConstraintSource.H b/src/fvModels/zeroDimensional/densityConstraintSource/densityConstraintSource.H
deleted file mode 100644
index daa39fdd8d..0000000000
--- a/src/fvModels/zeroDimensional/densityConstraintSource/densityConstraintSource.H
+++ /dev/null
@@ -1,142 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / 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::zeroDimensional::densityConstraintSource
-
-Description
- Zero-dimensional density constraint source.
-
- This model facilitates specification of a time-varying density (or,
- equivalently, specific volume) be using a Function1. It adds or removes
- mass appropriately to achieve the desired density.
-
- Fluid properties are added or removed with their current value. This model
- therefore represents a uniform expansion or contraction in an infinite
- space.
-
- Note that in the case of a constant density this model does not do
- anything. A zero-dimension case naturally has both constant mass and
- volume.
-
- This only works for a compressible fluid.
-
-Usage
- Example usage:
- \verbatim
- {
- type densityConstraintSource;
- rho
- {
- type scale;
- values
- (
- (0 1.16)
- (1 1.16)
- (1.1 2.02)
- (10 2.02)
- );
- }
- }
- \endverbatim
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef densityConstraintSource_H
-#define densityConstraintSource_H
-
-#include "constraintSource.H"
-#include "Function1.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace fv
-{
-namespace zeroDimensional
-{
-
-/*---------------------------------------------------------------------------*\
- Class densityConstraintSource Declaration
-\*---------------------------------------------------------------------------*/
-
-class densityConstraintSource
-:
- public constraintSource
-{
- // Private data
-
- //- The density value
- autoPtr> rho_;
-
-
- // Private member functions
-
- //- Non-virtual read
- void readCoeffs();
-
- //- Return the mass source
- virtual tmp dmdt() const;
-
-
-public:
-
- //- Runtime type information
- TypeName("densityConstraintSource");
-
-
- // Constructors
-
- //- Construct from dictionary
- densityConstraintSource
- (
- const word& name,
- const word& modelType,
- const fvMesh& mesh,
- const dictionary& dict
- );
-
-
- //- Destructor
- virtual ~densityConstraintSource();
-
-
- // Member Functions
-
- //- Read dictionary
- virtual bool read(const dictionary& dict);
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace zeroDimensional
-} // End namespace fv
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/fvModels/zeroDimensional/pressureConstraintSource/pressureConstraintSource.C b/src/fvModels/zeroDimensional/pressureConstraintSource/pressureConstraintSource.C
deleted file mode 100644
index 6e9927dd15..0000000000
--- a/src/fvModels/zeroDimensional/pressureConstraintSource/pressureConstraintSource.C
+++ /dev/null
@@ -1,120 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / 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 "pressureConstraintSource.H"
-#include "fluidThermo.H"
-#include "addToRunTimeSelectionTable.H"
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace fv
-{
-namespace zeroDimensional
-{
- defineTypeNameAndDebug(pressureConstraintSource, 0);
- addToRunTimeSelectionTable(fvModel, pressureConstraintSource, dictionary);
-}
-}
-}
-
-
-// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
-
-void Foam::fv::zeroDimensional::pressureConstraintSource::readCoeffs()
-{
- p_.reset(Function1::New("p", coeffs()).ptr());
-}
-
-
-Foam::tmp
-Foam::fv::zeroDimensional::pressureConstraintSource::dmdt() const
-{
- const fluidThermo& thermo =
- mesh().lookupObject(physicalProperties::typeName);
-
- if (thermo.incompressible())
- {
- FatalErrorInFunction
- << "Cannot constrain the pressure of an incompressible fluid"
- << exit(FatalError);
- }
-
- const scalar t = mesh().time().userTimeValue();
- const dimensionedScalar& deltaT = mesh().time().deltaT();
-
- const dimensionedScalar pTarget(dimPressure, p_->value(t));
-
- const volScalarField::Internal& p = thermo.p();
- const volScalarField::Internal& psi = thermo.psi();
-
- return (pTarget - p)*psi/deltaT;
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-Foam::fv::zeroDimensional::pressureConstraintSource::pressureConstraintSource
-(
- const word& name,
- const word& modelType,
- const fvMesh& mesh,
- const dictionary& dict
-)
-:
- constraintSource(name, modelType, mesh, dict),
- p_(nullptr)
-{
- readCoeffs();
-}
-
-
-// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
-
-Foam::fv::zeroDimensional::pressureConstraintSource::~pressureConstraintSource()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-
-bool Foam::fv::zeroDimensional::pressureConstraintSource::read
-(
- const dictionary& dict
-)
-{
- if (fvModel::read(dict))
- {
- readCoeffs();
- return true;
- }
- else
- {
- return false;
- }
-}
-
-
-// ************************************************************************* //
diff --git a/src/fvModels/zeroDimensional/pressureConstraintSource/pressureConstraintSource.H b/src/fvModels/zeroDimensional/pressureConstraintSource/pressureConstraintSource.H
deleted file mode 100644
index 340c16f35d..0000000000
--- a/src/fvModels/zeroDimensional/pressureConstraintSource/pressureConstraintSource.H
+++ /dev/null
@@ -1,131 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / 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::zeroDimensional::pressureConstraintSource
-
-Description
- Zero-dimensional pressure constraint source.
-
- This model facilitates specification of a constant or time-varying
- pressure. It uses the fluid’s compressibility to determine the amount of
- mass necessary to add or remove to achieve the desired pressure. Iteration
- may be necessary to converge the constraint in the case of non-linear
- equations of state.
-
- Properties are added or removed with their current value. The model
- therefore represents a uniform expansion or contraction in infinite space.
-
- This only works for a compressible fluid. In the case of an incompressible
- fluid, a standard fixed value fvConstraint should be used instead to bypass
- solution of the pressure equation alltogether.
-
-Usage
- Example usage:
- \verbatim
- {
- type pressureConstraintSource;
- p 1e5;
- }
- \endverbatim
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef pressureConstraintSource_H
-#define pressureConstraintSource_H
-
-#include "constraintSource.H"
-#include "Function1.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace fv
-{
-namespace zeroDimensional
-{
-
-/*---------------------------------------------------------------------------*\
- Class pressureConstraintSource Declaration
-\*---------------------------------------------------------------------------*/
-
-class pressureConstraintSource
-:
- public constraintSource
-{
- // Private data
-
- //- The pressure value
- autoPtr> p_;
-
-
- // Private member functions
-
- //- Non-virtual read
- void readCoeffs();
-
- //- Return the mass source
- tmp dmdt() const;
-
-
-public:
-
- //- Runtime type information
- TypeName("pressureConstraintSource");
-
-
- // Constructors
-
- //- Construct from dictionary
- pressureConstraintSource
- (
- const word& name,
- const word& modelType,
- const fvMesh& mesh,
- const dictionary& dict
- );
-
-
- //- Destructor
- virtual ~pressureConstraintSource();
-
-
- // Member Functions
-
- //- Read dictionary
- virtual bool read(const dictionary& dict);
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace zeroDimensional
-} // End namespace fv
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/fvModels/zeroDimensional/zeroDimensionalFvModel/zeroDimensionalFvModel.C b/src/fvModels/zeroDimensional/zeroDimensionalFvModel/zeroDimensionalFvModel.C
deleted file mode 100644
index 22aafde0d3..0000000000
--- a/src/fvModels/zeroDimensional/zeroDimensionalFvModel/zeroDimensionalFvModel.C
+++ /dev/null
@@ -1,101 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / 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 "zeroDimensionalFvModel.H"
-#include "fluidThermo.H"
-#include "fvModels.H"
-#include "fvMatrix.H"
-#include "fvmSup.H"
-#include "addToRunTimeSelectionTable.H"
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace fv
-{
- defineTypeNameAndDebug(zeroDimensionalFvModel, 0);
-}
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-Foam::fv::zeroDimensionalFvModel::zeroDimensionalFvModel
-(
- const word& name,
- const word& modelType,
- const fvMesh& mesh,
- const dictionary& dict
-)
-:
- fvModel(name, modelType, mesh, dict)
-{
- if (mesh.nGeometricD() != 0)
- {
- FatalIOErrorInFunction(dict)
- << "Zero-dimensional fvModel applied to a "
- << mesh.nGeometricD() << "-dimensional mesh"
- << exit(FatalIOError);
- }
-}
-
-
-// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
-
-Foam::fv::zeroDimensionalFvModel::~zeroDimensionalFvModel()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-
-bool Foam::fv::zeroDimensionalFvModel::movePoints()
-{
- return true;
-}
-
-
-void Foam::fv::zeroDimensionalFvModel::topoChange
-(
- const polyTopoChangeMap& map
-)
-{}
-
-
-void Foam::fv::zeroDimensionalFvModel::mapMesh
-(
- const polyMeshMap& map
-)
-{}
-
-
-void Foam::fv::zeroDimensionalFvModel::distribute
-(
- const polyDistributionMap& map
-)
-{}
-
-
-// ************************************************************************* //
diff --git a/src/fvModels/zeroDimensional/zeroDimensionalFvModel/zeroDimensionalFvModel.H b/src/fvModels/zeroDimensional/zeroDimensionalFvModel/zeroDimensionalFvModel.H
deleted file mode 100644
index ca646e773c..0000000000
--- a/src/fvModels/zeroDimensional/zeroDimensionalFvModel/zeroDimensionalFvModel.H
+++ /dev/null
@@ -1,101 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / 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::zeroDimensionalFvModel
-
-Description
- Base class for zero-dimensional fvModels.
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef zeroDimensionalFvModel_H
-#define zeroDimensionalFvModel_H
-
-#include "fvModel.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace fv
-{
-
-/*---------------------------------------------------------------------------*\
- Class zeroDimensionalFvModel Declaration
-\*---------------------------------------------------------------------------*/
-
-class zeroDimensionalFvModel
-:
- public fvModel
-{
-public:
-
- //- Runtime type information
- TypeName("zeroDimensionalFvModel");
-
-
- // Constructors
-
- //- Construct from dictionary
- zeroDimensionalFvModel
- (
- const word& name,
- const word& modelType,
- const fvMesh& mesh,
- const dictionary& dict
- );
-
-
- //- Destructor
- virtual ~zeroDimensionalFvModel();
-
-
- // Member Functions
-
- // Mesh changes
-
- //- 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&);
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace fv
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/tutorials/modules/multicomponentFluid/nc7h16/0/p b/tutorials/modules/multicomponentFluid/nc7h16/0/p
index 1c3f60c9cc..66a97e747e 100644
--- a/tutorials/modules/multicomponentFluid/nc7h16/0/p
+++ b/tutorials/modules/multicomponentFluid/nc7h16/0/p
@@ -16,7 +16,7 @@ FoamFile
dimensions [1 -1 -2 0 0 0 0];
-internalField uniform 5.06625e+06;
+internalField uniform 5.06625e6;
boundaryField {}
diff --git a/tutorials/modules/multicomponentFluid/nc7h16/constant/fvModels b/tutorials/modules/multicomponentFluid/nc7h16/constant/fvModels
index a52efafcf3..561c1f2c22 100644
--- a/tutorials/modules/multicomponentFluid/nc7h16/constant/fvModels
+++ b/tutorials/modules/multicomponentFluid/nc7h16/constant/fvModels
@@ -14,10 +14,9 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-pressureConstraintSource1
+zeroDimensionalFixedPressure1
{
- type pressureConstraintSource;
- p 1.36789e6;
+ type zeroDimensionalFixedPressure;
}
//************************************************************************* //
diff --git a/tutorials/modules/multicomponentFluid/nc7h16/system/fvConstraints b/tutorials/modules/multicomponentFluid/nc7h16/system/fvConstraints
new file mode 100644
index 0000000000..21f17ef045
--- /dev/null
+++ b/tutorials/modules/multicomponentFluid/nc7h16/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;
+ location "system";
+ object fvConstraints;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+zeroDimensionalFixedPressure1
+{
+ type zeroDimensionalFixedPressure;
+
+ pressure 5.06625e6;
+}
+
+// ************************************************************************* //
diff --git a/tutorials/modules/multicomponentFluid/nc7h16/system/fvSolution b/tutorials/modules/multicomponentFluid/nc7h16/system/fvSolution
index e452a1fd1f..728def1b9e 100644
--- a/tutorials/modules/multicomponentFluid/nc7h16/system/fvSolution
+++ b/tutorials/modules/multicomponentFluid/nc7h16/system/fvSolution
@@ -47,7 +47,7 @@ solvers
PIMPLE
{
nOuterCorrectors 1;
- nCorrectors 2;
+ nCorrectors 1;
nNonOrthogonalCorrectors 0;
}