35 #include "libmesh/dirichlet_boundaries.h"
36 #include "libmesh/dof_map.h"
37 #include "libmesh/getpot.h"
38 #include "libmesh/euler_solver.h"
39 #include "libmesh/twostep_time_solver.h"
49 _n_timesteps( input(
"unsteady-solver/n_timesteps", 1 ) ),
50 _backtrack_deltat( input(
"unsteady-solver/backtrack_deltat", 0 ) ),
51 _theta( input(
"unsteady-solver/theta", 0.5 ) ),
53 _deltat( input(
"unsteady-solver/deltat", 0.0 ) ),
54 _target_tolerance( input(
"unsteady-solver/target_tolerance", 0.0 ) ),
55 _upper_tolerance( input(
"unsteady-solver/upper_tolerance", 0.0 ) ),
56 _max_growth( input(
"unsteady-solver/max_growth", 0.0 ) )
58 const unsigned int n_component_norm =
59 input.vector_variable_size(
"unsteady-solver/component_norm");
60 for (
unsigned int i=0; i != n_component_norm; ++i)
62 const std::string current_norm = input(
"component_norm", std::string(
"L2"), i);
64 if (current_norm ==
"GRINSEnums::L2")
66 else if (current_norm ==
"GRINSEnums::H1")
69 libmesh_not_implemented();
82 libMesh::EulerSolver* time_solver =
new libMesh::EulerSolver( *(system) );
86 libMesh::TwostepTimeSolver *outer_solver =
87 new libMesh::TwostepTimeSolver(*system);
92 outer_solver->quiet =
false;
94 outer_solver->core_time_solver =
95 libMesh::AutoPtr<libMesh::UnsteadySolver>(time_solver);
96 system->time_solver = libMesh::AutoPtr<libMesh::TimeSolver>(outer_solver);
100 system->time_solver = libMesh::AutoPtr<libMesh::TimeSolver>(time_solver);
104 time_solver->theta = this->
_theta;
112 libmesh_assert( context.
system );
116 libMesh::Real sim_time;
124 std::time_t first_wall_time = std::time(NULL);
128 for (
unsigned int t_step=0; t_step < this->
_n_timesteps; t_step++)
130 std::time_t latest_wall_time = std::time(NULL);
132 std::cout <<
"==========================================================" << std::endl
133 <<
" Beginning time step " << t_step <<
134 ", t = " << context.
system->time <<
135 ", dt = " << context.
system->deltat <<
136 ", runtime = " << (latest_wall_time - first_wall_time) <<
138 <<
"==========================================================" << std::endl;
144 bool have_nonlinear_dirichlet_bc =
false;
146 const libMesh::DirichletBoundaries &db =
147 *context.
system->get_dof_map().get_dirichlet_boundaries();
148 for (libMesh::DirichletBoundaries::const_iterator
149 it = db.begin(); it != db.end(); ++it)
151 const libMesh::DirichletBoundary* bdy = *it;
152 if (bdy->f_fem.get())
154 have_nonlinear_dirichlet_bc =
true;
159 if (have_nonlinear_dirichlet_bc)
160 context.
system->get_equation_systems().reinit();
165 sim_time = context.
system->time;
179 libMesh::perflog.print_log();
182 for (
unsigned int v=0; v != context.
system->n_vars(); ++v)
183 if (context.
system->variable(v).type().family ==
186 std::cout << context.
system->variable_name(v) <<
188 std::vector<libMesh::dof_id_type> scalar_indices;
189 context.
system->get_dof_map().SCALAR_dof_indices
191 if (scalar_indices.size())
193 context.
system->current_solution(scalar_indices[0]);
194 for (
unsigned int i=1; i < scalar_indices.size();
197 context.
system->current_solution(scalar_indices[i]);
198 std::cout <<
'}' << std::endl;
202 context.
system->time_solver->advance_timestep();
205 std::time_t final_wall_time = std::time(NULL);
206 std::cout <<
"==========================================================" << std::endl
207 <<
" Ending time stepping, t = " << context.
system->time <<
208 ", runtime = " << (final_wall_time - first_wall_time) <<
210 <<
"==========================================================" << std::endl;
unsigned int _n_timesteps
UnsteadySolver(const GetPot &input)
std::tr1::shared_ptr< libMesh::EquationSystems > equation_system
unsigned int timesteps_per_perflog
virtual void init_time_solver(GRINS::MultiphysicsSystem *system)
unsigned int timesteps_per_vis
unsigned int _backtrack_deltat
GRINS::MultiphysicsSystem * system
Interface with libMesh for solving Multiphysics problems.
std::tr1::shared_ptr< PostProcessedQuantities< libMesh::Real > > postprocessing
virtual void solve(SolverContext &context)
libMesh::SystemNorm _component_norm
std::tr1::shared_ptr< GRINS::Visualization > vis
Simple class to hold objects passed to Solver::solve.
virtual ~UnsteadySolver()