GRINS-0.7.0
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
GRINS::UnsteadySolver Class Reference

#include <grins_unsteady_solver.h>

Inheritance diagram for GRINS::UnsteadySolver:
Inheritance graph
[legend]
Collaboration diagram for GRINS::UnsteadySolver:
Collaboration graph
[legend]

Public Member Functions

 UnsteadySolver (const GetPot &input)
 
virtual ~UnsteadySolver ()
 
virtual void solve (SolverContext &context)
 
- Public Member Functions inherited from GRINS::Solver
 Solver (const GetPot &input)
 
virtual ~Solver ()
 
virtual void initialize (const GetPot &input, SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system)
 
virtual void adjoint_qoi_parameter_sensitivity (SolverContext &, const libMesh::QoISet &, const libMesh::ParameterVector &, libMesh::SensitivityData &) const
 
virtual void forward_qoi_parameter_sensitivity (SolverContext &, const libMesh::QoISet &, const libMesh::ParameterVector &, libMesh::SensitivityData &) const
 
void steady_adjoint_solve (SolverContext &context)
 Do steady version of adjoint solve. More...
 
void print_scalar_vars (SolverContext &context)
 
void print_qoi (SolverContext &context, std::ostream &output)
 

Protected Member Functions

virtual void init_time_solver (GRINS::MultiphysicsSystem *system)
 
template<typename T >
void set_theta (libMesh::UnsteadySolver *time_solver)
 
void update_dirichlet_bcs (SolverContext &context)
 Updates Dirichlet boundary conditions. More...
 
void init_second_order_in_time_solvers (SolverContext &context)
 
- Protected Member Functions inherited from GRINS::Solver
void set_solver_options (libMesh::DiffSolver &solver)
 

Protected Attributes

std::string _time_solver_name
 
unsigned int _n_timesteps
 
unsigned int _backtrack_deltat
 
double _theta
 
double _deltat
 
AdaptiveTimeSteppingOptions _adapt_time_step_options
 
bool _is_second_order_in_time
 Track whether is this a second order (in time) solver or not. More...
 
- Protected Attributes inherited from GRINS::Solver
unsigned int _max_nonlinear_iterations
 
double _relative_step_tolerance
 
double _absolute_step_tolerance
 
double _relative_residual_tolerance
 
double _absolute_residual_tolerance
 
double _initial_linear_tolerance
 
double _minimum_linear_tolerance
 
unsigned int _max_linear_iterations
 
bool _continue_after_backtrack_failure
 
bool _continue_after_max_iterations
 
bool _require_residual_reduction
 
bool _solver_quiet
 
bool _solver_verbose
 

Detailed Description

Definition at line 39 of file grins_unsteady_solver.h.

Constructor & Destructor Documentation

GRINS::UnsteadySolver::UnsteadySolver ( const GetPot &  input)

Definition at line 52 of file grins_unsteady_solver.C.

53  : Solver(input),
61  {}
static unsigned int parse_n_timesteps(const GetPot &input)
Solver(const GetPot &input)
Definition: grins_solver.C:48
static unsigned int parse_backtrack_deltat(const GetPot &input)
Parse option to retry failed time steps with smaller .
static std::string parse_time_stepper_name(const GetPot &input)
AdaptiveTimeSteppingOptions _adapt_time_step_options
bool _is_second_order_in_time
Track whether is this a second order (in time) solver or not.
static double parse_theta(const GetPot &input)
Parse value of for theta method time stepping.
static double parse_deltat(const GetPot &input)
virtual GRINS::UnsteadySolver::~UnsteadySolver ( )
inlinevirtual

Definition at line 44 of file grins_unsteady_solver.h.

44 {};

Member Function Documentation

void GRINS::UnsteadySolver::init_second_order_in_time_solvers ( SolverContext context)
protected

Definition at line 226 of file grins_unsteady_solver.C.

References GRINS::SolverContext::have_restart, and GRINS::SolverContext::system.

Referenced by solve().

227  {
228  // Right now, only Newmark is available so we cast directly to that
229  libMesh::TimeSolver& base_time_solver = context.system->get_time_solver();
230 
231  libMesh::NewmarkSolver& time_solver = libMesh::libmesh_cast_ref<libMesh::NewmarkSolver&>(base_time_solver);
232 
233  // If there's a restart, the acceleration should already be there
234  if( context.have_restart )
235  time_solver.set_initial_accel_avail(true);
236 
237  // Otherwise, we need to compute it
238  else
239  {
240  libMesh::out << "==========================================================" << std::endl
241  << " Computing Initital Acceleration" << std::endl
242  << "==========================================================" << std::endl;
243 
244  time_solver.compute_initial_accel();
245  }
246  }
void GRINS::UnsteadySolver::init_time_solver ( GRINS::MultiphysicsSystem system)
protectedvirtual

Implements GRINS::Solver.

Definition at line 63 of file grins_unsteady_solver.C.

