@@ -19,27 +19,43 @@ 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+ std::tuple<Kokkos::View<ScanPathSegment *, Kokkos::HostSpace>,
24+ ElectronBeamHeatSource<dim, dealii::MemorySpace::Host>,
25+ GoldakHeatSource<dim, dealii::MemorySpace::Host>>
26+ create_heat_sources (std::string scan_path_file)
2327{
2428 boost::property_tree::ptree database;
2529
2630 database.put (" depth" , 0.1 );
2731 database.put (" absorption_efficiency" , 0.1 );
2832 database.put (" diameter" , 1.0 );
2933 database.put (" max_power" , 10 .);
30- database.put (" scan_path_file" , " scan_path.txt " );
34+ database.put (" scan_path_file" , scan_path_file );
3135 database.put (" scan_path_file_format" , " segment" );
3236 std::vector<ScanPathSegment> scan_path_segments =
3337 ScanPath<dealii::MemorySpace::Host>::extract_scan_paths (
3438 database.get <std::string>(" scan_path_file" ),
3539 database.get <std::string>(" scan_path_file_format" ));
36- Kokkos::View<ScanPathSegment *, Kokkos::HostSpace> scan_paths_segments_view (
37- scan_path_segments.data (), scan_path_segments.size ());
40+ Kokkos::View<ScanPathSegment *, Kokkos::HostSpace> scan_path_segments_view (
41+ " scan_path_segments" , scan_path_segments.size ());
42+ Kokkos::deep_copy (scan_path_segments_view,
43+ Kokkos::View<ScanPathSegment *, Kokkos::HostSpace>{
44+ scan_path_segments.data (), scan_path_segments.size ()});
3845 BeamHeatSourceProperties beam (database);
39- GoldakHeatSource<2 , dealii::MemorySpace::Host> goldak_heat_source (
40- 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));
46+ return std::tuple (
47+ scan_path_segments_view,
48+ ElectronBeamHeatSource<dim, dealii::MemorySpace::Host>{
49+ database,
50+ ScanPath<dealii::MemorySpace::Host>(scan_path_segments_view)},
51+ GoldakHeatSource<dim, dealii::MemorySpace::Host>{
52+ beam, ScanPath<dealii::MemorySpace::Host>(scan_path_segments_view)});
53+ }
54+
55+ BOOST_AUTO_TEST_CASE (heat_source_value_2d, *utf::tolerance (1e-12 ))
56+ {
57+ auto [scan_paths_segments, eb_heat_source, goldak_heat_source] =
58+ create_heat_sources<2 >(" scan_path.txt" );
4359
4460 double g_value = 0.0 ;
4561 double eb_value = 0.0 ;
@@ -110,26 +126,8 @@ BOOST_AUTO_TEST_CASE(heat_source_value_2d, *utf::tolerance(1e-12))
110126
111127BOOST_AUTO_TEST_CASE (heat_source_value_3d, *utf::tolerance (1e-12 ))
112128{
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));
129+ auto [scan_paths_segments, eb_heat_source, goldak_heat_source] =
130+ create_heat_sources<3 >(" scan_path.txt" );
133131
134132 double g_value = 0.0 ;
135133 double eb_value = 0.0 ;
@@ -188,26 +186,8 @@ BOOST_AUTO_TEST_CASE(heat_source_value_3d, *utf::tolerance(1e-12))
188186
189187BOOST_AUTO_TEST_CASE (heat_source_height, *utf::tolerance (1e-12 ))
190188{
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));
189+ auto [scan_paths_segments, eb_heat_source, goldak_heat_source] =
190+ create_heat_sources<2 >(" scan_path_layers.txt" );
211191
212192 double g_height = 0.0 ;
213193 double eb_height = 0.0 ;
0 commit comments