PRISMS-PF  v2.1
test_LinearSolverParameters.h
Go to the documentation of this file.
1 // Unit tests for the class "nonlinearSolverParameters"
2 #include "../../include/SolverParameters.h"
3 
4 template <int dim,typename T>
6 
7  char buffer[100];
8 
9  std::cout << "\nTesting 'LinearSolverParameters'... " << std::endl;
10 
11  // Create a nonlinearSolverParameters object
12  LinearSolverParameters test_object;
13 
14  test_object.loadParameters(2,ABSOLUTE_RESIDUAL,1.0e-3,123);
15  test_object.loadParameters(5,RELATIVE_RESIDUAL_CHANGE,1.0e-4,124);
16 
17  // Subtests
18  unsigned int subtest_index = 0;
19  bool result;
20  bool pass = true;
21 
22  // Subtest 1
23  subtest_index++;
24  result = false;
25  if (test_object.getMaxIterations(2) == 123 && test_object.getMaxIterations(5) == 124){
26  result = true;
27  }
28  std::cout << "Subtest " << subtest_index << " result for 'getMaxIterations': " << result << std::endl;
29 
30  pass = pass && result;
31 
32  //Subtest 2
33  subtest_index++;
34  result = false;
35  if (test_object.getToleranceType(2) == ABSOLUTE_RESIDUAL && test_object.getToleranceType(5) == RELATIVE_RESIDUAL_CHANGE){
36  result = true;
37  }
38  std::cout << "Subtest " << subtest_index << " result for 'getToleranceType': " << result << std::endl;
39 
40  pass = pass && result;
41 
42  //Subtest 3
43  subtest_index++;
44  result = false;
45  if (std::abs(test_object.getToleranceValue(2) - 1.0e-3) < 1.0e-12 && std::abs(test_object.getToleranceValue(5) - 1.0e-4) < 1.0e-12){
46  result = true;
47  }
48  std::cout << "Subtest " << subtest_index << " result for 'getToleranceValue': " << result << std::endl;
49 
50  pass = pass && result;
51 
52 
53  sprintf (buffer, "Test result for 'LinearSolverParameters': %u\n", pass);
54  std::cout << buffer;
55 
56  return pass;
57 }
SolverToleranceType getToleranceType(unsigned int index)
bool test_LinearSolverParameters()
unsigned int getMaxIterations(unsigned int index)
void loadParameters(unsigned int _var_index, SolverToleranceType _tolerance_type, double _tolerance_value, unsigned int _max_iterations)
double getToleranceValue(unsigned int index)