zeroDimensionalFixedPressureConstraint.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fv::zeroDimensionalFixedPressureConstraint
26 
27 Description
28  Zero-dimensional fixed pressure constraint. Should be used in conjunction
29  with the zeroDimensionalFixedPressureModel.
30 
31  This constraint and model facilitates specification of a constant or
32  time-varying pressure. It adds mass source terms proportional to the error
33  that remains when the pressure equation is evaluated at the desired
34  pressure. Iteration may be necessary to converge the constraint in the case
35  of non-linear equations of state.
36 
37  Properties are added or removed with their current value. The model
38  therefore represents a uniform expansion or contraction in infinite space.
39 
40 Usage
41  Example usage:
42  \verbatim
43  {
44  type zeroDimensionalFixedPressure;
45 
46  // Name of the pressure field, default = p
47  //p p;
48 
49  // Name of the density field, default = rho
50  //rho rho;
51 
52  // Pressure value
53  pressure 1e5;
54  }
55  \endverbatim
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef zeroDimensionalFixedPressureConstraint_H
60 #define zeroDimensionalFixedPressureConstraint_H
61 
62 #include "fvConstraint.H"
63 #include "Function1.H"
64 #include "volFields.H"
65 
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 
68 namespace Foam
69 {
70 namespace fv
71 {
72 
73 class zeroDimensionalFixedPressureModel;
74 
75 /*---------------------------------------------------------------------------*\
76  Class zeroDimensionalFixedPressureConstraint Declaration
77 \*---------------------------------------------------------------------------*/
78 
80 :
81  public fvConstraint
82 {
83  // Private data
84 
85  //- Pressure field name, default = p
86  word pName_;
87 
88  //- Density field name, default = rho
89  word rhoName_;
90 
91  //- The pressure value
93 
94  //- The mass or volume source
95  mutable autoPtr<volScalarField::Internal> sourcePtr_;
96 
97 
98  // Private member functions
99 
100  //- Access the corresponding model
101  const zeroDimensionalFixedPressureModel& model() const;
102 
103  //- Get the mass source
104  template<class AlphaFieldType>
106  (
107  const AlphaFieldType& alpha,
109  ) const;
110 
111  //- Non-virtual read
112  void readCoeffs();
113 
114 
115 public:
116 
117  //- Runtime type information
118  TypeName("zeroDimensionalFixedPressure");
119 
120 
121  // Constructors
122 
123  //- Construct from dictionary
125  (
126  const word& name,
127  const word& modelType,
128  const fvMesh& mesh,
129  const dictionary& dict
130  );
131 
132 
133  //- Destructor
135 
136 
137  // Member Functions
138 
139  // Access
140 
141  //- Pressure field name
142  inline const word& pName() const
143  {
144  return pName_;
145  }
146 
147  //- Density field name
148  inline const word& rhoName() const
149  {
150  return rhoName_;
151  }
152 
153 
154  // Checks
155 
156  //- Return the list of fields constrained by the fvConstraint
157  virtual wordList constrainedFields() const;
158 
159 
160  // Constraints
161 
162  //- Return the mass or volume source for the pressure equation
164  (
165  fvMatrix<scalar>& pEqn
166  ) const;
167 
168  //- Return the mass source
170  (
172  ) const;
173 
174  //- Return the mass source for a given phase
176  (
179  ) const;
180 
181  //- Apply the constraint to the pressure equation
182  virtual bool constrain
183  (
184  fvMatrix<scalar>& pEqn,
185  const word& fieldName
186  ) const;
187 
188 
189  // Mesh changes
190 
191  //- Update for mesh motion
192  virtual bool movePoints();
193 
194  //- Update topology using the given map
195  virtual void topoChange(const polyTopoChangeMap&);
196 
197  //- Update from another mesh using the given map
198  virtual void mapMesh(const polyMeshMap&);
199 
200  //- Redistribute or update using the given distribution map
201  virtual void distribute(const polyDistributionMap&);
202 
203 
204  // IO
205 
206  //- Read dictionary
207  virtual bool read(const dictionary& dict);
208 };
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace fv
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Finite volume options abstract base class.
Definition: fvConstraint.H:57
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvConstraintI.H:34
const word & name() const
Return const access to the source name.
Definition: fvConstraintI.H:28
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
This fvModel applies a mass source to the continuity equation and to all field equations.
Definition: massSource.H:250
Zero-dimensional fixed pressure constraint. Should be used in conjunction with the zeroDimensionalFix...
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
const volScalarField::Internal & pEqnSource(fvMatrix< scalar > &pEqn) const
Return the mass or volume source for the pressure equation.
virtual wordList constrainedFields() const
Return the list of fields constrained by the fvConstraint.
TypeName("zeroDimensionalFixedPressure")
Runtime type information.
virtual bool constrain(fvMatrix< scalar > &pEqn, const word &fieldName) const
Apply the constraint to the pressure equation.
zeroDimensionalFixedPressureConstraint(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from dictionary.
Zero-dimensional fixed pressure source. Should be used in conjunction with the zeroDimensionalFixedPr...
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Namespace for OpenFOAM.
labelList fv(nPoints)
dictionary dict