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

Public Member Functions

 CPPUNIT_TEST_SUITE (NewmarkSolverTest)
 
 CPPUNIT_TEST (testNewmarkSolverConstantSecondOrderODESecondOrderStyle)
 
 CPPUNIT_TEST (testNewmarkSolverLinearTimeSecondOrderODESecondOrderStyle)
 
 CPPUNIT_TEST (testNewmarkSolverConstantSecondOrderODEFirstOrderStyle)
 
 CPPUNIT_TEST (testNewmarkSolverLinearTimeSecondOrderODEFirstOrderStyle)
 
 CPPUNIT_TEST_SUITE_END ()
 
void testNewmarkSolverConstantSecondOrderODESecondOrderStyle ()
 
void testNewmarkSolverLinearTimeSecondOrderODESecondOrderStyle ()
 
void testNewmarkSolverConstantSecondOrderODEFirstOrderStyle ()
 
void testNewmarkSolverLinearTimeSecondOrderODEFirstOrderStyle ()
 

Protected Member Functions

virtual void aux_time_solver_init (NewmarkSolver &time_solver) libmesh_override
 
void set_beta (Real beta)
 
void run_test_with_exact_soln (Real deltat, unsigned int n_timesteps)
 

Protected Attributes

Real _beta
 

Detailed Description

Definition at line 99 of file second_order_unsteady_solver_test.C.

Member Function Documentation

virtual void NewmarkSolverTestBase::aux_time_solver_init ( NewmarkSolver &  time_solver)
protectedvirtualinherited

Reimplemented from TimeSolverTestImplementation< NewmarkSolver >.

Definition at line 89 of file second_order_unsteady_solver_test.C.

90  { time_solver.set_beta(_beta);
91  time_solver.compute_initial_accel(); }
NewmarkSolverTest::CPPUNIT_TEST ( testNewmarkSolverConstantSecondOrderODESecondOrderStyle  )
NewmarkSolverTest::CPPUNIT_TEST ( testNewmarkSolverLinearTimeSecondOrderODESecondOrderStyle  )
NewmarkSolverTest::CPPUNIT_TEST ( testNewmarkSolverConstantSecondOrderODEFirstOrderStyle  )
NewmarkSolverTest::CPPUNIT_TEST ( testNewmarkSolverLinearTimeSecondOrderODEFirstOrderStyle  )
NewmarkSolverTest::CPPUNIT_TEST_SUITE ( NewmarkSolverTest  )
NewmarkSolverTest::CPPUNIT_TEST_SUITE_END ( )
void TimeSolverTestImplementation< NewmarkSolver >::run_test_with_exact_soln ( Real  deltat,
unsigned int  n_timesteps 
)
protectedinherited

Definition at line 18 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::EquationSystems::init(), mesh, libMesh::Real, libMesh::DiffSolver::relative_residual_tolerance, libMesh::DiffSolver::relative_step_tolerance, libMesh::solver, and TestCommWorld.

19  {
23  SystemType & system = es.add_system<SystemType>("ScalarSystem");
24 
25  system.time_solver.reset(new TimeSolverType(system));
26 
27  es.init();
28 
29  DiffSolver & solver = *(system.time_solver->diff_solver().get());
30  solver.relative_step_tolerance = std::numeric_limits<Real>::epsilon()*10;
31  solver.relative_residual_tolerance = std::numeric_limits<Real>::epsilon()*10;
32  solver.absolute_residual_tolerance = std::numeric_limits<Real>::epsilon()*10;
33 
34  system.deltat = deltat;
35 
36  TimeSolverType * time_solver = cast_ptr<TimeSolverType *>(system.time_solver.get());
37  this->aux_time_solver_init(*time_solver);
38 
39  // We're going to want to check our solution, and when we run
40  // "make check" with LIBMESH_RUN='mpirun -np N" for N>1 then we'll
41  // need to avoid checking on the processors that are just
42  // twiddling their thumbs, not owning our mesh point.
43  std::vector<dof_id_type> solution_index;
44  solution_index.push_back(0);
45  const bool has_solution = system.get_dof_map().all_semilocal_indices(solution_index);
46 
47  for (unsigned int t_step=0; t_step != n_timesteps; ++t_step)
48  {
49  system.solve();
50  system.time_solver->advance_timestep();
51 
52  if (has_solution)
53  {
54  // Use relative error for comparison, so "exact" is 0
55  Number exact_soln = system.u(system.time);
56  Real rel_error = std::abs((exact_soln - (*system.solution)(0))/exact_soln);
57 
58  CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0,
59  rel_error,
60  std::numeric_limits<Real>::epsilon()*10 );
61  }
62  }
63  }
double abs(double a)
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.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
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
MeshBase & mesh
PetscDiffSolver & solver
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Definition: diff_solver.h:70
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:50
Real relative_residual_tolerance
Definition: diff_solver.h:192
void NewmarkSolverTestBase::set_beta ( Real  beta)
protectedinherited
void NewmarkSolverTest::testNewmarkSolverConstantSecondOrderODEFirstOrderStyle ( )

Definition at line 128 of file second_order_unsteady_solver_test.C.

129  {
130  this->run_test_with_exact_soln<ConstantSecondOrderODE<SecondOrderScalarSystemFirstOrderTimeSolverBase>>(0.5,10);
131  }
void NewmarkSolverTest::testNewmarkSolverConstantSecondOrderODESecondOrderStyle ( )

Definition at line 114 of file second_order_unsteady_solver_test.C.

115  {
116  this->run_test_with_exact_soln<ConstantSecondOrderODE<SecondOrderScalarSystemSecondOrderTimeSolverBase>>(0.5,10);
117  }
void NewmarkSolverTest::testNewmarkSolverLinearTimeSecondOrderODEFirstOrderStyle ( )

Definition at line 133 of file second_order_unsteady_solver_test.C.

134  {
135  // For \beta = 1/6, we have the "linear acceleration method" for which
136  // we should be able to exactly integrate linear (in time) acceleration
137  // functions.
138  this->set_beta(1.0/6.0);
139  this->run_test_with_exact_soln<LinearTimeSecondOrderODE<SecondOrderScalarSystemFirstOrderTimeSolverBase>>(0.5,10);
140  }
void NewmarkSolverTest::testNewmarkSolverLinearTimeSecondOrderODESecondOrderStyle ( )

Definition at line 119 of file second_order_unsteady_solver_test.C.

120  {
121  // For \beta = 1/6, we have the "linear acceleration method" for which
122  // we should be able to exactly integrate linear (in time) acceleration
123  // functions.
124  this->set_beta(1.0/6.0);
125  this->run_test_with_exact_soln<LinearTimeSecondOrderODE<SecondOrderScalarSystemSecondOrderTimeSolverBase>>(0.5,10);
126  }

Member Data Documentation

Real NewmarkSolverTestBase::_beta
protectedinherited

Definition at line 96 of file second_order_unsteady_solver_test.C.


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