All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-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::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 "HashSet.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of friend functions and operators
49 class fvConstraints;
50 
51 Ostream& operator<<(Ostream& os, const fvConstraints& constraints);
52 
53 
54 /*---------------------------------------------------------------------------*\
55  Class fvConstraints Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class fvConstraints
59 :
61  <
62  fvMesh,
63  TopoChangeableMeshObject,
64  fvConstraints
65  >,
66  public dictionary,
67  public PtrListDictionary<fvConstraint>
68 {
69  // Private Member Data
70 
71  //- Time index to check that all defined sources have been applied
72  mutable label checkTimeIndex_;
73 
74  //- Sets of the fields that have been constrained by the fvConstraints
75  mutable PtrList<wordHashSet> constrainedFields_;
76 
77 
78  // Private Member Functions
79 
80  //- Create IO object if dictionary is present
81  IOobject createIOobject(const fvMesh& mesh) const;
82 
83  //- Check that all fvConstraints have been applied
84  void checkApplied() const;
85 
86 
87 public:
88 
89  //- Runtime type information
90  TypeName("fvConstraints");
91 
92 
93  // Constructors
94 
95  //- Construct from components with list of field names
96  fvConstraints(const fvMesh& mesh);
97 
98  //- Disallow default bitwise copy construction
99  fvConstraints(const fvConstraints&) = delete;
100 
101  //- Inherit the base New method
103  <
104  fvMesh,
107  >::New;
108 
109 
110  //- Destructor
111  virtual ~fvConstraints()
112  {}
113 
114 
115  // Member Functions
116 
117  //- Declare fvConstraints to be a global dictionary
118  virtual bool global() const
119  {
120  return true;
121  }
122 
123 
124  // Checks
125 
126  //- Return true if an fvConstraint constrains the given field
127  virtual bool constrainsField(const word& fieldName) const;
128 
129 
130  // Constraints
131 
132  //- Apply constraints to an equation
133  template<class Type>
134  bool constrain(fvMatrix<Type>& eqn) const;
135 
136  //- Apply constraints to a field
137  template<class Type>
138  bool constrain
139  (
140  VolField<Type>& field
141  ) const;
142 
143 
144  // Mesh changes
145 
146  //- Update for mesh motion
147  virtual bool movePoints();
148 
149  //- Update topology using the given map
150  virtual void topoChange(const polyTopoChangeMap&);
151 
152  //- Update from another mesh using the given map
153  virtual void mapMesh(const polyMeshMap&);
154 
155  //- Redistribute or update using the given distribution map
156  virtual void distribute(const polyDistributionMap&);
157 
158 
159  // IO
160 
161  //- ReadData function which reads the fvConstraints dictionary
162  // required for regIOobject read operation
163  virtual bool readData(Istream&);
164 
165  //- Write data to Ostream
166  virtual bool writeData(Ostream& os) const;
167 
168  //- Read the fvConstraints dictionary if it has changed
169  // and update the constraints
170  virtual bool read();
171 
172 
173  // Member Operators
174 
175  //- Inherit the PtrListDictionary index operators
177 
178  //- Inherit the PtrListDictionary size function
180 
181  //- Disallow default bitwise assignment
182  void operator=(const fvConstraints&) = delete;
183 
184 
185  // IOstream Operators
186 
187  //- Ostream operator
188  friend Ostream& operator<<
189  (
190  Ostream& os,
191  const fvConstraints& constraints
192  );
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 //- Trait for obtaining global status
199 template<>
201 {
202  static const bool global = true;
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #ifdef NoRepository
209  #include "fvConstraintsTemplates.C"
210 #endif
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
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
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
Definition: dictionaryIO.C:100
Finite volume constraints.
Definition: fvConstraints.H:67
virtual bool movePoints()
Update for mesh motion.
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
virtual bool writeData(Ostream &os) const
Write data to Ostream.
virtual bool global() const
Declare fvConstraints to be a global dictionary.
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 components with list of field names.
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 readData(Istream &)
ReadData function which reads the fvConstraints dictionary.
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:99
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:62
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:504
static const bool global
Definition: IOobject.H:505