diff --git a/run.sh b/run.sh index 6485943005cc2d593c8423cef6b0fd7efc29a163..935d4c46961467f9a4c5e2e6672505fc34925ced 100755 --- a/run.sh +++ b/run.sh @@ -2,7 +2,8 @@ echo "RUN numerics test" -source $HOME/openfpm_vars +branch=$(git ls-remote --heads origin | grep $(git rev-parse HEAD) | cut -d / -f 3) +source $HOME/openfpm_vars_$branch mpirun -np $3 ./src/numerics if [ $? -ne 0 ]; then diff --git a/src/FiniteDifference/FDScheme.hpp b/src/FiniteDifference/FDScheme.hpp index ff669b8b7be61074c95d5884af6201d7003052dd..9f50ef2e1f6a4f7e9a9a9069d88ed9080f1c946c 100644 --- a/src/FiniteDifference/FDScheme.hpp +++ b/src/FiniteDifference/FDScheme.hpp @@ -134,32 +134,60 @@ public: private: - // Encapsulation of the b term as constant + //! Encapsulation of the b term as constant struct constant_b { + //! scalar typename Sys_eqs::stype scal; + /*! \brief Constrictor from a scalar + * + * \param scal scalar + * + */ constant_b(typename Sys_eqs::stype scal) { this->scal = scal; } + /*! \brief Get the b term on a grid point + * + * \note It does not matter the grid point it is a scalar + * + * \param key grid position (unused because it is a constant) + * + * \return the scalar + * + */ typename Sys_eqs::stype get(grid_dist_key_dx<Sys_eqs::dims> & key) { return scal; } }; - // Encapsulation of the b term as grid + //! Encapsulation of the b term as grid template<typename grid, unsigned int prp> struct grid_b { + //! b term fo the grid grid & gr; + /*! \brief gr grid that encapsulate + * + * \param gr grid + * + */ grid_b(grid & gr) :gr(gr) {} + /*! \brief Get the value of the b term on a grid point + * + * \param key grid point + * + * \return the value + * + */ typename Sys_eqs::stype get(grid_dist_key_dx<Sys_eqs::dims> & key) { return gr.template get<prp>(key); @@ -439,7 +467,7 @@ private: auto it = it_d; grid_sm<Sys_eqs::dims,void> gs = g_map.getGridInfoVoid(); - std::unordered_map<long int,float> cols; + std::unordered_map<long int,typename Sys_eqs::stype> cols; // iterate all the grid points while (it.isNext()) @@ -699,7 +727,6 @@ public: * * The periodicity is given by the grid b_g * - * \param pd Padding, how many points out of boundary are present * \param stencil maximum extension of the stencil on each directions * \param domain the domain * \param b_g object grid that will store the solution diff --git a/src/FiniteDifference/Laplacian.hpp b/src/FiniteDifference/Laplacian.hpp index 5736add6f102b96b1443d90b023630fdce975134..05f631705fafd212df599de6e1583a9d7ed8317a 100644 --- a/src/FiniteDifference/Laplacian.hpp +++ b/src/FiniteDifference/Laplacian.hpp @@ -26,7 +26,9 @@ class Lap * stub_or_real it is just for change the argument type when testing, in normal * conditions it is a distributed map * - * \param pos position where the laplacian is calculated + * \param g_map map grid + * \param kmap position in the grid + * \param spacing of the grid * \param gs Grid info * \param cols non-zero colums calculated by the function * \param coeff coefficent (constant in front of the derivative) @@ -36,19 +38,11 @@ class Lap * \snippet FDScheme_unit_tests.hpp Laplacian usage * */ - inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition::extended_type>::type & g_map, grid_dist_key_dx<Sys_eqs::dims> & kmap , const grid_sm<Sys_eqs::dims,void> & gs, std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff) - { - std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " only CENTRAL, FORWARD, BACKWARD derivative are defined"; - } - - /*! \brief Calculate the position where the derivative is calculated - * - * \param position where we are calculating the derivative - * \param gs Grid info - * \param s_pos staggered position of the properties - * - */ - inline static grid_key_dx<Sys_eqs::dims> position(grid_key_dx<Sys_eqs::dims> & pos, const grid_sm<Sys_eqs::dims,void> & gs) + inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition::extended_type>::type & g_map, + grid_dist_key_dx<Sys_eqs::dims> & kmap , + const grid_sm<Sys_eqs::dims,void> & gs, + std::unordered_map<long int,typename Sys_eqs::stype > & cols, + typename Sys_eqs::stype coeff) { std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " only CENTRAL, FORWARD, BACKWARD derivative are defined"; } @@ -81,7 +75,9 @@ public: * stub_or_real it is just for change the argument type when testing, in normal * conditions it is a distributed map * - * \param pos position where the laplacian is calculated + * \param g_map map grid + * \param kmap position in the grid + * \param spacing of the grid * \param gs Grid info * \param cols non-zero colums calculated by the function * \param coeff coefficent (constant in front of the derivative) @@ -91,7 +87,12 @@ public: * \snippet FDScheme_unit_tests.hpp Laplacian usage * */ - inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition::extended_type>::type & g_map, grid_dist_key_dx<Sys_eqs::dims> & kmap , const grid_sm<Sys_eqs::dims,void> & gs, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff) + inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition::extended_type>::type & g_map, + grid_dist_key_dx<Sys_eqs::dims> & kmap , + const grid_sm<Sys_eqs::dims,void> & gs, + typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , + std::unordered_map<long int,typename Sys_eqs::stype > & cols, + typename Sys_eqs::stype coeff) { // for each dimension for (size_t i = 0 ; i < Sys_eqs::dims ; i++) @@ -109,22 +110,6 @@ public: arg::value(g_map,kmap,gs,spacing,cols, - 2.0 * coeff/spacing[i]/spacing[i]); } } - - - /*! \brief Calculate the position where the derivative is calculated - * - * In case of non staggered case this function just return a null grid_key, in case of staggered, - * the CENTRAL Laplacian scheme return the position of the staggered property - * - * \param position where we are calculating the derivative - * \param gs Grid info - * \param s_pos staggered position of the properties - * - */ - inline static grid_key_dx<Sys_eqs::dims> position(grid_key_dx<Sys_eqs::dims> & pos, const grid_sm<Sys_eqs::dims,void> & gs, const comb<Sys_eqs::dims> (& s_pos)[Sys_eqs::nvar]) - { - return arg::position(pos,gs,s_pos); - } }; @@ -155,7 +140,9 @@ public: * stub_or_real it is just for change the argument type when testing, in normal * conditions it is a distributed map * - * \param pos position where the laplacian is calculated + * \param g_map map grid + * \param kmap position in the grid + * \param spacing of the grid * \param gs Grid info * \param cols non-zero colums calculated by the function * \param coeff coefficent (constant in front of the derivative) @@ -183,22 +170,6 @@ public: arg::value(g_map,kmap,gs,spacing,cols, - 2.0 * coeff/spacing[i]/spacing[i]/4.0); } } - - - /*! \brief Calculate the position where the derivative is calculated - * - * In case of non staggered case this function just return a null grid_key, in case of staggered, - * the CENTRAL Laplacian scheme return the position of the staggered property - * - * \param position where we are calculating the derivative - * \param gs Grid info - * \param s_pos staggered position of the properties - * - */ - inline static grid_key_dx<Sys_eqs::dims> position(grid_key_dx<Sys_eqs::dims> & pos, const grid_sm<Sys_eqs::dims,void> & gs, const comb<Sys_eqs::dims> (& s_pos)[Sys_eqs::nvar]) - { - return arg::position(pos,gs,s_pos); - } }; #endif /* OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_LAPLACIAN_HPP_ */ diff --git a/src/Vector/Vector.hpp b/src/Vector/Vector.hpp index 24ef44f6f5785d4e26010e4bb9f8d8fd3fc14e5f..66c5eec9795a63882fdd0d14595cc64410c0398d 100644 --- a/src/Vector/Vector.hpp +++ b/src/Vector/Vector.hpp @@ -32,32 +32,148 @@ class rval #define DEFAULT_VECTOR = 0 #endif -/* ! \brief Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support +/*! \brief Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support * */ template<typename T,unsigned int impl DEFAULT_VECTOR > class Vector { + //! stub T stub; + + //! stub int stub_i; public: - Vector(const Vector<T> & v) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} - Vector(Vector<T> && v) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} - Vector(size_t n) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} - Vector() {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} - Vector(size_t n, size_t n_row_local) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + /*! \brief stub copy constructor + * + * \param v stub + * + */ + Vector(const Vector<T> & v) + :stub(0),stub_i(0) + {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + /*! \brief stub copy constructor + * + * \param v vector to copy + * + */ + Vector(Vector<T> && v) + :stub(0),stub_i(0) + {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + /*! \brief stub constructor from number of rows + * + * \param n stub + * + */ + Vector(size_t n) + :stub(0),stub_i(0) + {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + //! stub default constructor + Vector() + :stub(0),stub_i(0) + {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + /*! \brief stub constructor + * + * \param n global number of row + * \param n_row_local local number of rows + * + */ + Vector(size_t n, size_t n_row_local) + :stub(0),stub_i(0) + {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + /*! \brief stub resize + * + * \param row stub + * \param row_n stub + * + */ void resize(size_t row, size_t row_n) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + /*! \brief stub insert + * + * \param i stub + * \param val stub + * + */ void insert(size_t i, T val) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + /*! \brief stub insert + * + * \param i stub + * + * \return stub + * + */ inline T & insert(size_t i) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;return stub;} + + /*! \brief stub insert + * + * \param i stub + * + */ inline const T & insert(size_t i) const {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl; return stub;} + + /*! \brief stub + * + * \param i stub + * + * \return stub + * + */ const T & operator()(size_t i) const {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;return stub;} + + /*! \brief stub + * + * \param i stub + * + * \return stub + * + */ T & operator()(size_t i) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;return stub;} + + /*! \brief scatter + * + */ void scatter() {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + /*! \brief fromFile + * + * \param file stub + * + */ void fromFile(std::string file) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl;} + + + /*! \brief stub operator= + * + * \param v stub + * + * \return itself + * + */ Vector<T> & operator=(const Vector<T> & v) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl; return *this;} + + /*! \brief stub operator= + * + * \param v stub + * + * \return itself + * + */ Vector<T> & operator=(Vector<T> && v) {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl; return *this;} + + /*! \brief stub getVec + * + * \return stub + * + */ int & getVec() {std::cerr << __FILE__ << ":" << __LINE__ << " Error in order to use this class you must compile OpenFPM with linear algebra support" << std::endl; return stub_i;} }; diff --git a/src/Vector/Vector_petsc.hpp b/src/Vector/Vector_petsc.hpp index 1f3a2cb8069fa728fd3f9e17974c6f5958fe982d..2ea14c75bb451efe528451528d04215f226075c7 100644 --- a/src/Vector/Vector_petsc.hpp +++ b/src/Vector/Vector_petsc.hpp @@ -168,8 +168,8 @@ public: /*! \brief Create a vector with n elements * - * \param n number of elements in the vector - * \param n_row_loc number + * \param n global number of elements in the vector + * \param n_row_local number * */ Vector(size_t n, size_t n_row_local)