$extrastylesheet
time_solver.C
Go to the documentation of this file.
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 #include "libmesh/diff_solver.h"
00019 #include "libmesh/diff_system.h"
00020 #include "libmesh/linear_solver.h"
00021 #include "libmesh/time_solver.h"
00022 #include "libmesh/no_solution_history.h"
00023 
00024 namespace libMesh
00025 {
00026 
00027 
00028 
00029 TimeSolver::TimeSolver (sys_type& s)
00030   : quiet (true),
00031     reduce_deltat_on_diffsolver_failure (0),
00032     _diff_solver (),
00033     _linear_solver (),
00034     _system (s),
00035     solution_history(new NoSolutionHistory()), // Default setting for solution_history
00036     _is_adjoint (false)
00037 {
00038 }
00039 
00040 
00041 
00042 TimeSolver::~TimeSolver ()
00043 {
00044 }
00045 
00046 
00047 
00048 void TimeSolver::reinit ()
00049 {
00050   libmesh_assert(this->diff_solver().get());
00051   libmesh_assert_equal_to (&(this->diff_solver()->system()), &(this->system()));
00052   this->diff_solver()->reinit();
00053 
00054   libmesh_assert(this->linear_solver().get());
00055   this->linear_solver()->clear();
00056   if (libMesh::on_command_line("--solver_system_names"))
00057     this->linear_solver()->init((_system.name()+"_").c_str());
00058   else
00059     this->linear_solver()->init();
00060 }
00061 
00062 
00063 
00064 void TimeSolver::init ()
00065 {
00066   // If the user hasn't given us a solver to use,
00067   // just build a default solver
00068   if (this->diff_solver().get() == NULL)
00069     this->diff_solver() = DiffSolver::build(_system);
00070 
00071   if (this->linear_solver().get() == NULL)
00072     this->linear_solver() = LinearSolver<Number>::build(_system.comm());
00073 }
00074 
00075 
00076 
00077 void TimeSolver::init_data ()
00078 {
00079   this->diff_solver()->init();
00080 
00081   if (libMesh::on_command_line("--solver_system_names"))
00082     this->linear_solver()->init((_system.name()+"_").c_str());
00083   else
00084     this->linear_solver()->init();
00085 }
00086 
00087 
00088 
00089 void TimeSolver::solve ()
00090 {
00091   libmesh_assert(this->diff_solver().get());
00092   libmesh_assert_equal_to (&(this->diff_solver()->system()), &(this->system()));
00093   this->diff_solver()->solve();
00094 }
00095 
00096 
00097 void TimeSolver::set_solution_history (const SolutionHistory & _solution_history)
00098 {
00099   solution_history = _solution_history.clone();
00100 }
00101 
00102 void TimeSolver::advance_timestep ()
00103 {
00104 }
00105 
00106 void TimeSolver::adjoint_advance_timestep ()
00107 {
00108 }
00109 
00110 void TimeSolver::retrieve_timestep ()
00111 {
00112 }
00113 
00114 } // namespace libMesh