Commit 5e304636 authored by incardon's avatar incardon

Adding left type expression and right type expression

parent bc9efd0e
......@@ -12,10 +12,37 @@
#include "PointIteratorSkin.hpp"
#include "Vector/vector_dist.hpp"
/*! \brief A class to draw/create particles based on simple shaped
*
* ## Draw box example
*
* \snippet Draw/DrawParticles_unit_tests.hpp DrawBox_example
*
*/
class DrawParticles
{
public:
/*! \brief Draw particles in a box B excluding the area of a second box A (B - A)
*
* The function return an iterator over particles defined on a virtual grid in the simulation domain.
*
* \param vd particles where we are creating the particles
* \param sz indicate the grid size of the virtual grid.
* \param domain Domain where the virtual grid is defined (Must match the domain of vd)
* \param sub_B box contained in domain that define where the particle iterator must iterate,
* particles are placed strictly inside this box
* \param sub_A box contained in the domain that define where the particle iterator should not
* iterate (excluding area)
*
* \note Suppose to have a simulation domain of 1.5 on x and we use sz = 16. Consider now
* to have particles with spacing 0.1 on x. if we define a sub_A that on extend from 0.65
* to 0.95 the first fluid particle
* is at 0.70 and the last is at 0.90
*
* \return an iterator to the selected particles
*
*/
template<unsigned int dim, typename T, typename aggr, typename Decomposition> static PointIteratorSkin<dim,T,Decomposition>
DrawSkin(vector_dist<dim,T,aggr,Decomposition> & vd,
size_t (& sz)[dim],
......@@ -28,9 +55,30 @@ public:
for (size_t i = 0 ; i < dim ; i++)
bc[i] = NON_PERIODIC;
return PointIteratorSkin<dim,T,Decomposition>(vd.getDecomposition(),sz,domain,sub_A, sub_B, bc);
return PointIteratorSkin<dim,T,Decomposition>(vd.getDecomposition(),sz,vd.getDecomposition().getDomain(),sub_A, sub_B, bc);
}
/*! \brief Draw particles in a box B excluding the areas of an array of boxes A_n
*
* The function return an iterator over particles defined on a virtual grid in the simulation domain.
*
* \param vd particles where we are creating the particles
* \param sz indicate the grid size of the virtual grid.
* \param domain Domain where the virtual grid is defined (Must match the domain of vd)
* \param sub_B box contained in domain that define where the particle iterator must iterate,
* particles are placed strictly inside this box
* \param sub_A array of boxes contained in the domain that define where the particle iterator should not
* iterate (excluding areas)
*
* \note Suppose to have a simulation domain of 1.5 on x and we use sz = 16. Consider now
* to have particles with spacing 0.1 on x. if we define a sub_A that on extend from 0.65
* to 0.95 the first fluid particle
* is at 0.70 and the last is at 0.90
*
* \return an iterator to the selected particles
*
*/
template<unsigned int dim, typename T, typename aggr, typename Decomposition> static PointIteratorSkin<dim,T,Decomposition>
DrawSkin(vector_dist<dim,T,aggr,Decomposition> & vd,
size_t (& sz)[dim],
......@@ -43,7 +91,7 @@ public:
for (size_t i = 0 ; i < dim ; i++)
bc[i] = NON_PERIODIC;
PointIteratorSkin<dim,T,Decomposition> it(vd.getDecomposition(),sz,domain,sub_A.get(0), sub_B, bc);
PointIteratorSkin<dim,T,Decomposition> it(vd.getDecomposition(),sz,vd.getDecomposition().getDomain(),sub_A.get(0), sub_B, bc);
for (size_t i = 1 ; i < sub_A.size() ; i++)
it.addBoxA(Box<dim,T>(sub_A.get(i)));
......@@ -51,13 +99,31 @@ public:
return it;
}
/*! \brief Draw particles in a box
*
* The function return an iterator over particles defined on a virtual grid in the simulation domain.
*
* \param vd particles where we are creating the particles
* \param sz indicate the grid size of the virtual grid.
* \param domain Domain where the virtual grid is defined (Must match the domain of vd)
* \param sub box contained in domain that define where the particle iterator must iterate,
* particles are placed strictly inside this box
*
* \note Suppose to have a simulation domain of 1.5 on x and we use sz = 16. Consider now
* to have particles with spacing 0.1 on x. if we define a sub box that on extend from 0.65
* to 0.95 the first fluid particle
* is at 0.70 and the last is at 0.90
*
* \return an iterator to the selected particles
*
*/
template<unsigned int dim, typename T, typename aggr, typename Decomposition> static PointIterator<dim,T,Decomposition>
DrawBox(vector_dist<dim,T,aggr,Decomposition> & vd,
size_t (& sz)[dim],
Box<dim,T> & domain,
Box<dim,T> & sub)
{
return PointIterator<dim,T,Decomposition>(vd.getDecomposition(),sz,domain,sub);
return PointIterator<dim,T,Decomposition>(vd.getDecomposition(),sz,vd.getDecomposition().getDomain(),sub);
}
};
......
......@@ -16,6 +16,8 @@ BOOST_AUTO_TEST_SUITE( draw_particles )
BOOST_AUTO_TEST_CASE(point_iterator)
{
//! [DrawBox_example]
size_t sz[] = {23,27,20};
Box<3,double> domain({-1.2,0.5,-0.6},{1.0,3.1,1.3});
......@@ -52,6 +54,8 @@ BOOST_AUTO_TEST_CASE(point_iterator)
++p;
}
//! [DrawBox_example]
Vcluster & v_cl = create_vcluster();
v_cl.sum(cnt);
......
......@@ -69,7 +69,7 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition>
//! Spacing
T sp[dim];
static grid_key_dx<dim> getStart(size_t (& gs)[dim], Box<dim,T> & dom, Box<dim,T> & sub_dom, T (& sp)[dim])
static grid_key_dx<dim> getStart(size_t (& gs)[dim], const Box<dim,T> & dom, Box<dim,T> & sub_dom, T (& sp)[dim])
{
for (size_t i = 0 ; i < dim ; i++)
sp[i] = (dom.getHigh(i) - dom.getLow(i)) / (gs[i] -1);
......@@ -82,7 +82,7 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition>
return pkey;
}
static grid_key_dx<dim> getStop(size_t (& gs)[dim], Box<dim,T> & dom, Box<dim,T> & sub_dom, T (& sp)[dim])
static grid_key_dx<dim> getStop(size_t (& gs)[dim], const Box<dim,T> & dom, Box<dim,T> & sub_dom, T (& sp)[dim])
{
for (size_t i = 0 ; i < dim ; i++)
sp[i] = (dom.getHigh(i) - dom.getLow(i)) / (gs[i] - 1);
......@@ -97,6 +97,9 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition>
void calculateAp()
{
if (grid_dist_id_iterator_dec<Decomposition>::isNext() == false)
return;
grid_key_dx<dim> key = grid_dist_id_iterator_dec<Decomposition>::get();
for (size_t i = 0 ; i < dim ; i++)
......@@ -110,7 +113,7 @@ public:
* \param sp grid spacing
*
*/
PointIterator( Decomposition & dec, size_t (& sz)[dim], Box<dim,T> & domain, Box<dim,T> & sub_domain)
PointIterator( Decomposition & dec, size_t (& sz)[dim], const Box<dim,T> & domain, Box<dim,T> & sub_domain)
:grid_dist_id_iterator_dec<Decomposition>(dec, sz, getStart(sz,domain,sub_domain,sp), getStop(sz,domain,sub_domain,sp)),sub_domain(sub_domain),domain(domain)
{
calculateAp();
......@@ -133,6 +136,7 @@ public:
PointIterator & operator++()
{
grid_dist_id_iterator_dec<Decomposition>::operator++();
calculateAp();
return *this;
......
......@@ -101,6 +101,9 @@ class PointIteratorSkin: protected grid_dist_id_iterator_dec_skin<Decomposition>
void calculateAp()
{
if (grid_dist_id_iterator_dec_skin<Decomposition>::isNext() == false)
return;
grid_key_dx<dim> key = grid_dist_id_iterator_dec_skin<Decomposition>::get();
for (size_t i = 0 ; i < dim ; i++)
......@@ -133,7 +136,7 @@ public:
* \param sp grid spacing
*
*/
PointIteratorSkin( Decomposition & dec, size_t (& sz)[dim], Box<dim,T> & domain, const Box<dim,T> & sub_A, const Box<dim,T> & sub_B, size_t (& bc)[dim])
PointIteratorSkin( Decomposition & dec, size_t (& sz)[dim], const Box<dim,T> & domain, const Box<dim,T> & sub_A, const Box<dim,T> & sub_B, size_t (& bc)[dim])
:grid_dist_id_iterator_dec_skin<Decomposition>(dec, sz, getAB(sz,domain,sub_A,sub_B,sp,RETURN_A), getAB(sz,domain,sub_A,sub_B,sp,RETURN_B), bc),domain(domain)
{
sub_domainA.add(sub_A);
......@@ -142,6 +145,7 @@ public:
/*! \Return the actual point
*
* \return the actual point
*
*/
Point<dim,T> & get()
......@@ -157,11 +161,13 @@ public:
PointIteratorSkin & operator++()
{
grid_dist_id_iterator_dec_skin<Decomposition>::operator++();
calculateAp();
while (grid_dist_id_iterator_dec_skin<Decomposition>::isNext() && isValidPoint() == false)
{
grid_dist_id_iterator_dec_skin<Decomposition>::operator++();
calculateAp();
}
......
This diff is collapsed.
......@@ -126,59 +126,67 @@ class FDScheme
{
public:
// Distributed grid map
//! Distributed grid map
typedef grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition::extended_type> g_map_type;
//! Type that specify the properties of the system of equations
typedef Sys_eqs Sys_eqs_typ;
private:
// Padding
//! Padding
Padding<Sys_eqs::dims> pd;
//! Sparse matrix triplet type
typedef typename Sys_eqs::SparseMatrix_type::triplet_type triplet;
// Vector b
//! Vector b
typename Sys_eqs::Vector_type b;
// Domain Grid informations
//! Domain Grid informations
const grid_sm<Sys_eqs::dims,void> & gs;
// Get the grid spacing
//! Get the grid spacing
typename Sys_eqs::stype spacing[Sys_eqs::dims];
// mapping grid
//! mapping grid
g_map_type g_map;
// row of the matrix
//! row of the matrix
size_t row;
// row on b
//! row on b
size_t row_b;
// Grid points that has each processor
//! Grid points that has each processor
openfpm::vector<size_t> pnt;
// Staggered position for each property
//! Staggered position for each property
comb<Sys_eqs::dims> s_pos[Sys_eqs::nvar];
// Each point in the grid has a global id, to decompose correctly the Matrix each processor contain a
// contiguos range of global id, example processor 0 can have from 0 to 234 and processor 1 from 235 to 512
// no processors can have holes in the sequence, this number indicate where the sequence start for this
// processor
//! Each point in the grid has a global id, to decompose correctly the Matrix each processor contain a
//! contiguos range of global id, example processor 0 can have from 0 to 234 and processor 1 from 235 to 512
//! no processors can have holes in the sequence, this number indicate where the sequence start for this
//! processor
size_t s_pnt;
/*! \brief Equation id + space position
*
*/
struct key_and_eq
{
//! space position
grid_key_dx<Sys_eqs::dims> key;
//! equation id
size_t eq;
};
/*! \brief From the row Matrix position to the spatial position
*
* \param row Matrix
* \param row Matrix row
*
* \return spatial position
* \return spatial position + equation id
*
*/
inline key_and_eq from_row_to_key(size_t row)
......@@ -205,9 +213,10 @@ private:
return ke;
}
/* \brief calculate the mapping grid size with padding
/*! \brief calculate the mapping grid size with padding
*
* \param gs original grid size
* \param sz original grid size
* \param pd padding
*
* \return padded grid size
*
......@@ -323,7 +332,7 @@ public:
/*! \brief set the staggered position for each property
*
* \param vector containing the staggered position for each property
* \param sp vector containing the staggered position for each property
*
*/
void setStagPos(comb<Sys_eqs::dims> (& sp)[Sys_eqs::nvar])
......@@ -335,10 +344,8 @@ public:
/*! \brief compute the staggered position for each property
*
* This is compute from the value_type stored by Sys_eqs::b_grid::value_type
* the position of the staggered properties
*
* ### Example
*
* \snippet eq_unit_test.hpp Compute staggered properties
*
*/
void computeStag()
......@@ -377,13 +384,17 @@ public:
/*! \brief Constructor
*
* \param pd Padding, how many points out of boundary are present
* \param domain extension of the domain
* \param stencil how many ghost points are required for this calculation
* \param domain the domain
* \param gs grid infos where Finite differences work
* \param stencil maximum extension of the stencil on each directions
* \param dec Decomposition of the domain
* \param b_g maximum extension of the stencil on each directions
*
*/
FDScheme(Padding<Sys_eqs::dims> & pd, const Ghost<Sys_eqs::dims,long int> & stencil, const Box<Sys_eqs::dims,typename Sys_eqs::stype> & domain, const grid_sm<Sys_eqs::dims,void> & gs, const typename Sys_eqs::b_grid & b_g)
FDScheme(Padding<Sys_eqs::dims> & pd,
const Ghost<Sys_eqs::dims,long int> & stencil,
const Box<Sys_eqs::dims,typename Sys_eqs::stype> & domain,
const grid_sm<Sys_eqs::dims,void> & gs,
const typename Sys_eqs::b_grid & b_g)
:pd(pd),gs(gs),g_map(b_g,stencil,pd),row(0),row_b(0)
{
Vcluster & v_cl = b_g.getDecomposition().getVC();
......@@ -450,9 +461,15 @@ public:
* \param id Equation id in the system that we are imposing
* \param start starting point of the box
* \param stop stop point of the box
* \param skip_first skip the first point
*
*/
template<typename T> void impose(const T & op , typename Sys_eqs::stype num ,long int id ,const long int (& start)[Sys_eqs::dims], const long int (& stop)[Sys_eqs::dims], bool skip_first = false)
template<typename T> void impose(const T & op,
typename Sys_eqs::stype num,
long int id,
const long int (& start)[Sys_eqs::dims],
const long int (& stop)[Sys_eqs::dims],
bool skip_first = false)
{
grid_key_dx<Sys_eqs::dims> start_k;
grid_key_dx<Sys_eqs::dims> stop_k;
......@@ -557,6 +574,7 @@ public:
}
}
//! type of the sparse matrix
typename Sys_eqs::SparseMatrix_type A;
/*! \brief produce the Matrix
......@@ -598,7 +616,7 @@ public:
* \tparam Grid_dst type of the target grid
* \tparam pos target properties
*
* \param scheme Discretization scheme
* \param v Vector that contain the solution of the system
* \param start point
* \param stop point
* \param g_dst Destination grid
......
......@@ -216,6 +216,11 @@ template<typename solver_type,typename lid_nn_3d> void lid_driven_cavity_3d()
std::string file1 = std::string("test/") + s + "lid_driven_cavity_3d_p" + std::to_string(v_cl.getProcessingUnits()) + "_grid_" + std::to_string(v_cl.getProcessUnitID()) + "_test_GCC5.vtk";
std::string file2 = s + "lid_driven_cavity_3d_p" + std::to_string(v_cl.getProcessingUnits()) + "_grid_" + std::to_string(v_cl.getProcessUnitID()) + ".vtk";
#elif __GNUC__ == 6
std::string file1 = std::string("test/") + s + "lid_driven_cavity_3d_p" + std::to_string(v_cl.getProcessingUnits()) + "_grid_" + std::to_string(v_cl.getProcessUnitID()) + "_test_GCC6.vtk";
std::string file2 = s + "lid_driven_cavity_3d_p" + std::to_string(v_cl.getProcessingUnits()) + "_grid_" + std::to_string(v_cl.getProcessUnitID()) + ".vtk";
#else
std::string file1 = std::string("test/") + s + "lid_driven_cavity_3d_p" + std::to_string(v_cl.getProcessingUnits()) + "_grid_" + std::to_string(v_cl.getProcessUnitID()) + "_test_GCC4.vtk";
......
......@@ -72,8 +72,8 @@ struct const_mul_functor_value
* \param kmap grid point (row) where we evaluate the non-zero colums
* \param gs grid size
* \param spacing grid spacing
* \param col non zero colums
* \param coefficent
* \param cols non zero colums
* \param coeff multiplication coefficent
*
*/
const_mul_functor_value(const grid_dist_id<last::dims,typename last::stype,scalar<size_t>,typename last::b_grid::decomposition::extended_type> & g_map,
......@@ -118,23 +118,31 @@ struct const_mul_functor_value
template<typename ... expr >
struct mul
{
// Transform from variadic template to boost mpl vector
//! Transform from variadic template to boost mpl vector
typedef boost::mpl::vector<expr... > v_expr;
// size of v_expr
//! size of v_expr
typedef typename boost::mpl::size<v_expr>::type v_sz;
//! type on which this expression operate
typedef typename boost::mpl::at<v_expr, boost::mpl::int_<v_sz::type::value - 1> >::type Sys_eqs;
/*! \brief Calculate which colums of the Matrix are non zero
*
* \param pos position where the multiplication is calculated
* \param g_map mapping grid
* \param kmap position where the multiplication is calculated
* \param gs Grid info
* \param spacing of the grid
* \param cols non-zero colums calculated by the function
* \param coeff coefficent (constant in front of the derivative)
*
*/
inline static void value(const grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition::extended_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 grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition::extended_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)
{
const_mul_functor_value<v_expr> mfv(g_map,kmap,gs,spacing,cols,coeff);
......@@ -151,12 +159,14 @@ struct mul
*
* it just return the position of the staggered property in the last expression
*
* \param position where we are calculating the derivative
* \param pos 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])
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 boost::mpl::at<v_expr, boost::mpl::int_<v_sz::type::value - 2> >::type::position(pos,gs,s_pos);
}
......
......@@ -56,8 +56,8 @@ template<typename prp1, typename expr1, typename prp2, typename expr2> void assi
{
auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_prop<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_propL<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_propL<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
++it;
}
......@@ -79,9 +79,9 @@ template<typename prp1, typename expr1, typename prp2, typename expr2, typename
{
auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_prop<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_prop<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_propL<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_propL<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_propL<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
++it;
}
......@@ -112,10 +112,10 @@ void assign(prp1 & p1, const expr1 & v_e1,
{
auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_prop<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_prop<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_prop<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_propL<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_propL<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_propL<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_propL<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
++it;
}
......@@ -151,11 +151,11 @@ void assign(prp1 & p1, const expr1 & v_e1,
{
auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_prop<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_prop<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_prop<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_prop<typename prp5::vtype,prp5::prop>::value(p5.getVector(),key) = v_exp5.value(key);
pos_or_propL<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_propL<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_propL<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_propL<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_propL<typename prp5::vtype,prp5::prop>::value(p5.getVector(),key) = v_exp5.value(key);
++it;
}
......@@ -194,12 +194,12 @@ void assign(prp1 & p1, const expr1 & v_e1,
{
auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_prop<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_prop<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_prop<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_prop<typename prp5::vtype,prp5::prop>::value(p5.getVector(),key) = v_exp5.value(key);
pos_or_prop<typename prp6::vtype,prp6::prop>::value(p6.getVector(),key) = v_exp6.value(key);
pos_or_propL<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_propL<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_propL<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_propL<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_propL<typename prp5::vtype,prp5::prop>::value(p5.getVector(),key) = v_exp5.value(key);
pos_or_propL<typename prp6::vtype,prp6::prop>::value(p6.getVector(),key) = v_exp6.value(key);
++it;
}
......@@ -244,13 +244,13 @@ void assign(prp1 & p1, const expr1 & v_e1,
{
auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_prop<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_prop<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_prop<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_prop<typename prp5::vtype,prp5::prop>::value(p5.getVector(),key) = v_exp5.value(key);
pos_or_prop<typename prp6::vtype,prp6::prop>::value(p6.getVector(),key) = v_exp6.value(key);
pos_or_prop<typename prp7::vtype,prp7::prop>::value(p7.getVector(),key) = v_exp7.value(key);
pos_or_propL<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_propL<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_propL<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_propL<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_propL<typename prp5::vtype,prp5::prop>::value(p5.getVector(),key) = v_exp5.value(key);
pos_or_propL<typename prp6::vtype,prp6::prop>::value(p6.getVector(),key) = v_exp6.value(key);
pos_or_propL<typename prp7::vtype,prp7::prop>::value(p7.getVector(),key) = v_exp7.value(key);
++it;
}
......@@ -298,14 +298,14 @@ void assign(prp1 & p1, const expr1 & v_e1,
{
auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_prop<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_prop<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_prop<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_prop<typename prp5::vtype,prp5::prop>::value(p5.getVector(),key) = v_exp5.value(key);
pos_or_prop<typename prp6::vtype,prp6::prop>::value(p6.getVector(),key) = v_exp6.value(key);
pos_or_prop<typename prp7::vtype,prp7::prop>::value(p7.getVector(),key) = v_exp7.value(key);
pos_or_prop<typename prp8::vtype,prp8::prop>::value(p8.getVector(),key) = v_exp8.value(key);
pos_or_propL<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key);
pos_or_propL<typename prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
pos_or_propL<typename prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
pos_or_propL<typename prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
pos_or_propL<typename prp5::vtype,prp5::prop>::value(p5.getVector(),key) = v_exp5.value(key);
pos_or_propL<typename prp6::vtype,prp6::prop>::value(p6.getVector(),key) = v_exp6.value(key);
pos_or_propL<typename prp7::vtype,prp7::prop>::value(p7.getVector(),key) = v_exp7.value(key);
pos_or_propL<typename prp8::vtype,prp8::prop>::value(p8.getVector(),key) = v_exp8.value(key);
++it;
}
......
......@@ -167,7 +167,8 @@ public:
* \return return the result of the expression
*
*/
template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx(0)) + o2.value(vect_dist_key_dx(0)))>::type > inline r_type value(const vect_dist_key_dx & key) const
template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx(0)) + o2.value(vect_dist_key_dx(0)))>::type >
inline r_type value(const vect_dist_key_dx & key) const
{
return o1.value(key) + o2.value(key);
}
......@@ -312,7 +313,7 @@ public:
}
};
/*! \brief selector for position or properties
/*! \brief selector for position or properties left side expression
*
* \tparam vector type of the original vector
*
......@@ -320,7 +321,7 @@ public:
*
*/
template <typename vector, unsigned int prp>
struct pos_or_prop
struct pos_or_propL
{
//! return the value (position or property) of the particle k in the vector v
static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(v.template getProp<prp>(k))
......@@ -329,7 +330,24 @@ struct pos_or_prop
}
};
/*! \brief selector for position or properties
/*! \brief selector for position or properties right side position
*
* \tparam vector type of the original vector
*
* \tparam prp property id
*
*/
template <typename vector, unsigned int prp>
struct pos_or_propR
{
//! return the value (position or property) of the particle k in the vector v
static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(v.template getProp<prp>(k))
{
return v.template getProp<prp>(k);
}
};
/*! \brief selector for position or properties left side
*
* \tparam vector type of the original vector
*
......@@ -337,13 +355,42 @@ struct pos_or_prop
*
*/
template <typename vector>
struct pos_or_prop<vector,PROP_POS>
struct pos_or_propL<vector,PROP_POS>
{
#ifdef SE_CLASS3
//! return the value (position or property) of the particle k in the vector v
static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(getExpr(v.getPos(k).getReference()))
{
return getExpr(v.getPos(k).getReference());
}
#else
//! return the value (position or property) of the particle k in the vector v
static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(getExpr(v.getPos(k)))
{
return getExpr(v.getPos(k));
}
#endif
};
/*! \brief selector for position or properties right side
*
* \tparam vector type of the original vector
*
* \tparam prp property id
*
*/
template <typename vector>
struct pos_or_propR<vector,PROP_POS>
{
//! return the value (position or property) of the particle k in the vector v
static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(getExprR(v.getPos(k)))
{
return getExprR(v.getPos(k));
}
};
/*! \brief it take an expression and create the negatove of this expression
......@@ -428,9 +475,9 @@ public:
* \return the result of the expression
*
*/
inline auto value(const vect_dist_key_dx & k) const -> decltype(pos_or_prop<vector,prp>::value(v,k))
inline auto value(const vect_dist_key_dx & k) const -> decltype(pos_or_propR<vector,prp>::value(v,k))
{
return pos_or_prop<vector,prp>::value(v,k);