adaptive_time_solver.C
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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 #include "libmesh/adaptive_time_solver.h" 00019 #include "libmesh/diff_system.h" 00020 #include "libmesh/numeric_vector.h" 00021 00022 namespace libMesh 00023 { 00024 00025 00026 00027 AdaptiveTimeSolver::AdaptiveTimeSolver (sys_type& s) 00028 : UnsteadySolver(s), 00029 core_time_solver(NULL), 00030 target_tolerance(1.e-3), upper_tolerance(0.0), 00031 max_deltat(0.), 00032 min_deltat(0.), 00033 max_growth(0.), 00034 global_tolerance(true) 00035 { 00036 // the child class must populate core_time_solver 00037 // with whatever actual time solver is to be used 00038 00039 // As an UnsteadySolver, we have an old_local_nonlinear_solution, but we're 00040 // going to drop it and use our core time solver's instead. 00041 old_local_nonlinear_solution.reset(); 00042 } 00043 00044 00045 00046 AdaptiveTimeSolver::~AdaptiveTimeSolver () 00047 { 00048 // As an UnsteadySolver, we have an old_local_nonlinear_solution, but it 00049 // is being managed by our core_time_solver. Make sure we don't delete 00050 // it out from under them, in case the user wants to keep using the core 00051 // solver after they're done with us. 00052 old_local_nonlinear_solution.release(); 00053 } 00054 00055 00056 00057 void AdaptiveTimeSolver::init() 00058 { 00059 libmesh_assert(core_time_solver.get()); 00060 00061 // We override this because our core_time_solver is the one that 00062 // needs to handle new vectors, diff_solver->init(), etc 00063 core_time_solver->init(); 00064 00065 // As an UnsteadySolver, we have an old_local_nonlinear_solution, but it 00066 // isn't pointing to the right place - fix it 00067 // 00068 // This leaves us with two AutoPtrs holding the same pointer - dangerous 00069 // for future use. Replace with shared_ptr? 00070 old_local_nonlinear_solution = 00071 AutoPtr<NumericVector<Number> >(core_time_solver->old_local_nonlinear_solution.get()); 00072 } 00073 00074 00075 00076 void AdaptiveTimeSolver::reinit() 00077 { 00078 libmesh_assert(core_time_solver.get()); 00079 00080 // We override this because our core_time_solver is the one that 00081 // needs to handle new vectors, diff_solver->reinit(), etc 00082 core_time_solver->reinit(); 00083 } 00084 00085 00086 void AdaptiveTimeSolver::advance_timestep () 00087 { 00088 NumericVector<Number> &old_nonlinear_soln = 00089 _system.get_vector("_old_nonlinear_solution"); 00090 NumericVector<Number> &nonlinear_solution = 00091 *(_system.solution); 00092 // _system.get_vector("_nonlinear_solution"); 00093 00094 old_nonlinear_soln = nonlinear_solution; 00095 00096 if (!first_solve) 00097 _system.time += last_deltat; 00098 } 00099 00100 00101 00102 Real AdaptiveTimeSolver::error_order () const 00103 { 00104 libmesh_assert(core_time_solver.get()); 00105 00106 return core_time_solver->error_order(); 00107 } 00108 00109 00110 00111 bool AdaptiveTimeSolver::element_residual (bool request_jacobian, 00112 DiffContext &context) 00113 { 00114 libmesh_assert(core_time_solver.get()); 00115 00116 return core_time_solver->element_residual(request_jacobian, context); 00117 } 00118 00119 00120 00121 bool AdaptiveTimeSolver::side_residual (bool request_jacobian, 00122 DiffContext &context) 00123 { 00124 libmesh_assert(core_time_solver.get()); 00125 00126 return core_time_solver->side_residual(request_jacobian, context); 00127 } 00128 00129 00130 00131 AutoPtr<DiffSolver> & AdaptiveTimeSolver::diff_solver() 00132 { 00133 return core_time_solver->diff_solver(); 00134 } 00135 00136 00137 00138 Real AdaptiveTimeSolver::calculate_norm(System &s, 00139 NumericVector<Number> &v) 00140 { 00141 return s.calculate_norm(v, component_norm); 00142 } 00143 00144 } // namespace libMesh
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:45 UTC
Hosted By: