18 #include "libmesh/petsc_vector.h" 20 #ifdef LIBMESH_HAVE_PETSC 23 #include "libmesh/petsc_matrix_base.h" 24 #include "libmesh/dense_subvector.h" 25 #include "libmesh/dense_vector.h" 26 #include "libmesh/int_range.h" 27 #include "libmesh/petsc_macro.h" 28 #include "libmesh/wrapped_petsc.h" 46 this->_restore_array();
51 LibmeshPetscCall(VecSum (_vec, &
value));
53 return static_cast<T
>(
value);
62 parallel_object_only();
64 this->_restore_array();
69 LibmeshPetscCall(VecNorm (_vec, N, &
value));
95 parallel_object_only();
97 this->_restore_array();
107 template <
typename T>
111 parallel_object_only();
113 this->_restore_array();
123 template <
typename T>
126 this->_restore_array();
127 libmesh_assert_less (i, size());
129 PetscInt i_val =
static_cast<PetscInt
>(i);
130 PetscScalar petsc_value =
PS(
value);
132 std::scoped_lock lock(this->_numeric_vector_mutex);
133 LibmeshPetscCall(VecSetValues (_vec, 1, &i_val, &petsc_value, INSERT_VALUES));
135 this->_is_closed =
false;
140 template <
typename T>
143 parallel_object_only();
147 LibmeshPetscCall(VecReciprocal(_vec));
152 template <
typename T>
155 parallel_object_only();
159 LibmeshPetscCall(VecConjugate(_vec));
164 template <
typename T>
167 this->_restore_array();
168 libmesh_assert_less (i, size());
170 PetscInt i_val =
static_cast<PetscInt
>(i);
171 PetscScalar petsc_value =
PS(
value);
173 std::scoped_lock lock(this->_numeric_vector_mutex);
174 LibmeshPetscCall(VecSetValues (_vec, 1, &i_val, &petsc_value, ADD_VALUES));
176 this->_is_closed =
false;
181 template <
typename T>
183 const std::vector<numeric_index_type> & dof_indices)
186 if (dof_indices.empty())
189 this->_restore_array();
191 const PetscInt * i_val =
reinterpret_cast<const PetscInt *
>(dof_indices.data());
192 const PetscScalar * petsc_value =
pPS(v);
194 std::scoped_lock lock(this->_numeric_vector_mutex);
195 LibmeshPetscCall(VecSetValues (_vec, cast_int<PetscInt>(dof_indices.size()),
196 i_val, petsc_value, ADD_VALUES));
198 this->_is_closed =
false;
203 template <
typename T>
207 parallel_object_only();
209 this->_restore_array();
211 const PetscVector<T> * v = cast_ptr<const PetscVector<T> *>(&v_in);
218 libmesh_warning(
"Matrix A must be assembled before calling PetscVector::add_vector(v, A).\n" 219 "Please update your code, as this warning will become an error in a future release.");
220 libmesh_deprecated();
231 template <
typename T>
235 parallel_object_only();
237 this->_restore_array();
239 const PetscVector<T> * v = cast_ptr<const PetscVector<T> *>(&v_in);
246 libmesh_warning(
"Matrix A must be assembled before calling PetscVector::add_vector_transpose(v, A).\n" 247 "Please update your code, as this warning will become an error in a future release.");
248 libmesh_deprecated();
259 template <
typename T>
263 parallel_object_only();
265 this->_restore_array();
267 const PetscVector<T> * v = cast_ptr<const PetscVector<T> *>(&v_in);
273 libmesh_warning(
"Matrix A must be assembled before calling PetscVector::add_vector_conjugate_transpose(v, A).\n" 274 "Please update your code, as this warning will become an error in a future release.");
275 libmesh_deprecated();
281 std::unique_ptr<NumericVector<Number>> this_clone = this->clone();
288 this->add(1., *this_clone);
293 template <
typename T>
296 this->_get_array(
false);
299 _values[i] += PetscScalar(v_in);
304 template <
typename T>
307 parallel_object_only();
314 template <
typename T>
317 parallel_object_only();
319 this->_restore_array();
328 PetscScalar a =
PS(a_in);
331 const PetscVector<T> * v = cast_ptr<const PetscVector<T> *>(&v_in);
334 libmesh_assert_equal_to (this->size(), v->
size());
336 LibmeshPetscCall(VecAXPY(_vec, a, v->
vec()));
341 VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
343 this->_is_closed =
true;
348 template <
typename T>
350 const std::vector<numeric_index_type> & dof_indices)
352 if (dof_indices.empty())
355 this->_restore_array();
358 std::scoped_lock lock(this->_numeric_vector_mutex);
359 LibmeshPetscCall(VecSetValues (_vec, cast_int<PetscInt>(dof_indices.size()),
360 idx_values,
pPS(v), INSERT_VALUES));
362 this->_is_closed =
false;
367 template <
typename T>
370 parallel_object_only();
372 this->_restore_array();
374 PetscScalar factor =
PS(factor_in);
376 LibmeshPetscCall(VecScale(_vec, factor));
381 VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
384 template <
typename T>
387 parallel_object_only();
390 const PetscVector<T> * v_vec = cast_ptr<const PetscVector<T> *>(&v);
392 LibmeshPetscCall(VecPointwiseMult(_vec, _vec, v_vec->
_vec));
397 template <
typename T>
400 parallel_object_only();
403 const PetscVector<T> * v_vec = cast_ptr<const PetscVector<T> *>(&v);
405 LibmeshPetscCall(VecPointwiseDivide(_vec, _vec, v_vec->
_vec));
410 template <
typename T>
413 parallel_object_only();
415 this->_restore_array();
417 LibmeshPetscCall(VecAbs(_vec));
422 VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
425 template <
typename T>
428 parallel_object_only();
430 this->_restore_array();
435 PetscScalar
value=0.;
438 const PetscVector<T> * v = cast_ptr<const PetscVector<T> *>(&v_in);
441 LibmeshPetscCall(VecDot(this->_vec, v->
_vec, &
value));
443 return static_cast<T
>(
value);
446 template <
typename T>
449 parallel_object_only();
451 this->_restore_array();
456 PetscScalar
value=0.;
459 const PetscVector<T> * v = cast_ptr<const PetscVector<T> *>(&v_in);
462 LibmeshPetscCall(VecTDot(this->_vec, v->
_vec, &
value));
464 return static_cast<T
>(
value);
468 template <
typename T>
472 parallel_object_only();
474 this->_restore_array();
477 PetscScalar s =
PS(s_in);
479 if (this->size() != 0)
481 LibmeshPetscCall(VecSet(_vec, s));
486 VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
494 template <
typename T>
498 parallel_object_only();
501 const PetscVector<T> * v = cast_ptr<const PetscVector<T> *>(&v_in);
510 template <
typename T>
514 parallel_object_only();
516 this->_restore_array();
519 libmesh_assert_equal_to (this->size(), v.
size());
520 libmesh_assert_equal_to (this->local_size(), v.
local_size());
524 LibmeshPetscCall(VecCopy (v.
_vec, this->_vec));
529 VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
531 this->_is_closed =
true;
538 template <
typename T>
542 parallel_object_only();
544 this->_get_array(
false);
550 if (this->size() == v.size())
555 _values[i] =
PS(v[first + i]);
565 _values[i] =
PS(v[i]);
577 template <
typename T>
580 parallel_object_only();
582 this->_restore_array();
585 PetscVector<T> * v_local = cast_ptr<PetscVector<T> *>(&v_local_in);
590 libmesh_assert_equal_to (v_local->
size(), this->size());
601 LibmeshPetscCall(VecScatterCreateToAll(_vec, scatter.
get(),
nullptr));
602 VecScatterBeginEnd(this->comm(), scatter, _vec, v_local->
_vec, INSERT_VALUES, SCATTER_FORWARD);
606 else if (this->local_size() == v_local->
local_size())
607 LibmeshPetscCall(VecCopy(_vec,v_local->
_vec));
609 libmesh_error_msg(
"Vectors are inconsistent");
614 VecGhostUpdateBeginEnd(this->comm(), v_local->
_vec, INSERT_VALUES, SCATTER_FORWARD);
619 template <
typename T>
621 const std::vector<numeric_index_type> & send_list)
const 623 parallel_object_only();
640 this->_restore_array();
643 PetscVector<T> * v_local = cast_ptr<PetscVector<T> *>(&v_local_in);
646 libmesh_assert_equal_to (v_local->
size(), this->size());
647 libmesh_assert_less_equal (send_list.size(), v_local->
size());
650 cast_int<numeric_index_type>(send_list.size());
652 std::vector<PetscInt>
idx(n_sl + this->local_size());
654 idx[i] = static_cast<PetscInt>(send_list[i]);
656 idx[n_sl+i] = i + this->first_local_index();
660 PetscInt * idxptr =
idx.empty() ? nullptr :
idx.data();
661 LibmeshPetscCall(ISCreateGeneral(this->comm().
get(), n_sl+this->local_size(),
662 idxptr, PETSC_USE_POINTER,
is.get()));
665 LibmeshPetscCall(VecScatterCreate(_vec,
is,
670 VecScatterBeginEnd(this->comm(), scatter, _vec, v_local->
_vec, INSERT_VALUES, SCATTER_FORWARD);
679 template <
typename T>
681 const std::vector<numeric_index_type> & indices)
const 683 parallel_object_only();
689 LibmeshPetscCall(VecCreateSeq(PETSC_COMM_SELF, cast_int<PetscInt>(indices.size()), dest.
get()));
697 LibmeshPetscCall(ISCreateGeneral(this->comm().
get(), cast_int<PetscInt>(indices.size()), idxptr,
698 PETSC_USE_POINTER,
is.get()));
702 LibmeshPetscCall(VecScatterCreate(_vec,
705 LIBMESH_PETSC_NULLPTR,
709 VecScatterBeginEnd(this->comm(), scatter, _vec, dest, INSERT_VALUES, SCATTER_FORWARD);
712 PetscScalar * values;
713 LibmeshPetscCall(VecGetArray (dest, &values));
718 v_local.reserve(indices.size());
720 v_local.insert(v_local.begin(), values, values+indices.size());
723 LibmeshPetscCall(VecRestoreArray (dest, &values));
728 template <
typename T>
731 const std::vector<numeric_index_type> & send_list)
733 parallel_object_only();
735 this->_restore_array();
737 libmesh_assert_less_equal (send_list.size(), this->size());
738 libmesh_assert_less_equal (last_local_idx+1, this->size());
747 if (this->n_processors() == 1)
755 parallel_vec.
init (my_size, my_local_size,
true,
PARALLEL);
761 std::vector<PetscInt>
idx(my_local_size);
766 LibmeshPetscCall(ISCreateGeneral(this->comm().
get(), my_local_size,
767 my_local_size ?
idx.data() :
nullptr, PETSC_USE_POINTER,
is.get()));
770 LibmeshPetscCall(VecScatterCreate(_vec,
is,
775 VecScatterBeginEnd(this->comm(), scatter, _vec, parallel_vec.
_vec, INSERT_VALUES, SCATTER_FORWARD);
779 parallel_vec.
close();
780 parallel_vec.
localize (*
this, send_list);
786 template <
typename T>
789 parallel_object_only();
791 this->_restore_array();
794 parallel_object_only();
796 const PetscInt n = this->size();
797 const PetscInt nl = this->local_size();
798 PetscScalar * values;
801 v_local.resize(n, 0.);
803 LibmeshPetscCall(VecGetArray (_vec, &values));
807 for (PetscInt i=0; i<nl; i++)
808 v_local[i+ioff] = static_cast<T>(values[i]);
810 LibmeshPetscCall(VecRestoreArray (_vec, &values));
812 this->comm().sum(v_local);
818 #ifdef LIBMESH_USE_REAL_NUMBERS 823 timpi_mpi_var(pid))
const 825 parallel_object_only();
827 this->_restore_array();
829 const PetscInt n = size();
830 PetscScalar * values;
833 if (n_processors() == 1)
837 LibmeshPetscCall(VecGetArray (_vec, &values));
839 for (PetscInt i=0; i<n; i++)
840 v_local[i] = static_cast<Real>(values[i]);
842 LibmeshPetscCall(VecRestoreArray (_vec, &values));
846 #ifdef LIBMESH_HAVE_MPI 854 LibmeshPetscCall(VecScatterCreateToZero(_vec,
ctx.get(), vout.
get()));
856 VecScatterBeginEnd(this->comm(),
ctx, _vec, vout, INSERT_VALUES, SCATTER_FORWARD);
858 if (processor_id() == 0)
862 LibmeshPetscCall(VecGetArray (vout, &values));
864 for (PetscInt i=0; i<n; i++)
865 v_local[i] = static_cast<Real>(values[i]);
867 LibmeshPetscCall(VecRestoreArray (vout, &values));
875 std::vector<Real> local_values (n, 0.);
878 LibmeshPetscCall(VecGetArray (_vec, &values));
880 const PetscInt nl = local_size();
881 for (PetscInt i=0; i<nl; i++)
882 local_values[i+ioff] = static_cast<Real>(values[i]);
884 LibmeshPetscCall(VecRestoreArray (_vec, &values));
888 MPI_Reduce (local_values.data(), v_local.data(), n,
894 #endif // LIBMESH_HAVE_MPI 901 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 907 parallel_object_only();
909 this->_restore_array();
911 const PetscInt n = size();
912 const PetscInt nl = local_size();
913 PetscScalar * values;
919 for (PetscInt i=0; i<n; i++)
923 if (n_processors() == 1)
925 LibmeshPetscCall(VecGetArray (_vec, &values));
927 for (PetscInt i=0; i<n; i++)
928 v_local[i] = static_cast<Complex>(values[i]);
930 LibmeshPetscCall(VecRestoreArray (_vec, &values));
941 std::vector<Real> real_local_values(n, 0.);
942 std::vector<Real> imag_local_values(n, 0.);
945 LibmeshPetscCall(VecGetArray (_vec, &values));
948 for (PetscInt i=0; i<nl; i++)
950 real_local_values[i+ioff] =
static_cast<Complex>(values[i]).
real();
951 imag_local_values[i+ioff] =
static_cast<Complex>(values[i]).
imag();
954 LibmeshPetscCall(VecRestoreArray (_vec, &values));
962 std::vector<Real> real_v_local(n);
963 std::vector<Real> imag_v_local(n);
966 MPI_Reduce (real_local_values.data(),
967 real_v_local.data(), n,
970 pid, this->comm().get());
972 MPI_Reduce (imag_local_values.data(),
973 imag_v_local.data(), n,
976 pid, this->comm().get());
979 for (PetscInt i=0; i<n; i++)
980 v_local[i] =
Complex(real_v_local[i], imag_v_local[i]);
988 template <
typename T>
992 parallel_object_only();
994 this->_restore_array();
997 const PetscVector<T> * vec1_petsc = cast_ptr<const PetscVector<T> *>(&vec1);
998 const PetscVector<T> * vec2_petsc = cast_ptr<const PetscVector<T> *>(&vec2);
1001 LibmeshPetscCall(VecPointwiseMult(_vec, vec1_petsc->
vec(), vec2_petsc->vec()));
1006 VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
1008 this->_is_closed =
true;
1011 template <
typename T>
1015 parallel_object_only();
1017 this->_restore_array();
1020 const PetscVector<T> *
const vec1_petsc = cast_ptr<const PetscVector<T> *>(&vec1);
1021 const PetscVector<T> *
const vec2_petsc = cast_ptr<const PetscVector<T> *>(&vec2);
1024 LibmeshPetscCall(VecPointwiseDivide(_vec, vec1_petsc->
vec(), vec2_petsc->vec()));
1029 VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
1031 this->_is_closed =
true;
1034 template <
typename T>
1037 parallel_object_only();
1039 this->_restore_array();
1044 LibmeshPetscCall(PetscViewerCreate (this->comm().
get(), petsc_viewer.
get()));
1050 LibmeshPetscCall(PetscViewerASCIIOpen(this->comm().
get(),
1052 petsc_viewer.
get()));
1054 #if PETSC_VERSION_LESS_THAN(3,7,0) 1055 LibmeshPetscCall(PetscViewerSetFormat (petsc_viewer,
1056 PETSC_VIEWER_ASCII_MATLAB));
1058 LibmeshPetscCall(PetscViewerPushFormat (petsc_viewer,
1059 PETSC_VIEWER_ASCII_MATLAB));
1062 LibmeshPetscCall(VecView (_vec, petsc_viewer));
1069 #if PETSC_VERSION_LESS_THAN(3,7,0) 1070 LibmeshPetscCall(PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD,
1071 PETSC_VIEWER_ASCII_MATLAB));
1073 LibmeshPetscCall(PetscViewerPushFormat (PETSC_VIEWER_STDOUT_WORLD,
1074 PETSC_VIEWER_ASCII_MATLAB));
1077 LibmeshPetscCall(VecView (_vec, PETSC_VIEWER_STDOUT_WORLD));
1085 template <
typename T>
1087 const std::vector<numeric_index_type> & rows,
1088 const bool supplying_global_rows)
const 1090 parallel_object_only();
1092 libmesh_error_msg_if(
1094 "We do not support scattering parallel information to ghosts for subvectors");
1096 this->_restore_array();
1101 PetscVector<T> * petsc_subvector = cast_ptr<PetscVector<T> *>(&subvector);
1110 if (supplying_global_rows)
1117 LibmeshPetscCall(VecCreateMPI(this->comm().
get(),
1119 cast_int<PetscInt>(rows.size()),
1120 &(petsc_subvector->
_vec)));
1122 LibmeshPetscCall(VecCreateMPI(this->comm().
get(),
1123 cast_int<PetscInt>(rows.size()),
1125 &(petsc_subvector->
_vec)));
1127 LibmeshPetscCall(VecSetFromOptions (petsc_subvector->
_vec));
1140 std::vector<PetscInt>
idx(rows.size());
1141 if (supplying_global_rows)
1146 LibmeshPetscCall(VecGetOwnershipRange(petsc_subvector->
_vec, &start,
nullptr));
1152 LibmeshPetscCall(ISCreateGeneral(this->comm().
get(),
1153 cast_int<PetscInt>(rows.size()),
1159 LibmeshPetscCall(ISCreateGeneral(this->comm().
get(),
1160 cast_int<PetscInt>(rows.size()),
1163 subvector_is.
get()));
1167 LibmeshPetscCall(VecScatterCreate(this->_vec,
1169 petsc_subvector->
_vec,
1174 VecScatterBeginEnd(this->comm(), scatter, this->_vec, petsc_subvector->
_vec, INSERT_VALUES, SCATTER_FORWARD);
1181 template <
typename T>
1186 bool initially_array_is_present = _array_is_present.load(std::memory_order_acquire);
1190 if (initially_array_is_present && read_only && !_values_read_only)
1191 _read_only_values = _values;
1197 if (initially_array_is_present && !read_only && _values_read_only)
1200 initially_array_is_present =
false;
1203 if (!initially_array_is_present)
1205 std::scoped_lock lock(_petsc_get_restore_array_mutex);
1206 if (!_array_is_present.load(std::memory_order_relaxed))
1212 LibmeshPetscCall(VecGetArrayRead(_vec, &_read_only_values));
1213 _values_read_only =
true;
1217 LibmeshPetscCall(VecGetArray(_vec, &_values));
1218 _values_read_only =
false;
1220 _local_size = this->local_size();
1224 LibmeshPetscCall(VecGhostGetLocalForm (_vec,&_local_form));
1228 LibmeshPetscCall(VecGetArrayRead(_local_form, &_read_only_values));
1229 _values_read_only =
true;
1233 LibmeshPetscCall(VecGetArray(_local_form, &_values));
1234 _values_read_only =
false;
1237 PetscInt my_local_size = 0;
1238 LibmeshPetscCall(VecGetLocalSize(_local_form, &my_local_size));
1243 PetscInt petsc_first=0, petsc_last=0;
1244 LibmeshPetscCall(VecGetOwnershipRange (_vec, &petsc_first, &petsc_last));
1248 _array_is_present.store(
true, std::memory_order_release);
1255 template <
typename T>
1258 libmesh_error_msg_if(_values_manually_retrieved,
1259 "PetscVector values were manually retrieved but are being automatically restored!");
1262 if (_array_is_present.load(std::memory_order_acquire))
1264 std::scoped_lock lock(_petsc_get_restore_array_mutex);
1265 if (_array_is_present.load(std::memory_order_relaxed))
1269 if (_values_read_only)
1270 LibmeshPetscCall(VecRestoreArrayRead (_vec, &_read_only_values));
1272 LibmeshPetscCall(VecRestoreArray (_vec, &_values));
1278 if (_values_read_only)
1279 LibmeshPetscCall(VecRestoreArrayRead (_local_form, &_read_only_values));
1281 LibmeshPetscCall(VecRestoreArray (_local_form, &_values));
1284 LibmeshPetscCall(VecGhostRestoreLocalForm (_vec,&_local_form));
1285 _local_form =
nullptr;
1288 _array_is_present.store(
false, std::memory_order_release);
1293 template <
typename T>
1294 std::unique_ptr<NumericVector<T>>
1299 LibmeshPetscCall(ISCreateGeneral(this->comm().
get(),
1300 cast_int<PetscInt>(rows.size()),
1306 LibmeshPetscCall(VecGetSubVector(_vec, parent_is, &subvec));
1308 this->_is_closed =
false;
1310 return std::make_unique<PetscVector<T>>(subvec, this->comm());
1313 template <
typename T>
1316 const std::vector<numeric_index_type> & rows)
1318 auto *
const petsc_subvector = cast_ptr<PetscVector<T> *>(subvector.get());
1322 LibmeshPetscCall(ISCreateGeneral(this->comm().
get(),
1323 cast_int<PetscInt>(rows.size()),
1328 Vec subvec = petsc_subvector->vec();
1329 LibmeshPetscCall(VecRestoreSubVector(_vec, parent_is, &subvec));
1332 VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
1334 this->_is_closed =
true;
1345 #endif // #ifdef LIBMESH_HAVE_PETSC std::string name(const ElemQuality q)
This function returns a string containing some name for q.
virtual Real l2_norm() const override
bool closed()
Checks that the library has been closed.
virtual void localize(std::vector< T > &v_local) const override
Creates a copy of the global vector in the local vector v_local.
This class provides a nice interface to PETSc's Vec object.
void add_vector_conjugate_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A)
.
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
This class provides a nice interface to the PETSc C-based data structures for parallel, sparse matrices.
virtual numeric_index_type size() const override
virtual Real linfty_norm() const override
virtual bool initialized() const
void _get_array(bool read_only) const
Queries the array (and the local form if the vector is ghosted) from PETSc.
virtual numeric_index_type local_size() const override
virtual void add(const numeric_index_type i, const T value) override
Adds value to the vector entry specified by i.
Vec _vec
Actual PETSc vector datatype to hold vector entries.
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
PetscScalar * pPS(T *ptr)
bool _is_initialized
true once init() has been called.
The libMesh namespace provides an interface to certain functionality in the library.
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
void _restore_array() const
Restores the array (and the local form if the vector is ghosted) to PETSc.
uint8_t processor_id_type
PetscInt * numeric_petsc_cast(const numeric_index_type *p)
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices) override
Inserts the entries of v in *this at the locations specified by v.
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
virtual Real l1_norm() const override
virtual void abs() override
Sets for each entry in the vector.
dof_id_type numeric_index_type
virtual NumericVector< T > & operator+=(const NumericVector< T > &v) override
Adds v to *this, .
virtual void conjugate() override
Negates the imaginary component of each entry in the vector.
virtual void localize_to_one(std::vector< T > &v_local, const processor_id_type proc_id=0) const override
Creates a local copy of the global vector in v_local only on processor proc_id.
PetscErrorCode PetscInt const PetscInt IS * is
ParallelType _type
Type of vector.
virtual void create_subvector(NumericVector< T > &subvector, const std::vector< numeric_index_type > &rows, bool supplying_global_rows=true) const override
Fills in subvector from this vector using the indices in rows.
virtual bool closed() const
virtual T sum() const override
std::complex< Real > Complex
ParallelType type() const
virtual void set(const numeric_index_type i, const T value) override
Sets v(i) = value.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
T indefinite_dot(const NumericVector< T > &v) const
virtual void restore_subvector(std::unique_ptr< NumericVector< T >> subvector, const std::vector< numeric_index_type > &rows) override
Restores a view into this vector using the indices in rows.
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
Change the dimension of the vector to n.
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...
bool initialized()
Checks that library initialization has been done.
PetscVector< T > & operator=(const PetscVector< T > &v)
Copy assignment operator.
virtual void reciprocal() override
Computes the component-wise reciprocal, .
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices) override
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
virtual NumericVector< T > & operator*=(const NumericVector< T > &v) override
Computes the component-wise multiplication of this vector's entries by another's, ...
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
virtual void print_matlab(const std::string &name="") const override
Print the contents of the vector in Matlab's sparse matrix format.
virtual std::unique_ptr< NumericVector< T > > get_subvector(const std::vector< numeric_index_type > &rows) override
Creates a view into this vector using the indices in rows.
virtual void scale(const T factor) override
Scale each element of the vector by the given factor.
bool _is_closed
Flag which tracks whether the vector's values are consistent on all processors after insertion or add...
virtual void close() override
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
virtual NumericVector< T > & operator/=(const NumericVector< T > &v) override
Computes the component-wise division of this vector's entries by another's, .
virtual NumericVector< T > & operator-=(const NumericVector< T > &v) override
Subtracts v from *this, .
virtual T dot(const NumericVector< T > &v) const override