$extrastylesheet
time_solver.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_TIME_SOLVER_H
00021 #define LIBMESH_TIME_SOLVER_H
00022 
00023 // Local includes
00024 #include "libmesh/auto_ptr.h"
00025 #include "libmesh/libmesh_common.h"
00026 #include "libmesh/linear_solver.h"
00027 #include "libmesh/numeric_vector.h"
00028 #include "libmesh/reference_counted_object.h"
00029 #include "libmesh/solution_history.h"
00030 
00031 // C++ includes
00032 
00033 namespace libMesh
00034 {
00035 
00036 // Forward Declarations
00037 class DiffContext;
00038 class DiffSolver;
00039 class DifferentiablePhysics;
00040 class DifferentiableSystem;
00041 class ParameterVector;
00042 class SystemNorm;
00043 
00058 // ------------------------------------------------------------
00059 // Solver class definition
00060 class TimeSolver : public ReferenceCountedObject<TimeSolver>
00061 {
00062 public:
00066   typedef DifferentiableSystem sys_type;
00067 
00072   explicit
00073   TimeSolver (sys_type& s);
00074 
00078   virtual ~TimeSolver ();
00079 
00084   virtual void init ();
00085 
00091   virtual void init_data ();
00092 
00097   virtual void reinit ();
00098 
00105   virtual void solve ();
00106 
00113   virtual void advance_timestep ();
00114 
00120   virtual void adjoint_advance_timestep ();
00121 
00126   virtual void retrieve_timestep();
00127 
00137   virtual bool element_residual (bool request_jacobian,
00138                                  DiffContext &) = 0;
00139 
00149   virtual bool side_residual (bool request_jacobian,
00150                               DiffContext &) = 0;
00151 
00161   virtual bool nonlocal_residual (bool request_jacobian,
00162                                   DiffContext &) = 0;
00163 
00168   virtual void before_timestep () {}
00169 
00173   const sys_type & system () const { return _system; }
00174 
00178   sys_type & system () { return _system; }
00179 
00183   virtual UniquePtr<DiffSolver> &diff_solver() { return _diff_solver; }
00184 
00188   virtual UniquePtr<LinearSolver<Number> > &linear_solver() { return _linear_solver; }
00189 
00193   bool quiet;
00194 
00204   virtual Real du(const SystemNorm& norm) const = 0;
00205 
00209   virtual bool is_steady() const = 0;
00210 
00221   unsigned int reduce_deltat_on_diffsolver_failure;
00222 
00227   void set_solution_history(const SolutionHistory & _solution_history);
00228 
00233   bool is_adjoint() const
00234   { return _is_adjoint; }
00235 
00240   void set_is_adjoint(bool _is_adjoint_value)
00241   { _is_adjoint = _is_adjoint_value; }
00242 
00243 protected:
00244 
00248   UniquePtr<DiffSolver> _diff_solver;
00249 
00253   UniquePtr<LinearSolver<Number> > _linear_solver;
00254 
00258   sys_type& _system;
00259 
00263   UniquePtr<NumericVector<Number> > old_local_nonlinear_solution;
00264 
00270   UniquePtr<SolutionHistory> solution_history;
00271 
00276   typedef bool (DifferentiablePhysics::*ResFuncType) (bool, DiffContext &);
00277 
00278   typedef void (DiffContext::*ReinitFuncType) (Real);
00279 
00280 private:
00281 
00286   bool _is_adjoint;
00287 
00288 };
00289 
00290 
00291 } // namespace libMesh
00292 
00293 
00294 #endif // LIBMESH_TIME_SOLVER_H