PRISMS-PF  v2.1
test_load_BC_list.h
Go to the documentation of this file.
1 // Unit test(s) for the method "parse_line"
2 
3 template <int dim,typename T>
5  bool pass = false;
6 
7  char buffer[100];
8 
9  std::cout << "\nTesting 'load_BC_list'... " << std::endl;
10 
11  //create test problem class object
12  variableAttributeLoader variable_attributes;
13  inputFileReader input_file_reader("parameters_test.in",variable_attributes);
14  userInputParameters<2> userInputs(input_file_reader,input_file_reader.parameter_handler,variable_attributes);
15 
16  // 2D test:
17  std::vector<std::string> list_of_BCs;
18  list_of_BCs.push_back("DIRICHLET: 2.5");
19  list_of_BCs.push_back("PERIODIC,PERIODIC,NATURAL,NATURAL");
20  list_of_BCs.push_back("DIRICHLET: 2.5,DIRICHLET: 1.5,NATURAL,NATURAL");
21 
22  userInputs.BC_list.clear();
23  userInputs.load_BC_list(list_of_BCs);
24 
25  bool pass1;
26  pass1 = userInputs.BC_list.size() == 3;
27  pass1 = pass1 && (userInputs.BC_list[0].var_BC_type.size() == 4);
28  for (unsigned int i=0; i<userInputs.BC_list[0].var_BC_type.size(); i++){
29  pass1 = pass1 && (userInputs.BC_list[0].var_BC_type[i] == DIRICHLET);
30  pass1 = pass1 && (userInputs.BC_list[0].var_BC_val[i] == 2.5);
31  }
32  sprintf (buffer, "Subtest 1 result for 'load_BC_list': %u\n", pass1);
33  std::cout << buffer;
34 
35  bool pass2;
36  pass2 = (userInputs.BC_list[1].var_BC_type[0] == PERIODIC);
37  pass2 = pass2 && (userInputs.BC_list[1].var_BC_type[1] == PERIODIC);
38  pass2 = pass2 && (userInputs.BC_list[1].var_BC_type[2] == NATURAL);
39  pass2 = pass2 && (userInputs.BC_list[1].var_BC_type[3] == NATURAL);
40  sprintf (buffer, "Subtest 2 result for 'load_BC_list': %u\n", pass2);
41  std::cout << buffer;
42 
43  bool pass3;
44  pass3 = (userInputs.BC_list[2].var_BC_type[0] == DIRICHLET);
45  pass3 = pass3 && (userInputs.BC_list[2].var_BC_val[0] == 2.5);
46  pass3 = pass3 && (userInputs.BC_list[2].var_BC_type[1] == DIRICHLET);
47  pass3 = pass3 && (userInputs.BC_list[2].var_BC_val[1] == 1.5);
48  pass3 = pass3 && (userInputs.BC_list[2].var_BC_type[2] == NATURAL);
49  pass3 = pass3 && (userInputs.BC_list[2].var_BC_type[3] == NATURAL);
50  sprintf (buffer, "Subtest 3 result for 'load_BC_list': %u\n", pass3);
51  std::cout << buffer;
52 
53  // 3D test:
54  list_of_BCs.clear();
55  userInputParameters<3> userInputs_3D(input_file_reader,input_file_reader.parameter_handler,variable_attributes);
56  list_of_BCs.push_back("DIRICHLET: 2.5");
57  list_of_BCs.push_back("PERIODIC,PERIODIC,NATURAL,NATURAL,PERIODIC,PERIODIC");
58 
59  userInputs_3D.BC_list.clear();
60  userInputs_3D.load_BC_list(list_of_BCs);
61  bool pass4;
62  pass4 = userInputs_3D.BC_list.size() == 2;
63  pass4 = pass4 && (userInputs_3D.BC_list[0].var_BC_type.size() == 6);
64  for (unsigned int i=0; i<userInputs_3D.BC_list[0].var_BC_type.size(); i++){
65  pass4 = pass4 && (userInputs_3D.BC_list[0].var_BC_type[i] == DIRICHLET);
66  pass4 = pass4 && (userInputs_3D.BC_list[0].var_BC_val[i] == 2.5);
67  }
68  sprintf (buffer, "Subtest 4 result for 'load_BC_list': %u\n", pass4);
69  std::cout << buffer;
70 
71  bool pass5;
72  pass5 = (userInputs_3D.BC_list[1].var_BC_type[0] == PERIODIC);
73  pass5 = pass5 && (userInputs_3D.BC_list[1].var_BC_type[1] == PERIODIC);
74  pass5 = pass5 && (userInputs_3D.BC_list[1].var_BC_type[2] == NATURAL);
75  pass5 = pass5 && (userInputs_3D.BC_list[1].var_BC_type[3] == NATURAL);
76  pass5 = pass5 && (userInputs_3D.BC_list[1].var_BC_type[4] == PERIODIC);
77  pass5 = pass5 && (userInputs_3D.BC_list[1].var_BC_type[5] == PERIODIC);
78  sprintf (buffer, "Subtest 5 result for 'load_BC_list': %u\n", pass5);
79  std::cout << buffer;
80 
81 
82  pass = pass1 && pass2 && pass3 && pass4 && pass5;
83 
84  sprintf (buffer, "Test result for 'load_BC_list': %u\n", pass);
85  std::cout << buffer;
86 
87  return pass;
88 }
Definition: varBCs.h:12
dealii::ParameterHandler parameter_handler
std::vector< varBCs< dim > > BC_list
bool test_load_BC_list()
void load_BC_list(const std::vector< std::string > list_of_BCs)
Definition: load_BC_list.cc:7