Skip to content

Commit

Permalink
mesh cell list do not have member of particle position
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangyu-Hu committed Sep 13, 2024
1 parent 339b36c commit d42ff8d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/shared/meshes/cell_linked_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vecd>("Position")) {}
: BaseMeshField("CellLinkedList"), kernel_(*sph_adaptation.getKernel()) {}
//=================================================================================================//
SplitCellLists *BaseCellLinkedList::getSplitCellLists()
{
Expand Down
9 changes: 3 additions & 6 deletions src/shared/meshes/cell_linked_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class BaseCellLinkedList : public BaseMeshField
{
protected:
Kernel &kernel_;
BaseParticles &base_particles_;
DiscreteVariable<Vecd> *dv_pos_;
/** clear split cell lists in this mesh*/
virtual void clearSplitCellLists(SplitCellLists &split_cell_lists);
/** update split particle list in this mesh */
Expand All @@ -79,15 +77,14 @@ class BaseCellLinkedList : public BaseMeshField
virtual void tagBodyPartByCell(ConcurrentCellLists &cell_lists, std::function<bool(Vecd, Real)> &check_included) = 0;
/** Tag domain bounding cells in an axis direction, called by domain bounding classes */
virtual void tagBoundingCells(StdVec<CellLists> &cell_data_lists, const BoundingBox &bounding_bounds, int axis) = 0;

DiscreteVariable<Vecd> *getParticlePosition() { return dv_pos_; };
};

class NeighborSearch : public Mesh
{
public:
template <class ExecutionPolicy>
NeighborSearch(const ExecutionPolicy &ex_policy, CellLinkedList &cell_linked_list);
NeighborSearch(const ExecutionPolicy &ex_policy,
CellLinkedList &cell_linked_list, DiscreteVariable<Vecd> *pos);

template <typename FunctionOnEach>
void forEachSearch(UnsignedInt index_i, const Vecd *source_pos,
Expand Down Expand Up @@ -162,7 +159,7 @@ class CellLinkedList : public BaseCellLinkedList, public Mesh
GetSearchDepth &get_search_depth, GetNeighborRelation &get_neighbor_relation);

template <class ExecutionPolicy>
NeighborSearch createNeighborSearch(const ExecutionPolicy &ex_policy);
NeighborSearch createNeighborSearch(const ExecutionPolicy &ex_policy, DiscreteVariable<Vecd> *pos);
UnsignedInt getCellOffsetListSize() { return cell_offset_list_size_; };
DiscreteVariable<UnsignedInt> *getParticleIndex() { return dv_particle_index_; };
DiscreteVariable<UnsignedInt> *getCellOffset() { return dv_cell_offset_; };
Expand Down
10 changes: 6 additions & 4 deletions src/shared/meshes/cell_linked_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ namespace SPH
{
//=================================================================================================//
template <class ExecutionPolicy>
NeighborSearch::NeighborSearch(const ExecutionPolicy &ex_policy, CellLinkedList &cell_linked_list)
NeighborSearch::NeighborSearch(
const ExecutionPolicy &ex_policy, CellLinkedList &cell_linked_list, DiscreteVariable<Vecd> *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)) {}
//=================================================================================================//
Expand Down Expand Up @@ -49,9 +50,10 @@ void NeighborSearch::forEachSearch(UnsignedInt index_i, const Vecd *source_pos,
}
//=================================================================================================//
template <class ExecutionPolicy>
NeighborSearch CellLinkedList::createNeighborSearch(const ExecutionPolicy &ex_policy)
NeighborSearch CellLinkedList::createNeighborSearch(
const ExecutionPolicy &ex_policy, DiscreteVariable<Vecd> *pos)
{
return NeighborSearch(ex_policy, *this);
return NeighborSearch(ex_policy, *this, pos);
}
//=================================================================================================//
template <class DynamicsRange, typename GetSearchDepth, typename GetNeighborRelation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ template <class ExecutionPolicy>
BodyRelationUpdate<Inner<Parameters...>>::ComputingKernel::ComputingKernel(
const ExecutionPolicy &ex_policy, BodyRelationUpdate<Inner<Parameters...>> &encloser)
: Interaction<Inner<Parameters...>>::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 <typename... Parameters>
void BodyRelationUpdate<Inner<Parameters...>>::
Expand Down Expand Up @@ -117,7 +117,7 @@ BodyRelationUpdate<Contact<Parameters...>>::
UnsignedInt contact_index)
: Interaction<Contact<>>::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 <typename... Parameters>
void BodyRelationUpdate<Contact<Parameters...>>::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ UpdateCellLinkedList<ExecutionPolicy, CellLinkedListType>::UpdateCellLinkedList(
cell_linked_list_(DynamicCast<CellLinkedListType>(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<Vecd>("Position")),
dv_particle_index_(cell_linked_list_.getParticleIndex()),
dv_cell_offset_(cell_linked_list_.getCellOffset()),
dv_current_cell_size_(DiscreteVariable<UnsignedInt>("CurrentCellSize", cell_offset_list_size_)),
Expand Down

0 comments on commit d42ff8d

Please sign in to comment.