$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 #include "libmesh/diff_solver.h" 00020 #include "libmesh/diff_system.h" 00021 #include "libmesh/steady_solver.h" 00022 00023 namespace libMesh 00024 { 00025 00026 00027 00028 SteadySolver::~SteadySolver () 00029 { 00030 } 00031 00032 00033 00034 bool SteadySolver::element_residual(bool request_jacobian, 00035 DiffContext& context) 00036 { 00037 return this->_general_residual(request_jacobian, 00038 context, 00039 &DifferentiablePhysics::element_time_derivative, 00040 &DifferentiablePhysics::element_constraint); 00041 } 00042 00043 00044 00045 bool SteadySolver::side_residual(bool request_jacobian, 00046 DiffContext& context) 00047 { 00048 return this->_general_residual(request_jacobian, 00049 context, 00050 &DifferentiablePhysics::side_time_derivative, 00051 &DifferentiablePhysics::side_constraint); 00052 } 00053 00054 00055 00056 bool SteadySolver::nonlocal_residual(bool request_jacobian, 00057 DiffContext& context) 00058 { 00059 return this->_general_residual(request_jacobian, 00060 context, 00061 &DifferentiablePhysics::nonlocal_time_derivative, 00062 &DifferentiablePhysics::nonlocal_constraint); 00063 } 00064 00065 00066 00067 bool SteadySolver::_general_residual(bool request_jacobian, 00068 DiffContext& context, 00069 ResFuncType time_deriv, 00070 ResFuncType constraint) 00071 { 00072 // If a fixed solution is requested, it will just be the current 00073 // solution 00074 if (_system.use_fixed_solution) 00075 { 00076 context.get_elem_fixed_solution() = context.get_elem_solution(); 00077 context.fixed_solution_derivative = 1.0; 00078 } 00079 00080 bool jacobian_computed = 00081 (_system.*time_deriv)(request_jacobian, context); 00082 00083 // The user shouldn't compute a jacobian unless requested 00084 libmesh_assert (request_jacobian || !jacobian_computed); 00085 00086 bool jacobian_computed2 = 00087 (_system.*constraint)(jacobian_computed, context); 00088 00089 // The user shouldn't compute a jacobian unless requested 00090 libmesh_assert (jacobian_computed || !jacobian_computed2); 00091 00092 return jacobian_computed2; 00093 } 00094 00095 00096 } // namespace libMesh