@@ -19,7 +19,8 @@ namespace utf = boost::unit_test;
1919namespace adamantine
2020{
2121
22- BOOST_AUTO_TEST_CASE (heat_source_value_2d, *utf::tolerance (1e-12 ))
22+ template <int dim>
23+ ElectronBeamHeatSource<dim, dealii::MemorySpace::Host> create_heat_sources ()
2324{
2425 boost::property_tree::ptree database;
2526
@@ -36,18 +37,24 @@ BOOST_AUTO_TEST_CASE(heat_source_value_2d, *utf::tolerance(1e-12))
3637 Kokkos::View<ScanPathSegment *, Kokkos::HostSpace> scan_paths_segments_view (
3738 scan_path_segments.data (), scan_path_segments.size ());
3839 BeamHeatSourceProperties beam (database);
39- GoldakHeatSource<2 , dealii::MemorySpace::Host> goldak_heat_source (
40+ GoldakHeatSource<dim , dealii::MemorySpace::Host> goldak_heat_source (
4041 beam, ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view));
41- ElectronBeamHeatSource<2 , dealii::MemorySpace::Host> eb_heat_source (
42- database, ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view));
42+ return {database,
43+ ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view)};
44+ }
45+
46+ BOOST_AUTO_TEST_CASE (heat_source_value_2d, *utf::tolerance (1e-12 ))
47+ {
48+ ElectronBeamHeatSource<2 , dealii::MemorySpace::Host> eb_heat_source =
49+ create_heat_sources<2 >();
4350
4451 double g_value = 0.0 ;
4552 double eb_value = 0.0 ;
4653
4754 std::cout << " Checking point 1..." << std::endl;
4855 dealii::Point<2 > point1 (0.0 , 0.15 );
49- goldak_heat_source .update_time (1.0e-7 );
50- g_value = goldak_heat_source .value (point1, 0.2 );
56+ eb_heat_source .update_time (1.0e-7 );
57+ g_value = eb_heat_source .value (point1, 0.2 );
5158 BOOST_TEST (g_value == 0.0 );
5259
5360 eb_heat_source.update_time (1.0e-7 );
@@ -56,8 +63,8 @@ BOOST_AUTO_TEST_CASE(heat_source_value_2d, *utf::tolerance(1e-12))
5663
5764 std::cout << " Checking point 2..." << std::endl;
5865 dealii::Point<2 > point2 (10.0 , 0.0 );
59- goldak_heat_source .update_time (5.0e-7 );
60- g_value = goldak_heat_source .value (point2, 0.2 );
66+ eb_heat_source .update_time (5.0e-7 );
67+ g_value = eb_heat_source .value (point2, 0.2 );
6168 BOOST_TEST (g_value == 0.0 );
6269
6370 eb_heat_source.update_time (5.0e-7 );
@@ -67,8 +74,8 @@ BOOST_AUTO_TEST_CASE(heat_source_value_2d, *utf::tolerance(1e-12))
6774 // Check the beam center 0.001 s into the second segment
6875 std::cout << " Checking point 3..." << std::endl;
6976 dealii::Point<2 > point3 (8.0e-4 , 0.2 );
70- goldak_heat_source .update_time (0.001001 );
71- g_value = goldak_heat_source .value (point3, 0.2 );
77+ eb_heat_source .update_time (0.001001 );
78+ g_value = eb_heat_source .value (point3, 0.2 );
7279 double pi_over_3_to_1p5 = std::pow (dealii::numbers::PI / 3.0 , 1.5 );
7380 double expected_value =
7481 2.0 * 0.1 * 10.0 / (0.5 * 0.5 * 0.1 * pi_over_3_to_1p5);
@@ -83,7 +90,7 @@ BOOST_AUTO_TEST_CASE(heat_source_value_2d, *utf::tolerance(1e-12))
8390 // Check slightly off beam center 0.001 s into the second segment
8491 std::cout << " Checking point 4..." << std::endl;
8592 dealii::Point<2 > point4 (7.0e-4 , 0.19 );
86- g_value = goldak_heat_source .value (point4, 0.2 );
93+ g_value = eb_heat_source .value (point4, 0.2 );
8794 expected_value = 2.0 * 0.1 * 10.0 / (0.5 * 0.5 * 0.1 * pi_over_3_to_1p5);
8895 expected_value *=
8996 std::exp (-3.0 * 1.0e-4 * 1.0e-4 / 0.25 - 3.0 * 0.01 * 0.01 / 0.1 / 0.1 );
@@ -98,8 +105,8 @@ BOOST_AUTO_TEST_CASE(heat_source_value_2d, *utf::tolerance(1e-12))
98105
99106 // Checking beyond the defined time, where the expected value is zero
100107 std::cout << " Checking point 5..." << std::endl;
101- goldak_heat_source .update_time (100.0 );
102- g_value = goldak_heat_source .value (point4, 0.2 );
108+ eb_heat_source .update_time (100.0 );
109+ g_value = eb_heat_source .value (point4, 0.2 );
103110 expected_value = 0.0 ;
104111 BOOST_TEST (g_value == expected_value);
105112
@@ -110,34 +117,16 @@ BOOST_AUTO_TEST_CASE(heat_source_value_2d, *utf::tolerance(1e-12))
110117
111118BOOST_AUTO_TEST_CASE (heat_source_value_3d, *utf::tolerance (1e-12 ))
112119{
113- boost::property_tree::ptree database;
114-
115- database.put (" depth" , 0.1 );
116- database.put (" absorption_efficiency" , 0.1 );
117- database.put (" diameter" , 1.0 );
118- database.put (" max_power" , 10 .);
119- database.put (" scan_path_file" , " scan_path.txt" );
120- database.put (" scan_path_file_format" , " segment" );
121- std::vector<ScanPathSegment> scan_path_segments =
122- ScanPath<dealii::MemorySpace::Host>::extract_scan_paths (
123- database.get <std::string>(" scan_path_file" ),
124- database.get <std::string>(" scan_path_file_format" ));
125- Kokkos::View<ScanPathSegment *, Kokkos::HostSpace> scan_paths_segments_view (
126- scan_path_segments.data (), scan_path_segments.size ());
127- BeamHeatSourceProperties beam (database);
128-
129- GoldakHeatSource<3 , dealii::MemorySpace::Host> goldak_heat_source (
130- beam, ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view));
131- ElectronBeamHeatSource<3 , dealii::MemorySpace::Host> eb_heat_source (
132- beam, ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view));
120+ ElectronBeamHeatSource<3 , dealii::MemorySpace::Host> eb_heat_source =
121+ create_heat_sources<3 >();
133122
134123 double g_value = 0.0 ;
135124 double eb_value = 0.0 ;
136125
137126 std::cout << " Checking point 1..." << std::endl;
138127 dealii::Point<3 > point1 (0.0 , 0.0 , 0.15 );
139- goldak_heat_source .update_time (1.0e-7 );
140- g_value = goldak_heat_source .value (point1, 0.2 );
128+ eb_heat_source .update_time (1.0e-7 );
129+ g_value = eb_heat_source .value (point1, 0.2 );
141130 BOOST_TEST (g_value == 0.0 );
142131
143132 eb_heat_source.update_time (1.0e-7 );
@@ -146,8 +135,8 @@ BOOST_AUTO_TEST_CASE(heat_source_value_3d, *utf::tolerance(1e-12))
146135
147136 std::cout << " Checking point 2..." << std::endl;
148137 dealii::Point<3 > point2 (10.0 , 0.0 , 0.0 );
149- goldak_heat_source .update_time (5.0e-7 );
150- g_value = goldak_heat_source .value (point2, 0.2 );
138+ eb_heat_source .update_time (5.0e-7 );
139+ g_value = eb_heat_source .value (point2, 0.2 );
151140 BOOST_TEST (g_value == 0.0 );
152141
153142 eb_heat_source.update_time (5.0e-7 );
@@ -157,8 +146,8 @@ BOOST_AUTO_TEST_CASE(heat_source_value_3d, *utf::tolerance(1e-12))
157146 // Check the beam center 0.001 s into the second segment
158147 std::cout << " Checking point 3..." << std::endl;
159148 dealii::Point<3 > point3 (8e-4 , 0.1 , 0.2 );
160- goldak_heat_source .update_time (0.001001 );
161- g_value = goldak_heat_source .value (point3, 0.2 );
149+ eb_heat_source .update_time (0.001001 );
150+ g_value = eb_heat_source .value (point3, 0.2 );
162151 double pi_over_3_to_1p5 = std::pow (dealii::numbers::PI / 3.0 , 1.5 );
163152 double expected_value = 2.0 * 0.1 * 10.0 / 0.5 / 0.5 / 0.1 / pi_over_3_to_1p5;
164153 BOOST_TEST (g_value == expected_value);
@@ -172,7 +161,7 @@ BOOST_AUTO_TEST_CASE(heat_source_value_3d, *utf::tolerance(1e-12))
172161 // Check slightly off beam center 0.001 s into the second segment
173162 std::cout << " Checking point 4..." << std::endl;
174163 dealii::Point<3 > point4 (7.0e-4 , 0.1 , 0.19 );
175- g_value = goldak_heat_source .value (point4, 0.2 );
164+ g_value = eb_heat_source .value (point4, 0.2 );
176165 expected_value = 2.0 * 0.1 * 10.0 / (0.5 * 0.5 * 0.1 * pi_over_3_to_1p5);
177166 expected_value *=
178167 std::exp (-3.0 * 1.0e-4 * 1.0e-4 / 0.25 - 3.0 * 0.01 * 0.01 / 0.1 / 0.1 );
@@ -188,46 +177,28 @@ BOOST_AUTO_TEST_CASE(heat_source_value_3d, *utf::tolerance(1e-12))
188177
189178BOOST_AUTO_TEST_CASE (heat_source_height, *utf::tolerance (1e-12 ))
190179{
191- boost::property_tree::ptree database;
192-
193- database.put (" depth" , 0.1 );
194- database.put (" absorption_efficiency" , 0.1 );
195- database.put (" diameter" , 1.0 );
196- database.put (" max_power" , 10 .);
197- database.put (" scan_path_file" , " scan_path_layers.txt" );
198- database.put (" scan_path_file_format" , " segment" );
199- std::vector<ScanPathSegment> scan_path_segments =
200- ScanPath<dealii::MemorySpace::Host>::extract_scan_paths (
201- database.get <std::string>(" scan_path_file" ),
202- database.get <std::string>(" scan_path_file_format" ));
203- Kokkos::View<ScanPathSegment *, Kokkos::HostSpace> scan_paths_segments_view (
204- scan_path_segments.data (), scan_path_segments.size ());
205- BeamHeatSourceProperties beam (database);
206-
207- GoldakHeatSource<2 , dealii::MemorySpace::Host> goldak_heat_source (
208- beam, ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view));
209- ElectronBeamHeatSource<2 , dealii::MemorySpace::Host> eb_heat_source (
210- beam, ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view));
180+ ElectronBeamHeatSource<2 , dealii::MemorySpace::Host> eb_heat_source =
181+ create_heat_sources<2 >();
211182
212183 double g_height = 0.0 ;
213184 double eb_height = 0.0 ;
214185
215186 // Check the height for the first segment
216- g_height = goldak_heat_source .get_current_height (1.0e-7 );
187+ g_height = eb_heat_source .get_current_height (1.0e-7 );
217188 BOOST_TEST (g_height == 0 .);
218189
219190 eb_height = eb_heat_source.get_current_height (1.0e-7 );
220191 BOOST_TEST (eb_height == 0 .);
221192
222193 // Check the height for the second segment
223- g_height = goldak_heat_source .get_current_height (0.001001 );
194+ g_height = eb_heat_source .get_current_height (0.001001 );
224195 BOOST_TEST (g_height == 0 .);
225196
226197 eb_height = eb_heat_source.get_current_height (0.001001 );
227198 BOOST_TEST (eb_height == 0 .);
228199
229200 // Check the height for the third segment
230- g_height = goldak_heat_source .get_current_height (0.003 );
201+ g_height = eb_heat_source .get_current_height (0.003 );
231202 BOOST_TEST (g_height == 0.001 );
232203
233204 eb_height = eb_heat_source.get_current_height (0.003 );
0 commit comments