PRISMS-PF  v2.1
main.cc
Go to the documentation of this file.
1 // Calls the unit tests for the PRISMS-PF code
2 // Orignal author: Stephen DeWitt (stvdwtt@umich.edu)
3 
4 #include <iostream>
5 #include "unitTest.h"
6 #include "../../include/userInputParameters.h"
7 #include "../../src/userInputParameters/userInputParameters.cc"
8 #include "../../include/vectorBCFunction.h"
9 #include "../../src/utilities/vectorBCFunction.cc"
10 #include "../../include/initialConditions.h"
11 #include "initialConditions.cc"
12 #include "boundaryConditions.cc"
13 #include "unit_test_inputs.cc"
14 
15 int main(int argc, char **argv)
16 {
17  dealii::deallog.depth_console(3);
18  //init MPI
19  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int);
20 
21  // Load input
22  variableAttributeLoader variable_attributes;
23  inputFileReader input_file_reader("parameters_test.in",variable_attributes);
24  userInputParameters<2> userInputs(input_file_reader,input_file_reader.parameter_handler,variable_attributes);
25  load_unit_test_inputs<2>(userInputs);
26 
27  std::cout << "Beginning unit tests..." << std::endl;
28  bool pass = false;
29  int tests_passed = 0, total_tests = 0;
30 
31  // Unit tests for the method "parse_line" in "inputFileReader"
32  total_tests++;
33  unitTest<2,double> parse_line_tester;
34  pass = parse_line_tester.test_parse_line();
35  tests_passed += pass;
36 
37  // Unit tests for the method "get_subsection_entry_list" in "inputFileReader"
38  total_tests++;
39  unitTest<2,double> get_subsection_entry_list_tester;
40  pass = get_subsection_entry_list_tester.test_get_subsection_entry_list();
41  tests_passed += pass;
42 
43  // Unit tests for the method "get_entry_name_ending_list" in "inputFileReader"
44  total_tests++;
45  unitTest<2,double> get_entry_name_ending_list_tester;
46  pass = get_entry_name_ending_list_tester.test_get_entry_name_ending_list();
47  tests_passed += pass;
48 
49  // Unit tests for the method "load_BC_list" in "userInputParameters"
50  total_tests++;
51  unitTest<2,double> load_BC_list_tester;
52  pass = load_BC_list_tester.test_load_BC_list();
53  tests_passed += pass;
54 
55  // Unit tests for the method "setOutputTimeSteps" for all four types of spacing, indirectly through "loadInputParameters"
56  total_tests++;
57  unitTest<2,double> setOutputTimeSteps_tester_eq;
58  pass = setOutputTimeSteps_tester_eq.test_setOutputTimeSteps();
59  tests_passed += pass;
60 
61  // Unit tests for the method "computeInvM"
62  total_tests++;
63  unitTest<2,double> computeInvM_tester_2D;
64  pass = computeInvM_tester_2D.test_computeInvM(argc, argv, userInputs);
65  tests_passed += pass;
66 
67  // Unit tests for the method "outputResults" (this test doesn't actually do anything)
68  // total_tests++;
69  // unitTest<2,double> outputResults_tester_2D;
70  // pass = outputResults_tester_2D.test_outputResults(argc, argv, userInputs);
71  // tests_passed += pass;
72 
73  // Unit tests for the method "computeStress"
74  total_tests++;
75  unitTest<1,dealii::VectorizedArray<double>[1][1]> computeStress_tester_1D;
76  pass = computeStress_tester_1D.test_computeStress();
77  tests_passed += pass;
78 
79  total_tests++;
80  unitTest<1,dealii::Table<2, double> > computeStress_tester_1DT;
81  pass = computeStress_tester_1DT.test_computeStress();
82  tests_passed += pass;
83 
84  total_tests++;
85  unitTest<2,dealii::VectorizedArray<double>[3][3]> computeStress_tester_2D;
86  pass = computeStress_tester_2D.test_computeStress();
87  tests_passed += pass;
88 
89  total_tests++;
90  unitTest<2,dealii::Table<2, double> > computeStress_tester_2DT;
91  pass = computeStress_tester_2DT.test_computeStress();
92  tests_passed += pass;
93 
94  total_tests++;
95  unitTest<3,dealii::VectorizedArray<double>[6][6]> computeStress_tester_3D;
96  pass = computeStress_tester_3D.test_computeStress();
97  tests_passed += pass;
98 
99  total_tests++;
100  unitTest<3,dealii::Table<2, double> > computeStress_tester_3DT;
101  pass = computeStress_tester_3DT.test_computeStress();
102  tests_passed += pass;
103 
104  // Unit tests for the method "setRigidBodyModeConstraints"
105  total_tests++;
106  unitTest<2,double> setRigidBodyModeConstraints_tester_null;
107  std::vector<int> rigidBodyModeComponents;
108  pass = setRigidBodyModeConstraints_tester_null.test_setRigidBodyModeConstraints(rigidBodyModeComponents, userInputs);
109  tests_passed += pass;
110 
111  total_tests++;
112  unitTest<2,double> setRigidBodyModeConstraints_tester_one;
113  rigidBodyModeComponents.clear();
114  rigidBodyModeComponents.push_back(0);
115  pass = setRigidBodyModeConstraints_tester_one.test_setRigidBodyModeConstraints(rigidBodyModeComponents, userInputs);
116  tests_passed += pass;
117 
118  // In debug mode this test has an exception because it is trying to access components higher than 0 on the mesh for a scalar.
119  // To get this test working again, I'll need a DoFHandler for a vector field.
120  // total_tests++;
121  // unitTest<2,double> setRigidBodyModeConstraints_tester_three;
122  // rigidBodyModeComponents.clear();
123  // rigidBodyModeComponents.push_back(0);
124  // rigidBodyModeComponents.push_back(1);
125  // rigidBodyModeComponents.push_back(2);
126  // pass = setRigidBodyModeConstraints_tester_three.test_setRigidBodyModeConstraints(rigidBodyModeComponents, userInputs);
127  // tests_passed += pass;
128 
129  // Unit tests for the "LinearSolverParameters" class
130  total_tests++;
131  unitTest<2,double> LinearSolverParameters_tester;
132  pass = LinearSolverParameters_tester.test_LinearSolverParameters();
133  tests_passed += pass;
134 
135  // Unit tests for the "NonlinearSolverParameters" class
136  total_tests++;
137  unitTest<2,double> NonlinearSolverParameters_tester;
138  pass = NonlinearSolverParameters_tester.test_NonlinearSolverParameters();
139  tests_passed += pass;
140 
141  // Unit tests for the "parseDependences" method in the "UserInputParameters" class
142  total_tests++;
143  unitTest<2,double> EquationDependencyParser_tester1;
144  pass = EquationDependencyParser_tester1.test_EquationDependencyParser_variables_and_residuals_needed();
145  tests_passed += pass;
146 
147  // Unit tests for the "parseDependences" method in the "UserInputParameters" class
148  total_tests++;
149  unitTest<2,double> EquationDependencyParser_tester2;
150  pass = EquationDependencyParser_tester2.test_EquationDependencyParser_nonlinear();
151  tests_passed += pass;
152 
153  // Unit tests for the "parseDependences" method in the "UserInputParameters" class
154  total_tests++;
155  unitTest<2,double> EquationDependencyParser_tester3;
156  pass = EquationDependencyParser_tester3.test_EquationDependencyParser_postprocessing();
157  tests_passed += pass;
158 
159  // Unit tests for the FloodFiller class
160  total_tests++;
161  unitTest<2,double> FloodFiller_tester;
162  pass = FloodFiller_tester.test_FloodFiller();
163  tests_passed += pass;
164 
165  // Unit tests for the SimplifiedGrainRepresentation class
166  total_tests++;
167  unitTest<2,double> SimplifiedGrainRepresentation_tester;
168  pass = SimplifiedGrainRepresentation_tester.test_SimplifiedGrainRepresentation();
169  tests_passed += pass;
170 
171  // Unit tests for the "transferGrainIds" method in the "SimplifiedGrainManipulator" class
172  total_tests++;
173  unitTest<2,double> SimplifiedGrainManipulator_tester1;
174  pass = SimplifiedGrainManipulator_tester1.test_SimplifiedGrainManipulator_transferGrainIds();
175  tests_passed += pass;
176 
177  // Unit tests for the "reassignGrains" method in the "SimplifiedGrainManipulator" class
178  total_tests++;
179  unitTest<2,double> SimplifiedGrainManipulator_tester2;
180  pass = SimplifiedGrainManipulator_tester2.test_SimplifiedGrainManipulator_reassignGrains();
181  tests_passed += pass;
182 
183  // Unit tests for the OrderParameterRemapper class
184  total_tests++;
185  unitTest<2,double> OrderParameterRemapper_tester;
186  pass = OrderParameterRemapper_tester.test_OrderParameterRemapper();
187  tests_passed += pass;
188 
189  // Print out results
190  char buffer[100];
191  sprintf(buffer, "\n\nNumber of tests passed: %u/%u \n\n", tests_passed, total_tests);
192  std::cout << buffer;
193 
194  // Write results to a file
195  std::ofstream result_file ("unit_test_results.txt");
196  result_file << tests_passed << std::endl;
197  result_file << total_tests << std::endl;
198  result_file.close();
199 
200 
201  return 0;
202 }
bool test_LinearSolverParameters()
bool test_parse_line()
dealii::ParameterHandler parameter_handler
bool test_computeStress()
bool test_computeInvM(int argc, char **argv, userInputParameters< dim >)
Definition: test_invM.h:57
bool test_setOutputTimeSteps()
bool test_EquationDependencyParser_postprocessing()
bool test_setRigidBodyModeConstraints(std::vector< int >, userInputParameters< dim > userInputs)
bool test_OrderParameterRemapper()
bool test_EquationDependencyParser_nonlinear()
int main(int argc, char **argv)
Definition: main.cc:15
bool test_FloodFiller()
bool test_SimplifiedGrainManipulator_transferGrainIds()
bool test_SimplifiedGrainManipulator_reassignGrains()
bool test_load_BC_list()
bool test_EquationDependencyParser_variables_and_residuals_needed()