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 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 mapPolyMesh;
50 
51 /*---------------------------------------------------------------------------*\
52  Class option Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class fvConstraint
56 {
57  // Private Member Data
58 
59  //- Constraint name
60  const word name_;
61 
62  //- Constraint type
63  const word constraintType_;
64 
65  //- Reference to the mesh database
66  const fvMesh& mesh_;
67 
68  //- Top level source dictionary
69  dictionary dict_;
70 
71  //- Dictionary containing source coefficients
72  dictionary coeffs_;
73 
74 
75  // Private Member Functions
76 
77  //- Apply a constraint to an equation
78  template<class Type>
79  bool constrainType
80  (
81  fvMatrix<Type>& eqn,
82  const word& fieldName
83  ) const;
84 
85  //- Apply constraint to a field
86  template<class Type>
87  bool constrainType(VolField<Type>& field) const;
88 
89 
90 public:
91 
92  //- Runtime type information
93  TypeName("fvConstraint");
94 
95 
96  // Declare run-time constructor selection table
97 
99  (
100  autoPtr,
101  fvConstraint,
102  dictionary,
103  (
104  const word& name,
105  const word& constraintType,
106  const dictionary& dict,
107  const fvMesh& mesh
108  ),
109  (name, constraintType, dict, mesh)
110  );
111 
112 
113  // Constructors
114 
115  //- Construct from components
117  (
118  const word& name,
119  const word& constraintType,
120  const dictionary& dict,
121  const fvMesh& mesh
122  );
123 
124  //- Return clone
126  {
128  return autoPtr<fvConstraint>(nullptr);
129  }
130 
131  //- Return pointer to new fvConstraint object created
132  // on the freestore from an Istream
133  class iNew
134  {
135  //- Reference to the mesh
136  const fvMesh& mesh_;
137 
138  const word& name_;
139 
140  public:
141 
143  (
144  const fvMesh& mesh,
145  const word& name
146  )
147  :
148  mesh_(mesh),
149  name_(name)
150  {}
153  {
154  // const word name(is);
155  const dictionary dict(is);
156 
157  return autoPtr<fvConstraint>
158  (
159  fvConstraint::New(name_, dict, mesh_)
160  );
161  }
162  };
163 
164 
165  // Selectors
166 
167  //- Return a reference to the selected fvConstraint
169  (
170  const word& name,
171  const dictionary& dict,
172  const fvMesh& mesh
173  );
174 
175 
176  //- Destructor
177  virtual ~fvConstraint();
178 
179 
180  // Member Functions
181 
182  // Access
183 
184  //- Return const access to the source name
185  inline const word& name() const;
186 
187  //- Return const access to the mesh database
188  inline const fvMesh& mesh() const;
189 
190  //- Return dictionary
191  inline const dictionary& coeffs() const;
192 
193 
194  // Checks
195 
196  //- Return the list of constrained fields
197  virtual wordList constrainedFields() const;
198 
199  //- Return true if the given field is constrained
200  virtual bool constrainsField(const word& fieldName) const;
201 
202 
203  // Constraints
204 
205  //- Apply a constraint to an equation
207 
208  //- Apply contraint to a field
210 
211 
212  // Mesh changes
213 
214  //- Update for mesh changes
215  virtual void updateMesh(const mapPolyMesh&);
216 
217  //- Update for mesh motion
218  virtual bool movePoints();
219 
220 
221  // IO
222 
223  //- Read source dictionary
224  virtual bool read(const dictionary& dict);
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #include "fvConstraintI.H"
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
dictionary dict
autoPtr< fvConstraint > clone() const
Return clone.
Definition: fvConstraint.H:124
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvConstraintI.H:34
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
declareRunTimeSelectionTable(autoPtr, fvConstraint, dictionary,(const word &name, const word &constraintType, const dictionary &dict, const fvMesh &mesh),(name, constraintType, dict, mesh))
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
Definition: fvConstraint.C:151
autoPtr< fvConstraint > operator()(Istream &is) const
Definition: fvConstraint.H:151
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
static autoPtr< fvConstraint > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvConstraint.
Definition: fvConstraint.C:82
#define DEFINE_FV_CONSTRAINT_CONSTRAIN_FIELD(Type, nullArg)
Definition: fvConstraintM.H:46
virtual wordList constrainedFields() const
Return the list of constrained fields.
Definition: fvConstraint.C:125
const dictionary & coeffs() const
Return dictionary.
Definition: fvConstraintI.H:40
Generic GeometricField class.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual bool constrainsField(const word &fieldName) const
Return true if the given field is constrained.
Definition: fvConstraint.C:131
#define DEFINE_FV_CONSTRAINT_CONSTRAIN(Type, nullArg)
Definition: fvConstraintM.H:26
iNew(const fvMesh &mesh, const word &name)
Definition: fvConstraint.H:142
const word & name() const
Return const access to the source name.
Definition: fvConstraintI.H:28
fvConstraint(const word &name, const word &constraintType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvConstraint.C:61
A class for handling words, derived from string.
Definition: word.H:59
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 bool movePoints()
Update for mesh motion.
Definition: fvConstraint.C:155
FOR_ALL_FIELD_TYPES(DEFINE_FV_CONSTRAINT_CONSTRAIN)
Apply a constraint to an equation.
Forward declarations of fvMatrix specialisations.
TypeName("fvConstraint")
Runtime type information.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvConstraint.C:143
rDeltaTY field()
virtual ~fvConstraint()
Destructor.
Definition: fvConstraint.C:119
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:370
Return pointer to new fvConstraint object created.
Definition: fvConstraint.H:132
Finite volume options abstract base class.
Definition: fvConstraint.H:54
Namespace for OpenFOAM.