motionSolver.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::motionSolver
29 
30 Description
31  Virtual base class for mesh motion solver.
32 
33 SourceFiles
34  motionSolver.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef motionSolver_H
39 #define motionSolver_H
40 
41 #include "IOdictionary.H"
42 #include "pointField.H"
43 
44 #include "Time.H"
45 #include "polyMesh.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class mapPolyMesh;
54 
55 /*---------------------------------------------------------------------------*\
56  Class motionSolver Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class motionSolver
60 :
61  public IOdictionary
62 {
63  // Private Data
64 
65  //- Reference to mesh
66  const polyMesh& mesh_;
67 
68  //- Model coefficients dictionary
69  dictionary coeffDict_;
70 
71 
72 protected:
73 
74  // Protected Member Functions
75 
76  //- De-register object if registered and assign to current
78 
79 
80 public:
81 
82  //- Runtime type information
83  TypeName("motionSolver");
84 
85 
86  // Declare run-time constructor selection tables
87 
89  (
90  autoPtr,
92  dictionary,
93  (const polyMesh& mesh, const IOdictionary& dict),
94  (mesh, dict)
95  );
96 
97 
98  // Selectors
99 
100  //- Select constructed from polyMesh
101  static autoPtr<motionSolver> New(const polyMesh&);
102 
103  //- Select constructed from polyMesh and dictionary. If dictionary
104  // was registered this will 'steal' that registration.
105  static autoPtr<motionSolver> New(const polyMesh&, const IOdictionary&);
106 
107  //- Class used for the construction of PtrLists of motionSolvers
108  class iNew
109  {
110  const polyMesh& mesh_;
111 
112  public:
113 
114  iNew(const polyMesh& mesh);
115 
117  };
119 
120 
121  // Constructors
122 
123  //- Construct from polyMesh
124  motionSolver(const polyMesh& mesh);
125 
126  //- Construct from polyMesh and dictionary and type.
128  (
129  const polyMesh& mesh,
130  const IOdictionary&,
131  const word& type
132  );
133 
134  //- Clone function
135  virtual autoPtr<motionSolver> clone() const;
136 
137 
138  //- Destructor
139  virtual ~motionSolver() = default;
140 
141 
142  // Member Functions
143 
144  //- Return reference to mesh
145  const polyMesh& mesh() const
146  {
147  return mesh_;
148  }
149 
150  //- Const access to the coefficients dictionary
151  const dictionary& coeffDict() const
152  {
153  return coeffDict_;
154  }
155 
156  //- Provide new points for motion. Solves for motion
157  virtual tmp<pointField> newPoints();
158 
159  //- Provide current points for motion. Uses current motion field
160  virtual tmp<pointField> curPoints() const = 0;
161 
162  virtual void twoDCorrectPoints(pointField&) const;
163 
164  //- Solve for motion
165  virtual void solve() = 0;
166 
167  //- Update local data for geometry changes
168  virtual void movePoints(const pointField&) = 0;
169 
170  //- Update local data for topology changes
171  virtual void updateMesh(const mapPolyMesh&) = 0;
172 
173  //- Write state using stream options
174  virtual bool writeObject
175  (
176  IOstreamOption streamOpt,
177  const bool writeOnProc
178  ) const;
179 
180  //- Read dynamicMeshDict dictionary
181  virtual bool read();
182 };
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
Class used for the construction of PtrLists of motionSolvers.
Definition: motionSolver.H:118
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write state using stream options.
Definition: motionSolver.C:211
dictionary dict
virtual tmp< pointField > newPoints()
Provide new points for motion. Solves for motion.
Definition: motionSolver.C:193
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
autoPtr< motionSolver > operator()(Istream &is) const
Definition: motionSolver.C:168
Virtual base class for mesh motion solver.
Definition: motionSolver.H:54
static autoPtr< motionSolver > New(const polyMesh &)
Select constructed from polyMesh.
Definition: motionSolver.C:143
A simple container for options an IOstream can normally have.
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
Definition: motionSolver.H:173
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
virtual void updateMesh(const mapPolyMesh &)=0
Update local data for topology changes.
Definition: motionSolver.C:206
iNew(const polyMesh &mesh)
Definition: motionSolver.C:161
virtual void movePoints(const pointField &)=0
Update local data for geometry changes.
A class for handling words, derived from Foam::string.
Definition: word.H:63
motionSolver(const polyMesh &mesh)
Construct from polyMesh.
Definition: motionSolver.C:58
static IOobject stealRegistration(const IOdictionary &dict)
De-register object if registered and assign to current.
Definition: motionSolver.C:40
virtual void solve()=0
Solve for motion.
virtual ~motionSolver()=default
Destructor.
virtual bool read()
Read dynamicMeshDict dictionary.
Definition: motionSolver.C:220
virtual tmp< pointField > curPoints() const =0
Provide current points for motion. Uses current motion field.
declareRunTimeSelectionTable(autoPtr, motionSolver, dictionary,(const polyMesh &mesh, const IOdictionary &dict),(mesh, dict))
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const polyMesh & mesh() const
Return reference to mesh.
Definition: motionSolver.H:165
A class for managing temporary objects.
Definition: HashPtrTable.H:50
TypeName("motionSolver")
Runtime type information.
virtual autoPtr< motionSolver > clone() const
Clone function.
Definition: motionSolver.C:88
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
virtual void twoDCorrectPoints(pointField &) const
Definition: motionSolver.C:200
Namespace for OpenFOAM.