fvConstraint.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-2024 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::fvConstraint
26 
27 Description
28  Finite volume options abstract base class.
29 
30 SourceFiles
31  fvConstraint.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef fvConstraint_H
36 #define fvConstraint_H
37 
38 #include "fvMatricesFwd.H"
39 #include "volFieldsFwd.H"
40 #include "dictionary.H"
41 #include "fvConstraintM.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 class fvMesh;
49 class polyTopoChangeMap;
50 class polyMeshMap;
51 class polyDistributionMap;
52 
53 /*---------------------------------------------------------------------------*\
54  Class option Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class fvConstraint
58 {
59  // Private Member Data
60 
61  //- Constraint name
62  const word name_;
63 
64  //- Constraint type
65  const word constraintType_;
66 
67  //- Reference to the mesh database
68  const fvMesh& mesh_;
69 
70 
71  // Private Member Functions
72 
73  //- Apply a constraint to an equation
74  template<class Type>
75  bool constrainType
76  (
77  fvMatrix<Type>& eqn,
78  const word& fieldName
79  ) const;
80 
81  //- Apply constraint to a field
82  template<class Type>
83  bool constrainType(VolField<Type>& field) const;
84 
85 
86 public:
87 
88  //- Runtime type information
89  TypeName("fvConstraint");
90 
91 
92  // Declare run-time constructor selection table
93 
95  (
96  autoPtr,
98  dictionary,
99  (
100  const word& name,
101  const word& constraintType,
102  const fvMesh& mesh,
103  const dictionary& dict
104  ),
105  (name, constraintType, mesh, dict)
106  );
107 
108 
109  // Constructors
110 
111  //- Construct from components
113  (
114  const word& name,
115  const word& constraintType,
116  const fvMesh& mesh,
117  const dictionary& dict
118  );
119 
120  //- Return clone
122  {
124  return autoPtr<fvConstraint>(nullptr);
125  }
126 
127  //- Return pointer to new fvConstraint object created
128  // on the freestore from an Istream
129  class iNew
130  {
131  //- Reference to the mesh
132  const fvMesh& mesh_;
133 
134  const word& name_;
135 
136  public:
137 
138  iNew
139  (
140  const fvMesh& mesh,
141  const word& name
142  )
143  :
144  mesh_(mesh),
145  name_(name)
146  {}
147 
149  {
150  // const word name(is);
151  const dictionary dict(is);
152 
153  return autoPtr<fvConstraint>
154  (
155  fvConstraint::New(name_, mesh_, dict)
156  );
157  }
158  };
159 
160 
161  // Selectors
162 
163  //- Return a reference to the selected fvConstraint
165  (
166  const word& name,
167  const fvMesh& mesh,
168  const dictionary& dict
169  );
170 
171 
172  //- Destructor
173  virtual ~fvConstraint();
174 
175 
176  // Member Functions
177 
178  // Access
179 
180  //- Return const access to the source name
181  inline const word& name() const;
182 
183  //- Return const access to the mesh database
184  inline const fvMesh& mesh() const;
185 
186  //- Return the coefficients sub-dictionary
187  inline const dictionary& coeffs(const dictionary&) const;
188 
189 
190  // Checks
191 
192  //- Return the list of constrained fields
193  virtual wordList constrainedFields() const;
194 
195  //- Return true if the given field is constrained
196  virtual bool constrainsField(const word& fieldName) const;
197 
198 
199  // Constraints
200 
201  //- Apply a constraint to an equation
203 
204  //- Apply constraint to a field
206 
207 
208  // Mesh changes
209 
210  //- Update for mesh motion
211  virtual bool movePoints() = 0;
212 
213  //- Update topology using the given map
214  virtual void topoChange(const polyTopoChangeMap&) = 0;
215 
216  //- Update from another mesh using the given map
217  virtual void mapMesh(const polyMeshMap&) = 0;
218 
219  //- Redistribute or update using the given distribution map
220  virtual void distribute(const polyDistributionMap&) = 0;
221 
222 
223  // IO
224 
225  //- Read source dictionary
226  virtual bool read(const dictionary& dict);
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace Foam
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #include "fvConstraintI.H"
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #endif
241 
242 // ************************************************************************* //
Generic GeometricField class.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Return pointer to new fvConstraint object created.
Definition: fvConstraint.H:129
autoPtr< fvConstraint > operator()(Istream &is) const
Definition: fvConstraint.H:147
iNew(const fvMesh &mesh, const word &name)
Definition: fvConstraint.H:138
Finite volume options abstract base class.
Definition: fvConstraint.H:57
virtual void mapMesh(const polyMeshMap &)=0
Update from another mesh using the given map.
virtual bool movePoints()=0
Update for mesh motion.
virtual void distribute(const polyDistributionMap &)=0
Redistribute or update using the given distribution map.
fvConstraint(const word &name, const word &constraintType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
Definition: fvConstraint.C:61
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvConstraint.C:164
const dictionary & coeffs(const dictionary &) const
Return the coefficients sub-dictionary.
Definition: fvConstraintI.H:41
virtual bool constrainsField(const word &fieldName) const
Return true if the given field is constrained.
Definition: fvConstraint.C:152
FOR_ALL_FIELD_TYPES(DEFINE_FV_CONSTRAINT_CONSTRAIN)
Apply a constraint to an equation.
virtual wordList constrainedFields() const
Return the list of constrained fields.
Definition: fvConstraint.C:146
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvConstraintI.H:34
const word & name() const
Return const access to the source name.
Definition: fvConstraintI.H:28
declareRunTimeSelectionTable(autoPtr, fvConstraint, dictionary,(const word &name, const word &constraintType, const fvMesh &mesh, const dictionary &dict),(name, constraintType, mesh, dict))
TypeName("fvConstraint")
Runtime type information.
autoPtr< fvConstraint > clone() const
Return clone.
Definition: fvConstraint.H:120
virtual ~fvConstraint()
Destructor.
Definition: fvConstraint.C:140
static autoPtr< fvConstraint > New(const word &name, const fvMesh &mesh, const dictionary &dict)
Return a reference to the selected fvConstraint.
Definition: fvConstraint.C:80
virtual void topoChange(const polyTopoChangeMap &)=0
Update topology using the given map.
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:96
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
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
#define DEFINE_FV_CONSTRAINT_CONSTRAIN_FIELD(Type, nullArg)
Definition: fvConstraintM.H:46
#define DEFINE_FV_CONSTRAINT_CONSTRAIN(Type, nullArg)
Definition: fvConstraintM.H:26
Forward declarations of fvMatrix specialisations.
Namespace for OpenFOAM.
dictionary dict