Skip to content
Snippets Groups Projects
Commit 3385f02c authored by Pietro Incardona's avatar Pietro Incardona
Browse files

Addimg METIS detection

parent 70629390
No related branches found
No related tags found
No related merge requests found
AC_DEFUN([IMMDX_LIB_METIS], [
AC_MSG_CHECKING(for METIS library)
AC_REQUIRE([AC_PROG_CC])
#
# User hints...
#
AC_ARG_VAR([METIS], [METIS library location])
AC_ARG_WITH([metis],
[AC_HELP_STRING([--with-metis],
[user defined path to METIS library])],
[
if test -n "$METIS" ; then
AC_MSG_RESULT(yes)
with_metis=$METIS
elif test "$withval" != no ; then
AC_MSG_RESULT(yes)
with_metis=$withval
else
AC_MSG_RESULT(no)
fi
],
[
if test -n "$METIS" ; then
with_metis=$METIS
AC_MSG_RESULT(yes)
else
with_metis=/usr
if test ! -f "$with_metis/include/metis.h" ; then
with_metis=/usr/local
if test ! -f "$with_metis/include/metis.h" ; then
with_metis=""
AC_MSG_RESULT(failed)
else
AC_MSG_RESULT(yes)
fi
else
AC_MSG_RESULT(yes)
fi
fi
])
#
# locate METIS library
#
if test -n "$with_metis" ; then
old_CFLAGS=$CFLAGS
old_LDFLAGS=$LDFLAGS
CFLAGS="-I$with_metis/include"
LDFLAGS="-L$with_metis/lib"
AC_LANG_SAVE
AC_LANG_C
AC_CHECK_LIB(metis, METIS_PartMeshDual,
[metis_lib=yes], [metis_lib=yes], [-lm])
AC_CHECK_HEADER(metis.h, [metis_h=yes],
[metis_h=no], [/* check */])
AC_LANG_RESTORE
CFLAGS=$old_CFLAGS
LDFLAGS=$old_LDFLAGS
AC_MSG_CHECKING(METIS in $with_metis)
if test "$metis_lib" = "yes" -a "$metis_h" = "yes" ; then
AC_SUBST(METIS_INCLUDE, [-I$with_metis/include])
AC_SUBST(METIS_LIB, [-L$with_metis/lib])
AC_MSG_RESULT(ok)
else
AC_MSG_RESULT(failed)
fi
fi
#
#
#
if test x = x"$METIS_LIB" ; then
ifelse([$2],,[AC_MSG_ERROR(Failed to find valid METIS library)],[$2])
:
else
ifelse([$1],,[AC_DEFINE(HAVE_METIS,1,[Define if you have METIS library])],[$1])
:
fi
])dnl IMMDX_LIB_METIS
......@@ -16,6 +16,7 @@
#include "Vector/map_vector.hpp"
#include "Grid/comb.hpp"
#include "FiniteDifference/util/common.hpp"
#include "util/util_num.hpp"
/*! \brief Derivative second order on h (spacing)
*
......@@ -62,7 +63,7 @@ class D<d,arg,Sys_eqs,CENTRAL>
*
*
*/
inline static void value(const grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition> & 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)
inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition>::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)
{
// if the system is staggered the CENTRAL derivative is equivalent to a forward derivative
if (is_grid_staggered<Sys_eqs>::value() == true)
......@@ -133,7 +134,7 @@ public:
*
*
*/
static void value(const grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition> & 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)
static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition>::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)
{
#ifdef SE_CLASS1
if (Sys_eqs::boundary[d] == PERIODIC)
......@@ -144,7 +145,7 @@ public:
if (pos.get(d) == (long int)gs.size(d)-1 )
{
arg::value(pos,gs,cols,1.5*coeff);
arg::value(g_map,kmap,gs,cols,1.5*coeff);
long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1);
......@@ -152,13 +153,13 @@ public:
kmap.getKeyRef().set_d(d,old_val);
old_val = kmap.getKeyRef().get(d);
pos.set_d(d, kmap.getKeyRef().get(d) - 2);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 2);
arg::value(g_map,kmap,gs,cols,0.5*coeff);
kmap.getKeyRef().set_d(d,old_val);
}
else if (pos.get(d) == 0)
{
arg::value(pos,gs,cols,-1.5*coeff);
arg::value(g_map,kmap,gs,cols,-1.5*coeff);
long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1);
......@@ -166,7 +167,7 @@ public:
kmap.getKeyRef().set_d(d,old_val);
old_val = kmap.getKeyRef().get(d);
pos.set_d(d, kmap.getKeyRef().get(d) + 2);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 2);
arg::value(g_map,kmap,gs,cols,-0.5*coeff);
kmap.getKeyRef().set_d(d,old_val);
}
......@@ -229,7 +230,7 @@ class D<d,arg,Sys_eqs,FORWARD>
*
*
*/
inline static void value(const grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition> & 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)
inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition>::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)
{
long int old_val = kmap.getKeyRef().get(d);
......
......@@ -17,8 +17,8 @@
/*! \brief Finite Differences
*
* This class is able to discreatize on a Matrix any operator. In order to create a consistent
* Matrix it is required that each processor must contain a contiguois range on grid points without
* hole. In order to ensure this, each processor produce a contiguos local labelling of its local
* Matrix it is required that each processor must contain a contiguos range on grid points without
* holes. In order to ensure this, each processor produce a contiguos local labelling of its local
* points. Each processor also add an offset equal to the number of local
* points of the processors with id smaller than him, to produce a global and non overlapping
* labelling. An example is shown in the figures down, here we have
......@@ -142,6 +142,16 @@ class FDScheme
}
}
/*! \brief Convert from integer ghost to continuos
*
* \return the continuos version of the ghost
*
*/
Ghost<dim,Sys_eqs::stype> convert_into_cg()
{
}
public:
/*! \brief Constructor
......@@ -151,7 +161,7 @@ public:
*
*/
FDScheme(Padding<Sys_eqs::dims> & pd, const Box<Sys_eqs::dims,typename Sys_eqs::stype> & domain, const grid_sm<Sys_eqs::dims,void> & gs, typename Sys_eqs::b_grid::decomposition & dec, Vcluster & v_cl)
:pd(pd),gs(gs),g_map(dec,gs.getSize(),domain,Ghost<Sys_eqs::dims,size_t>(1))
:pd(pd),gs(gs),g_map(dec.duplicate(Ghost<Sys_eqs::dims,long int>(1)),gs.getSize(),domain)
{
// Calculate the size of the local domain
size_t sz = g_map.getLocalDomainSize();
......@@ -204,9 +214,6 @@ public:
// get the position
auto key = it.get();
// convert into global coordinate the position
auto keyg = it.getGKey(key);
// Calculate the non-zero colums
T::value(g_map,key,gs,cols,1.0);
......
......@@ -11,6 +11,7 @@
#include "FiniteDifference/Derivative.hpp"
#include "FiniteDifference/Laplacian.hpp"
#include "Decomposition/CartDecomposition.hpp"
#include "util/grid_dist_testing.hpp"
constexpr unsigned int x = 0;
constexpr unsigned int y = 1;
......@@ -117,21 +118,24 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
// grid size
size_t sz[2]={16,16};
// grid_dist_testing
grid_dist_testing<2> g_map(sz);
// grid_sm
grid_sm<2,void> ginfo(sz);
// Create a derivative row Matrix
grid_key_dx<2> key11(1,1);
grid_key_dx<2> key00(0,0);
grid_key_dx<2> key22(2,2);
grid_key_dx<2> key1515(15,15);
// Create several keys
grid_dist_key_dx<2> key11(0,grid_key_dx<2>(1,1));
grid_dist_key_dx<2> key00(0,grid_key_dx<2>(0,0));
grid_dist_key_dx<2> key22(0,grid_key_dx<2>(2,2));
grid_dist_key_dx<2> key1515(0,grid_key_dx<2>(15,15));
// filled colums
std::unordered_map<long int,float> cols_x;
std::unordered_map<long int,float> cols_y;
/* D<x,Field<V,sys_nn>,sys_nn>::value(key11,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn>::value(key11,ginfo,cols_y,1);
D<x,Field<V,sys_nn>,sys_nn>::value(g_map,key11,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn>::value(g_map,key11,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
......@@ -151,10 +155,10 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
// Composed derivative
D<x,D<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(key22,ginfo,cols_xx,1);
D<x,D<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(key22,ginfo,cols_xy,1);
D<y,D<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(key22,ginfo,cols_yx,1);
D<y,D<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(key22,ginfo,cols_yy,1);
D<x,D<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,cols_xx,1);
D<x,D<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,cols_xy,1);
D<y,D<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,cols_yx,1);
D<y,D<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,cols_yy,1);
BOOST_REQUIRE_EQUAL(cols_xx.size(),3);
BOOST_REQUIRE_EQUAL(cols_xy.size(),4);
......@@ -184,8 +188,8 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
cols_x.clear();
cols_y.clear();
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key11,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key11,ginfo,cols_y,1);
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key11,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key11,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
......@@ -201,8 +205,8 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
cols_x.clear();
cols_y.clear();
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key00,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key00,ginfo,cols_y,1);
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key00,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key00,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),3);
BOOST_REQUIRE_EQUAL(cols_y.size(),3);
......@@ -220,8 +224,8 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
cols_x.clear();
cols_y.clear();
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key1515,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key1515,ginfo,cols_y,1);
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key1515,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key1515,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),3);
BOOST_REQUIRE_EQUAL(cols_y.size(),3);
......@@ -232,106 +236,9 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
BOOST_REQUIRE_EQUAL(cols_y[15*16+15],1.5);
BOOST_REQUIRE_EQUAL(cols_y[14*16+15],-2);
BOOST_REQUIRE_EQUAL(cols_y[13*16+15],0.5);*/
BOOST_REQUIRE_EQUAL(cols_y[13*16+15],0.5);
}
BOOST_AUTO_TEST_CASE( fd_test_use_periodic)
{
// grid size
size_t sz[2]={16,16};
// grid_sm
grid_sm<2,void> ginfo(sz);
// Create a derivative row Matrix
grid_key_dx<2> key11(1,1);
grid_key_dx<2> key00(0,0);
grid_key_dx<2> key22(2,2);
grid_key_dx<2> key1515(15,15);
// filled colums
std::unordered_map<long int,float> cols_x;
std::unordered_map<long int,float> cols_y;
/* D<x,Field<V,sys_pp>,sys_pp>::value(key11,ginfo,cols_x,1);
D<y,Field<V,sys_pp>,sys_pp>::value(key11,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
BOOST_REQUIRE_EQUAL(cols_x[17+1],1);
BOOST_REQUIRE_EQUAL(cols_x[17-1],-1);
BOOST_REQUIRE_EQUAL(cols_y[17+16],1);
BOOST_REQUIRE_EQUAL(cols_y[17-16],-1);
cols_x.clear();
cols_y.clear();
D<x,Field<V,sys_pp>,sys_pp>::value(key00,ginfo,cols_x,1);
D<y,Field<V,sys_pp>,sys_pp>::value(key00,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
BOOST_REQUIRE_EQUAL(cols_x[1],1);
BOOST_REQUIRE_EQUAL(cols_x[15],-1);
BOOST_REQUIRE_EQUAL(cols_y[16],1);
BOOST_REQUIRE_EQUAL(cols_y[16*15],-1);
// periodic composed derivative
std::unordered_map<long int,float> cols_xx;
std::unordered_map<long int,float> cols_xy;
std::unordered_map<long int,float> cols_yx;
std::unordered_map<long int,float> cols_yy;
D<x,D<x,Field<V,sys_pp>,sys_pp>,sys_pp>::value(key00,ginfo,cols_xx,1);
D<x,D<y,Field<V,sys_pp>,sys_pp>,sys_pp>::value(key00,ginfo,cols_xy,1);
D<y,D<x,Field<V,sys_pp>,sys_pp>,sys_pp>::value(key00,ginfo,cols_yx,1);
D<y,D<y,Field<V,sys_pp>,sys_pp>,sys_pp>::value(key00,ginfo,cols_yy,1);
BOOST_REQUIRE_EQUAL(cols_xx.size(),3);
BOOST_REQUIRE_EQUAL(cols_xy.size(),4);
BOOST_REQUIRE_EQUAL(cols_yx.size(),4);
BOOST_REQUIRE_EQUAL(cols_yy.size(),3);
BOOST_REQUIRE_EQUAL(cols_xx[14],1);
BOOST_REQUIRE_EQUAL(cols_xx[0],-2);
BOOST_REQUIRE_EQUAL(cols_xx[2],1);
BOOST_REQUIRE_EQUAL(cols_xy[17],1);
BOOST_REQUIRE_EQUAL(cols_xy[16+15],-1);
BOOST_REQUIRE_EQUAL(cols_xy[15*16+1],-1);
BOOST_REQUIRE_EQUAL(cols_xy[15*16+15],1);
BOOST_REQUIRE_EQUAL(cols_yx[17],1);
BOOST_REQUIRE_EQUAL(cols_yx[16+15],-1);
BOOST_REQUIRE_EQUAL(cols_yx[15*16+1],-1);
BOOST_REQUIRE_EQUAL(cols_xy[15*16+15],1);
BOOST_REQUIRE_EQUAL(cols_yy[32],1);
BOOST_REQUIRE_EQUAL(cols_yy[0],-2);
BOOST_REQUIRE_EQUAL(cols_yy[14*16],1);
// Border Top right
cols_x.clear();
cols_y.clear();
D<x,Field<V,sys_pp>,sys_pp>::value(key1515,ginfo,cols_x,1);
D<y,Field<V,sys_pp>,sys_pp>::value(key1515,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
BOOST_REQUIRE_EQUAL(cols_x[15*16+0],1);
BOOST_REQUIRE_EQUAL(cols_x[15*16+14],-1);
BOOST_REQUIRE_EQUAL(cols_y[0*16+15],1);
BOOST_REQUIRE_EQUAL(cols_y[14*16+15],-1);*/
}
BOOST_AUTO_TEST_CASE( fd_test_use_staggered_non_periodic)
{
......@@ -341,18 +248,20 @@ BOOST_AUTO_TEST_CASE( fd_test_use_staggered_non_periodic)
// grid_sm
grid_sm<2,void> ginfo(sz);
// Create a derivative row Matrix
grid_key_dx<2> key11(1,1);
grid_key_dx<2> key00(0,0);
grid_key_dx<2> key22(2,2);
grid_key_dx<2> key1515(15,15);
// grid_dist_testing
grid_dist_testing<2> g_map(sz);
// Create several keys
grid_dist_key_dx<2> key11(0,grid_key_dx<2>(1,1));
grid_dist_key_dx<2> key22(0,grid_key_dx<2>(2,2));
grid_dist_key_dx<2> key1515(0,grid_key_dx<2>(15,15));
// filled colums
std::unordered_map<long int,float> cols_x;
std::unordered_map<long int,float> cols_y;
/* D<x,Field<V,syss_pp>,syss_pp>::value(key11,ginfo,cols_x,1);
D<y,Field<V,syss_pp>,syss_pp>::value(key11,ginfo,cols_y,1);
D<x,Field<V,syss_pp>,syss_pp>::value(g_map,key11,ginfo,cols_x,1);
D<y,Field<V,syss_pp>,syss_pp>::value(g_map,key11,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
......@@ -365,18 +274,6 @@ BOOST_AUTO_TEST_CASE( fd_test_use_staggered_non_periodic)
cols_x.clear();
cols_y.clear();
D<x,Field<V,syss_pp>,syss_pp>::value(key00,ginfo,cols_x,1);
D<y,Field<V,syss_pp>,syss_pp>::value(key00,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
BOOST_REQUIRE_EQUAL(cols_x[1],1);
BOOST_REQUIRE_EQUAL(cols_x[0],-1);
BOOST_REQUIRE_EQUAL(cols_y[16],1);
BOOST_REQUIRE_EQUAL(cols_y[0],-1);*/
}
/////////////// Laplacian test
......@@ -389,16 +286,18 @@ BOOST_AUTO_TEST_CASE( fd_test_lap_use_periodic)
// grid_sm
grid_sm<2,void> ginfo(sz);
// Create a derivative row Matrix
grid_key_dx<2> key11(1,1);
grid_key_dx<2> key00(0,0);
grid_key_dx<2> key22(2,2);
grid_key_dx<2> key1515(15,15);
// grid_dist_testing
grid_dist_testing<2> g_map(sz);
// Create several keys
grid_dist_key_dx<2> key11(0,grid_key_dx<2>(1,1));
grid_dist_key_dx<2> key22(0,grid_key_dx<2>(2,2));
grid_dist_key_dx<2> key1414(0,grid_key_dx<2>(14,14));
// filled colums
std::unordered_map<long int,float> cols;
/* Lap<Field<V,sys_pp>,sys_pp>::value(key11,ginfo,cols,1);
Lap<Field<V,sys_pp>,sys_pp>::value(g_map,key11,ginfo,cols,1);
BOOST_REQUIRE_EQUAL(cols.size(),5);
......@@ -411,31 +310,16 @@ BOOST_AUTO_TEST_CASE( fd_test_lap_use_periodic)
cols.clear();
Lap<Field<V,sys_pp>,sys_pp>::value(key00,ginfo,cols,1);
Lap<Field<V,sys_pp>,sys_pp>::value(g_map,key1414,ginfo,cols,1);
BOOST_REQUIRE_EQUAL(cols.size(),5);
BOOST_REQUIRE_EQUAL(cols[1],1);
BOOST_REQUIRE_EQUAL(cols[15],1);
BOOST_REQUIRE_EQUAL(cols[16],1);
BOOST_REQUIRE_EQUAL(cols[15*16],1);
BOOST_REQUIRE_EQUAL(cols[0],-4);
// Border Top right
cols.clear();
Lap<Field<V,sys_pp>,sys_pp>::value(key1515,ginfo,cols,1);
BOOST_REQUIRE_EQUAL(cols.size(),5);
BOOST_REQUIRE_EQUAL(cols[15*16+14],1);
BOOST_REQUIRE_EQUAL(cols[15*16],1);
BOOST_REQUIRE_EQUAL(cols[14*16+13],1);
BOOST_REQUIRE_EQUAL(cols[14*16+15],1);
BOOST_REQUIRE_EQUAL(cols[15],1);
BOOST_REQUIRE_EQUAL(cols[13*16+14],1);
BOOST_REQUIRE_EQUAL(cols[15*16+14],1);
BOOST_REQUIRE_EQUAL(cols[15*16+15],-4);*/
BOOST_REQUIRE_EQUAL(cols[14*16+14],-4);
}
//////////////// Position ////////////////////
......
......@@ -23,7 +23,7 @@ class Lap
* \tparam ord
*
*/
inline static void value(const grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition> & 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)
inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition>::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";
}
......@@ -53,7 +53,7 @@ public:
*
*
*/
inline static void value(const grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition> & 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)
inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition>::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)
{
// for each dimension
for (size_t i = 0 ; i < Sys_eqs::dims ; i++)
......
......@@ -18,6 +18,7 @@
#define NON_PERIODIC false
#include "data_type/scalar.hpp"
#include "util/util_num.hpp"
/*! \brief Equation
*
......@@ -125,13 +126,15 @@ struct pos_val
template<unsigned int f, typename Sys_eqs>
class Field
{
typedef typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition>::type map_grid;
public:
/*! \brief fill the row
*
*
*/
static void value(const grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition> & 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)
static void value(const map_grid & 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)
{
if (Sys_eqs::ord == EQS_FIELD)
cols[g_map.template get<0>(kmap)*Sys_eqs::nvar + f] += coeff;
......
......@@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE( lid_driven_cavity )
// Ghost
Ghost<2,float> g(0.01);
size_t sz[] = {32,32};
size_t sz[] = {256,256};
Padding<2> pd({1,2},{1,2});
// Initialize the global VCluster
......@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE( lid_driven_cavity )
FDScheme<lid_nn> fd(pd,domain,g_dist.getGridInfo(),g_dist.getDecomposition(),g_dist.getVC());
// start and end of the bulk
grid_key_dx<2> bulk_start(0,0);
/* grid_key_dx<2> bulk_start(0,0);
grid_key_dx<2> bulk_end(sz[0],sz[1]);
// Impose the vx and vy equation in the bulk
......@@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE( lid_driven_cavity )
grid_key_dx<2> pvtop_start(0,33);
grid_key_dx<2> pvtop_end(31,33);
fd.imposeA(v_x(), g_dist.getSubDomainIterator(pvtop_start,pvtop_end));
fd.imposeB(0.0, g_dist.getSubDomainIterator(pvtop_start,pvtop_end));
fd.imposeB(0.0, g_dist.getSubDomainIterator(pvtop_start,pvtop_end));*/
}
BOOST_AUTO_TEST_SUITE_END()
......
......@@ -25,14 +25,15 @@ struct sum_functor_value
//! sum functor
std::unordered_map<long int,typename last::stype> & cols;
//! Grid info
const grid_sm<last::dims,void> & gs;
// grid mapping
const grid_dist_id<last::dims,typename last::stype,scalar<size_t>,typename last::b_grid::decomposition> & g_map;
// grid position
grid_dist_key_dx<last::dims> & kmap;
const grid_sm<last::dims,void> & gs;
//! position
grid_key_dx<last::dims> & key;
......@@ -43,7 +44,7 @@ struct sum_functor_value
*
*/
sum_functor_value(const grid_dist_id<last::dims,typename last::stype,scalar<size_t>,typename last::b_grid::decomposition> & g_map, grid_dist_key_dx<last::dims> & kmap, const grid_sm<last::dims,void> & gs, std::unordered_map<long int,typename last::stype> & cols, typename last::stype coeff)
:g_map(g_map),kmap(kmap),cols(cols),gs(gs),key(key),coeff(coeff)
:cols(cols),gs(gs),g_map(g_map),kmap(kmap),key(key),coeff(coeff)
{};
......
......@@ -12,6 +12,56 @@ template<unsigned int dim>
class grid_dist_testing
{
grid_cpu<dim,scalar<size_t>> grid_test;
public:
/*! \brief It create a test map suitable for testing
*
* \param size of the grid with padding
*
*/
grid_dist_testing(const size_t (& g_sz)[dim])
:grid_test(g_sz)
{
grid_test.setMemory();
// We fill the testing map
auto dom = grid_test.getIterator();
const auto & gs = grid_test.getGrid();
while (dom.isNext())
{
auto key = dom.get();
grid_test.template get<0>(key) = gs.LinId(key);
++dom;
}
}
/*! \brief Get the element at position key
*
* \warning it is a stub object, it just return number in the underline grid
*
*/
template <unsigned int p> size_t get(const grid_dist_key_dx<dim> & key) const
{
if (p != 0)
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " mapping grid is suppose to have only one scalar size_t \n";
return grid_test.template get<0>(key.getKey());
}
/*! \brief Return the global key
*
* \warning it is a stub object, it just return the key
*
*/
grid_key_dx<dim> getGKey(const grid_dist_key_dx<dim> & key) const
{
return key.getKey();
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment