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 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  //- Return complete path + object name if the file exists
114  // either in the case/processor or case otherwise null
115  virtual fileName filePath() const
116  {
117  return globalFilePath(type());
118  }
119 
120 
121  // Checks
122 
123  //- Return true if an fvConstraint constrains the given field
124  virtual bool constrainsField(const word& fieldName) const;
125 
126 
127  // Constraints
128 
129  //- Apply constraints to an equation
130  template<class Type>
131  bool constrain(fvMatrix<Type>& eqn) const;
132 
133  //- Apply constraints to a field
134  template<class Type>
135  bool constrain
136  (
138  ) const;
139 
140 
141  // Mesh changes
142 
143  //- Update for mesh changes
144  virtual void updateMesh(const mapPolyMesh&);
145 
146  //- Update for mesh motion
147  virtual bool movePoints();
148 
149 
150  // IO
151 
152  //- ReadData function which reads the fvConstraints dictionary
153  // required for regIOobject read operation
154  virtual bool readData(Istream&);
155 
156  //- Write data to Ostream
157  virtual bool writeData(Ostream& os) const;
158 
159  //- Read the fvConstraints dictionary if it has changed
160  // and update the constraints
161  virtual bool read();
162 
163 
164  // Member Operators
165 
166  //- Disallow default bitwise assignment
167  void operator=(const fvConstraints&) = delete;
168 
169 
170  // IOstream Operators
171 
172  //- Ostream operator
173  friend Ostream& operator<<
174  (
175  Ostream& os,
176  const fvConstraints& constraints
177  );
178 };
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 //- Template function for obtaining global status
184 template<>
185 inline bool typeGlobal<fvConstraints>()
186 {
187  return true;
188 }
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #ifdef NoRepository
194  #include "fvConstraintsTemplates.C"
195 #endif
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #endif
205 
206 // ************************************************************************* //
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
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
A class for handling file names.
Definition: fileName.H:79
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.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:85
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
fileName globalFilePath(const word &typeName) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:392
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
virtual fileName filePath() const
Return complete path + object name if the file exists.
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.
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:78
Ostream & operator<<(Ostream &, const ensightPart &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
virtual bool global() const
Declare fvConstraints to be a global dictionary.
rDeltaTY field()
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.
virtual bool readData(Istream &)
ReadData function which reads the fvConstraints dictionary.