From 6794c24bc6fe9c474496f9b5908b97a823214ded Mon Sep 17 00:00:00 2001 From: Pietro Incardona Date: Tue, 13 Dec 2016 18:30:20 +0100 Subject: [PATCH] Fixing change name in VCluster --- src/Makefile.am | 2 +- src/Matrix/SparseMatrix_Eigen.hpp | 2 +- .../vector_dist_operators_apply_kernel.hpp | 51 +++++++++++++++++++ .../vector_dist_operators_functions.hpp | 17 ++++++- .../vector_dist_operators_unit_tests.hpp | 13 +++++ src/unit_test_init_cleanup.hpp | 2 +- 6 files changed, 82 insertions(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7aa6946..d631e1b 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,7 @@ LINKLIBS = $(OPENMP_LDFLAGS) $(LIBHILBERT_LIB) $(PETSC_LIB) $(SUITESPARSE_LIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(METIS_LIB) $(PARMETIS_LIB) $(DEFAULT_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_IOSTREAMS_LIB) $(HDF5_LDFLAGS) $(HDF5_LIBS) $(LIBQUADMATH) $(OPENMP_LDFLAGS) $(LIBIFCORE) noinst_PROGRAMS = numerics -numerics_SOURCES = main.cpp ../../openfpm_vcluster/src/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp +numerics_SOURCES = main.cpp ../../openfpm_vcluster/src/VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp numerics_CXXFLAGS = $(OPENMP_CFLAGS) $(LIBHILBERT_INCLUDE) $(AM_CXXFLAGS) $(HDF5_CPPFLAGS) $(INCLUDES_PATH) $(BOOST_CPPFLAGS) $(SUITESPARSE_INCLUDE) $(METIS_INCLUDE) $(PARMETIS_INCLUDE) $(EIGEN_INCLUDE) $(PETSC_INCLUDE) -Wno-deprecated-declarations -Wno-unused-local-typedefs numerics_CFLAGS = $(CUDA_CFLAGS) numerics_LDADD = $(LINKLIBS) -lparmetis -lmetis diff --git a/src/Matrix/SparseMatrix_Eigen.hpp b/src/Matrix/SparseMatrix_Eigen.hpp index 9a5fc42..ce65579 100644 --- a/src/Matrix/SparseMatrix_Eigen.hpp +++ b/src/Matrix/SparseMatrix_Eigen.hpp @@ -10,7 +10,7 @@ #include "Vector/map_vector.hpp" #include -#include "VCluster.hpp" +#include "VCluster/VCluster.hpp" #define EIGEN_TRIPLET 1 diff --git a/src/Operators/Vector/vector_dist_operators_apply_kernel.hpp b/src/Operators/Vector/vector_dist_operators_apply_kernel.hpp index 59bbc47..f80da3a 100644 --- a/src/Operators/Vector/vector_dist_operators_apply_kernel.hpp +++ b/src/Operators/Vector/vector_dist_operators_apply_kernel.hpp @@ -199,15 +199,27 @@ struct apply_kernel_is_number_or_expression_gen template class vector_dist_expression_op { + //! Type of neighborhood typedef typename boost::mpl::at>::type NN; + //! Type of kernel typedef typename boost::mpl::at>::type Kernel; + + // Type of the vector containing the particles typedef typename boost::mpl::at>::type vector_orig; + //! expression const exp1 o1; + + //! neighborhood list NN & cl; + + //! kernel Kernel & ker; + + //! Vector of particles const vector_orig & vd; + //! Return type of the expression typedef typename apply_kernel_rtype::rtype rtype; public: @@ -246,14 +258,25 @@ public: template class vector_dist_expression_op { + //! Type of neighborhood list typedef typename boost::mpl::at>::type NN; + + //! Type of the kernel typedef typename boost::mpl::at>::type Kernel; + + //! Type that store the particles typedef typename boost::mpl::at>::type vector_orig; + //! Neighborhood list NN & cl; + + //! kernel Kernel & ker; + + //! vector of particles const vector_orig & vd; + //! return type of the expression typedef typename apply_kernel_rtype().value(Point(0.0), Point(0.0) ) )>::rtype rtype; @@ -268,6 +291,13 @@ public: { } + /*! \brief Constructor + * + * \param cl neighborhood-list + * \param ker kernel to apply + * \param vd particle set to which apply the kernel + * + */ vector_dist_expression_op(NN & cl, Kernel & ker, const vector_orig & vd) :cl(cl),ker(ker),vd(vd) {} @@ -293,15 +323,28 @@ public: template class vector_dist_expression_op { + //! Type of nearest neighborhood typedef typename boost::mpl::at>::type NN; + + //! Type of kernel typedef typename boost::mpl::at>::type Kernel; + + //! Type of vector typedef typename boost::mpl::at>::type vector_orig; + //! expression 1 const exp1 o1; + + //! nearest neighborhood NN & cl; + + //! kernel Kernel & ker; + + //! Vector containing the particles const vector_orig & vd; + //! Return type of the kernel typedef typename apply_kernel_rtype::rtype rtype; public: @@ -316,6 +359,14 @@ public: o1.init(); } + /*! \brief Constructor from expression + * + * \param o1 first expression + * \param NN neighborhood + * \param kernel + * \param vd vector with particles + * + */ vector_dist_expression_op(const exp1 & o1, NN & cl, Kernel & ker, const vector_orig & vd) :o1(o1),cl(cl),ker(ker),vd(vd) {} diff --git a/src/Operators/Vector/vector_dist_operators_functions.hpp b/src/Operators/Vector/vector_dist_operators_functions.hpp index ff7308e..53d28f9 100644 --- a/src/Operators/Vector/vector_dist_operators_functions.hpp +++ b/src/Operators/Vector/vector_dist_operators_functions.hpp @@ -208,24 +208,34 @@ CREATE_VDIST_ARG2_FUNC(pmul,pmul,VECT_PMUL) ////////// Special function reduce ///////////////////////// +/*! \brief expression that encapsulate a vector reduction expression + * + * \tparam exp1 expression 1 + * \tparam vector_type type of vector on which the expression is acting + * + */ template class vector_dist_expression_op { + //! expression 1 const exp1 o1; + //! return type comming from the expression typedef typename apply_kernel_rtype::rtype rtype; - // calculated value + //! r_type without reference mutable typename std::remove_reference::type val; const vector_type & vd; public: + //! constructor from an epxression exp1 and a vector vd vector_dist_expression_op(const exp1 & o1, const vector_type & vd) :o1(o1), vd(vd) {} + //! initialize the expression inline void init() const { o1.init(); @@ -244,19 +254,21 @@ public: } } + //! Get the value of the expression inline typename std::remove_reference::type get() { init(); return value(vect_dist_key_dx(0)); } + //! Get the value of the expression template::type > inline r_type value(const vect_dist_key_dx & key) const { return val; } }; - +//! Reduce function (it generate an expression) template inline vector_dist_expression_op,vector_type,VECT_SUM_REDUCE> rsum(const vector_dist_expression_op & va, const vector_type & vd) @@ -266,6 +278,7 @@ rsum(const vector_dist_expression_op & va, const vector_type & v return exp_sum; } +//! Reduce function (It generate an expression) template inline vector_dist_expression_op,vector_type,VECT_SUM_REDUCE> rsum(const vector_dist_expression & va, const vector_type & vd) diff --git a/src/Operators/Vector/vector_dist_operators_unit_tests.hpp b/src/Operators/Vector/vector_dist_operators_unit_tests.hpp index 372bde7..7ec35c5 100644 --- a/src/Operators/Vector/vector_dist_operators_unit_tests.hpp +++ b/src/Operators/Vector/vector_dist_operators_unit_tests.hpp @@ -652,12 +652,16 @@ typedef vector_dist<3,float,aggregate,VectorS //! Exponential kernel struct exp_kernel { + //! variance of the exponential kernel float var; + //! Exponential kernel giving variance exp_kernel(float var) :var(var) {} + //! Calculate the value of the exponential kernel given two points p and q + // pA is the property on p pB is the property on B inline float value(const Point<3,float> & p, const Point<3,float> & q,float pA,float pB) { float dist = norm(p-q); @@ -665,6 +669,8 @@ struct exp_kernel return (pA + pB) * exp(dist * dist / var); } + //! Calculate the value of the exponential kernel given two points p and q + // pA is the value of the property on pA and pB is the value of the property on pB inline Point<3,float> value(const Point<3,float> & p, const Point<3,float> & q,const Point<3,float> & pA, const Point<3,float> & pB) { float dist = norm(p-q); @@ -672,6 +678,9 @@ struct exp_kernel return (pA + pB) * exp(dist * dist / var); } + //! Calculate the value of the exponential kernel given two points p and q + // pA is the value of the property on pA and pB is the value of the property on pB + // vd1 is the set of particles inline float value(size_t p, size_t q, float pA, float pB, const vector_type & vd1) { Point<3,float> pp = vd1.getPos(p); @@ -682,6 +691,9 @@ struct exp_kernel return (pA + pB) * exp(dist * dist / var); } + //! Calculate the value of the exponential kernel given two points p and q + // pA is the value of the property on pA and pB is the value of the property on pB + // vd1 is the set of particles inline Point<3,float> value(size_t p, size_t q, const Point<3,float> & pA, const Point<3,float> & pB , const vector_type & vd1) { Point<3,float> pp = vd1.getPos(p); @@ -692,6 +704,7 @@ struct exp_kernel return (pA + pB) * exp(dist * dist / var); } + //! Calculate the value of the exponential kernel given two points p and q inline Point<2,float> value(const Point<3,float> & p, const Point<3,float> & q) { float dist = norm(p-q); diff --git a/src/unit_test_init_cleanup.hpp b/src/unit_test_init_cleanup.hpp index 5128804..7cf89f0 100644 --- a/src/unit_test_init_cleanup.hpp +++ b/src/unit_test_init_cleanup.hpp @@ -8,7 +8,7 @@ #ifndef UNIT_TEST_INIT_CLEANUP_HPP_ #define UNIT_TEST_INIT_CLEANUP_HPP_ -#include "VCluster.hpp" +#include "VCluster/VCluster.hpp" struct ut_start { ut_start() { -- GitLab