time_solver.C
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 #include "libmesh/diff_solver.h"
19 #include "libmesh/diff_system.h"
20 #include "libmesh/linear_solver.h"
21 #include "libmesh/time_solver.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() == nullptr)
70 
71  if (this->linear_solver().get() == 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 void advance_timestep()
Definition: time_solver.C:102
static std::unique_ptr< LinearSolver< T > > build(const libMesh::Parallel::Communicator &comm_in, const SolverPackage solver_package=libMesh::default_solver_package())
Definition: linear_solver.C:57
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
const Parallel::Communicator & comm() const
static std::unique_ptr< DiffSolver > build(sys_type &s)
Definition: diff_solver.C:53
virtual std::unique_ptr< SolutionHistory > clone() const =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
sys_type & _system
Definition: time_solver.h:258
TimeSolver(sys_type &s)
Definition: time_solver.C:29
For storing and retrieving timestep data.
virtual void init()
Definition: time_solver.C:64
virtual void retrieve_timestep()
Definition: time_solver.C:110
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
bool on_command_line(std::string arg)
Definition: libmesh.C:876
virtual void adjoint_advance_timestep()
Definition: time_solver.C:106
const std::string & name() const
Definition: system.h:2017
virtual void solve()
Definition: time_solver.C:89