From 0bba4248cbb0b55ea0ba92d3ecc47d7440b6451e Mon Sep 17 00:00:00 2001 From: absingh <absingh@mpi-cbg.de> Date: Mon, 26 Apr 2021 13:10:13 +0200 Subject: [PATCH] Adding multiple checks for detecting mistakes in SE_CLASS1. Also adding Subset number prop name. --- src/Vector/vector_dist.hpp | 41 +++++++++++++++++++++++++++++-- src/Vector/vector_dist_subset.hpp | 41 +++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/src/Vector/vector_dist.hpp b/src/Vector/vector_dist.hpp index 4a9d70d94..3b1cc0b7a 100644 --- a/src/Vector/vector_dist.hpp +++ b/src/Vector/vector_dist.hpp @@ -39,6 +39,7 @@ #include "NN/CellList/cuda/CellList_gpu.hpp" #include "lib/pdata.hpp" #include "cuda/vector_dist_operators_list_ker.hpp" +#include <type_traits> #define DEC_GRAN(gr) ((size_t)gr << 32) @@ -303,6 +304,12 @@ private: #endif +#ifdef SE_CLASS1 + int map_ctr=0; + //ghost check to be done. + int ghostget_ctr=0; +#endif + /*! \brief Initialize the structures * * \param np number of particles @@ -430,6 +437,11 @@ public: //! yes I am vector dist typedef int yes_i_am_vector_dist; + //! yes I am vector subset dist + typedef std::integral_constant<bool,false> is_it_a_subset; + + + /*! \brief Operator= for distributed vector * * \param v vector to copy @@ -2322,6 +2334,9 @@ public: #ifdef SE_CLASS3 se3.map_pre(); #endif +#ifdef SE_CLASS1 + map_ctr++; +#endif this->template map_<obp>(v_pos,v_prp,g_m,opt); @@ -2333,12 +2348,23 @@ public: se3.map_post(); #endif } +#ifdef SE_CLASS1 + int getMapCtr() const + { + return map_ctr; + } +#endif + /*! \brief Stub does not do anything * */ void ghost_get_subset() - {} + { + #ifdef SE_CLASS1 + std::cerr<<__FILE__<<":"<<__LINE__<<":You Used a ghost_get on a subset. This does not do anything. Please use ghostget on the entire set."; + #endif + } /*! \brief It synchronize the properties and position of the ghost particles * @@ -2960,7 +2986,18 @@ public: prp_names = names; } - /*! \brief Get a special particle iterator able to iterate across particles using + /*! \brief Get the properties names + * + * It is useful to get name for the properties in vtk writers + * + */ + openfpm::vector<std::string> & getPropNames() + { + return prp_names; + } + + + /*! \brief Get a special particle iterator able to iterate across particles using * symmetric crossing scheme * * \param NN Verlet list neighborhood diff --git a/src/Vector/vector_dist_subset.hpp b/src/Vector/vector_dist_subset.hpp index e2be20c28..48f94ff0e 100644 --- a/src/Vector/vector_dist_subset.hpp +++ b/src/Vector/vector_dist_subset.hpp @@ -35,6 +35,27 @@ class vector_dist_ws : public vector_dist<dim,St,typename AggregateAppend<int,pr { this->template getProp<flag_prop::value>(this->size_local()-1) = sub_id; } + + inline bool write_frame(std::string out, size_t iteration, int opt = VTK_WRITER) + { + auto &prop_names=this->getPropNames(); + if(prop_names.size()<prop::max_prop+1){ + prop_names.add({"SubsetNumber"}); + } + + return vector_dist<dim,St,typename AggregateAppend<int,prop>::type,Decomposition,Memory,layout_base>::write_frame(out,iteration,opt); + } + + inline bool write(std::string out,int opt = VTK_WRITER) + { + auto &prop_names=this->getPropNames(); + if(prop_names.size()<prop::max_prop+1){ + prop_names.add({"SubsetNumber"}); + } + + return vector_dist<dim,St,typename AggregateAppend<int,prop>::type,Decomposition,Memory,layout_base>::write(out,"",opt); + } + }; template<unsigned int dim, @@ -55,6 +76,10 @@ class vector_dist_subset size_t sub_id; +#ifdef SE_CLASS1 + int subsetUpdate_ctr=0; +#endif + void check_gm() { #ifdef SE_CLASS1 @@ -86,6 +111,9 @@ public: //! typedef int yes_i_am_vector_dist; + //! Subset detection + typedef std::integral_constant<bool,true> is_it_a_subset; + vector_dist_subset(vector_dist_ws<dim,St,prop,Decomposition,Memory,layout_base> & vd, int sub_id) :vd(vd),pid(pid),sub_id(sub_id) @@ -125,11 +153,24 @@ public: return pid; } +#ifdef SE_CLASS1 + int getUpdateCtr() const{ + return subsetUpdate_ctr; + } + int getMapCtr() + { + return vd.getMapCtr(); + } +#endif + /*! \brief Update the subset indexes * */ inline void update() { +#ifdef SE_CLASS1 + subsetUpdate_ctr=vd.getMapCtr(); +#endif ghost_get_subset(); -- GitLab