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-2022 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 "MeshObject.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 MeshObject<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 
100  //- Destructor
101  virtual ~fvConstraints()
102  {}
103 
104 
105  // Member Functions
106 
107  //- Declare fvConstraints to be a global dictionary
108  virtual bool global() const
109  {
110  return true;
111  }
112 
113 
114  // Checks
115 
116  //- Return true if an fvConstraint constrains the given field
117  virtual bool constrainsField(const word& fieldName) const;
118 
119 
120  // Constraints
121 
122  //- Apply constraints to an equation
123  template<class Type>
124  bool constrain(fvMatrix<Type>& eqn) const;
125 
126  //- Apply constraints to a field
127  template<class Type>
128  bool constrain
129  (
131  ) const;
132 
133 
134  // Mesh changes
135 
136  //- Update for mesh motion
137  virtual bool movePoints();
138 
139  //- Update topology using the given map
140  virtual void topoChange(const polyTopoChangeMap&);
141 
142  //- Update from another mesh using the given map
143  virtual void mapMesh(const polyMeshMap&);
144 
145  //- Redistribute or update using the given distribution map
146  virtual void distribute(const polyDistributionMap&);
147 
148 
149  // IO
150 
151  //- ReadData function which reads the fvConstraints dictionary
152  // required for regIOobject read operation
153  virtual bool readData(Istream&);
154 
155  //- Write data to Ostream
156  virtual bool writeData(Ostream& os) const;
157 
158  //- Read the fvConstraints dictionary if it has changed
159  // and update the constraints
160  virtual bool read();
161 
162 
163  // Member Operators
164 
165  //- Disallow default bitwise assignment
166  void operator=(const fvConstraints&) = delete;
167 
168 
169  // IOstream Operators
170 
171  //- Ostream operator
172  friend Ostream& operator<<
173  (
174  Ostream& os,
175  const fvConstraints& constraints
176  );
177 };
178 
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 //- Template function for obtaining global status
183 template<>
184 inline bool typeGlobal<fvConstraints>()
185 {
186  return true;
187 }
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #ifdef NoRepository
193  #include "fvConstraintsTemplates.C"
194 #endif
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
TypeName("fvConstraints")
Runtime type information.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual bool constrainsField(const word &fieldName) const
Return true if an fvConstraint constrains the given field.
virtual bool movePoints()
Update for mesh motion.
Generic GeometricField class.
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:87
virtual bool read()
Read the fvConstraints dictionary if it has changed.
Template dictionary class which manages the storage associated with it.
virtual bool writeData(Ostream &os) const
Write data to Ostream.
Foam::fvConstraints & fvConstraints
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
fvConstraints(const fvMesh &mesh)
Construct from components with list of field names.
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
virtual ~fvConstraints()
Destructor.
void operator=(const fvConstraints &)=delete
Disallow default bitwise assignment.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
bool typeGlobal< fvConstraints >()
Template function for obtaining global status.
Finite volume constraints.
Definition: fvConstraints.H:57
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
Ostream & operator<<(Ostream &, const ensightPart &)
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 global() const
Declare fvConstraints to be a global dictionary.
rDeltaTY field()
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
Namespace for OpenFOAM.
virtual bool readData(Istream &)
ReadData function which reads the fvConstraints dictionary.