time_solver.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_TIME_SOLVER_H
21 #define LIBMESH_TIME_SOLVER_H
22 
23 // Local includes
24 #include "libmesh/auto_ptr.h" // deprecated
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/linear_solver.h"
27 #include "libmesh/numeric_vector.h"
30 
31 // C++ includes
32 #include <memory>
33 
34 namespace libMesh
35 {
36 
37 // Forward Declarations
38 class DiffContext;
39 class DiffSolver;
40 class DifferentiablePhysics;
41 class DifferentiableSystem;
42 class ParameterVector;
43 class SystemNorm;
44 
59 class TimeSolver : public ReferenceCountedObject<TimeSolver>
60 {
61 public:
66 
71  explicit
72  TimeSolver (sys_type & s);
73 
77  virtual ~TimeSolver ();
78 
83  virtual void init ();
84 
90  virtual void init_data ();
91 
96  virtual void reinit ();
97 
104  virtual void solve ();
105 
112  virtual void advance_timestep ();
113 
119  virtual void adjoint_advance_timestep ();
120 
125  virtual void retrieve_timestep();
126 
136  virtual bool element_residual (bool request_jacobian,
137  DiffContext &) = 0;
138 
148  virtual bool side_residual (bool request_jacobian,
149  DiffContext &) = 0;
150 
160  virtual bool nonlocal_residual (bool request_jacobian,
161  DiffContext &) = 0;
162 
167  virtual void before_timestep () {}
168 
172  const sys_type & system () const { return _system; }
173 
177  sys_type & system () { return _system; }
178 
182  virtual std::unique_ptr<DiffSolver> & diff_solver() { return _diff_solver; }
183 
187  virtual std::unique_ptr<LinearSolver<Number>> & linear_solver() { return _linear_solver; }
188 
192  bool quiet;
193 
203  virtual Real du(const SystemNorm & norm) const = 0;
204 
208  virtual bool is_steady() const = 0;
209 
222 
227  void set_solution_history(const SolutionHistory & _solution_history);
228 
233  bool is_adjoint() const
234  { return _is_adjoint; }
235 
240  void set_is_adjoint(bool _is_adjoint_value)
241  { _is_adjoint = _is_adjoint_value; }
242 
243 protected:
244 
248  std::unique_ptr<DiffSolver> _diff_solver;
249 
253  std::unique_ptr<LinearSolver<Number>> _linear_solver;
254 
259 
265  std::unique_ptr<SolutionHistory> solution_history;
266 
271  typedef bool (DifferentiablePhysics::*ResFuncType) (bool, DiffContext &);
272 
273  typedef void (DiffContext::*ReinitFuncType) (Real);
274 
275 private:
276 
282 
283 };
284 
285 
286 } // namespace libMesh
287 
288 
289 #endif // LIBMESH_TIME_SOLVER_H
virtual bool side_residual(bool request_jacobian, DiffContext &)=0
std::unique_ptr< DiffSolver > _diff_solver
Definition: time_solver.h:248
virtual void advance_timestep()
Definition: time_solver.C:102
virtual void init_data()
Definition: time_solver.C:77
std::unique_ptr< SolutionHistory > solution_history
Definition: time_solver.h:265
virtual void reinit()
Definition: time_solver.C:48
virtual bool is_steady() const =0
void(DiffContext::* ReinitFuncType)(Real)
Definition: time_solver.h:273
virtual bool nonlocal_residual(bool request_jacobian, DiffContext &)=0
virtual std::unique_ptr< DiffSolver > & diff_solver()
Definition: time_solver.h:182
For storing and retrieving timestep data.
const sys_type & system() const
Definition: time_solver.h:172
virtual bool element_residual(bool request_jacobian, DiffContext &)=0
sys_type & _system
Definition: time_solver.h:258
void set_is_adjoint(bool _is_adjoint_value)
Definition: time_solver.h:240
TimeSolver(sys_type &s)
Definition: time_solver.C:29
virtual void init()
Definition: time_solver.C:64
bool is_adjoint() const
Definition: time_solver.h:233
bool(DifferentiablePhysics::* ResFuncType)(bool, DiffContext &)
Definition: time_solver.h:271
sys_type & system()
Definition: time_solver.h:177
unsigned int reduce_deltat_on_diffsolver_failure
Definition: time_solver.h:221
virtual void retrieve_timestep()
Definition: time_solver.C:110
std::unique_ptr< LinearSolver< Number > > _linear_solver
Definition: time_solver.h:253
virtual void before_timestep()
Definition: time_solver.h:167
DifferentiableSystem sys_type
Definition: time_solver.h:65
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_solution_history(const SolutionHistory &_solution_history)
Definition: time_solver.C:97
virtual std::unique_ptr< LinearSolver< Number > > & linear_solver()
Definition: time_solver.h:187
virtual ~TimeSolver()
Definition: time_solver.C:42
virtual void adjoint_advance_timestep()
Definition: time_solver.C:106
virtual Real du(const SystemNorm &norm) const =0
virtual void solve()
Definition: time_solver.C:89