-
Notifications
You must be signed in to change notification settings - Fork 25
[SPH][GSPH][Common] Make the rendering module of SPH common to SPH and GSPH #1717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
y-lapeyre
wants to merge
3
commits into
Shamrock-code:main
Choose a base branch
from
y-lapeyre:doc/gsph_shocktube
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/shammodels/common/include/shammodels/common/modules/render/RenderConfig.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // -------------------------------------------------------// | ||
| // | ||
| // SHAMROCK code for hydrodynamics | ||
| // Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me> | ||
| // SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1 | ||
| // Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information | ||
| // | ||
| // -------------------------------------------------------// | ||
|
|
||
| #pragma once | ||
|
|
||
| /** | ||
| * @file RenderConfig.hpp | ||
|
|
||
| * @author Yona Lapeyre (yona.lapeyre@ens-lyon.fr) | ||
| * @brief | ||
| * | ||
| */ | ||
|
|
||
|
|
||
| namespace shammodels::common { | ||
|
|
||
| template<class Tscal> | ||
| struct RenderConfig; | ||
|
|
||
| template<class Tscal> | ||
| struct RenderConfig { | ||
| //Tscal hfact; | ||
| Tscal gpart_mass; | ||
| unsigned int tree_reduction_level; | ||
|
|
||
| }; | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,12 +18,15 @@ | |
| #include "shambase/exception.hpp" | ||
| #include "shambackends/kernel_call.hpp" | ||
| #include "shammath/AABB.hpp" | ||
| #include "shammodels/sph/math/density.hpp" | ||
| #include "shammodels/sph/modules/render/CartesianRender.hpp" | ||
| #include "shammodels/sph/modules/render/RenderFieldGetter.hpp" | ||
| #include "shammodels/common/density.hpp" | ||
| #include "shammodels/common/modules/render/CartesianRender.hpp" | ||
| #include "shamtree/KarrasRadixTreeField.hpp" | ||
| #include "shamtree/RadixTree.hpp" | ||
| #include "shamtree/TreeTraversal.hpp" | ||
| #include "shammodels/common/modules/render/RenderFieldGetter.hpp" | ||
| #include "shamrock/scheduler/SchedulerUtility.hpp" | ||
|
|
||
| namespace shammodels::sph::modules { | ||
| namespace shammodels::common::modules { | ||
|
|
||
| template<class Tvec> | ||
| sham::DeviceBuffer<Tvec> pixel_to_positions( | ||
|
|
@@ -95,8 +98,8 @@ namespace shammodels::sph::modules { | |
| return ret; | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_slice( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_slice( | ||
| std::string field_name, | ||
| const sham::DeviceBuffer<Tvec> &positions, | ||
| std::optional<std::function<py::array_t<Tfield>(size_t, pybind11::dict &)>> custom_getter) | ||
|
|
@@ -114,7 +117,7 @@ namespace shammodels::sph::modules { | |
| shambase::Timer t; | ||
| t.start(); | ||
|
|
||
| auto ret = RenderFieldGetter<Tvec, Tfield, SPHKernel>(context, solver_config, storage) | ||
| auto ret = RenderFieldGetter<Tvec, Tfield, SPHKernel, TStorage>(context, render_config, storage) | ||
| .runner_function( | ||
| field_name, | ||
| [&](auto field_getter) -> sham::DeviceBuffer<Tfield> { | ||
|
|
@@ -132,8 +135,8 @@ namespace shammodels::sph::modules { | |
| return ret; | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_column_integ( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_column_integ( | ||
| std::string field_name, | ||
| const sham::DeviceBuffer<shammath::Ray<Tvec>> &rays, | ||
| std::optional<std::function<py::array_t<Tfield>(size_t, pybind11::dict &)>> custom_getter) | ||
|
|
@@ -151,7 +154,7 @@ namespace shammodels::sph::modules { | |
| shambase::Timer t; | ||
| t.start(); | ||
|
|
||
| auto ret = RenderFieldGetter<Tvec, Tfield, SPHKernel>(context, solver_config, storage) | ||
| auto ret = RenderFieldGetter<Tvec, Tfield, SPHKernel, TStorage>(context, render_config, storage) | ||
| .runner_function( | ||
| field_name, | ||
| [&](auto field_getter) -> sham::DeviceBuffer<Tfield> { | ||
|
|
@@ -169,8 +172,8 @@ namespace shammodels::sph::modules { | |
| return ret; | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_azymuthal_integ( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_azymuthal_integ( | ||
| std::string field_name, | ||
| const sham::DeviceBuffer<shammath::RingRay<Tvec>> &ring_rays, | ||
| std::optional<std::function<py::array_t<Tfield>(size_t, pybind11::dict &)>> custom_getter) | ||
|
|
@@ -188,7 +191,7 @@ namespace shammodels::sph::modules { | |
| shambase::Timer t; | ||
| t.start(); | ||
|
|
||
| auto ret = RenderFieldGetter<Tvec, Tfield, SPHKernel>(context, solver_config, storage) | ||
| auto ret = RenderFieldGetter<Tvec, Tfield, SPHKernel, TStorage>(context, render_config, storage) | ||
| .runner_function( | ||
| field_name, | ||
| [&](auto field_getter) -> sham::DeviceBuffer<Tfield> { | ||
|
|
@@ -206,8 +209,8 @@ namespace shammodels::sph::modules { | |
| return ret; | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_slice( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_slice( | ||
| std::function<field_getter_t> field_getter, const sham::DeviceBuffer<Tvec> &positions) | ||
| -> sham::DeviceBuffer<Tfield> { | ||
|
|
||
|
|
@@ -240,7 +243,7 @@ namespace shammodels::sph::modules { | |
| {box.lower, box.upper}, | ||
| buf_xyz, | ||
| obj_cnt, | ||
| solver_config.tree_reduction_level); | ||
| render_config.tree_reduction_level); | ||
|
|
||
| tree.compute_cell_ibounding_box(shamsys::instance::get_compute_queue()); | ||
| tree.convert_bounding_box(shamsys::instance::get_compute_queue()); | ||
|
|
@@ -269,7 +272,7 @@ namespace shammodels::sph::modules { | |
|
|
||
| constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern; | ||
|
|
||
| Tscal partmass = solver_config.gpart_mass; | ||
| Tscal partmass = render_config.gpart_mass; | ||
|
|
||
| shambase::parallel_for( | ||
| cgh, positions.get_size(), "compute slice render", [=](u32 gid) { | ||
|
|
@@ -320,8 +323,8 @@ namespace shammodels::sph::modules { | |
| return ret; | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_column_integ( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_column_integ( | ||
| std::function<field_getter_t> field_getter, | ||
| const sham::DeviceBuffer<shammath::Ray<Tvec>> &rays) -> sham::DeviceBuffer<Tfield> { | ||
|
|
||
|
|
@@ -354,7 +357,7 @@ namespace shammodels::sph::modules { | |
| {box.lower, box.upper}, | ||
| buf_xyz, | ||
| obj_cnt, | ||
| solver_config.tree_reduction_level); | ||
| render_config.tree_reduction_level); | ||
|
|
||
| tree.compute_cell_ibounding_box(shamsys::instance::get_compute_queue()); | ||
| tree.convert_bounding_box(shamsys::instance::get_compute_queue()); | ||
|
|
@@ -383,7 +386,7 @@ namespace shammodels::sph::modules { | |
|
|
||
| constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern; | ||
|
|
||
| Tscal partmass = solver_config.gpart_mass; | ||
| Tscal partmass = render_config.gpart_mass; | ||
|
|
||
| shambase::parallel_for(cgh, rays.get_size(), "compute slice render", [=](u32 gid) { | ||
| Tfield ret = sham::VectorProperties<Tfield>::get_zero(); | ||
|
|
@@ -435,8 +438,8 @@ namespace shammodels::sph::modules { | |
| return ret; | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_azymuthal_integ( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_azymuthal_integ( | ||
| std::function<field_getter_t> field_getter, | ||
| const sham::DeviceBuffer<shammath::RingRay<Tvec>> &ring_rays) | ||
| -> sham::DeviceBuffer<Tfield> { | ||
|
|
@@ -470,7 +473,7 @@ namespace shammodels::sph::modules { | |
| {box.lower, box.upper}, | ||
| buf_xyz, | ||
| obj_cnt, | ||
| solver_config.tree_reduction_level); | ||
| render_config.tree_reduction_level); | ||
|
|
||
| tree.compute_cell_ibounding_box(shamsys::instance::get_compute_queue()); | ||
| tree.convert_bounding_box(shamsys::instance::get_compute_queue()); | ||
|
|
@@ -499,7 +502,7 @@ namespace shammodels::sph::modules { | |
|
|
||
| constexpr Tscal Rker2 = Kernel::Rkern * Kernel::Rkern; | ||
|
|
||
| Tscal partmass = solver_config.gpart_mass; | ||
| Tscal partmass = render_config.gpart_mass; | ||
|
|
||
| shambase::parallel_for( | ||
| cgh, ring_rays.get_size(), "compute slice render", [=](u32 gid) { | ||
|
|
@@ -560,8 +563,8 @@ namespace shammodels::sph::modules { | |
| return ret; | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_slice( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_slice( | ||
| std::function<field_getter_t> field_getter, | ||
| Tvec center, | ||
| Tvec delta_x, | ||
|
|
@@ -574,8 +577,8 @@ namespace shammodels::sph::modules { | |
| return compute_slice(field_getter, positions); | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_column_integ( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_column_integ( | ||
| std::function<field_getter_t> field_getter, | ||
| Tvec center, | ||
| Tvec delta_x, | ||
|
|
@@ -588,8 +591,8 @@ namespace shammodels::sph::modules { | |
| return compute_column_integ(field_getter, rays); | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_slice( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_slice( | ||
| std::string field_name, | ||
| Tvec center, | ||
| Tvec delta_x, | ||
|
|
@@ -602,8 +605,8 @@ namespace shammodels::sph::modules { | |
| return compute_slice(field_name, positions, custom_getter); | ||
| } | ||
|
|
||
| template<class Tvec, class Tfield, template<class> class SPHKernel> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel>::compute_column_integ( | ||
| template<class Tvec, class Tfield, template<class> class SPHKernel, class TStorage> | ||
| auto CartesianRender<Tvec, Tfield, SPHKernel, TStorage>::compute_column_integ( | ||
| std::string field_name, | ||
| Tvec center, | ||
| Tvec delta_x, | ||
|
|
@@ -617,20 +620,3 @@ namespace shammodels::sph::modules { | |
| } | ||
|
|
||
| } // namespace shammodels::sph::modules | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| using namespace shammath; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64, M4>; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64, M6>; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64, M8>; | ||
|
|
||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64, C2>; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64, C4>; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64, C6>; | ||
|
|
||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64_3, M4>; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64_3, M6>; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64_3, M8>; | ||
|
|
||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64_3, C2>; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64_3, C4>; | ||
| template class shammodels::sph::modules::CartesianRender<f64_3, f64_3, C6>; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The forward declaration
template<class Tscal> struct RenderConfig;on line 24 is redundant since the struct is defined immediately after. Also, the struct definition has inconsistent indentation. I'd also recommend adding a newline at the end of the file for consistency with other files.