adaptive_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 
19 #include "libmesh/diff_system.h"
20 #include "libmesh/numeric_vector.h"
21 
22 namespace libMesh
23 {
24 
25 
26 
29  core_time_solver(),
30  target_tolerance(1.e-3),
31  upper_tolerance(0.0),
32  max_deltat(0.),
33  min_deltat(0.),
34  max_growth(0.),
35  global_tolerance(true)
36 {
37  // the child class must populate core_time_solver
38  // with whatever actual time solver is to be used
39 
40  // As an UnsteadySolver, we have an old_local_nonlinear_solution, but we're
41  // going to drop it and use our core time solver's instead.
43 }
44 
45 
46 
48 {
49  // As an UnsteadySolver, we have an old_local_nonlinear_solution, but it
50  // is being managed by our core_time_solver. Make sure we don't delete
51  // it out from under them, in case the user wants to keep using the core
52  // solver after they're done with us.
54 }
55 
56 
57 
59 {
60  libmesh_assert(core_time_solver.get());
61 
62  // We override this because our core_time_solver is the one that
63  // needs to handle new vectors, diff_solver->init(), etc
64  core_time_solver->init();
65 
66  // As an UnsteadySolver, we have an old_local_nonlinear_solution, but it
67  // isn't pointing to the right place - fix it
68  //
69  // This leaves us with two std::unique_ptrs holding the same pointer - dangerous
70  // for future use. Replace with shared_ptr?
72  std::unique_ptr<NumericVector<Number>>(core_time_solver->old_local_nonlinear_solution.get());
73 }
74 
75 
76 
78 {
79  libmesh_assert(core_time_solver.get());
80 
81  // We override this because our core_time_solver is the one that
82  // needs to handle new vectors, diff_solver->reinit(), etc
83  core_time_solver->reinit();
84 }
85 
86 
88 {
89  NumericVector<Number> & old_nonlinear_soln =
90  _system.get_vector("_old_nonlinear_solution");
91  NumericVector<Number> & nonlinear_solution =
92  *(_system.solution);
93 
94  old_nonlinear_soln = nonlinear_solution;
95 
96  if (!first_solve)
98 }
99 
100 
101 
103 {
104  libmesh_assert(core_time_solver.get());
105 
106  return core_time_solver->error_order();
107 }
108 
109 
110 
111 bool AdaptiveTimeSolver::element_residual (bool request_jacobian,
112  DiffContext & context)
113 {
114  libmesh_assert(core_time_solver.get());
115 
116  return core_time_solver->element_residual(request_jacobian, context);
117 }
118 
119 
120 
121 bool AdaptiveTimeSolver::side_residual (bool request_jacobian,
122  DiffContext & context)
123 {
124  libmesh_assert(core_time_solver.get());
125 
126  return core_time_solver->side_residual(request_jacobian, context);
127 }
128 
129 
130 
131 bool AdaptiveTimeSolver::nonlocal_residual (bool request_jacobian,
132  DiffContext & context)
133 {
134  libmesh_assert(core_time_solver.get());
135 
136  return core_time_solver->nonlocal_residual(request_jacobian, context);
137 }
138 
139 
140 
141 std::unique_ptr<DiffSolver> & AdaptiveTimeSolver::diff_solver()
142 {
143  return core_time_solver->diff_solver();
144 }
145 
146 
147 
148 std::unique_ptr<LinearSolver<Number>> & AdaptiveTimeSolver::linear_solver()
149 {
150  return core_time_solver->linear_solver();
151 }
152 
153 
154 
157 {
158  return s.calculate_norm(v, component_norm);
159 }
160 
161 } // namespace libMesh
virtual Real calculate_norm(System &, NumericVector< Number > &)
std::unique_ptr< NumericVector< Number > > old_local_nonlinear_solution
virtual bool side_residual(bool get_jacobian, DiffContext &) override
virtual Real error_order() const override
virtual std::unique_ptr< DiffSolver > & diff_solver() override
sys_type & _system
Definition: time_solver.h:258
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:92
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1378
virtual bool nonlocal_residual(bool get_jacobian, DiffContext &) override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void reinit() override
virtual void advance_timestep() override
virtual bool element_residual(bool get_jacobian, DiffContext &) override
std::unique_ptr< UnsteadySolver > core_time_solver
virtual std::unique_ptr< LinearSolver< Number > > & linear_solver() override
virtual void init() override