@@ -43,6 +43,14 @@ public:
4343 */
4444 void update_time (double time);
4545
46+ /* *
47+ * Update the scan paths for all heat sources reading again from the
48+ * respective files.
49+ */
50+ template <typename Dummy = MemorySpaceType>
51+ std::enable_if_t <std::is_same_v<Dummy, dealii::MemorySpace::Host>>
52+ update_scan_paths ();
53+
4654 /* *
4755 * Compute the cumulative heat source at a given point at a given time given
4856 * the current height of the object being manufactured.
@@ -77,6 +85,11 @@ private:
7785 friend class HeatSources <dim, dealii::MemorySpace::Default>;
7886 friend class HeatSources <dim, dealii::MemorySpace::Host>;
7987
88+ /* *
89+ * Private helper for update_scan_paths
90+ */
91+ void internal_update_scan_paths ();
92+
8093 /* *
8194 * Private constructor used by copy_to_host.
8295 */
@@ -117,17 +130,67 @@ private:
117130 std::vector<int > _electron_beam_indices;
118131 std::vector<int > _cube_indices;
119132 std::vector<int > _goldak_indices;
133+
134+ std::vector<std::string> _goldak_scan_files;
135+ std::vector<std::string> _electron_beam_scan_files;
136+ std::vector<std::string> _goldak_scan_formats;
137+ std::vector<std::string> _electron_beam_scan_formats;
120138};
121139
140+ template <int dim, typename MemorySpaceType>
141+ void HeatSources<dim, MemorySpaceType>::internal_update_scan_paths()
142+ {
143+ std::vector<ScanPathSegment> scan_path_segments;
144+ for (unsigned int i = 0 ; i < _goldak_indices.size (); ++i)
145+ {
146+ scan_path_segments = ScanPath<MemorySpaceType>::extract_scan_paths (
147+ _goldak_scan_files[i], _goldak_scan_formats[i]);
148+ _goldak_scan_path_segments.emplace_back (
149+ Kokkos::view_alloc (Kokkos::WithoutInitializing,
150+ " goldak_scan_path_segments_" + std::to_string (i)),
151+ scan_path_segments.size ());
152+ Kokkos::deep_copy (
153+ _goldak_scan_path_segments.back (),
154+ Kokkos::View<ScanPathSegment *, Kokkos::HostSpace>(
155+ scan_path_segments.data (), scan_path_segments.size ()));
156+ }
157+ for (unsigned int i = 0 ; i < _electron_beam_indices.size (); ++i)
158+ {
159+ scan_path_segments = ScanPath<MemorySpaceType>::extract_scan_paths (
160+ _electron_beam_scan_files[i], _electron_beam_scan_formats[i]);
161+ _electron_beam_scan_path_segments.emplace_back (
162+ Kokkos::view_alloc (Kokkos::WithoutInitializing,
163+ " electron_beam_scan_path_segments_" +
164+ std::to_string (i)),
165+ scan_path_segments.size ());
166+ Kokkos::deep_copy (
167+ _electron_beam_scan_path_segments.back (),
168+ Kokkos::View<ScanPathSegment *, Kokkos::HostSpace>(
169+ scan_path_segments.data (), scan_path_segments.size ()));
170+ }
171+ }
172+
173+ template <int dim, typename MemorySpaceType>
174+ template <typename Dummy>
175+ std::enable_if_t <std::is_same_v<Dummy, dealii::MemorySpace::Host>>
176+ HeatSources<dim, MemorySpaceType>::update_scan_paths()
177+ {
178+ internal_update_scan_paths ();
179+ for (int i = 0 ; _goldak_heat_sources.size (); ++i)
180+ _goldak_heat_sources (i).set_scan_path (
181+ ScanPath<MemorySpaceType>{_goldak_scan_path_segments[i]});
182+ for (int i = 0 ; _electron_beam_heat_sources.size (); ++i)
183+ _electron_beam_heat_sources (i).set_scan_path (
184+ ScanPath<MemorySpaceType>{_electron_beam_scan_path_segments[i]});
185+ }
186+
122187template <int dim, typename MemorySpaceType>
123188HeatSources<dim, MemorySpaceType>::HeatSources(
124189 boost::property_tree::ptree const &source_database)
125190{
126191 unsigned int const n_beams = source_database.get <unsigned int >(" n_beams" );
127192 std::vector<BeamHeatSourceProperties> goldak_beams;
128193 std::vector<BeamHeatSourceProperties> electron_beam_beams;
129- std::vector<std::vector<ScanPathSegment>> goldak_scan_path_segments;
130- std::vector<std::vector<ScanPathSegment>> electron_beam_scan_path_segments;
131194 std::vector<CubeHeatSource<dim>> cube_heat_sources;
132195
133196 for (unsigned int i = 0 ; i < n_beams; ++i)
@@ -138,20 +201,20 @@ HeatSources<dim, MemorySpaceType>::HeatSources(
138201 if (type == " goldak" )
139202 {
140203 goldak_beams.emplace_back (beam_database);
141- goldak_scan_path_segments.push_back (
142- ScanPath<MemorySpaceType>::extract_scan_paths (
143- beam_database.get <std::string>(" scan_path_file" ),
144- beam_database.get <std::string>(" scan_path_file_format" )));
145204 _goldak_indices.push_back (i);
205+ _goldak_scan_files.push_back (
206+ beam_database.get <std::string>(" scan_path_file" ));
207+ _goldak_scan_formats.push_back (
208+ beam_database.get <std::string>(" scan_path_file_format" ));
146209 }
147210 else if (type == " electron_beam" )
148211 {
149212 electron_beam_beams.emplace_back (beam_database);
150- electron_beam_scan_path_segments.push_back (
151- ScanPath<MemorySpaceType>::extract_scan_paths (
152- beam_database.get <std::string>(" scan_path_file" ),
153- beam_database.get <std::string>(" scan_path_file_format" )));
154213 _electron_beam_indices.push_back (i);
214+ _electron_beam_scan_files.push_back (
215+ beam_database.get <std::string>(" scan_path_file" ));
216+ _electron_beam_scan_formats.push_back (
217+ beam_database.get <std::string>(" scan_path_file_format" ));
155218 }
156219 else if (type == " cube" )
157220 {
@@ -166,35 +229,20 @@ HeatSources<dim, MemorySpaceType>::HeatSources(
166229 }
167230 }
168231
232+ internal_update_scan_paths ();
233+
169234 std::vector<GoldakHeatSource<dim, MemorySpaceType>> goldak_heat_sources;
170- for (unsigned int i = 0 ; i < goldak_scan_path_segments .size (); ++i)
235+ for (unsigned int i = 0 ; i < goldak_beams .size (); ++i)
171236 {
172- _goldak_scan_path_segments.emplace_back (
173- Kokkos::view_alloc (Kokkos::WithoutInitializing,
174- " goldak_scan_path_segments_" + std::to_string (i)),
175- goldak_scan_path_segments[i].size ());
176- Kokkos::deep_copy (_goldak_scan_path_segments.back (),
177- Kokkos::View<ScanPathSegment *, Kokkos::HostSpace>(
178- goldak_scan_path_segments[i].data (),
179- goldak_scan_path_segments[i].size ()));
180237 goldak_heat_sources.emplace_back (
181238 goldak_beams[i],
182239 ScanPath<MemorySpaceType>(_goldak_scan_path_segments.back ()));
183240 }
184241
185242 std::vector<ElectronBeamHeatSource<dim, MemorySpaceType>>
186243 electron_beam_heat_sources;
187- for (unsigned int i = 0 ; i < electron_beam_scan_path_segments .size (); ++i)
244+ for (unsigned int i = 0 ; i < electron_beam_beams .size (); ++i)
188245 {
189- _electron_beam_scan_path_segments.emplace_back (
190- Kokkos::view_alloc (Kokkos::WithoutInitializing,
191- " electron_beam_scan_path_segments_" +
192- std::to_string (i)),
193- electron_beam_scan_path_segments[i].size ());
194- Kokkos::deep_copy (_electron_beam_scan_path_segments.back (),
195- Kokkos::View<ScanPathSegment *, Kokkos::HostSpace>(
196- electron_beam_scan_path_segments[i].data (),
197- electron_beam_scan_path_segments[i].size ()));
198246 electron_beam_heat_sources.emplace_back (
199247 electron_beam_beams[i],
200248 ScanPath<MemorySpaceType>(_electron_beam_scan_path_segments.back ()));
0 commit comments