libMesh
Loading...
Searching...
No Matches
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
41namespace libMesh
42{
43
44
45// forward declarations
46template <typename T> class NumericVector;
47template <typename T> class DenseVector;
48template <typename T> class DenseSubVector;
49template <typename T> class SparseMatrix;
50template <typename T> class ShellMatrix;
51enum SolverPackage : int;
52
67template <typename T>
68class NumericVector : public ReferenceCountedObject<NumericVector<T>>,
69 public ParallelObject
70{
71public:
72
76 explicit
78 const ParallelType ptype = AUTOMATIC);
79
83 explicit
85 const numeric_index_type n,
86 const ParallelType ptype = AUTOMATIC);
87
93 const numeric_index_type n,
94 const numeric_index_type n_local,
95 const ParallelType ptype = AUTOMATIC);
96
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
120
126 NumericVector (const NumericVector &) = default;
128
133 virtual ~NumericVector() = default;
134
140 static std::unique_ptr<NumericVector<T>>
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
386
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
431
440
448 NumericVector<T> & operator *= (const T a) { this->scale(a); return *this; }
449
458
466 NumericVector<T> & operator /= (const T a) { this->scale(1./a); return *this; }
467
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
861protected:
862
869
874
879
884};
885
886
887/*----------------------- Inline functions ----------------------------------*/
888
889
890
891template <typename T>
892inline
894 const ParallelType ptype) :
895 ParallelObject(comm_in),
896 _is_closed(false),
897 _is_initialized(false),
898 _type(ptype)
899{
900}
901
902
903
904template <typename T>
905inline
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
920template <typename T>
921inline
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
937template <typename T>
938inline
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
955template <typename T>
956inline
958{
959 _is_closed = false;
960 _is_initialized = false;
961}
962
963
964
965template <typename T>
966inline
967void 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
979template <typename T>
980inline
981void 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
994template <typename T>
995inline
996void 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
1006template <typename T>
1007inline
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
1018template <typename T>
1019inline
1020void 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
1030template <typename T>
1031inline
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
1042template <typename T>
1043inline
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
1057template <>
1058inline
1059void 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
1075template <typename T>
1076inline
1077void 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
1090template <>
1091inline
1092void 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
1112template <typename T>
1113inline
1114void 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
1133template <typename T>
1134inline
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
1142template <typename T>
1143auto
1145{
1146 return vec.l1_norm();
1147}
1148
1149template <typename T>
1150auto
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
1163namespace boost { namespace multiprecision { namespace detail {
1164template <typename T, typename To>
1165struct 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
void ErrorVector unsigned int
Defines a dense subvector for use in finite element computations.
virtual unsigned int size() const override final
virtual bool empty() const override final
Defines a dense vector for use in Finite Element-type computations.
virtual bool empty() const override final
virtual unsigned int size() const override final
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
Computes (summation not implied) i.e.
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.
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
virtual void init(const NumericVector< T > &other, const bool fast=false)=0
Creates a vector that has the same dimension and storage type as other, including ghost dofs.
virtual Real l1_norm() const =0
Real l1_norm_diff(const NumericVector< T > &other_vec) const
virtual numeric_index_type last_local_index() const =0
bool is_effectively_serial() const
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.
virtual void clear()
Restores the NumericVector<T> to a pristine state.
ParallelType type() const
void add_vector(const DenseVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a DenseVector and each dof_indices[i] specifies where to add value v(i).
void set_type(ParallelType t)
Allow the user to change the ParallelType of the NumericVector under some circumstances.
virtual T operator()(const numeric_index_type i) const =0
virtual NumericVector< T > & operator+=(const NumericVector< T > &v)=0
Adds v to *this, .
virtual Real max() const =0
Real l2_norm_diff(const NumericVector< T > &other_vec) const
virtual std::size_t max_allowed_id() const =0
bool is_effectively_ghosted() const
virtual void conjugate()=0
Negates the imaginary component of each entry in the vector.
virtual void localize(std::vector< T > &v_local, const std::vector< numeric_index_type > &indices) const =0
Fill in the local std::vector "v_local" with the global indices given in "indices".
virtual void print(std::ostream &os=libMesh::out) const
Prints the local contents of the vector, by default to libMesh::out.
void get(const std::vector< numeric_index_type > &index, std::vector< T > &values) const
Access multiple components at once.
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
virtual void read_matlab(const std::string &filename)
Read the contents of the vector from the Matlab-script format used by PETSc.
NumericVector(const Parallel::Communicator &comm_in, const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const ParallelType ptype=AUTOMATIC)
Constructor.
virtual void swap(NumericVector< T > &v)
Swaps the contents of this with v.
virtual T dot(const NumericVector< T > &v) const =0
virtual NumericVector< T > & operator-=(const NumericVector< T > &v)=0
Subtracts v from *this, .
void add_vector(const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a std::vector and each dof_indices[i] specifies where to add value v[i].
virtual void print_matlab(const std::string &filename="") const
Print the contents of the vector in Matlab's sparse matrix format.
ParallelType _type
Type of vector.
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 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].
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 bool initialized() const
virtual void abs()=0
Sets for each entry in the vector.
NumericVector(const NumericVector &)=default
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 void localize(const numeric_index_type first_local_idx, const numeric_index_type last_local_idx, const std::vector< numeric_index_type > &send_list)=0
Updates a local vector with selected values from neighboring processors, as defined by send_list.
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A)=0
Computes , i.e.
virtual Real l2_norm() const =0
std::mutex _numeric_vector_mutex
Mutex for performing thread-safe operations.
bool _is_initialized
true once init() has been called.
virtual void scale(const T factor)=0
Scale each element of the vector by the given factor.
virtual void add_vector(const NumericVector< T > &v, const SparseMatrix< T > &A)=0
Computes , i.e.
NumericVector(const Parallel::Communicator &comm_in, const numeric_index_type n, const ParallelType ptype=AUTOMATIC)
Constructor.
virtual void zero()=0
Set all entries to zero.
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 void print_global(std::ostream &os=libMesh::out) const
Prints the global contents of the vector, by default to libMesh::out.
virtual numeric_index_type size() const =0
virtual void localize(NumericVector< T > &v_local) const =0
Same, but fills a NumericVector<T> instead of a std::vector.
virtual std::unique_ptr< NumericVector< T > > clone() const =0
ParallelType & type()
virtual Real linfty_norm() const =0
bool _is_closed
Flag which tracks whether the vector's values are consistent on all processors after insertion or add...
NumericVector(NumericVector &&)=default
These 3 special functions can be defaulted for this class, as it does not manage any memory itself.
virtual bool closed() const
virtual void add(const T a, const NumericVector< T > &v)=0
Vector addition with a scalar multiple, .
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Create a vector that holds the local indices plus those specified in the ghost argument.
bool compatible(const NumericVector< T > &v) const
virtual void reciprocal()=0
Computes the component-wise reciprocal, .
virtual NumericVector< T > & operator=(const NumericVector< T > &v)=0
This looks like a copy assignment operator, but note that, unlike normal copy assignment operators,...
friend std::ostream & operator<<(std::ostream &os, const NumericVector< T > &v)
Same as above but allows you to use stream syntax.
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
virtual void localize(NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const =0
Creates a local vector v_local containing only information relevant to this processor,...
void insert(const DenseVector< 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 min() const =0
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.
NumericVector(const Parallel::Communicator &comm_in, const numeric_index_type n, const numeric_index_type n_local, const ParallelType ptype=AUTOMATIC)
Constructor.
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
virtual void init(const numeric_index_type n, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Call init() with n_local = N.
NumericVector< T > & operator/=(const T a)
Scales the vector by 1/a, .
virtual numeric_index_type local_size() const =0
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
virtual T sum() const =0
NumericVector< T > & operator*=(const T a)
Scales the vector by a, .
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
void insert(const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
Inserts the entries of v in *this at the locations specified by v.
virtual int compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual numeric_index_type first_local_index() const =0
void insert(const DenseSubVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
Inserts the entries of v in *this at the locations specified by v.
virtual void add(const T s)=0
Adds s to each entry of the vector, .
virtual ~NumericVector()=default
While this class doesn't manage any memory, the derived class might and users may be deleting through...
NumericVector(const Parallel::Communicator &comm_in, const ParallelType ptype=AUTOMATIC)
Dummy-Constructor.
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
Computes (summation not implied) i.e.
virtual T el(const numeric_index_type i) const
virtual void add(const NumericVector< T > &v)=0
Adds v to this, .
virtual int local_relative_compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual int global_relative_compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
An object whose state is distributed along a set of processors.
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
This class implements reference counting.
Generic shell matrix, i.e.
Generic sparse matrix.
The libMesh namespace provides an interface to certain functionality in the library.
auto l1_norm(const NumericVector< T > &vec)
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
ParallelType
Defines an enum for parallel data structure types.
SolverPackage default_solver_package()
Definition libmesh.C:1064
libmesh_assert(ctx)
OStreamProxy out
dof_id_type numeric_index_type
Definition id_types.h:99
SolverPackage
Defines an enum for various linear solver packages.
bool initialized()
Checks that library initialization has been done.
Definition libmesh.C:324
static constexpr Real TOLERANCE
auto l1_norm_diff(const NumericVector< T > &vec1, const NumericVector< T > &vec2)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
Definition id_types.h:104
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 const bool value
Definition xdr_io.C:55