From dadb9cc092e85de84aad6daee1d60c6ea51b8161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20P=C3=A9an?= Date: Tue, 19 Nov 2024 16:54:10 +0100 Subject: [PATCH 1/3] Fix `TransformShape::findBounds` --- src/shared/geometries/transform_shape.h | 29 ++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/shared/geometries/transform_shape.h b/src/shared/geometries/transform_shape.h index 2eab0e12f3..e3d1ea5b52 100644 --- a/src/shared/geometries/transform_shape.h +++ b/src/shared/geometries/transform_shape.h @@ -72,13 +72,36 @@ class TransformShape : public BaseShapeType protected: Transform transform_; + /// Returns the AABB of the rotated underlying shape's AABB + /// ⚠️ It is not the tight fit AABB of the underlying shape + /// But at least it encloses the underlying shape fully virtual BoundingBox findBounds() override { BoundingBox original_bound = BaseShapeType::findBounds(); - return BoundingBox(transform_.shiftFrameStationToBase(original_bound.first_), - transform_.shiftFrameStationToBase(original_bound.second_)); + Vecd bb_min = Vecd::Constant(Infinity); + Vecd bb_max = Vecd::Constant(-Infinity); + for (auto x : {original_bound.first_.x(), original_bound.second_.x()}) + { + for (auto y : {original_bound.first_.y(), original_bound.second_.y()}) + { + if constexpr (Dimensions == 3) + { + for (auto z : {original_bound.first_.z(), original_bound.second_.z()}) + { + bb_min = bb_min.cwiseMin(transform_.shiftFrameStationToBase(Vecd(x, y, z))); + bb_max = bb_max.cwiseMax(transform_.shiftFrameStationToBase(Vecd(x, y, z))); + } + } + else + { + bb_min = bb_min.cwiseMin(transform_.shiftFrameStationToBase(Vecd(x, y))); + bb_max = bb_max.cwiseMax(transform_.shiftFrameStationToBase(Vecd(x, y))); + } + } + } + return BoundingBox(bb_min, bb_max); }; }; } // namespace SPH -#endif // TRANSFORM_SHAPE_H \ No newline at end of file +#endif // TRANSFORM_SHAPE_H From d7a0c317feaa43127c98794eb067eba83bcb9de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20P=C3=A9an?= Date: Tue, 19 Nov 2024 19:33:51 +0100 Subject: [PATCH 2/3] Fix variable initialization --- src/shared/geometries/transform_shape.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/geometries/transform_shape.h b/src/shared/geometries/transform_shape.h index e3d1ea5b52..5fc0ee31e3 100644 --- a/src/shared/geometries/transform_shape.h +++ b/src/shared/geometries/transform_shape.h @@ -78,8 +78,8 @@ class TransformShape : public BaseShapeType virtual BoundingBox findBounds() override { BoundingBox original_bound = BaseShapeType::findBounds(); - Vecd bb_min = Vecd::Constant(Infinity); - Vecd bb_max = Vecd::Constant(-Infinity); + Vecd bb_min = Vecd::Constant(MaxReal); + Vecd bb_max = Vecd::Constant(-MaxReal); for (auto x : {original_bound.first_.x(), original_bound.second_.x()}) { for (auto y : {original_bound.first_.y(), original_bound.second_.y()}) From 7f3ab0aeff355e380fc4d70c5a21e952c8ac16f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20P=C3=A9an?= Date: Wed, 20 Nov 2024 09:54:19 +0100 Subject: [PATCH 3/3] Fix SYCL compilation error --- .../particle_dynamics/general_dynamics/general_reduce_ck.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/shared_ck/particle_dynamics/general_dynamics/general_reduce_ck.hpp b/src/shared/shared_ck/particle_dynamics/general_dynamics/general_reduce_ck.hpp index b768132bb9..60cd56a8ba 100644 --- a/src/shared/shared_ck/particle_dynamics/general_dynamics/general_reduce_ck.hpp +++ b/src/shared/shared_ck/particle_dynamics/general_dynamics/general_reduce_ck.hpp @@ -16,7 +16,7 @@ template template VariableNormCK::ReduceKernel:: ReduceKernel(const ExecutionPolicy &ex_policy, EncloserType &encloser) - : variable_(encloser.dv_variable_->template DelegatedDataField(ex_policy)) {} + : variable_(encloser.dv_variable_->DelegatedDataField(ex_policy)) {} //=================================================================================================// template TotalKineticEnergyCK::ReduceKernel::