8 #ifndef OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_PETSC_HPP_ 
    9 #define OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_PETSC_HPP_ 
   11 #include "Vector/map_vector.hpp" 
   12 #include "Vector/vector_def.hpp" 
   13 #include <boost/mpl/int.hpp> 
   15 #include "util/petsc_util.hpp" 
   16 #include <unordered_map> 
   32     typedef boost::fusion::vector<PetscInt,T> 
type;
 
   38     static const unsigned int row = 0;
 
   41     static const unsigned int value = 1;
 
   44     static const unsigned int max_prop = 2;
 
   53         return boost::fusion::at_c<row>(data);
 
   63         return boost::fusion::at_c<value>(data);
 
   94 constexpr 
unsigned int row_id = 0;
 
   95 constexpr 
unsigned int val_id = 1;
 
  113     mutable bool v_created = 
false;
 
  122     mutable std::unordered_map<size_t,size_t> 
map;
 
  133         if (v_created == 
false)
 
  134         {PETSC_SAFE_CALL(VecSetType(v,VECMPI));}
 
  139         if (row_val.size() != 0)
 
  140             PETSC_SAFE_CALL(VecSetValues(v,row_val.size(),&row_val.template get<row_id>(0),&row_val.template get<val_id>(0),INSERT_VALUES))
 
  142         PETSC_SAFE_CALL(VecAssemblyBegin(v));
 
  143         PETSC_SAFE_CALL(VecAssemblyEnd(v));
 
  166     :n_row(0),n_row_local(0),invalid(0)
 
  177         if (is_openfpm_init() == 
true)
 
  178         {PETSC_SAFE_CALL(VecDestroy(&v));}
 
  188     :n_row_local(n_row_local),v(NULL),invalid(0)
 
  191         PETSC_SAFE_CALL(VecCreate(PETSC_COMM_WORLD,&v));
 
  200     :n_row(0),n_row_local(0),invalid(0)
 
  203         PETSC_SAFE_CALL(VecCreate(PETSC_COMM_WORLD,&v));
 
  217         PETSC_SAFE_CALL(VecSetSizes(v,n_row_local,n_row));
 
  231         map[i] = row_val.size()-1;
 
  233         row_val.last().template get<row_id>() = i;
 
  234         row_val.last().template get<val_id>() = val;
 
  249         map[i] = row_val.size()-1;
 
  251         row_val.last().template get<row_id>() = i;
 
  252         return row_val.last().template get<val_id>();
 
  262     inline const PetscScalar & 
insert(
size_t i)
 const 
  267         map[i] = row_val.size()-1;
 
  269         row_val.last().template get<row_id>() = i;
 
  270         return row_val.last().template get<val_id>();
 
  286         std::unordered_map<size_t,size_t>::iterator it = map.find(i);
 
  288         if ( it != map.end() )
 
  289             return row_val.template get<val_id>(it->second);
 
  307         std::unordered_map<size_t,size_t>::iterator it = map.find(i);
 
  309         if ( it != map.end() )
 
  310             return row_val.template get<val_id>(it->second);
 
  345         PetscInt n_row_local;
 
  348         VecGetSize(v,&n_row);
 
  349         VecGetLocalSize(v,&n_row_local);
 
  352         this->n_row_local = n_row_local;
 
  354         row_val.resize(n_row_local);
 
  361         VecGetOwnershipRange(v,&low,&high);
 
  366         for (
size_t i = low ; i < (size_t)high ; i++)
 
  368             row_val.template get<row_id>(k) = i;
 
  373         PETSC_SAFE_CALL(VecGetValues(v,row_val.size(),&row_val.template get<row_id>(0),&row_val.template get<val_id>(0)))
 
  397         row_val.swap(v.row_val);
 
  408         if (v_created == 
false)
 
  409         {PETSC_SAFE_CALL(VecSetType(v,VECMPI));}
 
PetscScalar & operator()(size_t i)
Return a reference to the vector element. 
 
void insert(size_t i, T val)
stub insert 
 
void update()
Update the Vector with the PETSC object. 
 
size_t n_row
Number of row the petsc vector has. 
 
rval(long int i, T val)
Constructor from row, column and value. 
 
Vector(const Vector< T, PETSC_BASE > &v)
Copy the vector. 
 
std::unordered_map< size_t, size_t > map
Global to local map. 
 
static bool noPointers()
Indicate that the structure has no pointer. 
 
void insert(size_t i, T val)
Return a reference to the vector element. 
 
void resize(size_t row, size_t l_row)
Resize the Vector. 
 
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support...
 
PETSC vector for linear algebra. 
 
Vector(size_t n, size_t n_row_local)
Create a vector with n elements. 
 
Vec & getVec()
Get the PETSC Vector object. 
 
openfpm::vector< rval< PetscScalar, PETSC_RVAL >, HeapMemory, typename memory_traits_inte< rval< PetscScalar, PETSC_RVAL > >::type, memory_traits_inte > row_val
Mutable row value vector. 
 
PetscScalar & insert(size_t i)
Return a reference to the vector element. 
 
~Vector()
Destroy the vector. 
 
This class allocate, and destroy CPU memory. 
 
const PetscScalar & insert(size_t i) const 
Return a reference to the vector element. 
 
Transform the boost::fusion::vector into memory specification (memory_traits) 
 
const Vec & getVec() const 
Get the PETSC Vector object. 
 
Vector< T > & operator=(const Vector< T > &v)
stub operator= 
 
long int & rw()
Get the row. 
 
type data
structure that store the data of the point 
 
void resize(size_t row, size_t row_n)
stub resize 
 
Vector(Vector< T, PETSC_BASE > &&v)
Copy the vector. 
 
It store one row value of a vector. 
 
const PetscScalar & operator()(size_t i) const 
Return a reference to the vector element. 
 
size_t n_row_local
Number of local rows. 
 
boost::fusion::vector< PetscInt, T > type
boost fusion that store the point 
 
void setPetsc() const 
Set the Eigen internal vector. 
 
rval()
Default constructor. 
 
Vector()
Create a vector with 0 elements. 
 
Vector< T, PETSC_BASE > & operator=(const Vector< T, PETSC_BASE > &v)
Copy the vector. 
 
Implementation of 1-D std::vector like structure. 
 
Vector< T, PETSC_BASE > & operator=(Vector< T, PETSC_BASE > &&v)
Copy the vector. 
 
void setZero()
Set to zero all the entries.