All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-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::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  //- Top level source dictionary
71  dictionary dict_;
72 
73  //- Dictionary containing source coefficients
74  dictionary coeffs_;
75 
76 
77  // Private Member Functions
78 
79  //- Apply a constraint to an equation
80  template<class Type>
81  bool constrainType
82  (
83  fvMatrix<Type>& eqn,
84  const word& fieldName
85  ) const;
86 
87  //- Apply constraint to a field
88  template<class Type>
89  bool constrainType(VolField<Type>& field) const;
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("fvConstraint");
96 
97 
98  // Declare run-time constructor selection table
99 
101  (
102  autoPtr,
103  fvConstraint,
104  dictionary,
105  (
106  const word& name,
107  const word& constraintType,
108  const fvMesh& mesh,
109  const dictionary& dict
110  ),
111  (name, constraintType, mesh, dict)
112  );
113 
114 
115  // Constructors
116 
117  //- Construct from components
119  (
120  const word& name,
121  const word& constraintType,
122  const fvMesh& mesh,
123  const dictionary& dict
124  );
125 
126  //- Return clone
128  {
130  return autoPtr<fvConstraint>(nullptr);
131  }
132 
133  //- Return pointer to new fvConstraint object created
134  // on the freestore from an Istream
135  class iNew
136  {
137  //- Reference to the mesh
138  const fvMesh& mesh_;
139 
140  const word& name_;
141 
142  public:
143 
144  iNew
145  (
146  const fvMesh& mesh,
147  const word& name
148  )
149  :
150  mesh_(mesh),
151  name_(name)
152  {}
153 
155  {
156  // const word name(is);
157  const dictionary dict(is);
158 
159  return autoPtr<fvConstraint>
160  (
161  fvConstraint::New(name_, mesh_, dict)
162  );
163  }
164  };
165 
166 
167  // Selectors
168 
169  //- Return a reference to the selected fvConstraint
171  (
172  const word& name,
173  const fvMesh& mesh,
174  const dictionary& dict
175  );
176 
177 
178  //- Destructor
179  virtual ~fvConstraint();
180 
181 
182  // Member Functions
183 
184  // Access
185 
186  //- Return const access to the source name
187  inline const word& name() const;
188 
189  //- Return const access to the mesh database
190  inline const fvMesh& mesh() const;
191 
192  //- Return dictionary
193  inline const dictionary& coeffs() const;
194 
195 
196  // Checks
197 
198  //- Return the list of constrained fields
199  virtual wordList constrainedFields() const;
200 
201  //- Return true if the given field is constrained
202  virtual bool constrainsField(const word& fieldName) const;
203 
204 
205  // Constraints
206 
207  //- Apply a constraint to an equation
209 
210  //- Apply constraint to a field
212 
213 
214  // Mesh changes
215 
216  //- Update for mesh motion
217  virtual bool movePoints() = 0;
218 
219  //- Update topology using the given map
220  virtual void topoChange(const polyTopoChangeMap&) = 0;
221 
222  //- Update from another mesh using the given map
223  virtual void mapMesh(const polyMeshMap&) = 0;
224 
225  //- Redistribute or update using the given distribution map
226  virtual void distribute(const polyDistributionMap&) = 0;
227 
228 
229  // IO
230 
231  //- Read source dictionary
232  virtual bool read(const dictionary& dict);
233 };
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace Foam
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #include "fvConstraintI.H"
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #endif
247 
248 // ************************************************************************* //
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Return pointer to new fvConstraint object created.
Definition: fvConstraint.H:135
autoPtr< fvConstraint > operator()(Istream &is) const
Definition: fvConstraint.H:153
iNew(const fvMesh &mesh, const word &name)
Definition: fvConstraint.H:144
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.
const dictionary & coeffs() const
Return dictionary.
Definition: fvConstraintI.H:40
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:166
virtual bool constrainsField(const word &fieldName) const
Return true if the given field is constrained.
Definition: fvConstraint.C:154
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:148
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:126
virtual ~fvConstraint()
Destructor.
Definition: fvConstraint.C:142
static autoPtr< fvConstraint > New(const word &name, const fvMesh &mesh, const dictionary &dict)
Return a reference to the selected fvConstraint.
Definition: fvConstraint.C:82
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: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
#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