Conversation
source/ScanPath.cc
Outdated
|
|
||
| _segment_list.push_back(segment); | ||
| if (_segment_list_length == MAX_NUMBER_OF_SEGMENTS) | ||
| Kokkos::abort("too many segmnets"); |
There was a problem hiding this comment.
Typo:
| Kokkos::abort("too many segmnets"); | |
| Kokkos::abort("too many segments"); |
source/ScanPath.hh
Outdated
| #include <istream> | ||
| #include <vector> | ||
|
|
||
| #define MAX_NUMBER_OF_SEGMENTS 100 |
There was a problem hiding this comment.
This is too low -- if we had a 50-layer print with only two segments per layer, we'd hit this. I'm not sure that we've done enough sliced full parts to know a good upper bound. For example the AOP hourglass has 8055 segments and that's pretty simple as far as "real" parts go. Can we use a Kokkos::View with a runtime-defined length instead?
There was a problem hiding this comment.
That was one of my next steps but I would need to manage the allocations for the segments outside the heat sources to avoid Views of managed Views. I'm not sure how much freedom we have to change those APIs.
The current version should be (more or less) device-usable already at least.
There was a problem hiding this comment.
Ok, got it. Maybe another option would be to make it a template parameter? Even with the dynamic scan path in #223, we wouldn't be changing the length of the scan path too many times per simulation.
There was a problem hiding this comment.
Sure, changing it to a template argument for the heat source and the scan path is easy. The question then is if we want to have a runtime dispatch for pre-instantiated maximum sizes or any other mechanism that doesn't require rebuilding the library and the application for certain input files.
There was a problem hiding this comment.
We don't want to do this. We don't know how many segments we will need but it's potentially very large. If someone wants to do point-source raster for PBF, the number of segments will be huge.
In the current code, the scan path is part of the heat source. You need to change that. Move the scan path to HeatSources, add a function that evaluates the scan patch from t_0 to t_1 and fill a Kokkos::View. This way we don't need to know the number of segments and you don't waste memory if you have a ton a segments.
I'm not sure how much freedom we have to change those APIs.
adamantine is not a library. Everything but the input parameters is an implementation detail.
d1ce403 to
456fa4e
Compare
6d9d625 to
ac4d8a9
Compare
ac4d8a9 to
cf6263f
Compare
aaa3bdf to
4ec8fd0
Compare
source/HeatSources.hh
Outdated
| template <typename MemorySpace, int dim> | ||
| std::vector<ScanPath<MemorySpace>> | ||
| HeatSources<MemorySpace, dim>::get_scan_paths() const | ||
| { | ||
| std::vector<ScanPath<MemorySpace>> scan_paths; | ||
| for (unsigned int i = 0; i < _electron_beam_heat_sources.size(); ++i) | ||
| scan_paths.push_back(_electron_beam_heat_sources(i).get_scan_path()); | ||
| for (unsigned int i = 0; i < _goldak_heat_sources.size(); ++i) | ||
| scan_paths.push_back(_goldak_heat_sources(i).get_scan_path()); | ||
| return scan_paths; | ||
| } |
There was a problem hiding this comment.
Is it important for the order here to match the input file?
There was a problem hiding this comment.
No it's not. There is no order in the input file. You can reorder everything and the same input file will work.
Rombur
left a comment
There was a problem hiding this comment.
You will need to rebase the PR on develop. There was some small changes in ScanPath.
application/adamantine.hh
Outdated
| // coarsest mesh we may need to add other points to check (e.g. | ||
| // quadrature points, vertices). | ||
| for (unsigned int f = 0; f < cell->reference_cell().n_faces(); ++f) | ||
| if (heat_sources.max_value(cell->face(f)->center(), current_source_height) > |
There was a problem hiding this comment.
You should just use value. In practice, value and max_value will probably always be the same because heat sources do not overlap.
application/adamantine.hh
Outdated
| const double refinement_beam_cutoff = | ||
| refinement_database.get<double>("beam_cutoff", 1.0e-15); | ||
|
|
||
| adamantine::HeatSources<dim, dealii::MemorySpace::Host> host_heat_sources = heat_sources.copy_to(dealii::MemorySpace::Host{}); |
There was a problem hiding this comment.
Please use heat_sources_host instead of host_heat_sources. We use the suffixes _host and _dev instead of the prefixes host_ and dev_. This helps when using autocomplete.
application/adamantine.hh
Outdated
| mechanical_physics, displacement, material_properties, timers); | ||
| ++n_time_step; | ||
|
|
||
| adamantine::HeatSources<dim, dealii::MemorySpace::Host> host_heat_sources = heat_sources.copy_to(dealii::MemorySpace::Host{}); |
source/CubeHeatSource.cc
Outdated
| #include <instantiation.hh> | ||
| #include <types.hh> | ||
|
|
||
| #include <deal.II/base/memory_space.h> |
source/CubeHeatSource.hh
Outdated
| */ | ||
| template <int dim> | ||
| class CubeHeatSource final : public HeatSource<dim> | ||
| class CubeHeatSource final |
There was a problem hiding this comment.
| class CubeHeatSource final | |
| class CubeHeatSource |
source/ThermalPhysics.templates.hh
Outdated
| } | ||
| _current_source_height = temp_height; | ||
| _current_source_height = | ||
| _heat_sources.copy_to(dealii::MemorySpace::Host{}).get_current_height(t); |
|
|
||
| template <int dim> | ||
| class HeatSource; | ||
|
|
There was a problem hiding this comment.
You don't need a forward declaration because you are relying on the order of the includes.
There was a problem hiding this comment.
You still need a forward declaration, otherwise the code may break if the include are reordered.
source/ScanPath.hh
Outdated
| } | ||
|
|
||
| static std::vector<ScanPathSegment> | ||
| extract_scan_paths(std::string scan_path_file, std::string file_format); |
There was a problem hiding this comment.
I don't really like this name. You are just reading from a file.
tests/test_heat_source.cc
Outdated
| GoldakHeatSource<2, dealii::MemorySpace::Host> goldak_heat_source( | ||
| beam, ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view)); | ||
| ElectronBeamHeatSource<2, dealii::MemorySpace::Host> eb_heat_source( | ||
| database, ScanPath<dealii::MemorySpace::Host>(scan_paths_segments_view)); |
There was a problem hiding this comment.
Can you put this code in a function instead of copy/pasting three times.
tests/test_material_deposition.cc
Outdated
| scan_paths_segments_view(scan_path_segments.data(), | ||
| scan_path_segments.size()); | ||
| adamantine::ScanPath<dealii::MemorySpace::Host> scan_path( | ||
| scan_paths_segments_view); |
There was a problem hiding this comment.
Put this code in a function to avoid the copy/paste.
a100e94 to
b467051
Compare
433f9ec to
ab3a2d5
Compare
|
Retest this please. |
|
Let me know when you want another review on this. |
This could take another review now. Some notes:
|
application/adamantine.hh
Outdated
| heat_sources_host = | ||
| heat_sources.copy_to(dealii::MemorySpace::Host{}); | ||
| heat_sources_host.update_scan_paths(); | ||
| heat_sources = heat_sources_host.copy_to(MemorySpaceType{}); |
There was a problem hiding this comment.
I don't like that you are copying back and forth such a heavy class just to read a file. update_scan_path() should do the right thing.
| { | ||
| template <int dim> | ||
| CubeHeatSource<dim>::CubeHeatSource(boost::property_tree::ptree const &database) | ||
| : HeatSource<dim>() |
There was a problem hiding this comment.
Update the copyright date to 2024
| #define CUBE_HEAT_SOURCE_HH | ||
|
|
||
| #include <HeatSource.hh> | ||
| #include <BeamHeatSourceProperties.hh> |
There was a problem hiding this comment.
This line should be removed and the copyright date updated.
| template <int dim, typename MemorySpaceType> | ||
| void ElectronBeamHeatSource<dim, MemorySpaceType>::update_time(double time) | ||
| { | ||
| static const double log_01 = std::log(0.1); |
source/ElectronBeamHeatSource.hh
Outdated
| void set_scan_path(ScanPath<MemorySpaceType> const scan_path) | ||
| { | ||
| _scan_path = scan_path; | ||
| } |
There was a problem hiding this comment.
Move the implementation out of the class declaration
source/HeatSources.hh
Outdated
|
|
||
| for (unsigned int i = 0; i < _goldak_heat_sources.size(); ++i) | ||
| _goldak_heat_sources(i).set_scan_path( | ||
| ScanPath<MemorySpaceType>{_goldak_scan_path_segments[i]}); |
There was a problem hiding this comment.
Why are we keeping track of the scan path in HeatSources and in each individual sources? We should not duplicate this information.
| value += _cube_heat_sources(i).value(point, height); | ||
| for (unsigned int i = 0; i < _goldak_heat_sources.size(); ++i) | ||
| value += _goldak_heat_sources(i).value(point, height); | ||
| return value; |
source/ScanPath.cc
Outdated
|
|
||
| template <typename MemorySpaceType> | ||
| std::vector<ScanPathSegment> | ||
| ScanPath<MemorySpaceType>::extract_scan_paths(std::string scan_path_file, |
source/ScanPath.hh
Outdated
| * gives the power modifier for the current segment. It reads in the scan path | ||
| * from a text file. | ||
| */ | ||
| template <typename MemorySpaceType> |
There was a problem hiding this comment.
Is is actually necessary to have the ScanPath on the GPU? I feel like this should only exists on the CPU and we should only move part of the data when it's necessary. Otherwise, we will end up using several GBs of memory on the GPU just for the ScanPath.
|
|
||
| template <int dim> | ||
| class HeatSource; | ||
|
|
There was a problem hiding this comment.
You still need a forward declaration, otherwise the code may break if the include are reordered.
8c5c979 to
1f5f784
Compare
This is a step towards #190. This pull request replaces
std::vector<std::shared_ptr<adamantine::HeatSource<dim>>>withHeatSourcesthat contains all heat sources as Kokkos::Views and loops over them in its member functions. With this approach, there is no dynamic polymorphism and the compiler could inline all function calls for the heat sources. In particular, this object would be usable on GPUs (apart from function annotations).