libMesh
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ThetaSolverTestBase< TimeSolverType > Class Template Reference
Inheritance diagram for ThetaSolverTestBase< TimeSolverType >:
[legend]

Public Member Functions

 ThetaSolverTestBase ()
 
 ThetaSolverTestBase ()
 

Protected Member Functions

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

Protected Attributes

Real _theta
 

Detailed Description

template<typename TimeSolverType>
class ThetaSolverTestBase< TimeSolverType >

Definition at line 53 of file first_order_unsteady_solver_test.C.

Constructor & Destructor Documentation

◆ ThetaSolverTestBase() [1/2]

template<typename TimeSolverType >
ThetaSolverTestBase< TimeSolverType >::ThetaSolverTestBase ( )
inline

◆ ThetaSolverTestBase() [2/2]

template<typename TimeSolverType >
ThetaSolverTestBase< TimeSolverType >::ThetaSolverTestBase ( )
inline

Member Function Documentation

◆ aux_time_solver_init() [1/2]

template<typename TimeSolverType >
virtual void ThetaSolverTestBase< TimeSolverType >::aux_time_solver_init ( TimeSolverType &  time_solver)
inlineprotectedvirtual

Reimplemented from TimeSolverTestImplementation< TimeSolverType >.

Definition at line 63 of file first_order_unsteady_solver_test.C.

64 { time_solver.theta = _theta; }

References ThetaSolverTestBase< TimeSolverType >::_theta.

◆ aux_time_solver_init() [2/2]

template<typename TimeSolverType >
virtual void ThetaSolverTestBase< TimeSolverType >::aux_time_solver_init ( TimeSolverType &  time_solver)
inlineprotectedvirtual

Reimplemented from TimeSolverTestImplementation< TimeSolverType >.

Definition at line 148 of file second_order_unsteady_solver_test.C.

149 { time_solver.theta = _theta; }

References ThetaSolverTestBase< TimeSolverType >::_theta.

◆ 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 
)
inlineprotectedinherited

Definition at line 28 of file time_solver_test_common.h.

29 {
30 Mesh mesh(*TestCommWorld);
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 }
virtual void aux_time_solver_init(TimeSolverType &)
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Definition diff_solver.h:70
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
This is the EquationSystems class.
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.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
LinearSolver< Number > & get_linear_solver()
MeshBase & mesh
void build_point(UnstructuredMesh &mesh, const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 0D meshes.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References libMesh::DiffSolver::absolute_residual_tolerance, libMesh::EquationSystems::add_system(), TimeSolverTestImplementation< TimeSolverType >::aux_time_solver_init(), 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.

◆ set_theta() [1/2]

template<typename TimeSolverType >
void ThetaSolverTestBase< TimeSolverType >::set_theta ( Real  theta)
inlineprotected

Definition at line 66 of file first_order_unsteady_solver_test.C.

67 { _theta = theta; }

References ThetaSolverTestBase< TimeSolverType >::_theta.

◆ set_theta() [2/2]

template<typename TimeSolverType >
void ThetaSolverTestBase< TimeSolverType >::set_theta ( Real  theta)
inlineprotected

Definition at line 151 of file second_order_unsteady_solver_test.C.

152 { _theta = theta; }

References ThetaSolverTestBase< TimeSolverType >::_theta.

Member Data Documentation

◆ _theta

template<typename TimeSolverType >
Real ThetaSolverTestBase< TimeSolverType >::_theta
protected

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