PRISMS-PF  v2.1
test_setOutputTimeSteps.h
Go to the documentation of this file.
1 // Unit test(s) for the method "setOutputTimeSteps"
2 
3 template <int dim,typename T>
5  bool pass = false;
6  char buffer[100];
7  std::cout << "\nTesting 'setOutputTimeSteps' via the public 'loadInputParameters' method...'" << std::endl;
8 
9  dealii::ParameterHandler parameter_handler;
10  variableAttributeLoader variable_attributes;
11  inputFileReader input_file_reader("parameters_test.in",variable_attributes);
12  std::vector<fieldType> var_types;
13  var_types.push_back(SCALAR);
14  std::vector<PDEType> var_eq_types;
15  var_eq_types.push_back(TIME_INDEPENDENT);
16  std::vector<bool> var_nucleates;
17  var_nucleates.push_back(false);
18  input_file_reader.declare_parameters(parameter_handler,var_types,var_eq_types,0,var_nucleates);
19  #if (DEAL_II_VERSION_MAJOR < 9 && DEAL_II_VERSION_MINOR < 5)
20  parameter_handler.read_input("parameters_test.in");
21  #else
22  parameter_handler.parse_input("parameters_test.in");
23  #endif
24 
25  //userInputParameters<dim> userInputs;
26 
27  // Subtest 1 (EQUAL_SPACING)
28  parameter_handler.set("Output condition","EQUAL_SPACING");
29  input_file_reader.var_types = var_types;
30  input_file_reader.num_pp_vars = 0;
31  input_file_reader.num_constants = 0;
32 
33  //userInputs.loadInputParameters(input_file_reader,parameter_handler,var_types.size(),0,0,0);
34  userInputParameters<dim> userInputs1(input_file_reader,parameter_handler,variable_attributes);
35 
36  std::vector<unsigned int> expected_result = {0, 2000, 4000, 6000, 8000, 10000, 12000, 14000, 16000, 18000, 20000};
37 
38  bool pass1 = true;
39  for (unsigned int i=0; i < userInputs1.outputTimeStepList.size(); i++){
40  if (userInputs1.outputTimeStepList[i] != expected_result[i]){
41  pass1 = false;
42  }
43  }
44 
45  sprintf (buffer, "Subtest 1 for 'setOutputTimeSteps' (EQUAL_SPACING) result: %u\n", pass1);
46  std::cout << buffer;
47 
48  // Subtest 2 (LOG_SPACING)
49  parameter_handler.set("Output condition","LOG_SPACING");
50  userInputParameters<dim> userInputs2(input_file_reader,parameter_handler,variable_attributes);
51 
52  expected_result = {0,3,7,20,53,141,381,1025,2759,7429,20000};
53 
54  bool pass2 = true;
55  for (unsigned int i=0; i < userInputs2.outputTimeStepList.size(); i++){
56  if (userInputs2.outputTimeStepList[i] != expected_result[i]){
57  pass2 = false;
58  }
59  }
60 
61  sprintf (buffer, "Subtest 2 for 'setOutputTimeSteps' (LOG_SPACING) result: %u\n", pass2);
62  std::cout << buffer;
63 
64  // Subtest 3 (N_PER_DECADE)
65  parameter_handler.set("Output condition","N_PER_DECADE");
66  userInputParameters<dim> userInputs3(input_file_reader,parameter_handler,variable_attributes);
67 
68  expected_result = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
69  200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000,
70  8000, 9000, 10000, 20000};
71 
72  bool pass3 = true;
73  for (unsigned int i=0; i < userInputs3.outputTimeStepList.size(); i++){
74  if (userInputs3.outputTimeStepList[i] != expected_result[i]){
75  pass3 = false;
76  }
77  }
78 
79  sprintf (buffer, "Subtest 3 for 'setOutputTimeSteps' (N_PER_DECADE) result: %u\n", pass3);
80  std::cout << buffer;
81 
82  // Subtest 4 (LIST)
83  parameter_handler.set("Output condition","LIST");
84  userInputParameters<dim> userInputs4(input_file_reader,parameter_handler,variable_attributes);
85 
86  expected_result = {0, 3, 55, 61};
87 
88  bool pass4 = true;
89  for (unsigned int i=0; i < userInputs4.outputTimeStepList.size(); i++){
90  if (userInputs4.outputTimeStepList[i] != expected_result[i]){
91  pass4 = false;
92  }
93  }
94 
95  sprintf (buffer, "Subtest 4 for 'setOutputTimeSteps' (LIST) result: %u\n", pass4);
96  std::cout << buffer;
97 
98 
99  if (pass4 && pass3 && pass2 && pass1) {
100  pass=true;
101  }
102 
103  sprintf (buffer, "Test result for 'setOutputTimeSteps': %u\n", pass);
104  std::cout << buffer;
105 
106  return pass;
107 }
bool test_setOutputTimeSteps()
void declare_parameters(dealii::ParameterHandler &parameter_handler, const std::vector< fieldType > var_types, const std::vector< PDEType > var_eq_types, const unsigned int num_of_constants, const std::vector< bool >) const
std::vector< fieldType > var_types
unsigned int num_constants
std::vector< unsigned int > outputTimeStepList
unsigned int num_pp_vars