libMesh
Protected Member Functions | List of all members
TimeSolverTestImplementation< TimeSolverType > Class Template Reference

#include <time_solver_test_common.h>

Protected Member Functions

virtual void aux_time_solver_init (TimeSolverType &)
 
template<typename SystemType >
void run_test_with_exact_soln (Real deltat, unsigned int n_timesteps)
 

Detailed Description

template<typename TimeSolverType>
class TimeSolverTestImplementation< TimeSolverType >

Definition at line 10 of file time_solver_test_common.h.

Member Function Documentation

◆ aux_time_solver_init()

template<typename TimeSolverType >
virtual void TimeSolverTestImplementation< TimeSolverType >::aux_time_solver_init ( TimeSolverType &  )
protectedvirtual

Definition at line 15 of file time_solver_test_common.h.

15 {}

◆ run_test_with_exact_soln()

template<typename TimeSolverType >
template<typename SystemType >
void TimeSolverTestImplementation< TimeSolverType >::run_test_with_exact_soln ( Real  deltat,
unsigned int  n_timesteps 
)
protected

Definition at line 21 of file time_solver_test_common.h.

References std::abs(), libMesh::DiffSolver::absolute_residual_tolerance, libMesh::EquationSystems::add_system(), libMesh::MeshTools::Generation::build_point(), libMesh::NewtonSolver::get_linear_solver(), libMesh::IDENTITY_PRECOND, libMesh::EquationSystems::init(), libMesh::JACOBI, libMesh::Real, libMesh::DiffSolver::relative_residual_tolerance, libMesh::DiffSolver::relative_step_tolerance, libMesh::LinearSolver< T >::set_preconditioner_type(), libMesh::LinearSolver< T >::set_solver_type(), and TestCommWorld.

22  {
23  Mesh mesh(*TestCommWorld);
25  EquationSystems es(mesh);
26  SystemType & system = es.add_system<SystemType>("ScalarSystem");
27 
28  system.time_solver.reset(new TimeSolverType(system));
29 
30  es.init();
31 
32  DiffSolver & solver = *(system.time_solver->diff_solver().get());
33  solver.relative_step_tolerance = std::numeric_limits<Real>::epsilon()*10;
34  solver.relative_residual_tolerance = std::numeric_limits<Real>::epsilon()*10;
35  solver.absolute_residual_tolerance = std::numeric_limits<Real>::epsilon()*10;
36 
37  NewtonSolver & newton = cast_ref<NewtonSolver &>(solver);
38 
39  // LASPACK GMRES + ILU defaults don't like these problems, so
40  // we'll use a sophisticated "just divide the scalars" solver instead.
43 
44  system.deltat = deltat;
45 
46  TimeSolverType * time_solver = cast_ptr<TimeSolverType *>(system.time_solver.get());
47  this->aux_time_solver_init(*time_solver);
48 
49  // We're going to want to check our solution, and when we run
50  // "make check" with LIBMESH_RUN='mpirun -np N" for N>1 then we'll
51  // need to avoid checking on the processors that are just
52  // twiddling their thumbs, not owning our mesh point.
53  std::vector<dof_id_type> solution_index;
54  solution_index.push_back(0);
55  const bool has_solution = system.get_dof_map().all_semilocal_indices(solution_index);
56 
57  for (unsigned int t_step=0; t_step != n_timesteps; ++t_step)
58  {
59  system.solve();
60  system.time_solver->advance_timestep();
61 
62  if (has_solution)
63  {
64  // Use relative error for comparison, so "exact" is 0
65  Number exact_soln = system.u(system.time);
66  Real rel_error = std::abs((exact_soln - (*system.solution)(0))/exact_soln);
67 
68  CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0,
69  rel_error,
70  std::numeric_limits<Real>::epsilon()*10 );
71  }
72  }
73  }
double abs(double a)
LinearSolver< Number > & get_linear_solver()
Definition: newton_solver.h:81
This is the EquationSystems class.
void build_point(UnstructuredMesh &mesh, const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 0D meshes.
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
Definition: diff_solver.h:192
libMesh::Parallel::Communicator * TestCommWorld
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
Definition: newton_solver.h:46
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Definition: diff_solver.h:71
void set_preconditioner_type(const PreconditionerType pct)
Sets the type of preconditioner to use.
void set_solver_type(const SolverType st)
Sets the type of solver to use.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:51
Real relative_residual_tolerance
Definition: diff_solver.h:193
virtual void aux_time_solver_init(TimeSolverType &)

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