References _adapt_time_step_options, _backtrack_deltat, _is_second_order_in_time, _time_solver_name, GRINS::AdaptiveTimeSteppingOptions::component_norm(), GRINS::AdaptiveTimeSteppingOptions::is_time_adaptive(), GRINS::SolverNames::libmesh_euler2_solver(), GRINS::SolverNames::libmesh_euler_solver(), GRINS::SolverNames::libmesh_newmark_solver(), GRINS::AdaptiveTimeSteppingOptions::max_growth(), GRINS::AdaptiveTimeSteppingOptions::target_tolerance(), and GRINS::AdaptiveTimeSteppingOptions::upper_tolerance().

64  {
65  libMesh::UnsteadySolver* time_solver = NULL;
66 
68  {
69  time_solver = new libMesh::EulerSolver( *(system) );
70 
71  this->set_theta<libMesh::EulerSolver>(time_solver);
72  }
74  {
75  time_solver = new libMesh::Euler2Solver( *(system) );
76 
77  this->set_theta<libMesh::Euler2Solver>(time_solver);
78  }
80  {
81  time_solver = new libMesh::NewmarkSolver( *(system) );
83  }
84  else
85  libmesh_error_msg("ERROR: Unsupported time stepper "+_time_solver_name);
86 
88  {
89  libMesh::TwostepTimeSolver *outer_solver =
90  new libMesh::TwostepTimeSolver(*system);
91 
92  outer_solver->target_tolerance = _adapt_time_step_options.target_tolerance();
93  outer_solver->upper_tolerance = _adapt_time_step_options.upper_tolerance();
94  outer_solver->max_growth = _adapt_time_step_options.max_growth();
95  outer_solver->component_norm = _adapt_time_step_options.component_norm();
96  outer_solver->quiet = false;
97 
98  outer_solver->core_time_solver =
99  libMesh::UniquePtr<libMesh::UnsteadySolver>(time_solver);
100  system->time_solver = libMesh::UniquePtr<libMesh::TimeSolver>(outer_solver);
101  }
102  else
103  {
104  system->time_solver = libMesh::UniquePtr<libMesh::TimeSolver>(time_solver);
105  }
106 
107  time_solver->reduce_deltat_on_diffsolver_failure = this->_backtrack_deltat;
108  }
static const std::string libmesh_euler2_solver()
Definition: solver_names.h:49
AdaptiveTimeSteppingOptions _adapt_time_step_options
bool _is_second_order_in_time
Track whether is this a second order (in time) solver or not.
static const std::string libmesh_euler_solver()
Definition: solver_names.h:46
static const std::string libmesh_newmark_solver()
Definition: solver_names.h:52
template<typename T >
void GRINS::UnsteadySolver::set_theta ( libMesh::UnsteadySolver *  time_solver)
inlineprotected

Definition at line 80 of file grins_unsteady_solver.h.

References _theta.

81  {
82  T* deriv_solver = libMesh::libmesh_cast_ptr<T*>(time_solver);
83  deriv_solver->theta = this->_theta;
84  }
void GRINS::UnsteadySolver::solve ( SolverContext context)
virtual

Implements GRINS::Solver.

Reimplemented in GRINS::UnsteadyMeshAdaptiveSolver.

Definition at line 110 of file grins_unsteady_solver.C.

References _deltat, _is_second_order_in_time, _n_timesteps, GRINS::SolverContext::equation_system, init_second_order_in_time_solvers(), GRINS::SolverContext::output_residual, GRINS::SolverContext::output_vis, GRINS::SolverContext::postprocessing, GRINS::SolverContext::print_perflog, GRINS::Solver::print_scalar_vars(), GRINS::SolverContext::print_scalars, GRINS::SolverContext::system, GRINS::SolverContext::timesteps_per_perflog, GRINS::SolverContext::timesteps_per_vis, update_dirichlet_bcs(), and GRINS::SolverContext::vis.

