fvConstraints.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) 2021-2026 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::fvConstraints
26 
27 Description
28  Finite volume constraints
29 
30 SourceFiles
31  fvConstraints.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef fvConstraints_H
36 #define fvConstraints_H
37 
38 #include "fvConstraint.H"
39 #include "PtrListDictionary.H"
40 #include "DemandDrivenMeshObject.H"
41 #include "IOdictionary.H"
42 #include "HashSet.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of friend functions and operators
50 class fvConstraints;
51 
52 Ostream& operator<<(Ostream& os, const fvConstraints& constraints);
53 
54 
55 /*---------------------------------------------------------------------------*\
56  Class fvConstraints Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class fvConstraints
60 :
62  <
63  fvMesh,
64  TopoChangeableMeshObject,
65  fvConstraints,
66  IOdictionary
67  >,
68  public PtrListDictionary<fvConstraint>
69 {
70  // Private Data
71 
72  //- Time index to check that all defined sources have been applied
73  mutable label checkTimeIndex_;
74 
75  //- Sets of the fields that have been constrained by the fvConstraints
76  mutable PtrList<wordHashSet> constrainedFields_;
77 
78 
79  // Private Member Functions
80 
81  //- Create IO object if dictionary is present
82  IOobject createIOobject(const fvMesh& mesh) const;
83 
84  //- Check that all fvConstraints have been applied
85  void checkApplied() const;
86 
87 
88 protected:
89 
90  friend class DemandDrivenMeshObject;
91 
92  // Protected Constructors
93 
94  //- Construct from fvMesh
95  explicit fvConstraints(const fvMesh& mesh);
96 
97 
98 public:
99 
100  //- Runtime type information
101  TypeName("fvConstraints");
102 
103 
104  // Constructors
105 
106  //- Disallow default bitwise copy construction
107  fvConstraints(const fvConstraints&) = delete;
108 
109  //- Inherit the base New method
111  <
112  fvMesh,
116  >::New;
117 
118 
119  //- Destructor
120  virtual ~fvConstraints()
121  {}
122 
123 
124  // Member Functions
125 
126  // Checks
127 
128  //- Return true if an fvConstraint constrains the given field
129  virtual bool constrainsField(const word& fieldName) const;
130 
131 
132  // Constraints
133 
134  //- Apply constraints to an equation
135  template<class Type>
136  bool constrain(fvMatrix<Type>& eqn) const;
137 
138  //- Apply constraints to a field
139  template<class Type>
140  bool constrain
141  (
142  VolField<Type>& field
143  ) const;
144 
145 
146  // Mesh changes
147 
148  //- Update for mesh motion
149  virtual bool movePoints();
150 
151  //- Update topology using the given map
152  virtual void topoChange(const polyTopoChangeMap&);
153 
154  //- Update from another mesh using the given map
155  virtual void mapMesh(const polyMeshMap&);
156 
157  //- Redistribute or update using the given distribution map
158  virtual void distribute(const polyDistributionMap&);
159 
160 
161  // IO
162 
163  //- Read the fvConstraints dictionary if it has changed
164  // and update the constraints
165  virtual bool read();
166 
167 
168  // Member Operators
169 
170  //- Inherit the PtrListDictionary index operators
172 
173  //- Inherit the PtrListDictionary size function
175 
176  //- Disallow default bitwise assignment
177  void operator=(const fvConstraints&) = delete;
178 
179 
180  // IOstream Operators
181 
182  //- Ostream operator
183  friend Ostream& operator<<
184  (
185  Ostream& os,
186  const fvConstraints& constraints
187  );
188 };
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 //- Trait for obtaining global status
194 template<>
196 {
197  static const bool global = true;
198 };
199 
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #ifdef NoRepository
204  #include "fvConstraintsTemplates.C"
205 #endif
206 
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace Foam
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #endif
215 
216 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
static fvConstraints & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Generic GeometricField class.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Template dictionary class which manages the storage associated with it.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
Finite volume constraints.
Definition: fvConstraints.H:68
virtual bool movePoints()
Update for mesh motion.
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
fvConstraints(const fvMesh &mesh)
Construct from fvMesh.
virtual bool constrainsField(const word &fieldName) const
Return true if an fvConstraint constrains the given field.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
TypeName("fvConstraints")
Runtime type information.
virtual ~fvConstraints()
Destructor.
void operator=(const fvConstraints &)=delete
Disallow default bitwise assignment.
virtual bool read()
Read the fvConstraints dictionary if it has changed.
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:98
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 handling words, derived from string.
Definition: word.H:63
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
Trait for obtaining global status.
Definition: IOobject.H:518
static const bool global
Definition: IOobject.H:519