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

Public Member Functions

 LIBMESH_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) 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 82 of file second_order_unsteady_solver_test.C.

Member Function Documentation

◆ aux_time_solver_init()

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

Reimplemented from TimeSolverTestImplementation< NewmarkSolver >.

Definition at line 72 of file second_order_unsteady_solver_test.C.

References NewmarkSolverTestBase::_beta.

73  { time_solver.set_beta(_beta);
74  time_solver.compute_initial_accel(); }

◆ CPPUNIT_TEST() [1/4]

NewmarkSolverTest::CPPUNIT_TEST ( testNewmarkSolverConstantSecondOrderODESecondOrderStyle  )

◆ CPPUNIT_TEST() [2/4]

NewmarkSolverTest::CPPUNIT_TEST ( testNewmarkSolverLinearTimeSecondOrderODESecondOrderStyle  )

◆ CPPUNIT_TEST() [3/4]

NewmarkSolverTest::CPPUNIT_TEST ( testNewmarkSolverConstantSecondOrderODEFirstOrderStyle  )

◆ CPPUNIT_TEST() [4/4]

NewmarkSolverTest::CPPUNIT_TEST ( testNewmarkSolverLinearTimeSecondOrderODEFirstOrderStyle  )

◆ CPPUNIT_TEST_SUITE_END()

NewmarkSolverTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

NewmarkSolverTest::LIBMESH_CPPUNIT_TEST_SUITE ( NewmarkSolverTest  )

◆ run_test_with_exact_soln()

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

Definition at line 28 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, mesh, 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.

29  {
33  SystemType & system = es.add_system<SystemType>("ScalarSystem");
34 
35  system.time_solver = std::make_unique<TimeSolverType>(system);
36 
37  es.init();
38 
39  DiffSolver & solver = *(system.time_solver->diff_solver().get());
40  solver.relative_step_tolerance = std::numeric_limits<Real>::epsilon()*10;
41  solver.relative_residual_tolerance = std::numeric_limits<Real>::epsilon()*10;
42  solver.absolute_residual_tolerance = std::numeric_limits<Real>::epsilon()*10;
43 
44  NewtonSolver & newton = cast_ref<NewtonSolver &>(solver);
45 
46  // LASPACK GMRES + ILU defaults don't like these problems, so
47  // we'll use a sophisticated "just divide the scalars" solver instead.
50 
51  system.deltat = deltat;
52 
53  TimeSolverType * time_solver = cast_ptr<TimeSolverType *>(system.time_solver.get());
54  this->aux_time_solver_init(*time_solver);
55 
56  // We're going to want to check our solution, and when we run
57  // "make check" with LIBMESH_RUN='mpirun -np N" for N>1 then we'll
58  // need to keep that check in sync with the processors that are just
59  // twiddling their thumbs, not owning our mesh point.
60  std::vector<dof_id_type> solution_index;
61  solution_index.push_back(0);
62  const bool has_solution = system.get_dof_map().all_semilocal_indices(solution_index);
63 
64  for (unsigned int t_step=0; t_step != n_timesteps; ++t_step)
65  {
66  system.solve();
67  system.time_solver->advance_timestep();
68 
69  Real rel_error = 0;
70 
71  if (has_solution)
72  {
73  Number exact_soln = system.u(system.time);
74  rel_error = std::abs((exact_soln - (*system.solution)(0))/exact_soln);
75  }
76  system.comm().max(rel_error);
77 
78  // Using relative error for comparison, so "exact" is 0
79  LIBMESH_ASSERT_FP_EQUAL( rel_error,
80  0.0,
81  std::numeric_limits<Real>::epsilon()*10 );
82  }
83  }
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.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
Definition: diff_solver.h:189
MeshBase & mesh
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
Definition: newton_solver.h:46
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
Definition: type_vector.h:57
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Definition: diff_solver.h:68
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:50
Real relative_residual_tolerance
Definition: diff_solver.h:190

◆ set_beta()

void NewmarkSolverTestBase::set_beta ( Real  beta)
inlineprotectedinherited

◆ testNewmarkSolverConstantSecondOrderODEFirstOrderStyle()

void NewmarkSolverTest::testNewmarkSolverConstantSecondOrderODEFirstOrderStyle ( )
inline

Definition at line 117 of file second_order_unsteady_solver_test.C.

118  {
119  LOG_UNIT_TEST;
120 
121  this->run_test_with_exact_soln<ConstantSecondOrderODE<SecondOrderScalarSystemFirstOrderTimeSolverBase>>(0.5,10);
122  }

◆ testNewmarkSolverConstantSecondOrderODESecondOrderStyle()

void NewmarkSolverTest::testNewmarkSolverConstantSecondOrderODESecondOrderStyle ( )
inline

Definition at line 99 of file second_order_unsteady_solver_test.C.

100  {
101  LOG_UNIT_TEST;
102 
103  this->run_test_with_exact_soln<ConstantSecondOrderODE<SecondOrderScalarSystemSecondOrderTimeSolverBase>>(0.5,10);
104  }

◆ testNewmarkSolverLinearTimeSecondOrderODEFirstOrderStyle()

void NewmarkSolverTest::testNewmarkSolverLinearTimeSecondOrderODEFirstOrderStyle ( )
inline

Definition at line 124 of file second_order_unsteady_solver_test.C.

References libMesh::Real, and NewmarkSolverTestBase::set_beta().

125  {
126  LOG_UNIT_TEST;
127 
128  // For \beta = 1/6, we have the "linear acceleration method" for which
129  // we should be able to exactly integrate linear (in time) acceleration
130  // functions.
131  this->set_beta(Real(1)/Real(6));
132  this->run_test_with_exact_soln<LinearTimeSecondOrderODE<SecondOrderScalarSystemFirstOrderTimeSolverBase>>(0.5,10);
133  }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ testNewmarkSolverLinearTimeSecondOrderODESecondOrderStyle()

void NewmarkSolverTest::testNewmarkSolverLinearTimeSecondOrderODESecondOrderStyle ( )
inline

Definition at line 106 of file second_order_unsteady_solver_test.C.

References libMesh::Real, and NewmarkSolverTestBase::set_beta().

107  {
108  LOG_UNIT_TEST;
109 
110  // For \beta = 1/6, we have the "linear acceleration method" for which
111  // we should be able to exactly integrate linear (in time) acceleration
112  // functions.
113  this->set_beta(Real(1)/Real(6));
114  this->run_test_with_exact_soln<LinearTimeSecondOrderODE<SecondOrderScalarSystemSecondOrderTimeSolverBase>>(0.5,10);
115  }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Member Data Documentation

◆ _beta

Real NewmarkSolverTestBase::_beta
protectedinherited

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