111  {
112  libmesh_assert( context.system );
113 
114  context.system->deltat = this->_deltat;
115 
116  libMesh::Real sim_time;
117 
118  if( context.output_vis )
119  {
120  context.postprocessing->update_quantities( *(context.equation_system) );
121  context.vis->output( context.equation_system );
122  }
123 
124  // We may need to initialize acceleration for second order solvers
126  this->init_second_order_in_time_solvers(context);
127 
128  std::time_t first_wall_time = std::time(NULL);
129 
130  // Now we begin the timestep loop to compute the time-accurate
131  // solution of the equations.
132  for (unsigned int t_step=0; t_step < this->_n_timesteps; t_step++)
133  {
134  std::time_t latest_wall_time = std::time(NULL);
135 
136  std::cout << "==========================================================" << std::endl
137  << " Beginning time step " << t_step <<
138  ", t = " << context.system->time <<
139  ", dt = " << context.system->deltat <<
140  ", runtime = " << (latest_wall_time - first_wall_time) <<
141  std::endl
142  << "==========================================================" << std::endl;
143 
144  // If we have any solution-dependent Dirichlet boundaries, we
145  // need to update them with the current solution.
146  this->update_dirichlet_bcs(context);
147 
148  // GRVY timers contained in here (if enabled)
149  context.system->solve();
150 
151  sim_time = context.system->time;
152 
153  if( context.output_vis && !((t_step+1)%context.timesteps_per_vis) )
154  {
155  context.postprocessing->update_quantities( *(context.equation_system) );
156  context.vis->output( context.equation_system, t_step, sim_time );
157  }
158 
159  if( context.output_residual && !((t_step+1)%context.timesteps_per_vis) )
160  context.vis->output_residual( context.equation_system, context.system,
161  t_step, sim_time );
162 
163  if ( context.print_perflog && context.timesteps_per_perflog
164  && !((t_step+1)%context.timesteps_per_perflog) )
165  libMesh::perflog.print_log();
166 
167  if ( context.print_scalars )
168  this->print_scalar_vars(context);
169 
170  // Advance to the next timestep
171  context.system->time_solver->advance_timestep();
172  }
173 
174  std::time_t final_wall_time = std::time(NULL);
175  std::cout << "==========================================================" << std::endl
176  << " Ending time stepping, t = " << context.system->time <<
177  ", runtime = " << (final_wall_time - first_wall_time) <<
178  std::endl
179  << "==========================================================" << std::endl;
180 
181 
182  return;
183  }
bool _is_second_order_in_time
Track whether is this a second order (in time) solver or not.
void print_scalar_vars(SolverContext &context)
Definition: grins_solver.C:133
void update_dirichlet_bcs(SolverContext &context)
Updates Dirichlet boundary conditions.
void init_second_order_in_time_solvers(SolverContext &context)
void GRINS::UnsteadySolver::update_dirichlet_bcs ( SolverContext context)
protected

Updates Dirichlet boundary conditions.

If the Dirichlet boundary condition is nonlinear or time-dependent, we need to update the constraints with the new solution.

Definition at line 185 of file grins_unsteady_solver.C.

References GRINS::SolverContext::system.

Referenced by solve(), and GRINS::UnsteadyMeshAdaptiveSolver::solve().

186  {
187  // FIXME: This needs to be much more efficient and intuitive.
188  bool have_nonlinear_dirichlet_bc = false;
189  bool have_time_dependence = false;
190  {
191  const libMesh::DirichletBoundaries &db =
192  *context.system->get_dof_map().get_dirichlet_boundaries();
193 
194  for (libMesh::DirichletBoundaries::const_iterator
195  it = db.begin(); it != db.end(); ++it)
196  {
197  const libMesh::DirichletBoundary* bdy = *it;
198 
199  // If we have a FEMFunctionBase, we assume nonlinearity
200  if (bdy->f_fem.get())
201  have_nonlinear_dirichlet_bc = true;
202 
203  // Check for time-dependence of FunctionBase
204  if( bdy->f.get() )
205  if( bdy->f->is_time_dependent() )
206  have_time_dependence = true;
207 
208  if( have_nonlinear_dirichlet_bc || have_time_dependence )
209  break;
210 
211  } // End loop over DirichletBoundaries
212  }
213 
214 
215  // Nonlinear Dirichlet constraints change as the solution does
216  // and time-dependent constraints have to be updated
217  if (have_nonlinear_dirichlet_bc || have_time_dependence )
218  {
219  context.system->reinit_constraints();
220  context.system->get_dof_map().enforce_constraints_exactly(*context.system);
221  context.system->get_dof_map().enforce_constraints_exactly(*context.system,
222  dynamic_cast<libMesh::UnsteadySolver*>(context.system->time_solver.get())->old_local_nonlinear_solution.get());
223  }
224  }

Member Data Documentation

AdaptiveTimeSteppingOptions GRINS::UnsteadySolver::_adapt_time_step_options
protected

Definition at line 70 of file grins_unsteady_solver.h.

Referenced by init_time_solver().

unsigned int GRINS::UnsteadySolver::_backtrack_deltat
protected

Definition at line 65 of file grins_unsteady_solver.h.

Referenced by init_time_solver().

double GRINS::UnsteadySolver::_deltat
protected

Definition at line 67 of file grins_unsteady_solver.h.

Referenced by solve(), and GRINS::UnsteadyMeshAdaptiveSolver::solve().

bool GRINS::UnsteadySolver::_is_second_order_in_time
protected

Track whether is this a second order (in time) solver or not.

If it is, we need to potentially initialize the acceleration

Definition at line 74 of file grins_unsteady_solver.h.

Referenced by init_time_solver(), and solve().

unsigned int GRINS::UnsteadySolver::_n_timesteps
protected

Definition at line 64 of file grins_unsteady_solver.h.

Referenced by solve(), and GRINS::UnsteadyMeshAdaptiveSolver::solve().

double GRINS::UnsteadySolver::_theta
protected

Definition at line 66 of file grins_unsteady_solver.h.

Referenced by set_theta().

std::string GRINS::UnsteadySolver::_time_solver_name
protected

Definition at line 62 of file grins_unsteady_solver.h.

Referenced by init_time_solver().


The documentation for this class was generated from the following files:

Generated on Thu Jun 2 2016 21:52:32 for GRINS-0.7.0 by  doxygen 1.8.10