Commit 58e62895 authored by Pietro Incardona's avatar Pietro Incardona

Support for vector operations

parent 57a0ee07
# Change Log
All notable changes to this project will be documented in this file.
## [0.5.0] - mid July 2016
## [0.5.0 - Gingold] - End July 2016
### Added
- map_list map communicate particles across processors mooving the information of all the particle map_list give the possibility to give a list of property to move from one to another processor
- Numeric: Finite Differences discretization with matrix contruction and parallel solvers
- map communicate particles across processors mooving the information of all the particle map_list give the possibility to give a list of property to move from one to another processor
- Numeric: Finite Differences discretization with matrix contruction and parallel solvers (See example ... )
- vector_dist now support complex object like Point VectorS Box ... , with no limitation
and more generic object like std::vector ... (WARNING TEMPORARY LIMITATION: Communication is not supported property must be excluded from communication using map_list and ghost_get)
- vector_dist support expressions (See example ...)
- No limit to ghost extension (they can be arbitrary extended)
- Multi-phase CellList
- Hilber curve data and computation reordering for cache firndliness
### Fixed
......@@ -94,5 +100,6 @@ All notable changes to this project will be documented in this file.
## [0.6.0] - Beginning of september
### Added
- Parallel IO, new formats, imroved writers
- Parallel IO, new formats, improved writers
- Algebraic Multigrid solver
openfpm_data @ 9d44c008
Subproject commit 32c0433fe9cf7c125ef2ad019b80955e8f8a73c5
Subproject commit 9d44c008f04e855666b1ea15d02e681f2bfcf2e9
openfpm_io @ ca2becb0
Subproject commit 088fa4a38c15f09f48cc78165f56d327d1a399bb
Subproject commit ca2becb045ef96fcf6287f8ef5da2314248bcb66
openfpm_numerics @ 6274ea12
Subproject commit 29d4f60747846e9f526ac03557904ec8ab93d413
Subproject commit 6274ea12ff26d87573f361a2b1b801cb1883e38c
......@@ -27,7 +27,6 @@
#include "Vector/vector_dist_ofb.hpp"
#include "Decomposition/CartDecomposition.hpp"
#include "data_type/aggregate.hpp"
#include "vector_dist_operators.hpp"
#define V_SUB_UNIT_FACTOR 64
......@@ -776,6 +775,12 @@ private:
public:
//! space type
typedef St stype;
//! dimensions of space
static const unsigned int dims = dim;
/*! \brief Constructor
*
* \param np number of elements
......@@ -869,6 +874,20 @@ public:
return v_pos.template get<0>(vec_key.getKey());
}
/*! \brief Get the position of an element
*
* see the vector_dist iterator usage to get an element key
*
* \param vec_key element
*
* \return the position of the element in space
*
*/
inline auto getPos(vect_dist_key_dx vec_key) const -> decltype(v_pos.template get<0>(vec_key.getKey()))
{
return v_pos.template get<0>(vec_key.getKey());
}
/*! \brief Get the property of an element
*
* see the vector_dist iterator usage to get an element key
......@@ -1627,15 +1646,6 @@ public:
#endif
return v_cl;
}
//////////////////////////// Vector expression implementation ////////////////////////
template <unsigned int prp> inline vector_dist_expression<prp,vector_dist<dim,St,prop,Decomposition,Memory> > getV()
{
vector_dist_expression<prp,vector_dist<dim,St,prop,Decomposition,Memory> > exp_v(*this);
return exp_v;
}
};
......
......@@ -39,7 +39,7 @@ public:
* \return the local key
*
*/
inline size_t getKey()
inline size_t getKey() const
{
return key;
}
......
This diff is collapsed.
/*
* vector_dist_operators_unit_tests.hpp
*
* Created on: Jun 11, 2016
* Author: i-bird
*/
#ifndef SRC_VECTOR_VECTOR_DIST_OPERATORS_UNIT_TESTS_HPP_
#define SRC_VECTOR_VECTOR_DIST_OPERATORS_UNIT_TESTS_HPP_
constexpr int A = 0;
constexpr int B = 1;
constexpr int C = 2;
constexpr int PA = 3;
constexpr int PB = 4;
constexpr int PC = 5;
//////////////////// Here we define all the function to checl the operators
template <unsigned int prp, typename vector> bool check_values(const vector & v,float a)
{
bool ret = true;
auto it = v.getDomainIterator();
while (it.isNext())
{
ret &= v.template getProp<prp>(it.get()) == a;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename vector> bool check_values_complex_expr(const vector & vd)
{
bool ret = true;
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
float base1 = vd.template getProp<B>(key) + 2.0 + vd.template getProp<B>(key) - 2.0*vd.template getProp<C>(key) / 5.0;
float base2 = vd.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sum(const vector & vd, double d)
{
bool ret = true;
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd.template getProp<B>(key) + d;
rtype base2 = vd.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sum(const vector & vd1, const vector & vd2)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<B>(key) + vd2.template getProp<C>(key);
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sum_3(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<B>(key) + vd1.template getProp<C>(key) + vd1.template getProp<B>(key);
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sum_4(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<B>(key) + vd1.template getProp<C>(key) + vd1.template getProp<B>(key) + vd1.template getProp<C>(key);
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub(const vector & vd, double d)
{
bool ret = true;
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd.template getProp<B>(key) - d;
rtype base2 = vd.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub(double d, const vector & vd)
{
bool ret = true;
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = d - vd.template getProp<B>(key);
rtype base2 = vd.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub(const vector & vd1, const vector & vd2)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<C>(key) - vd2.template getProp<B>(key);
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub_31(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<B>(key) - (vd1.template getProp<C>(key) + vd1.template getProp<B>(key));
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub_32(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = (vd1.template getProp<C>(key) + vd1.template getProp<B>(key)) - vd1.template getProp<B>(key);
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub_4(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = (vd1.template getProp<C>(key) + vd1.template getProp<B>(key)) - (vd1.template getProp<C>(key) + vd1.template getProp<B>(key));
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_mul(const vector & vd, double d)
{
bool ret = true;
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd.template getProp<B>(key) * d;
rtype base2 = vd.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_mul(const vector & vd1, const vector & vd2)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<C>(key) * vd2.template getProp<B>(key);
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_mul_3(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<B>(key) * (vd1.template getProp<B>(key) + vd1.template getProp<C>(key));
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_mul_4(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = (vd1.template getProp<B>(key) + vd1.template getProp<C>(key)) * (vd1.template getProp<B>(key) + vd1.template getProp<C>(key));
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div(const vector & vd, double d)
{
bool ret = true;
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd.template getProp<B>(key) / d;
rtype base2 = vd.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div(double d, const vector & vd)
{
bool ret = true;
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = d / vd.template getProp<B>(key);
rtype base2 = vd.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div(const vector & vd1, const vector & vd2)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<C>(key) / vd2.template getProp<B>(key);
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div_31(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = vd1.template getProp<B>(key) / (vd1.template getProp<B>(key) + vd1.template getProp<C>(key));
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div_32(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = (vd1.template getProp<C>(key) + vd1.template getProp<B>(key)) / vd1.template getProp<B>(key);
rtype base2 = vd1.template getProp<A>(key);
ret &= base1 == base2;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
return ret;
}
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div_4(const vector & vd1)
{
bool ret = true;
auto it = vd1.getDomainIterator();
while (it.isNext())
{
auto key = it.get();
rtype base1 = (vd1.template getProp<B>(key) + vd1.template getProp<C>(key)) / (vd1.template getProp<B>(key) + vd1.template getProp<C>(key));
rtype base2 = vd1.template getProp<A>(key);