libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EulerSolverSecondOrderTest Class Reference
Inheritance diagram for EulerSolverSecondOrderTest:
[legend]

Public Member Functions

 CPPUNIT_TEST_SUITE (EulerSolverSecondOrderTest)
 
 CPPUNIT_TEST (testEulerSolverConstantSecondOrderODE)
 
 CPPUNIT_TEST_SUITE_END ()
 
void testEulerSolverConstantSecondOrderODE ()
 

Protected Member Functions

virtual void aux_time_solver_init (EulerSolver &time_solver)
 
virtual void aux_time_solver_init (EulerSolver &time_solver)
 
void set_theta (Real theta)
 
void set_theta (Real theta)
 
void run_test_with_exact_soln (Real deltat, unsigned int n_timesteps)
 

Protected Attributes

Real _theta
 

Detailed Description

Definition at line 149 of file second_order_unsteady_solver_test.C.

Member Function Documentation

◆ aux_time_solver_init() [1/2]

virtual void ThetaSolverTestBase< EulerSolver >::aux_time_solver_init ( EulerSolver &  time_solver)
inlineprotectedvirtualinherited

Reimplemented from TimeSolverTestImplementation< EulerSolver >.

Definition at line 63 of file first_order_unsteady_solver_test.C.

64  { time_solver.theta = _theta; }

◆ aux_time_solver_init() [2/2]

virtual void ThetaSolverTestBase< EulerSolver >::aux_time_solver_init ( EulerSolver &  time_solver)
inlineprotectedvirtualinherited

Reimplemented from TimeSolverTestImplementation< EulerSolver >.

Definition at line 140 of file second_order_unsteady_solver_test.C.

141  { time_solver.theta = _theta; }

◆ CPPUNIT_TEST()

EulerSolverSecondOrderTest::CPPUNIT_TEST ( testEulerSolverConstantSecondOrderODE  )

◆ CPPUNIT_TEST_SUITE()

EulerSolverSecondOrderTest::CPPUNIT_TEST_SUITE ( EulerSolverSecondOrderTest  )

◆ CPPUNIT_TEST_SUITE_END()

EulerSolverSecondOrderTest::CPPUNIT_TEST_SUITE_END ( )

◆ run_test_with_exact_soln()

void TimeSolverTestImplementation< EulerSolver >::run_test_with_exact_soln ( Real  deltat,
unsigned int  n_timesteps 
)
inlineprotectedinherited

Definition at line 27 of file time_solver_test_common.h.

28  {
32  SystemType & system = es.add_system<SystemType>("ScalarSystem");
33 
34  system.time_solver = libmesh_make_unique<TimeSolverType>(system);
35 
36  es.init();
37 
38  DiffSolver & solver = *(system.time_solver->diff_solver().get());
39  solver.relative_step_tolerance = std::numeric_limits<Real>::epsilon()*10;
40  solver.relative_residual_tolerance = std::numeric_limits<Real>::epsilon()*10;
41  solver.absolute_residual_tolerance = std::numeric_limits<Real>::epsilon()*10;
42 
43  NewtonSolver & newton = cast_ref<NewtonSolver &>(solver);
44 
45  // LASPACK GMRES + ILU defaults don't like these problems, so
46  // we'll use a sophisticated "just divide the scalars" solver instead.
49 
50  system.deltat = deltat;
51 
52  TimeSolverType * time_solver = cast_ptr<TimeSolverType *>(system.time_solver.get());
53  this->aux_time_solver_init(*time_solver);
54 
55  // We're going to want to check our solution, and when we run
56  // "make check" with LIBMESH_RUN='mpirun -np N" for N>1 then we'll
57  // need to keep that check in sync with the processors that are just
58  // twiddling their thumbs, not owning our mesh point.
59  std::vector<dof_id_type> solution_index;
60  solution_index.push_back(0);
61  const bool has_solution = system.get_dof_map().all_semilocal_indices(solution_index);
62 
63  for (unsigned int t_step=0; t_step != n_timesteps; ++t_step)
64  {
65  system.solve();
66  system.time_solver->advance_timestep();
67 
68  Real rel_error = 0;
69 
70  if (has_solution)
71  {
72  Number exact_soln = system.u(system.time);
73  rel_error = std::abs((exact_soln - (*system.solution)(0))/exact_soln);
74  }
75  system.comm().max(rel_error);
76 
77  // Using relative error for comparison, so "exact" is 0
78  LIBMESH_ASSERT_FP_EQUAL( 0.0,
79  rel_error,
80  std::numeric_limits<Real>::epsilon()*10 );
81  }
82  }

◆ set_theta() [1/2]

void ThetaSolverTestBase< EulerSolver >::set_theta ( Real  theta)
inlineprotectedinherited

Definition at line 66 of file first_order_unsteady_solver_test.C.

67  { _theta = theta; }

◆ set_theta() [2/2]

void ThetaSolverTestBase< EulerSolver >::set_theta ( Real  theta)
inlineprotectedinherited

Definition at line 143 of file second_order_unsteady_solver_test.C.

144  { _theta = theta; }

◆ testEulerSolverConstantSecondOrderODE()

void EulerSolverSecondOrderTest::testEulerSolverConstantSecondOrderODE ( )
inline

Definition at line 163 of file second_order_unsteady_solver_test.C.

164  {
165  this->set_theta(0.5);
166  this->run_test_with_exact_soln<ConstantSecondOrderODE<SecondOrderScalarSystemFirstOrderTimeSolverBase>>(0.5,10);
167  }

References ThetaSolverTestBase< EulerSolver >::set_theta().

Member Data Documentation

◆ _theta

Real ThetaSolverTestBase< EulerSolver >::_theta
protectedinherited

Definition at line 69 of file first_order_unsteady_solver_test.C.


The documentation for this class was generated from the following file:
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::Mesh
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
libMesh::JACOBI
Definition: enum_solver_type.h:46
libMesh::IDENTITY_PRECOND
Definition: enum_preconditioner_type.h:34
libMesh::DiffSolver
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Definition: diff_solver.h:70
ThetaSolverTestBase< EulerSolver >::_theta
Real _theta
Definition: first_order_unsteady_solver_test.C:69
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::LinearSolver::set_solver_type
void set_solver_type(const SolverType st)
Sets the type of solver to use.
Definition: linear_solver.h:126
libMesh::DiffSolver::relative_step_tolerance
Real relative_step_tolerance
Definition: diff_solver.h:204
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
TimeSolverTestImplementation< EulerSolver >::aux_time_solver_init
virtual void aux_time_solver_init(EulerSolver &)
Definition: time_solver_test_common.h:21
libMesh::NewtonSolver
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
Definition: newton_solver.h:46
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::DiffSolver::relative_residual_tolerance
Real relative_residual_tolerance
Definition: diff_solver.h:192
libMesh::DiffSolver::absolute_residual_tolerance
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
Definition: diff_solver.h:191
libMesh::NewtonSolver::get_linear_solver
LinearSolver< Number > & get_linear_solver()
Definition: newton_solver.h:81
libMesh::LinearSolver::set_preconditioner_type
void set_preconditioner_type(const PreconditionerType pct)
Sets the type of preconditioner to use.
Definition: linear_solver.C:108
libMesh::MeshTools::Generation::build_point
void build_point(UnstructuredMesh &mesh, const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 0D meshes.
Definition: mesh_generation.C:1462
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
ThetaSolverTestBase< EulerSolver >::set_theta
void set_theta(Real theta)
Definition: first_order_unsteady_solver_test.C:66