Commit 64d29477 authored by Pietro Incardona's avatar Pietro Incardona

Staggered to normal for grid

parent dfb8b8f7
...@@ -65,24 +65,24 @@ class Avg<d,arg,Sys_eqs,CENTRAL> ...@@ -65,24 +65,24 @@ class Avg<d,arg,Sys_eqs,CENTRAL>
* *
* *
*/ */
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) 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, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , 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 the system is staggered the CENTRAL derivative is equivalent to a forward derivative
if (is_grid_staggered<Sys_eqs>::value()) if (is_grid_staggered<Sys_eqs>::value())
{ {
Avg<d,arg,Sys_eqs,BACKWARD>::value(g_map,kmap,gs,cols,coeff); Avg<d,arg,Sys_eqs,BACKWARD>::value(g_map,kmap,gs,spacing,cols,coeff);
return; return;
} }
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1);
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/2);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
old_val = kmap.getKeyRef().get(d); old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1);
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/2);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
} }
...@@ -135,16 +135,16 @@ class Avg<d,arg,Sys_eqs,FORWARD> ...@@ -135,16 +135,16 @@ class Avg<d,arg,Sys_eqs,FORWARD>
* *
* *
*/ */
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) 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, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff)
{ {
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1);
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/2);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
// backward // backward
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/2);
} }
...@@ -177,15 +177,15 @@ class Avg<d,arg,Sys_eqs,BACKWARD> ...@@ -177,15 +177,15 @@ class Avg<d,arg,Sys_eqs,BACKWARD>
* *
* *
*/ */
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) 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, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims], std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff)
{ {
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1);
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/2);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
// forward // forward
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/2);
} }
......
...@@ -64,24 +64,24 @@ class D<d,arg,Sys_eqs,CENTRAL> ...@@ -64,24 +64,24 @@ class D<d,arg,Sys_eqs,CENTRAL>
* *
* *
*/ */
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) 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, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , 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 the system is staggered the CENTRAL derivative is equivalent to a forward derivative
if (is_grid_staggered<Sys_eqs>::value()) if (is_grid_staggered<Sys_eqs>::value())
{ {
D<d,arg,Sys_eqs,BACKWARD>::value(g_map,kmap,gs,cols,coeff); D<d,arg,Sys_eqs,BACKWARD>::value(g_map,kmap,gs,spacing,cols,coeff);
return; return;
} }
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1);
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/spacing[d]/2.0 );
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
old_val = kmap.getKeyRef().get(d); old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1);
arg::value(g_map,kmap,gs,cols,-coeff); arg::value(g_map,kmap,gs,spacing,cols,-coeff/spacing[d]/2.0 );
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
} }
...@@ -135,7 +135,7 @@ public: ...@@ -135,7 +135,7 @@ public:
* *
* *
*/ */
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) 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, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff)
{ {
#ifdef SE_CLASS1 #ifdef SE_CLASS1
if (Sys_eqs::boundary[d] == PERIODIC) if (Sys_eqs::boundary[d] == PERIODIC)
...@@ -146,42 +146,42 @@ public: ...@@ -146,42 +146,42 @@ public:
if (pos.get(d) == (long int)gs.size(d)-1 ) if (pos.get(d) == (long int)gs.size(d)-1 )
{ {
arg::value(g_map,kmap,gs,cols,1.5*coeff); arg::value(g_map,kmap,gs,spacing,cols,1.5*coeff/spacing[d]);
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1);
arg::value(g_map,kmap,gs,cols,-2.0*coeff); arg::value(g_map,kmap,gs,spacing,cols,-2.0*coeff/spacing[d]);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
old_val = kmap.getKeyRef().get(d); old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().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); arg::value(g_map,kmap,gs,spacing,cols,0.5*coeff/spacing[d]);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
} }
else if (pos.get(d) == 0) else if (pos.get(d) == 0)
{ {
arg::value(g_map,kmap,gs,cols,-1.5*coeff); arg::value(g_map,kmap,gs,spacing,cols,-1.5*coeff/spacing[d]);
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1);
arg::value(g_map,kmap,gs,cols,2.0*coeff); arg::value(g_map,kmap,gs,spacing,cols,2.0*coeff/spacing[d]);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
old_val = kmap.getKeyRef().get(d); old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().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); arg::value(g_map,kmap,gs,spacing,cols,-0.5*coeff/spacing[d]);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
} }
else else
{ {
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1);
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/spacing[d]);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
old_val = kmap.getKeyRef().get(d); old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1);
arg::value(g_map,kmap,gs,cols,-coeff); arg::value(g_map,kmap,gs,spacing,cols,-coeff/spacing[d]);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
} }
} }
...@@ -231,16 +231,16 @@ class D<d,arg,Sys_eqs,FORWARD> ...@@ -231,16 +231,16 @@ class D<d,arg,Sys_eqs,FORWARD>
* *
* *
*/ */
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) 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, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] ,std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff)
{ {
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) + 1);
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/spacing[d]);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
// backward // backward
arg::value(g_map,kmap,gs,cols,-coeff); arg::value(g_map,kmap,gs,spacing,cols,-coeff/spacing[d]);
} }
...@@ -273,16 +273,16 @@ class D<d,arg,Sys_eqs,BACKWARD> ...@@ -273,16 +273,16 @@ class D<d,arg,Sys_eqs,BACKWARD>
* *
* *
*/ */
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) 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, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims], std::unordered_map<long int,typename Sys_eqs::stype > & cols , typename Sys_eqs::stype coeff)
{ {
long int old_val = kmap.getKeyRef().get(d); long int old_val = kmap.getKeyRef().get(d);
kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1); kmap.getKeyRef().set_d(d, kmap.getKeyRef().get(d) - 1);
arg::value(g_map,kmap,gs,cols,-coeff); arg::value(g_map,kmap,gs,spacing,cols,-coeff/spacing[d]);
kmap.getKeyRef().set_d(d,old_val); kmap.getKeyRef().set_d(d,old_val);
// forward // forward
arg::value(g_map,kmap,gs,cols,coeff); arg::value(g_map,kmap,gs,spacing,cols,coeff/spacing[d]);
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "Grid/grid_dist_id_iterator_sub.hpp" #include "Grid/grid_dist_id_iterator_sub.hpp"
#include "eq.hpp" #include "eq.hpp"
#include "data_type/scalar.hpp" #include "data_type/scalar.hpp"
#include "NN/CellList/CellDecomposer.hpp"
/*! \brief Finite Differences /*! \brief Finite Differences
* *
...@@ -73,6 +74,15 @@ ...@@ -73,6 +74,15 @@
template<typename Sys_eqs> template<typename Sys_eqs>
class FDScheme class FDScheme
{ {
public:
// Distributed grid map
typedef grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition> g_map_type;
typedef Sys_eqs Sys_eqs_typ;
private:
// Padding // Padding
Padding<Sys_eqs::dims> pd; Padding<Sys_eqs::dims> pd;
...@@ -86,7 +96,8 @@ class FDScheme ...@@ -86,7 +96,8 @@ class FDScheme
// Domain Grid informations // Domain Grid informations
const grid_sm<Sys_eqs::dims,void> & gs; const grid_sm<Sys_eqs::dims,void> & gs;
typedef grid_dist_id<Sys_eqs::dims,typename Sys_eqs::stype,scalar<size_t>,typename Sys_eqs::b_grid::decomposition> g_map_type; // Get the grid spacing
typename Sys_eqs::stype spacing[Sys_eqs::dims];
// mapping grid // mapping grid
g_map_type g_map; g_map_type g_map;
...@@ -154,14 +165,14 @@ class FDScheme ...@@ -154,14 +165,14 @@ class FDScheme
for (size_t i = 0 ; i < nz_rows.size() ; i++) for (size_t i = 0 ; i < nz_rows.size() ; i++)
{ {
if (nz_rows.get(i) == false) if (nz_rows.get(i) == false)
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " Ill posed matrix not all the rows are filled\n"; std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " Ill posed matrix row " << i << " is not filled\n";
} }
// all the colums must have a non zero element // all the colums must have a non zero element
for (size_t i = 0 ; i < nz_cols.size() ; i++) for (size_t i = 0 ; i < nz_cols.size() ; i++)
{ {
if (nz_cols.get(i) == false) if (nz_cols.get(i) == false)
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " Ill posed matrix not all the colums are filled\n"; std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " Ill posed matrix colum " << i << " is not filled\n";
} }
} }
...@@ -177,6 +188,26 @@ class FDScheme ...@@ -177,6 +188,26 @@ class FDScheme
public: public:
/*! \brief Get the grid padding
*
* \return the grid padding
*
*/
const Padding<Sys_eqs::dims> & getPadding()
{
return pd;
}
/*! \brief Return the map between the grid index position and the position in the distributed vector
*
* \return the map
*
*/
const g_map_type & getMap()
{
return g_map;
}
/*! \brief Constructor /*! \brief Constructor
* *
* \param pd Padding * \param pd Padding
...@@ -219,27 +250,69 @@ public: ...@@ -219,27 +250,69 @@ public:
// sync the ghost // sync the ghost
g_map.template ghost_get<0>(); g_map.template ghost_get<0>();
// Create a CellDecomposer and calculate the spacing
size_t sz_g[Sys_eqs::dims];
for (size_t i = 0 ; i < Sys_eqs::dims ; i++)
sz_g[i] = gs.getSize()[i] - 1;
CellDecomposer_sm<Sys_eqs::dims,typename Sys_eqs::stype> cd(domain,sz_g,0);
for (size_t i = 0 ; i < Sys_eqs::dims ; i++)
spacing[i] = cd.getCellBox().getHigh(i);
} }
/*! \brief Impose an operator /*! \brief Impose an operator
* *
* This function impose an operator on a box region to produce the system
*
* Ax = b
*
* ## Stokes equation, lid driven cavity with one splipping wall
* *
* \param op Operator to impose (A term)
* \param num right hand side of the term (b term)
* \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
* *
*/ */
template<typename T> void imposeA(const T & op , grid_dist_iterator_sub<Sys_eqs::dims,typename Sys_eqs::b_grid::d_grid> it_d, 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)
{ {
// key one
grid_key_dx<Sys_eqs::dims> gk_one;
gk_one.one();
// add padding to start and stop // add padding to start and stop
grid_key_dx<Sys_eqs::dims> start = it_d.getStart() + pd.getKP1(); grid_key_dx<Sys_eqs::dims> start_k = grid_key_dx<Sys_eqs::dims>(start) + pd.getKP1();
grid_key_dx<Sys_eqs::dims> stop = it_d.getStop() + pd.getKP1(); grid_key_dx<Sys_eqs::dims> stop_k = grid_key_dx<Sys_eqs::dims>(stop) + pd.getKP1();
auto it = g_map.getSubDomainIterator(start,stop); auto it = g_map.getSubDomainIterator(start_k,stop_k);
impose(op,num,id,it,skip_first);
}
/*! \brief Impose an operator
*
* This function impose an operator on a particular grid region to produce the system
*
* Ax = b
*
* ## Stokes equation, lid driven cavity with one splipping wall
*
* \param op Operator to impose (A term)
* \param num right hand side of the term (b term)
* \param id Equation id in the system that we are imposing
* \param it_d iterator that define where you want to impose
*
*/
template<typename T> void impose(const T & op , typename Sys_eqs::stype num ,long int id ,grid_dist_iterator_sub<Sys_eqs::dims,typename g_map_type::d_grid> it_d, bool skip_first = false)
{
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,float> cols;
// resize b if needed
b.resize(Sys_eqs::nvar * gs.size());
bool is_first = skip_first; bool is_first = skip_first;
// iterate all the grid points // iterate all the grid points
...@@ -254,68 +327,29 @@ public: ...@@ -254,68 +327,29 @@ public:
// get the position // get the position
auto key = it.get(); auto key = it.get();
grid_key_dx<2> gkey = g_map.getGKey(key);
// Calculate the non-zero colums // Calculate the non-zero colums
T::value(g_map,key,gs,cols,1.0); T::value(g_map,key,gs,spacing,cols,1.0);
// create the triplet // create the triplet
for ( auto it = cols.begin(); it != cols.end(); ++it ) for ( auto it = cols.begin(); it != cols.end(); ++it )
{ {
trpl.add(); trpl.add();
trpl.last().row() = row; trpl.last().row() = Sys_eqs::nvar * gs.LinId(gkey) + id;
trpl.last().col() = it->first; trpl.last().col() = it->first;
trpl.last().value() = it->second; trpl.last().value() = it->second;
std::cout << "(" << trpl.last().row() << "," << trpl.last().col() << "," << trpl.last().value() << ")" << "\n"; std::cout << "(" << trpl.last().row() << "," << trpl.last().col() << "," << trpl.last().value() << ")" << "\n";
} }
b.get(Sys_eqs::nvar * gs.LinId(gkey) + id) = num;
cols.clear(); cols.clear();
std::cout << "\n"; std::cout << "\n";
++row; ++row;
++it;
}
}
/*! \brief Impose an operator
*
*
*
*/
void imposeB(typename Sys_eqs::stype num , grid_dist_iterator_sub<Sys_eqs::dims,typename Sys_eqs::b_grid::d_grid> it_d, bool skip_first = false)
{
// key one
grid_key_dx<Sys_eqs::dims> gk_one;
gk_one.one();
// add padding to start and stop
grid_key_dx<Sys_eqs::dims> start = it_d.getStart() + pd.getKP1();
grid_key_dx<Sys_eqs::dims> stop = it_d.getStop() + pd.getKP1();
auto it = g_map.getSubDomainIterator(start,stop);
std::unordered_map<long int,float> cols;
bool is_first = skip_first;
// iterate all the grid points
while (it.isNext())
{
if (is_first == true)
{
++it;
is_first = false;
continue;
}