libMesh
time_solver.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 #include "libmesh/diff_solver.h"
19 #include "libmesh/diff_system.h"
20 #include "libmesh/linear_solver.h"
21 #include "libmesh/time_solver.h"
22 #include "libmesh/no_solution_history.h"
23 
24 namespace libMesh
25 {
26 
27 
28 
30  : quiet (true),
31  reduce_deltat_on_diffsolver_failure (0),
32  _diff_solver (),
33  _linear_solver (),
34  _system (s),
35  solution_history(new NoSolutionHistory()), // Default setting for solution_history
36  _is_adjoint (false)
37 {
38 }
39 
40 
41 
43 {
44 }
45 
46 
47 
49 {
50  libmesh_assert(this->diff_solver().get());
51  libmesh_assert_equal_to (&(this->diff_solver()->system()), &(this->system()));
52  this->diff_solver()->reinit();
53 
54  libmesh_assert(this->linear_solver().get());
55  this->linear_solver()->clear();
56  if (libMesh::on_command_line("--solver_system_names"))
57  this->linear_solver()->init((_system.name()+"_").c_str());
58  else
59  this->linear_solver()->init();
60 }
61 
62 
63 
65 {
66  // If the user hasn't given us a solver to use,
67  // just build a default solver
68  if (this->diff_solver().get() == libmesh_nullptr)
70 
71  if (this->linear_solver().get() == libmesh_nullptr)
73 }
74 
75 
76 
78 {
79  this->diff_solver()->init();
80 
81  if (libMesh::on_command_line("--solver_system_names"))
82  this->linear_solver()->init((_system.name()+"_").c_str());
83  else
84  this->linear_solver()->init();
85 }
86 
87 
88 
90 {
91  libmesh_assert(this->diff_solver().get());
92  libmesh_assert_equal_to (&(this->diff_solver()->system()), &(this->system()));
93  this->diff_solver()->solve();
94 }
95 
96 
97 void TimeSolver::set_solution_history (const SolutionHistory & _solution_history)
98 {
99  solution_history = _solution_history.clone();
100 }
101 
103 {
104 }
105 
107 {
108 }
109 
111 {
112 }
113 
114 } // namespace libMesh
virtual UniquePtr< DiffSolver > & diff_solver()
An implicit linear or nonlinear solver to use at each timestep.
Definition: time_solver.h:181
virtual void advance_timestep()
This method advances the solution to the next timestep, after a solve() has been performed.
Definition: time_solver.C:102
virtual void init_data()
The data initialization function.
Definition: time_solver.C:77
static UniquePtr< LinearSolver< T > > build(const libMesh::Parallel::Communicator &comm_in, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a LinearSolver using the linear solver package specified by solver_package.
Definition: linear_solver.C:42
virtual UniquePtr< SolutionHistory > clone() const =0
Cloning function for a UniquePtr, pure virtual, used in the setter function in time_solver.C.
static UniquePtr< DiffSolver > build(sys_type &s)
Factory method.
Definition: diff_solver.C:53
virtual void reinit()
The reinitialization function.
Definition: time_solver.C:48
const class libmesh_nullptr_t libmesh_nullptr
The libMesh namespace provides an interface to certain functionality in the library.
const std::string & name() const
Definition: system.h:1998
A SolutionHistory class that enables the storage and retrieval of timesteps and (in the future) adapt...
libmesh_assert(j)
This class provides a specific system class.
Definition: diff_system.h:53
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:257
TimeSolver(sys_type &s)
Constructor.
Definition: time_solver.C:29
&#39;Save nothing&#39; subclass of Solution History, this is the default.
virtual void init()
The initialization function.
Definition: time_solver.C:64
const sys_type & system() const
Definition: time_solver.h:171
virtual void retrieve_timestep()
This method retrieves all the stored solutions at the current system.time.
Definition: time_solver.C:110
void set_solution_history(const SolutionHistory &_solution_history)
A setter function users will employ if they need to do something other than save no solution history...
Definition: time_solver.C:97
bool on_command_line(const std::string &arg)
Definition: libmesh.C:921
virtual UniquePtr< LinearSolver< Number > > & linear_solver()
An implicit linear solver to use for adjoint and sensitivity problems.
Definition: time_solver.h:186
const Parallel::Communicator & comm() const
virtual ~TimeSolver()
Destructor.
Definition: time_solver.C:42
virtual void adjoint_advance_timestep()
This method advances the adjoint solution to the previous timestep, after an adjoint_solve() has been...
Definition: time_solver.C:106
virtual void solve()
This method solves for the solution at the next timestep (or solves for a steady-state solution)...
Definition: time_solver.C:89
UniquePtr< SolutionHistory > solution_history
A UniquePtr to a SolutionHistory object.
Definition: time_solver.h:264