25 #ifndef __DOLFIN_PETSC_VECTOR_H 26 #define __DOLFIN_PETSC_VECTOR_H 34 #include <unordered_map> 40 #include <dolfin/log/log.h> 41 #include <dolfin/common/types.h> 42 #include "GenericVector.h" 43 #include "PETScObject.h" 48 class SparsityPattern;
49 template<
typename T>
class Array;
93 virtual void apply(std::string mode);
99 virtual std::string
str(
bool verbose)
const;
104 virtual std::shared_ptr<GenericVector>
copy()
const;
107 virtual void init(std::size_t N);
110 virtual void init(std::pair<std::size_t, std::size_t> range);
114 virtual void init(std::pair<std::size_t, std::size_t> range,
115 const std::vector<std::size_t>& local_to_global_map,
116 const std::vector<la_index>& ghost_indices);
122 virtual bool empty()
const;
125 virtual std::size_t
size()
const;
131 virtual std::pair<std::int64_t, std::int64_t>
local_range()
const;
138 virtual void get(
double* block, std::size_t m,
142 virtual void get_local(
double* block, std::size_t m,
146 virtual void set(
const double* block, std::size_t m,
150 virtual void set_local(
const double* block, std::size_t m,
154 virtual void add(
const double* block, std::size_t m,
158 virtual void add_local(
const double* block, std::size_t m,
162 virtual void get_local(std::vector<double>& values)
const;
165 virtual void set_local(
const std::vector<double>& values);
175 const std::vector<dolfin::la_index>& indices)
const;
179 virtual void gather(std::vector<double>& x,
180 const std::vector<dolfin::la_index>& indices)
const;
196 virtual double norm(std::string norm_type)
const;
199 virtual double min()
const;
202 virtual double max()
const;
205 virtual double sum()
const;
272 void _init(std::pair<std::size_t, std::size_t> range,
273 const std::vector<std::size_t>& local_to_global_map,
274 const std::vector<la_index>& ghost_indices);
280 static const std::map<std::string, NormType> norm_types;
Definition: PETScVector.h:60
virtual void init(const TensorLayout &tensor_layout)
Definition: GenericVector.h:58
virtual void gather(GenericVector &y, const std::vector< dolfin::la_index > &indices) const
Definition: PETScVector.cpp:699
virtual std::size_t size() const
Return size of vector.
Definition: PETScVector.cpp:317
void set_from_options()
Definition: PETScVector.cpp:847
virtual void axpy(double a, const GenericVector &x)
Add multiple of given vector (AXPY operation)
Definition: PETScVector.cpp:532
virtual double sum() const
Return sum of values of vector.
Definition: PETScVector.cpp:599
virtual MPI_Comm mpi_comm() const
Return MPI communicator.
Definition: PETScVector.cpp:294
Definition: SparsityPattern.h:45
virtual void abs()
Replace all entries in the vector by their absolute values.
Definition: PETScVector.cpp:552
virtual const GenericVector & operator=(const GenericVector &x)
Assignment operator.
Definition: PETScVector.cpp:375
PETScVector()
Create empty vector (on MPI_COMM_WORLD)
Definition: PETScVector.cpp:48
virtual GenericLinearAlgebraFactory & factory() const
Return linear algebra backend factory.
Definition: PETScVector.cpp:813
virtual double min() const
Return minimum value of vector.
Definition: PETScVector.cpp:579
virtual double inner(const GenericVector &v) const
Return inner product with given vector.
Definition: PETScVector.cpp:521
virtual void zero()
Set all entries to zero and keep any sparse structure.
Definition: PETScVector.cpp:303
virtual const PETScVector & operator*=(double a)
Multiply vector by given number.
Definition: PETScVector.cpp:479
virtual void add(const double *block, std::size_t m, const dolfin::la_index *rows)
Add block of values using global indices.
Definition: PETScVector.cpp:264
virtual const PETScVector & operator+=(const GenericVector &x)
Add given vector.
Definition: PETScVector.cpp:448
virtual void add_local(const double *block, std::size_t m, const dolfin::la_index *rows)
Add block of values using local indices.
Definition: PETScVector.cpp:272
Base class for LinearAlgebra factories.
Definition: GenericLinearAlgebraFactory.h:46
virtual std::pair< std::int64_t, std::int64_t > local_range() const
Return ownership range of a vector.
Definition: PETScVector.cpp:357
void reset(Vec vec)
Definition: PETScVector.cpp:865
void set_options_prefix(std::string options_prefix)
Definition: PETScVector.cpp:818
virtual std::shared_ptr< GenericVector > copy() const
Return copy of vector.
Definition: PETScVector.cpp:101
virtual const PETScVector & operator-=(const GenericVector &x)
Subtract given vector.
Definition: PETScVector.cpp:466
virtual void get_local(double *block, std::size_t m, const dolfin::la_index *rows) const
Get block of values using local indices.
Definition: PETScVector.cpp:196
Vec vec() const
Return pointer to PETSc Vec object.
Definition: PETScVector.cpp:860
virtual std::size_t local_size() const
Return local size of vector.
Definition: PETScVector.cpp:338
virtual ~PETScVector()
Destructor.
Definition: PETScVector.cpp:95
PetscInt la_index
Index type for compatibility with linear algebra backend(s)
Definition: types.h:32
virtual double max() const
Return maximum value of vector.
Definition: PETScVector.cpp:589
Definition: PETScObject.h:33
virtual void update_ghost_values()
Update values shared from remote processes.
Definition: PETScVector.cpp:425
virtual std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: PETScVector.cpp:661
virtual void set_local(const double *block, std::size_t m, const dolfin::la_index *rows)
Set block of values using local indices.
Definition: PETScVector.cpp:256
virtual void apply(std::string mode)
Finalize assembly of tensor.
Definition: PETScVector.cpp:280
virtual void gather_on_zero(std::vector< double > &x) const
Definition: PETScVector.cpp:784
virtual bool owns_index(std::size_t i) const
Determine whether global vector index is owned by this process.
Definition: PETScVector.cpp:368
virtual bool empty() const
Return true if vector is empty.
Definition: PETScVector.cpp:312
This class defines a common interface for vectors.
Definition: GenericVector.h:47
virtual double norm(std::string norm_type) const
Return norm of vector.
Definition: PETScVector.cpp:562
virtual void init(std::size_t N)
Initialize vector to global size N.
Definition: PETScVector.cpp:106
std::string get_options_prefix() const
Definition: PETScVector.cpp:832
virtual const PETScVector & operator/=(double a)
Divide vector by given number.
Definition: PETScVector.cpp:512