From d42ff8d3f3882124008bd5b54a40b88ff34380f5 Mon Sep 17 00:00:00 2001 From: Xiangyu Date: Fri, 13 Sep 2024 09:08:20 +0200 Subject: [PATCH] mesh cell list do not have member of particle position --- src/shared/meshes/cell_linked_list.cpp | 3 +-- src/shared/meshes/cell_linked_list.h | 9 +++------ src/shared/meshes/cell_linked_list.hpp | 10 ++++++---- .../configuration_dynamics/update_body_relation.hpp | 4 ++-- .../configuration_dynamics/update_cell_linked_list.hpp | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/shared/meshes/cell_linked_list.cpp b/src/shared/meshes/cell_linked_list.cpp index f6b44223f8..faccfc03c3 100644 --- a/src/shared/meshes/cell_linked_list.cpp +++ b/src/shared/meshes/cell_linked_list.cpp @@ -11,8 +11,7 @@ namespace SPH //=================================================================================================// BaseCellLinkedList:: BaseCellLinkedList(BaseParticles &base_particles, SPHAdaptation &sph_adaptation) - : BaseMeshField("CellLinkedList"), kernel_(*sph_adaptation.getKernel()), - base_particles_(base_particles), dv_pos_(base_particles.getVariableByName("Position")) {} + : BaseMeshField("CellLinkedList"), kernel_(*sph_adaptation.getKernel()) {} //=================================================================================================// SplitCellLists *BaseCellLinkedList::getSplitCellLists() { diff --git a/src/shared/meshes/cell_linked_list.h b/src/shared/meshes/cell_linked_list.h index a0546f2648..baae6d2cf5 100644 --- a/src/shared/meshes/cell_linked_list.h +++ b/src/shared/meshes/cell_linked_list.h @@ -51,8 +51,6 @@ class BaseCellLinkedList : public BaseMeshField { protected: Kernel &kernel_; - BaseParticles &base_particles_; - DiscreteVariable *dv_pos_; /** clear split cell lists in this mesh*/ virtual void clearSplitCellLists(SplitCellLists &split_cell_lists); /** update split particle list in this mesh */ @@ -79,15 +77,14 @@ class BaseCellLinkedList : public BaseMeshField virtual void tagBodyPartByCell(ConcurrentCellLists &cell_lists, std::function &check_included) = 0; /** Tag domain bounding cells in an axis direction, called by domain bounding classes */ virtual void tagBoundingCells(StdVec &cell_data_lists, const BoundingBox &bounding_bounds, int axis) = 0; - - DiscreteVariable *getParticlePosition() { return dv_pos_; }; }; class NeighborSearch : public Mesh { public: template - NeighborSearch(const ExecutionPolicy &ex_policy, CellLinkedList &cell_linked_list); + NeighborSearch(const ExecutionPolicy &ex_policy, + CellLinkedList &cell_linked_list, DiscreteVariable *pos); template void forEachSearch(UnsignedInt index_i, const Vecd *source_pos, @@ -162,7 +159,7 @@ class CellLinkedList : public BaseCellLinkedList, public Mesh GetSearchDepth &get_search_depth, GetNeighborRelation &get_neighbor_relation); template - NeighborSearch createNeighborSearch(const ExecutionPolicy &ex_policy); + NeighborSearch createNeighborSearch(const ExecutionPolicy &ex_policy, DiscreteVariable *pos); UnsignedInt getCellOffsetListSize() { return cell_offset_list_size_; }; DiscreteVariable *getParticleIndex() { return dv_particle_index_; }; DiscreteVariable *getCellOffset() { return dv_cell_offset_; }; diff --git a/src/shared/meshes/cell_linked_list.hpp b/src/shared/meshes/cell_linked_list.hpp index 9f26b95400..80be0772a2 100644 --- a/src/shared/meshes/cell_linked_list.hpp +++ b/src/shared/meshes/cell_linked_list.hpp @@ -18,9 +18,10 @@ namespace SPH { //=================================================================================================// template -NeighborSearch::NeighborSearch(const ExecutionPolicy &ex_policy, CellLinkedList &cell_linked_list) +NeighborSearch::NeighborSearch( + const ExecutionPolicy &ex_policy, CellLinkedList &cell_linked_list, DiscreteVariable *pos) : Mesh(cell_linked_list), grid_spacing_squared_(grid_spacing_ * grid_spacing_), - pos_(cell_linked_list.getParticlePosition()->DelegatedDataField(ex_policy)), + pos_(pos->DelegatedDataField(ex_policy)), particle_index_(cell_linked_list.getParticleIndex()->DelegatedDataField(ex_policy)), cell_offset_(cell_linked_list.getCellOffset()->DelegatedDataField(ex_policy)) {} //=================================================================================================// @@ -49,9 +50,10 @@ void NeighborSearch::forEachSearch(UnsignedInt index_i, const Vecd *source_pos, } //=================================================================================================// template -NeighborSearch CellLinkedList::createNeighborSearch(const ExecutionPolicy &ex_policy) +NeighborSearch CellLinkedList::createNeighborSearch( + const ExecutionPolicy &ex_policy, DiscreteVariable *pos) { - return NeighborSearch(ex_policy, *this); + return NeighborSearch(ex_policy, *this, pos); } //=================================================================================================// template diff --git a/src/shared/shared_ck/particle_dynamics/configuration_dynamics/update_body_relation.hpp b/src/shared/shared_ck/particle_dynamics/configuration_dynamics/update_body_relation.hpp index 2b6bea8b9d..3c294a642e 100644 --- a/src/shared/shared_ck/particle_dynamics/configuration_dynamics/update_body_relation.hpp +++ b/src/shared/shared_ck/particle_dynamics/configuration_dynamics/update_body_relation.hpp @@ -23,7 +23,7 @@ template BodyRelationUpdate>::ComputingKernel::ComputingKernel( const ExecutionPolicy &ex_policy, BodyRelationUpdate> &encloser) : Interaction>::InteractKernel(ex_policy, encloser), - neighbor_search_(encloser.cell_linked_list_.createNeighborSearch(ex_policy)) {} + neighbor_search_(encloser.cell_linked_list_.createNeighborSearch(ex_policy, encloser.dv_pos_)) {} //=================================================================================================// template void BodyRelationUpdate>:: @@ -117,7 +117,7 @@ BodyRelationUpdate>:: UnsignedInt contact_index) : Interaction>::InteractKernel(ex_policy, encloser, contact_index), neighbor_search_(encloser.contact_cell_linked_list_[contact_index] - ->createNeighborSearch(ex_policy)) {} + ->createNeighborSearch(ex_policy, encloser.contact_pos_[contact_index])) {} //=================================================================================================// template void BodyRelationUpdate>:: diff --git a/src/shared/shared_ck/particle_dynamics/configuration_dynamics/update_cell_linked_list.hpp b/src/shared/shared_ck/particle_dynamics/configuration_dynamics/update_cell_linked_list.hpp index 5444ff7ac7..f422e6d026 100644 --- a/src/shared/shared_ck/particle_dynamics/configuration_dynamics/update_cell_linked_list.hpp +++ b/src/shared/shared_ck/particle_dynamics/configuration_dynamics/update_cell_linked_list.hpp @@ -16,7 +16,7 @@ UpdateCellLinkedList::UpdateCellLinkedList( cell_linked_list_(DynamicCast(this, real_body.getCellLinkedList())), mesh_(cell_linked_list_), cell_offset_list_size_(cell_linked_list_.getCellOffsetListSize()), - dv_pos_(cell_linked_list_.getParticlePosition()), + dv_pos_(particles_->getVariableByName("Position")), dv_particle_index_(cell_linked_list_.getParticleIndex()), dv_cell_offset_(cell_linked_list_.getCellOffset()), dv_current_cell_size_(DiscreteVariable("CurrentCellSize", cell_offset_list_size_)),