libMesh
steady_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 
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_residual(bool request_jacobian, DiffContext &) libmesh_override
This method uses the DifferentiablePhysics' side_time_derivative() and side_constraint() to build a f...
Definition: steady_solver.C:45
virtual bool side_constraint(bool request_jacobian, DiffContext &)
Adds the constraint contribution on side of elem to elem_residual.
Definition: diff_physics.h:190
virtual bool nonlocal_residual(bool request_jacobian, DiffContext &) libmesh_override
This method uses the DifferentiablePhysics' nonlocal_time_derivative() and nonlocal_constraint() to b...
Definition: steady_solver.C:56
Real fixed_solution_derivative
The derivative of elem_fixed_solution with respect to the nonlinear solution, for use by systems cons...
Definition: diff_context.h:504
const DenseVector< Number > & get_elem_solution() const
Accessor for element solution.
Definition: diff_context.h:110
This class provides all data required for a physics package (e.g.
Definition: diff_context.h:54
virtual bool element_time_derivative(bool request_jacobian, DiffContext &)
Adds the time derivative contribution on elem to elem_residual.
Definition: diff_physics.h:123
virtual ~SteadySolver()
Destructor.
Definition: steady_solver.C:28
const DenseVector< Number > & get_elem_fixed_solution() const
Accessor for element fixed solution.
Definition: diff_context.h:214
virtual bool nonlocal_time_derivative(bool request_jacobian, DiffContext &)
Adds any nonlocal time derivative contributions (e.g.
Definition: diff_physics.h:208
The libMesh namespace provides an interface to certain functionality in the library.
virtual bool nonlocal_constraint(bool request_jacobian, DiffContext &)
Adds any nonlocal constraint contributions (e.g.
Definition: diff_physics.h:226
libmesh_assert(j)
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:257
bool use_fixed_solution
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e...
Definition: system.h:1493
bool(DifferentiablePhysics::* ResFuncType)(bool, DiffContext &)
Definitions of argument types for use in refactoring subclasses.
Definition: time_solver.h:270
virtual bool element_residual(bool request_jacobian, DiffContext &) libmesh_override
This method uses the DifferentiablePhysics&#39; element_time_derivative() and element_constraint() to bui...
Definition: steady_solver.C:34
virtual bool _general_residual(bool request_jacobian, DiffContext &, ResFuncType time_deriv, ResFuncType constraint)
This method is the underlying implementation of the public residual methods.
Definition: steady_solver.C:67
const DifferentiablePhysics * get_physics() const
Definition: diff_system.h:169
virtual bool side_time_derivative(bool request_jacobian, DiffContext &)
Adds the time derivative contribution on side of elem to elem_residual.
Definition: diff_physics.h:170
virtual bool element_constraint(bool request_jacobian, DiffContext &)
Adds the constraint contribution on elem to elem_residual.
Definition: diff_physics.h:141