steady_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 
19 #include "libmesh/diff_solver.h"
20 #include "libmesh/diff_system.h"
21 #include "libmesh/steady_solver.h"
22 
23 namespace libMesh
24 {
25 
26 
27 
29 {
30 }
31 
32 
33 
34 bool SteadySolver::element_residual(bool request_jacobian,
35  DiffContext & context)
36 {
37  return this->_general_residual(request_jacobian,
38  context,
41 }
42 
43 
44 
45 bool SteadySolver::side_residual(bool request_jacobian,
46  DiffContext & context)
47 {
48  return this->_general_residual(request_jacobian,
49  context,
52 }
53 
54 
55 
56 bool SteadySolver::nonlocal_residual(bool request_jacobian,
57  DiffContext & context)
58 {
59  return this->_general_residual(request_jacobian,
60  context,
63 }
64 
65 
66 
67 bool SteadySolver::_general_residual(bool request_jacobian,
68  DiffContext & context,
69  ResFuncType time_deriv,
70  ResFuncType constraint)
71 {
72  // If a fixed solution is requested, it will just be the current
73  // solution
75  {
76  context.get_elem_fixed_solution() = context.get_elem_solution();
77  context.fixed_solution_derivative = 1.0;
78  }
79 
80  bool jacobian_computed =
81  (_system.get_physics()->*time_deriv)(request_jacobian, context);
82 
83  // The user shouldn't compute a jacobian unless requested
84  libmesh_assert (request_jacobian || !jacobian_computed);
85 
86  bool jacobian_computed2 =
87  (_system.get_physics()->*constraint)(jacobian_computed, context);
88 
89  // The user shouldn't compute a jacobian unless requested
90  libmesh_assert (jacobian_computed || !jacobian_computed2);
91 
92  return jacobian_computed2;
93 }
94 
95 
96 } // namespace libMesh
virtual bool side_constraint(bool request_jacobian, DiffContext &)
Definition: diff_physics.h:191
virtual bool element_time_derivative(bool request_jacobian, DiffContext &)
Definition: diff_physics.h:124
const DenseVector< Number > & get_elem_fixed_solution() const
Definition: diff_context.h:215
virtual bool nonlocal_time_derivative(bool request_jacobian, DiffContext &)
Definition: diff_physics.h:209
virtual bool nonlocal_constraint(bool request_jacobian, DiffContext &)
Definition: diff_physics.h:227
sys_type & _system
Definition: time_solver.h:258
const DenseVector< Number > & get_elem_solution() const
Definition: diff_context.h:111
bool use_fixed_solution
Definition: system.h:1493
virtual bool _general_residual(bool request_jacobian, DiffContext &, ResFuncType time_deriv, ResFuncType constraint)
Definition: steady_solver.C:67
const DifferentiablePhysics * get_physics() const
Definition: diff_system.h:182
virtual bool nonlocal_residual(bool request_jacobian, DiffContext &) override
Definition: steady_solver.C:56
virtual bool element_residual(bool request_jacobian, DiffContext &) override
Definition: steady_solver.C:34
virtual bool side_residual(bool request_jacobian, DiffContext &) override
Definition: steady_solver.C:45
virtual bool side_time_derivative(bool request_jacobian, DiffContext &)
Definition: diff_physics.h:171
virtual bool element_constraint(bool request_jacobian, DiffContext &)
Definition: diff_physics.h:142