Commit 5e304636 authored by incardon's avatar incardon

Adding left type expression and right type expression

parent bc9efd0e
...@@ -12,10 +12,37 @@ ...@@ -12,10 +12,37 @@
#include "PointIteratorSkin.hpp" #include "PointIteratorSkin.hpp"
#include "Vector/vector_dist.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 class DrawParticles
{ {
public: 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> template<unsigned int dim, typename T, typename aggr, typename Decomposition> static PointIteratorSkin<dim,T,Decomposition>
DrawSkin(vector_dist<dim,T,aggr,Decomposition> & vd, DrawSkin(vector_dist<dim,T,aggr,Decomposition> & vd,
size_t (& sz)[dim], size_t (& sz)[dim],
...@@ -28,9 +55,30 @@ public: ...@@ -28,9 +55,30 @@ public:
for (size_t i = 0 ; i < dim ; i++) for (size_t i = 0 ; i < dim ; i++)
bc[i] = NON_PERIODIC; 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> template<unsigned int dim, typename T, typename aggr, typename Decomposition> static PointIteratorSkin<dim,T,Decomposition>
DrawSkin(vector_dist<dim,T,aggr,Decomposition> & vd, DrawSkin(vector_dist<dim,T,aggr,Decomposition> & vd,
size_t (& sz)[dim], size_t (& sz)[dim],
...@@ -43,7 +91,7 @@ public: ...@@ -43,7 +91,7 @@ public:
for (size_t i = 0 ; i < dim ; i++) for (size_t i = 0 ; i < dim ; i++)
bc[i] = NON_PERIODIC; 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++) for (size_t i = 1 ; i < sub_A.size() ; i++)
it.addBoxA(Box<dim,T>(sub_A.get(i))); it.addBoxA(Box<dim,T>(sub_A.get(i)));
...@@ -51,13 +99,31 @@ public: ...@@ -51,13 +99,31 @@ public:
return it; 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> template<unsigned int dim, typename T, typename aggr, typename Decomposition> static PointIterator<dim,T,Decomposition>
DrawBox(vector_dist<dim,T,aggr,Decomposition> & vd, DrawBox(vector_dist<dim,T,aggr,Decomposition> & vd,
size_t (& sz)[dim], size_t (& sz)[dim],
Box<dim,T> & domain, Box<dim,T> & domain,
Box<dim,T> & sub) 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 ) ...@@ -16,6 +16,8 @@ BOOST_AUTO_TEST_SUITE( draw_particles )
BOOST_AUTO_TEST_CASE(point_iterator) BOOST_AUTO_TEST_CASE(point_iterator)
{ {
//! [DrawBox_example]
size_t sz[] = {23,27,20}; size_t sz[] = {23,27,20};
Box<3,double> domain({-1.2,0.5,-0.6},{1.0,3.1,1.3}); 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) ...@@ -52,6 +54,8 @@ BOOST_AUTO_TEST_CASE(point_iterator)
++p; ++p;
} }
//! [DrawBox_example]
Vcluster & v_cl = create_vcluster(); Vcluster & v_cl = create_vcluster();
v_cl.sum(cnt); v_cl.sum(cnt);
......
...@@ -69,7 +69,7 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition> ...@@ -69,7 +69,7 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition>
//! Spacing //! Spacing
T sp[dim]; 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++) for (size_t i = 0 ; i < dim ; i++)
sp[i] = (dom.getHigh(i) - dom.getLow(i)) / (gs[i] -1); sp[i] = (dom.getHigh(i) - dom.getLow(i)) / (gs[i] -1);
...@@ -82,7 +82,7 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition> ...@@ -82,7 +82,7 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition>
return pkey; 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++) for (size_t i = 0 ; i < dim ; i++)
sp[i] = (dom.getHigh(i) - dom.getLow(i)) / (gs[i] - 1); sp[i] = (dom.getHigh(i) - dom.getLow(i)) / (gs[i] - 1);
...@@ -97,6 +97,9 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition> ...@@ -97,6 +97,9 @@ class PointIterator: protected grid_dist_id_iterator_dec<Decomposition>
void calculateAp() void calculateAp()
{ {
if (grid_dist_id_iterator_dec<Decomposition>::isNext() == false)
return;
grid_key_dx<dim> key = grid_dist_id_iterator_dec<Decomposition>::get(); grid_key_dx<dim> key = grid_dist_id_iterator_dec<Decomposition>::get();
for (size_t i = 0 ; i < dim ; i++) for (size_t i = 0 ; i < dim ; i++)
...@@ -110,7 +113,7 @@ public: ...@@ -110,7 +113,7 @@ public:
* \param sp grid spacing * \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) :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(); calculateAp();
...@@ -133,6 +136,7 @@ public: ...@@ -133,6 +136,7 @@ public:
PointIterator & operator++() PointIterator & operator++()
{ {
grid_dist_id_iterator_dec<Decomposition>::operator++(); grid_dist_id_iterator_dec<Decomposition>::operator++();
calculateAp(); calculateAp();
return *this; return *this;
......
...@@ -101,6 +101,9 @@ class PointIteratorSkin: protected grid_dist_id_iterator_dec_skin<Decomposition> ...@@ -101,6 +101,9 @@ class PointIteratorSkin: protected grid_dist_id_iterator_dec_skin<Decomposition>
void calculateAp() 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(); grid_key_dx<dim> key = grid_dist_id_iterator_dec_skin<Decomposition>::get();
for (size_t i = 0 ; i < dim ; i++) for (size_t i = 0 ; i < dim ; i++)
...@@ -133,7 +136,7 @@ public: ...@@ -133,7 +136,7 @@ public:
* \param sp grid spacing * \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) :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); sub_domainA.add(sub_A);
...@@ -142,6 +145,7 @@ public: ...@@ -142,6 +145,7 @@ public:
/*! \Return the actual point /*! \Return the actual point
* *
* \return the actual point
* *
*/ */
Point<dim,T> & get() Point<dim,T> & get()
...@@ -157,11 +161,13 @@ public: ...@@ -157,11 +161,13 @@ public:
PointIteratorSkin & operator++() PointIteratorSkin & operator++()
{ {
grid_dist_id_iterator_dec_skin<Decomposition>::operator++(); grid_dist_id_iterator_dec_skin<Decomposition>::operator++();
calculateAp(); calculateAp();
while (grid_dist_id_iterator_dec_skin<Decomposition>::isNext() && isValidPoint() == false) while (grid_dist_id_iterator_dec_skin<Decomposition>::isNext() && isValidPoint() == false)
{ {
grid_dist_id_iterator_dec_skin<Decomposition>::operator++(); grid_dist_id_iterator_dec_skin<Decomposition>::operator++();
calculateAp(); calculateAp();
} }
......
This diff is collapsed.
...@@ -126,59 +126,67 @@ class FDScheme ...@@ -126,59 +126,67 @@ class FDScheme
{ {
public: 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; 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; typedef Sys_eqs Sys_eqs_typ;
private: private:
// Padding //! Padding
Padding<Sys_eqs::dims> pd; Padding<Sys_eqs::dims> pd;
//! Sparse matrix triplet type
typedef typename Sys_eqs::SparseMatrix_type::triplet_type triplet; typedef typename Sys_eqs::SparseMatrix_type::triplet_type triplet;
// Vector b //! Vector b
typename Sys_eqs::Vector_type b; typename Sys_eqs::Vector_type b;
// Domain Grid informations //! Domain Grid informations
const grid_sm<Sys_eqs::dims,void> & gs; const grid_sm<Sys_eqs::dims,void> & gs;
// Get the grid spacing //! Get the grid spacing
typename Sys_eqs::stype spacing[Sys_eqs::dims]; typename Sys_eqs::stype spacing[Sys_eqs::dims];
// mapping grid //! mapping grid
g_map_type g_map; g_map_type g_map;
// row of the matrix //! row of the matrix
size_t row; size_t row;
// row on b //! row on b
size_t row_b; size_t row_b;
// Grid points that has each processor //! Grid points that has each processor
openfpm::vector<size_t> pnt; openfpm::vector<size_t> pnt;
// Staggered position for each property //! Staggered position for each property
comb<Sys_eqs::dims> s_pos[Sys_eqs::nvar]; 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 //! 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 //! 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 //! no processors can have holes in the sequence, this number indicate where the sequence start for this
// processor //! processor
size_t s_pnt; size_t s_pnt;
/*! \brief Equation id + space position
*
*/
struct key_and_eq struct key_and_eq
{ {
//! space position
grid_key_dx<Sys_eqs::dims> key; grid_key_dx<Sys_eqs::dims> key;
//! equation id
size_t eq; size_t eq;
}; };
/*! \brief From the row Matrix position to the spatial position /*! \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) inline key_and_eq from_row_to_key(size_t row)
...@@ -205,9 +213,10 @@ private: ...@@ -205,9 +213,10 @@ private:
return ke; 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 * \return padded grid size
* *
...@@ -323,7 +332,7 @@ public: ...@@ -323,7 +332,7 @@ public:
/*! \brief set the staggered position for each property /*! \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]) void setStagPos(comb<Sys_eqs::dims> (& sp)[Sys_eqs::nvar])
...@@ -335,10 +344,8 @@ public: ...@@ -335,10 +344,8 @@ public:
/*! \brief compute the staggered position for each property /*! \brief compute the staggered position for each property
* *
* This is compute from the value_type stored by Sys_eqs::b_grid::value_type * 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() void computeStag()
...@@ -377,13 +384,17 @@ public: ...@@ -377,13 +384,17 @@ public:
/*! \brief Constructor /*! \brief Constructor
* *
* \param pd Padding, how many points out of boundary are present * \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 gs grid infos where Finite differences work
* \param stencil maximum extension of the stencil on each directions * \param b_g maximum extension of the stencil on each directions
* \param dec Decomposition of the domain
* *
*/ */
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) :pd(pd),gs(gs),g_map(b_g,stencil,pd),row(0),row_b(0)
{ {
Vcluster & v_cl = b_g.getDecomposition().getVC(); Vcluster & v_cl = b_g.getDecomposition().getVC();
...@@ -450,9 +461,15 @@ public: ...@@ -450,9 +461,15 @@ public:
* \param id Equation id in the system that we are imposing * \param id Equation id in the system that we are imposing
* \param start starting point of the box * \param start starting point of the box
* \param stop stop 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> start_k;
grid_key_dx<Sys_eqs::dims> stop_k; grid_key_dx<Sys_eqs::dims> stop_k;
...@@ -557,6 +574,7 @@ public: ...@@ -557,6 +574,7 @@ public:
} }
} }
//! type of the sparse matrix
typename Sys_eqs::SparseMatrix_type A; typename Sys_eqs::SparseMatrix_type A;
/*! \brief produce the Matrix /*! \brief produce the Matrix
...@@ -598,7 +616,7 @@ public: ...@@ -598,7 +616,7 @@ public:
* \tparam Grid_dst type of the target grid * \tparam Grid_dst type of the target grid
* \tparam pos target properties * \tparam pos target properties
* *
* \param scheme Discretization scheme * \param v Vector that contain the solution of the system
* \param start point * \param start point
* \param stop point * \param stop point
* \param g_dst Destination grid * \param g_dst Destination grid
......
...@@ -216,6 +216,11 @@ template<typename solver_type,typename lid_nn_3d> void lid_driven_cavity_3d() ...@@ -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 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"; 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 #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"; 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 ...@@ -72,8 +72,8 @@ struct const_mul_functor_value
* \param kmap grid point (row) where we evaluate the non-zero colums * \param kmap grid point (row) where we evaluate the non-zero colums
* \param gs grid size * \param gs grid size
* \param spacing grid spacing * \param spacing grid spacing
* \param col non zero colums * \param cols non zero colums
* \param coefficent * \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, 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 ...@@ -118,23 +118,31 @@ struct const_mul_functor_value
template<typename ... expr > template<typename ... expr >
struct mul 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; 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; 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; 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 /*! \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 gs Grid info
* \param spacing of the grid
* \param cols non-zero colums calculated by the function * \param cols non-zero colums calculated by the function
* \param coeff coefficent (constant in front of the derivative) * \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); const_mul_functor_value<v_expr> mfv(g_map,kmap,gs,spacing,cols,coeff);
...@@ -151,12 +159,14 @@ struct mul ...@@ -151,12 +159,14 @@ struct mul
* *
* it just return the position of the staggered property in the last expression * 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 gs Grid info
* \param s_pos staggered position of the properties * \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); 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 ...@@ -56,8 +56,8 @@ template<typename prp1, typename expr1, typename prp2, typename expr2> void assi
{ {
auto key = it.get(); auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key); pos_or_propL<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 prp2::vtype,prp2::prop>::value(p2.getVector(),key) = v_exp2.value(key);
++it; ++it;
} }
...@@ -79,9 +79,9 @@ template<typename prp1, typename expr1, typename prp2, typename expr2, typename ...@@ -79,9 +79,9 @@ template<typename prp1, typename expr1, typename prp2, typename expr2, typename
{ {
auto key = it.get(); auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key); pos_or_propL<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 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 prp3::vtype,prp3::prop>::value(p3.getVector(),key) = v_exp3.value(key);
++it; ++it;
} }
...@@ -112,10 +112,10 @@ void assign(prp1 & p1, const expr1 & v_e1, ...@@ -112,10 +112,10 @@ void assign(prp1 & p1, const expr1 & v_e1,
{ {
auto key = it.get(); auto key = it.get();
pos_or_prop<typename prp1::vtype,prp1::prop>::value(p1.getVector(),key) = v_exp1.value(key); pos_or_propL<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 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 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 prp4::vtype,prp4::prop>::value(p4.getVector(),key) = v_exp4.value(key);
++it; ++it;
} }
...@@ -151,11 +151,11 @@ void assign(prp1 & p1, const expr1 & v_e1, ...@@ -151,11 +151,11 @@ void assign(prp1 & p1, const expr1 & v_e1,
{ {
auto key = it.get(); auto key = it.get();