libMesh
numeric_vector.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_NUMERIC_VECTOR_H
21 #define LIBMESH_NUMERIC_VECTOR_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/enum_parallel_type.h" // AUTOMATIC
26 #include "libmesh/id_types.h"
27 #include "libmesh/int_range.h"
28 #include "libmesh/reference_counted_object.h"
29 #include "libmesh/libmesh.h"
30 #include "libmesh/parallel_object.h"
31 #include "libmesh/dense_subvector.h"
32 #include "libmesh/dense_vector.h"
33 
34 // C++ includes
35 #include <cstddef>
36 #include <set>
37 #include <vector>
38 #include <memory>
39 #include <mutex>
40 
41 namespace libMesh
42 {
43 
44 
45 // forward declarations
46 template <typename T> class NumericVector;
47 template <typename T> class DenseVector;
48 template <typename T> class DenseSubVector;
49 template <typename T> class SparseMatrix;
50 template <typename T> class ShellMatrix;
51 enum SolverPackage : int;
52 
67 template <typename T>
68 class NumericVector : public ReferenceCountedObject<NumericVector<T>>,
69  public ParallelObject
70 {
71 public:
72 
76  explicit
77  NumericVector (const Parallel::Communicator & comm_in,
78  const ParallelType ptype = AUTOMATIC);
79 
83  explicit
84  NumericVector (const Parallel::Communicator & comm_in,
85  const numeric_index_type n,
86  const ParallelType ptype = AUTOMATIC);
87 
92  NumericVector (const Parallel::Communicator & comm_in,
93  const numeric_index_type n,
94  const numeric_index_type n_local,
95  const ParallelType ptype = AUTOMATIC);
96 
102  NumericVector (const Parallel::Communicator & comm_in,
103  const numeric_index_type N,
104  const numeric_index_type n_local,
105  const std::vector<numeric_index_type> & ghost,
106  const ParallelType ptype = AUTOMATIC);
107 
119  virtual NumericVector<T> & operator= (const NumericVector<T> & v) = 0;
120 
125  NumericVector (NumericVector &&) = default;
126  NumericVector (const NumericVector &) = default;
127  NumericVector & operator= (NumericVector &&) = default;
128 
133  virtual ~NumericVector() = default;
134 
140  static std::unique_ptr<NumericVector<T>>
141  build(const Parallel::Communicator & comm,
143  ParallelType parallel_type = AUTOMATIC);
144 
149  virtual bool initialized() const { return _is_initialized; }
150 
158  ParallelType type() const { return _type; }
159 
169  { return (this->n_processors()==1) || (_type == SERIAL); }
170 
182  { return (this->n_processors()!=1) && (_type == GHOSTED); }
183 
191 #ifdef LIBMESH_ENABLE_DEPRECATED
192  ParallelType & type() { return _type; }
193 #endif
194 
204  void set_type(ParallelType t);
205 
210  virtual bool closed() const { return _is_closed; }
211 
216  virtual void close () = 0;
217 
221  virtual void clear ();
222 
227  virtual void zero () = 0;
228 
235  virtual std::unique_ptr<NumericVector<T>> zero_clone () const = 0;
236 
242  virtual std::unique_ptr<NumericVector<T>> clone () const = 0;
243 
254  virtual void init (const numeric_index_type n,
255  const numeric_index_type n_local,
256  const bool fast = false,
257  const ParallelType ptype = AUTOMATIC) = 0;
258 
262  virtual void init (const numeric_index_type n,
263  const bool fast = false,
264  const ParallelType ptype = AUTOMATIC) = 0;
265 
270  virtual void init (const numeric_index_type n,
271  const numeric_index_type n_local,
272  const std::vector<numeric_index_type> & ghost,
273  const bool fast = false,
274  const ParallelType ptype = AUTOMATIC) = 0;
275 
280  virtual void init (const NumericVector<T> & other,
281  const bool fast = false) = 0;
282 
288  virtual NumericVector<T> & operator= (const T s) = 0;
289 
295  virtual NumericVector<T> & operator= (const std::vector<T> & v) = 0;
296 
301  virtual Real min () const = 0;
302 
307  virtual Real max () const = 0;
308 
312  virtual T sum() const = 0;
313 
318  virtual Real l1_norm () const = 0;
319 
324  virtual Real l2_norm () const = 0;
325 
330  virtual Real linfty_norm () const = 0;
331 
338  virtual Real subset_l1_norm (const std::set<numeric_index_type> & indices) const;
339 
347  virtual Real subset_l2_norm (const std::set<numeric_index_type> & indices) const;
348 
355  virtual Real subset_linfty_norm (const std::set<numeric_index_type> & indices) const;
356 
361  Real l2_norm_diff (const NumericVector<T> & other_vec) const;
362 
367  Real l1_norm_diff (const NumericVector<T> & other_vec) const;
368 
372  virtual numeric_index_type size () const = 0;
373 
377  virtual numeric_index_type local_size() const = 0;
378 
385  virtual numeric_index_type first_local_index() const = 0;
386 
393  virtual numeric_index_type last_local_index() const = 0;
394 
398  virtual T operator() (const numeric_index_type i) const = 0;
399 
403  virtual T el(const numeric_index_type i) const { return (*this)(i); }
404 
411  virtual void get(const std::vector<numeric_index_type> & index,
412  T * values) const;
413 
420  void get(const std::vector<numeric_index_type> & index,
421  std::vector<T> & values) const;
422 
430  virtual NumericVector<T> & operator += (const NumericVector<T> & v) = 0;
431 
439  virtual NumericVector<T> & operator -= (const NumericVector<T> & v) = 0;
440 
448  NumericVector<T> & operator *= (const T a) { this->scale(a); return *this; }
449 
457  virtual NumericVector<T> & operator *= (const NumericVector<T> & v) = 0;
458 
466  NumericVector<T> & operator /= (const T a) { this->scale(1./a); return *this; }
467 
474  virtual NumericVector<T> & operator /= (const NumericVector<T> & v) = 0;
475 
480  virtual void reciprocal() = 0;
481 
485  virtual void conjugate() = 0;
486 
491  virtual void set (const numeric_index_type i, const T value) = 0;
492 
497  virtual void add (const numeric_index_type i, const T value) = 0;
498 
503  virtual void add (const T s) = 0;
504 
510  virtual void add (const NumericVector<T> & v) = 0;
511 
517  virtual void add (const T a, const NumericVector<T> & v) = 0;
518 
526  virtual void add_vector (const T * v,
527  const std::vector<numeric_index_type> & dof_indices);
528 
535  void add_vector (const std::vector<T> & v,
536  const std::vector<numeric_index_type> & dof_indices);
537 
544  void add_vector (const NumericVector<T> & v,
545  const std::vector<numeric_index_type> & dof_indices);
546 
553  void add_vector (const DenseVector<T> & v,
554  const std::vector<numeric_index_type> & dof_indices);
555 
561  virtual void add_vector (const NumericVector<T> & v,
562  const SparseMatrix<T> & A) = 0;
563 
569  void add_vector (const NumericVector<T> & v,
570  const ShellMatrix<T> & A);
571 
577  virtual void add_vector_transpose (const NumericVector<T> & v,
578  const SparseMatrix<T> & A) = 0;
579 
584  virtual void insert (const T * v,
585  const std::vector<numeric_index_type> & dof_indices);
586 
591  void insert (const std::vector<T> & v,
592  const std::vector<numeric_index_type> & dof_indices);
593 
598  void insert (const NumericVector<T> & v,
599  const std::vector<numeric_index_type> & dof_indices);
600 
605  void insert (const DenseVector<T> & v,
606  const std::vector<numeric_index_type> & dof_indices);
607 
612  void insert (const DenseSubVector<T> & v,
613  const std::vector<numeric_index_type> & dof_indices);
614 
618  virtual void scale (const T factor) = 0;
619 
623  virtual void abs() = 0;
624 
631  virtual T dot(const NumericVector<T> & v) const = 0;
632 
637  virtual void localize (std::vector<T> & v_local) const = 0;
638 
643  virtual void localize (NumericVector<T> & v_local) const = 0;
644 
649  virtual void localize (NumericVector<T> & v_local,
650  const std::vector<numeric_index_type> & send_list) const = 0;
651 
681  virtual void localize (std::vector<T> & v_local,
682  const std::vector<numeric_index_type> & indices) const = 0;
683 
688  virtual void localize (const numeric_index_type first_local_idx,
689  const numeric_index_type last_local_idx,
690  const std::vector<numeric_index_type> & send_list) = 0;
691 
697  virtual void localize_to_one (std::vector<T> & v_local,
698  const processor_id_type proc_id=0) const = 0;
699 
705  virtual int compare (const NumericVector<T> & other_vector,
706  const Real threshold = TOLERANCE) const;
707 
713  virtual int local_relative_compare (const NumericVector<T> & other_vector,
714  const Real threshold = TOLERANCE) const;
715 
721  virtual int global_relative_compare (const NumericVector<T> & other_vector,
722  const Real threshold = TOLERANCE) const;
723 
729  virtual void pointwise_mult (const NumericVector<T> & vec1,
730  const NumericVector<T> & vec2) = 0;
731 
737  virtual void pointwise_divide (const NumericVector<T> & vec1,
738  const NumericVector<T> & vec2) = 0;
739 
744  virtual void print(std::ostream & os=libMesh::out) const;
745 
750  virtual void print_global(std::ostream & os=libMesh::out) const;
751 
755  friend std::ostream & operator << (std::ostream & os, const NumericVector<T> & v)
756  {
757  v.print_global(os);
758  return os;
759  }
760 
766  virtual void print_matlab(const std::string & filename = "") const;
767 
779  virtual void read_matlab(const std::string & filename);
780 
794  virtual void create_subvector(NumericVector<T> & /* subvector */,
795  const std::vector<numeric_index_type> & /* rows */,
796  bool /* supplying_global_rows */ = true) const
797  {
798  libmesh_not_implemented();
799  }
800 
809  virtual std::unique_ptr<NumericVector<T>>
810  get_subvector(const std::vector<numeric_index_type> & /* rows */)
811  {
812  libmesh_not_implemented();
813  }
814 
823  virtual void restore_subvector(std::unique_ptr<NumericVector<T>> /* subvector */,
824  const std::vector<numeric_index_type> & /* rows */)
825  {
826  libmesh_not_implemented();
827  }
828 
834  virtual void swap (NumericVector<T> & v);
835 
847  virtual std::size_t max_allowed_id() const = 0;
848 
853  bool readable() const;
854 
859  bool compatible(const NumericVector<T> & v) const;
860 
861 protected:
862 
869 
874 
879 
884 };
885 
886 
887 /*----------------------- Inline functions ----------------------------------*/
888 
889 
890 
891 template <typename T>
892 inline
894  const ParallelType ptype) :
895  ParallelObject(comm_in),
896  _is_closed(false),
897  _is_initialized(false),
898  _type(ptype)
899 {
900 }
901 
902 
903 
904 template <typename T>
905 inline
907  const numeric_index_type /*n*/,
908  const ParallelType ptype) :
909  ParallelObject(comm_in),
910  _is_closed(false),
911  _is_initialized(false),
912  _type(ptype)
913 {
914  libmesh_not_implemented(); // Abstract base class!
915  // init(n, n, false, ptype);
916 }
917 
918 
919 
920 template <typename T>
921 inline
923  const numeric_index_type /*n*/,
924  const numeric_index_type /*n_local*/,
925  const ParallelType ptype) :
926  ParallelObject(comm_in),
927  _is_closed(false),
928  _is_initialized(false),
929  _type(ptype)
930 {
931  libmesh_not_implemented(); // Abstract base class!
932  // init(n, n_local, false, ptype);
933 }
934 
935 
936 
937 template <typename T>
938 inline
940  const numeric_index_type /*n*/,
941  const numeric_index_type /*n_local*/,
942  const std::vector<numeric_index_type> & /*ghost*/,
943  const ParallelType ptype) :
944  ParallelObject(comm_in),
945  _is_closed(false),
946  _is_initialized(false),
947  _type(ptype)
948 {
949  libmesh_not_implemented(); // Abstract base class!
950  // init(n, n_local, ghost, false, ptype);
951 }
952 
953 
954 
955 template <typename T>
956 inline
958 {
959  _is_closed = false;
960  _is_initialized = false;
961 }
962 
963 
964 
965 template <typename T>
966 inline
967 void NumericVector<T>::get(const std::vector<numeric_index_type> & index,
968  T * values) const
969 {
970  const std::size_t num = index.size();
971  for (std::size_t i=0; i<num; i++)
972  {
973  values[i] = (*this)(index[i]);
974  }
975 }
976 
977 
978 
979 template <typename T>
980 inline
981 void NumericVector<T>::get(const std::vector<numeric_index_type> & index,
982  std::vector<T> & values) const
983 {
984  const std::size_t num = index.size();
985  values.resize(num);
986  if (!num)
987  return;
988 
989  this->get(index, values.data());
990 }
991 
992 
993 
994 template <typename T>
995 inline
996 void NumericVector<T>::add_vector(const std::vector<T> & v,
997  const std::vector<numeric_index_type> & dof_indices)
998 {
999  libmesh_assert(v.size() == dof_indices.size());
1000  if (!v.empty())
1001  this->add_vector(v.data(), dof_indices);
1002 }
1003 
1004 
1005 
1006 template <typename T>
1007 inline
1009  const std::vector<numeric_index_type> & dof_indices)
1010 {
1011  libmesh_assert(v.size() == dof_indices.size());
1012  if (!v.empty())
1013  this->add_vector(&v(0), dof_indices);
1014 }
1015 
1016 
1017 
1018 template <typename T>
1019 inline
1020 void NumericVector<T>::insert(const std::vector<T> & v,
1021  const std::vector<numeric_index_type> & dof_indices)
1022 {
1023  libmesh_assert(v.size() == dof_indices.size());
1024  if (!v.empty())
1025  this->insert(v.data(), dof_indices);
1026 }
1027 
1028 
1029 
1030 template <typename T>
1031 inline
1033  const std::vector<numeric_index_type> & dof_indices)
1034 {
1035  libmesh_assert(v.size() == dof_indices.size());
1036  if (!v.empty())
1037  this->insert(&v(0), dof_indices);
1038 }
1039 
1040 
1041 
1042 template <typename T>
1043 inline
1045  const std::vector<numeric_index_type> & dof_indices)
1046 {
1047  libmesh_assert(v.size() == dof_indices.size());
1048  if (!v.empty())
1049  this->insert(&v(0), dof_indices);
1050 }
1051 
1052 
1053 
1054 // Full specialization of the print() member for complex
1055 // variables. This must precede the non-specialized
1056 // version, at least according to icc v7.1
1057 template <>
1058 inline
1059 void NumericVector<Complex>::print(std::ostream & os) const
1060 {
1061  libmesh_assert (this->initialized());
1062  os << "Size\tglobal = " << this->size()
1063  << "\t\tlocal = " << this->local_size() << std::endl;
1064 
1065  // std::complex<>::operator<<() is defined, but use this form
1066  os << "#\tReal part\t\tImaginary part" << std::endl;
1067  for (auto i : index_range(*this))
1068  os << i << "\t"
1069  << (*this)(i).real() << "\t\t"
1070  << (*this)(i).imag() << std::endl;
1071 }
1072 
1073 
1074 
1075 template <typename T>
1076 inline
1077 void NumericVector<T>::print(std::ostream & os) const
1078 {
1079  libmesh_assert (this->initialized());
1080  os << "Size\tglobal = " << this->size()
1081  << "\t\tlocal = " << this->local_size() << std::endl;
1082 
1083  os << "#\tValue" << std::endl;
1084  for (auto i : index_range(*this))
1085  os << i << "\t" << (*this)(i) << std::endl;
1086 }
1087 
1088 
1089 
1090 template <>
1091 inline
1092 void NumericVector<Complex>::print_global(std::ostream & os) const
1093 {
1094  libmesh_assert (this->initialized());
1095 
1096  std::vector<Complex> v(this->size());
1097  this->localize(v);
1098 
1099  // Right now we only want one copy of the output
1100  if (this->processor_id())
1101  return;
1102 
1103  os << "Size\tglobal = " << this->size() << std::endl;
1104  os << "#\tReal part\t\tImaginary part" << std::endl;
1105  for (auto i : make_range(v.size()))
1106  os << i << "\t"
1107  << v[i].real() << "\t\t"
1108  << v[i].imag() << std::endl;
1109 }
1110 
1111 
1112 template <typename T>
1113 inline
1114 void NumericVector<T>::print_global(std::ostream & os) const
1115 {
1116  libmesh_assert (this->initialized());
1117 
1118  std::vector<T> v(this->size());
1119  this->localize(v);
1120 
1121  // Right now we only want one copy of the output
1122  if (this->processor_id())
1123  return;
1124 
1125  os << "Size\tglobal = " << this->size() << std::endl;
1126  os << "#\tValue" << std::endl;
1127  for (auto i : make_range(v.size()))
1128  os << i << "\t" << v[i] << std::endl;
1129 }
1130 
1131 
1132 
1133 template <typename T>
1134 inline
1136 {
1137  std::swap(_is_closed, v._is_closed);
1138  std::swap(_is_initialized, v._is_initialized);
1139  std::swap(_type, v._type);
1140 }
1141 
1142 template <typename T>
1143 auto
1145 {
1146  return vec.l1_norm();
1147 }
1148 
1149 template <typename T>
1150 auto
1152 {
1153  return vec1.l1_norm_diff(vec2);
1154 }
1155 
1156 } // namespace libMesh
1157 
1158 
1159 // Workaround for weird boost/NumericVector interaction bug
1160 #ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
1161 #include <boost/mpl/bool.hpp>
1162 
1163 namespace boost { namespace multiprecision { namespace detail {
1164 template <typename T, typename To>
1165 struct is_lossy_conversion<libMesh::NumericVector<T>, To> {
1166  typedef boost::mpl::true_ type;
1167  static const bool value = type::value;
1168 };
1169 }}}
1170 #endif
1171 
1172 
1173 #endif // LIBMESH_NUMERIC_VECTOR_H
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
Inserts the entries of v in *this at the locations specified by v.
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
std::mutex _numeric_vector_mutex
Mutex for performing thread-safe operations.
virtual void print_global(std::ostream &os=libMesh::out) const
Prints the global contents of the vector, by default to libMesh::out.
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
virtual T el(const numeric_index_type i) const
static constexpr Real TOLERANCE
virtual T sum() const =0
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A)=0
Computes , i.e.
virtual bool initialized() const
virtual numeric_index_type size() const =0
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
virtual unsigned int size() const override final
virtual NumericVector< T > & operator=(const NumericVector< T > &v)=0
This looks like a copy assignment operator, but note that, unlike normal copy assignment operators...
ParallelType & type()
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
Definition: vector_fe_ex5.C:44
const Parallel::Communicator & comm() const
virtual std::unique_ptr< NumericVector< T > > clone() const =0
bool is_effectively_ghosted() const
bool _is_initialized
true once init() has been called.
The libMesh namespace provides an interface to certain functionality in the library.
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
virtual T dot(const NumericVector< T > &v) const =0
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Change the dimension of the vector to n.
virtual bool empty() const override final
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
uint8_t processor_id_type
Definition: id_types.h:104
virtual void zero()=0
Set all entries to zero.
Defines a dense subvector for use in finite element computations.
virtual void create_subvector(NumericVector< T > &, const std::vector< numeric_index_type > &, bool=true) const
Fills in subvector from this vector using the indices in rows.
Real l2_norm_diff(const NumericVector< T > &other_vec) const
Generic sparse matrix.
Definition: vector_fe_ex5.C:46
SolverPackage default_solver_package()
Definition: libmesh.C:1064
virtual void scale(const T factor)=0
Scale each element of the vector by the given factor.
processor_id_type n_processors() const
bool is_effectively_serial() const
virtual void localize_to_one(std::vector< T > &v_local, const processor_id_type proc_id=0) const =0
Creates a local copy of the global vector in v_local only on processor proc_id.
virtual Real l2_norm() const =0
virtual NumericVector< T > & operator+=(const NumericVector< T > &v)=0
Adds v to *this, .
virtual ~NumericVector()=default
While this class doesn&#39;t manage any memory, the derived class might and users may be deleting through...
auto l1_norm(const NumericVector< T > &vec)
dof_id_type numeric_index_type
Definition: id_types.h:99
bool _is_initialized
Flag that tells if init() has been called.
Definition: libmesh.C:305
NumericVector(const Parallel::Communicator &comm_in, const ParallelType ptype=AUTOMATIC)
Dummy-Constructor.
NumericVector< T > & operator/=(const T a)
Scales the vector by 1/a, .
auto l1_norm_diff(const NumericVector< T > &vec1, const NumericVector< T > &vec2)
NumericVector< T > & operator*=(const T a)
Scales the vector by a, .
virtual bool empty() const override final
Definition: dense_vector.h:109
libmesh_assert(ctx)
virtual void read_matlab(const std::string &filename)
Read the contents of the vector from the Matlab-script format used by PETSc.
bool compatible(const NumericVector< T > &v) const
virtual int global_relative_compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual void print(std::ostream &os=libMesh::out) const
Prints the local contents of the vector, by default to libMesh::out.
virtual Real max() const =0
virtual Real min() const =0
virtual std::unique_ptr< NumericVector< T > > get_subvector(const std::vector< numeric_index_type > &)
Creates a view into this vector using the indices in rows.
An object whose state is distributed along a set of processors.
virtual Real l1_norm() const =0
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
ParallelType _type
Type of vector.
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
Computes (summation not implied) i.e.
virtual bool closed() const
Real l1_norm_diff(const NumericVector< T > &other_vec) const
virtual void abs()=0
Sets for each entry in the vector.
virtual numeric_index_type first_local_index() const =0
ParallelType type() const
virtual int local_relative_compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual void print_matlab(const std::string &filename="") const
Print the contents of the vector in Matlab&#39;s sparse matrix format.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual NumericVector< T > & operator-=(const NumericVector< T > &v)=0
Subtracts v from *this, .
virtual void swap(NumericVector< T > &v)
Swaps the contents of this with v.
virtual int compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
OStreamProxy out
virtual numeric_index_type local_size() const =0
virtual std::size_t max_allowed_id() const =0
static const bool value
Definition: xdr_io.C:55
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
virtual unsigned int size() const override final
Definition: dense_vector.h:104
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:324
virtual void clear()
Restores the NumericVector<T> to a pristine state.
Defines a dense vector for use in Finite Element-type computations.
Definition: dof_map.h:74
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
virtual void reciprocal()=0
Computes the component-wise reciprocal, .
SolverPackage
Defines an enum for various linear solver packages.
Generic shell matrix, i.e.
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
virtual T operator()(const numeric_index_type i) const =0
virtual numeric_index_type last_local_index() const =0
virtual Real linfty_norm() const =0
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153
void set_type(ParallelType t)
Allow the user to change the ParallelType of the NumericVector under some circumstances.
const Elem & get(const ElemType type_in)
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
Computes (summation not implied) i.e.
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...
virtual void conjugate()=0
Negates the imaginary component of each entry in the vector.
ParallelType
Defines an enum for parallel data structure types.
virtual void restore_subvector(std::unique_ptr< NumericVector< T >>, const std::vector< numeric_index_type > &)
Restores a view into this vector using the indices in rows.
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.