Home
About Us
Publications
Developers
Installation
Examples
Documentation
SomeWebsiteLogo
Home
About Us
Publications
Developers
Installation
Examples
Documentation
src
solvers
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
"
22
#include "
libmesh/no_solution_history.h
"
23
24
namespace
libMesh
25
{
26
27
28
29
TimeSolver::TimeSolver
(
sys_type
& s)
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
42
TimeSolver::~TimeSolver
()
43
{
44
}
45
46
47
48
void
TimeSolver::reinit
()
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
64
void
TimeSolver::init
()
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
)
69
this->
diff_solver
() =
DiffSolver::build
(
_system
);
70
71
if
(this->
linear_solver
().
get
() ==
nullptr
)
72
this->
linear_solver
() =
LinearSolver<Number>::build
(
_system
.
comm
());
73
}
74
75
76
77
void
TimeSolver::init_data
()
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
89
void
TimeSolver::solve
()
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
102
void
TimeSolver::advance_timestep
()
103
{
104
}
105
106
void
TimeSolver::adjoint_advance_timestep
()
107
{
108
}
109
110
void
TimeSolver::retrieve_timestep
()
111
{
112
}
113
114
}
// namespace libMesh
no_solution_history.h
libMesh::TimeSolver::advance_timestep
virtual void advance_timestep()
Definition:
time_solver.C:102
libMesh::LinearSolver::build
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
libMesh::TimeSolver::init_data
virtual void init_data()
Definition:
time_solver.C:77
libMesh::TimeSolver::solution_history
std::unique_ptr< SolutionHistory > solution_history
Definition:
time_solver.h:265
linear_solver.h
libMesh::TimeSolver::reinit
virtual void reinit()
Definition:
time_solver.C:48
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition:
parallel_object.h:89
time_solver.h
libMesh
Definition:
default_coupling.C:31
libMesh::DiffSolver::build
static std::unique_ptr< DiffSolver > build(sys_type &s)
Definition:
diff_solver.C:53
libMesh::SolutionHistory::clone
virtual std::unique_ptr< SolutionHistory > clone() const =0
libMesh::TimeSolver::diff_solver
virtual std::unique_ptr< DiffSolver > & diff_solver()
Definition:
time_solver.h:182
libMesh::SolutionHistory
For storing and retrieving timestep data.
Definition:
solution_history.h:35
libMesh::TimeSolver::system
const sys_type & system() const
Definition:
time_solver.h:172
diff_solver.h
libMesh::DifferentiableSystem
Definition:
diff_system.h:54
libMesh::TimeSolver::_system
sys_type & _system
Definition:
time_solver.h:258
libMesh::TimeSolver::TimeSolver
TimeSolver(sys_type &s)
Definition:
time_solver.C:29
libMesh::NoSolutionHistory
For storing and retrieving timestep data.
Definition:
no_solution_history.h:35
libMesh::TimeSolver::init
virtual void init()
Definition:
time_solver.C:64
libMesh::TimeSolver::retrieve_timestep
virtual void retrieve_timestep()
Definition:
time_solver.C:110
libMesh::TimeSolver::set_solution_history
void set_solution_history(const SolutionHistory &_solution_history)
Definition:
time_solver.C:97
libMesh::TimeSolver::linear_solver
virtual std::unique_ptr< LinearSolver< Number > > & linear_solver()
Definition:
time_solver.h:187
libMesh::TimeSolver::~TimeSolver
virtual ~TimeSolver()
Definition:
time_solver.C:42
libMesh::on_command_line
bool on_command_line(std::string arg)
Definition:
libmesh.C:876
libMesh::TimeSolver::adjoint_advance_timestep
virtual void adjoint_advance_timestep()
Definition:
time_solver.C:106
libMesh::System::name
const std::string & name() const
Definition:
system.h:2017
diff_system.h
libMesh::TimeSolver::solve
virtual void solve()
Definition:
time_solver.C:89
generated by