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 :
60  public DemandDrivenMeshObject<fvMesh, UpdateableMeshObject, fvConstraints>,
61  public dictionary,
62  public PtrListDictionary<fvConstraint>
63 {
64  // Private Member Data
65 
66  //- Time index to check that all defined sources have been applied
67  mutable label checkTimeIndex_;
68 
69  //- Sets of the fields that have been constrained by the fvConstraints
70  mutable PtrList<wordHashSet> constrainedFields_;
71 
72 
73  // Private Member Functions
74 
75  //- Create IO object if dictionary is present
76  IOobject createIOobject(const fvMesh& mesh) const;
77 
78  //- Check that all fvConstraints have been applied
79  void checkApplied() const;
80 
81 
82 public:
83 
84  //- Runtime type information
85  TypeName("fvConstraints");
86 
87 
88  // Constructors
89 
90  //- Construct from components with list of field names
91  fvConstraints(const fvMesh& mesh);
92 
93  //- Disallow default bitwise copy construction
94  fvConstraints(const fvConstraints&) = delete;
95 
96  //- Inherit the base New method
98  <
99  fvMesh,
102  >::New;
103 
104 
105  //- Destructor
106  virtual ~fvConstraints()
107  {}
108 
109 
110  // Member Functions
111 
112  //- Declare fvConstraints to be a global dictionary
113  virtual bool global() const
114  {
115  return true;
116  }
117 
118 
119  // Checks
120 
121  //- Return true if an fvConstraint constrains the given field
122  virtual bool constrainsField(const word& fieldName) const;
123 
124 
125  // Constraints
126 
127  //- Apply constraints to an equation
128  template<class Type>
129  bool constrain(fvMatrix<Type>& eqn) const;
130 
131  //- Apply constraints to a field
132  template<class Type>
133  bool constrain
134  (
135  VolField<Type>& field
136  ) const;
137 
138 
139  // Mesh changes
140 
141  //- Update for mesh motion
142  virtual bool movePoints();
143 
144  //- Update topology using the given map
145  virtual void topoChange(const polyTopoChangeMap&);
146 
147  //- Update from another mesh using the given map
148  virtual void mapMesh(const polyMeshMap&);
149 
150  //- Redistribute or update using the given distribution map
151  virtual void distribute(const polyDistributionMap&);
152 
153 
154  // IO
155 
156  //- ReadData function which reads the fvConstraints dictionary
157  // required for regIOobject read operation
158  virtual bool readData(Istream&);
159 
160  //- Write data to Ostream
161  virtual bool writeData(Ostream& os) const;
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...
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
UpdateableMeshObject(regIOobject &io, const fvMesh &mesh)
Definition: MeshObjects.H:150
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
Definition: dictionaryIO.C:100
Finite volume constraints.
Definition: fvConstraints.H:62
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:101
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 &, const ensightPart &)
Trait for obtaining global status.
Definition: IOobject.H:504
static const bool global
Definition: IOobject.H:505