libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
trilinos_epetra_vector.h
浏览该文件的文档.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2023 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 #ifndef LIBMESH_TRILINOS_EPETRA_VECTOR_H
19 #define LIBMESH_TRILINOS_EPETRA_VECTOR_H
20 
21 
22 #include "libmesh/libmesh_common.h"
23 
24 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
25 
26 // Local includes
27 #include "libmesh/numeric_vector.h"
28 #include "libmesh/parallel.h"
29 
30 // Trilinos includes
31 #include "libmesh/ignore_warnings.h"
32 #include <Epetra_CombineMode.h>
33 #include <Epetra_Map.h>
34 #include <Epetra_MultiVector.h>
35 #include <Epetra_Vector.h>
36 #include <Epetra_MpiComm.h>
37 #include "libmesh/restore_warnings.h"
38 
39 // C++ includes
40 #include <cstddef>
41 #include <limits>
42 #include <memory>
43 #include <mutex>
44 #include <vector>
45 
46 // Forward declarations
47 class Epetra_IntSerialDenseVector;
48 class Epetra_SerialDenseVector;
49 
50 namespace libMesh
51 {
52 
53 // forward declarations
54 template <typename T> class SparseMatrix;
55 
62 template <typename T>
63 class EpetraVector final : public NumericVector<T>
64 {
65 public:
66  typedef T value_type;
67 
74  explicit EpetraVector (const Parallel::Communicator & comm,
75  const ParallelType type = AUTOMATIC);
76 
84  explicit EpetraVector (const Parallel::Communicator & comm,
85  const numeric_index_type n,
86  const ParallelType type = AUTOMATIC);
87 
96  EpetraVector (const Parallel::Communicator & comm,
97  const numeric_index_type n,
98  const numeric_index_type n_local,
99  const ParallelType type = AUTOMATIC);
100 
110  EpetraVector (const Parallel::Communicator & comm,
111  const numeric_index_type N,
112  const numeric_index_type n_local,
113  const std::vector<numeric_index_type> & ghost,
114  const ParallelType type = AUTOMATIC);
115 
124  EpetraVector(Epetra_Vector & v,
125  const Parallel::Communicator & comm);
126 
131  EpetraVector (EpetraVector &&) = delete;
132  EpetraVector (const EpetraVector &) = delete;
133  EpetraVector & operator= (const EpetraVector &) = delete;
134  EpetraVector & operator= (EpetraVector &&) = delete;
135 
139  virtual void close () override;
140 
144  virtual void clear () noexcept override;
145 
149  virtual void zero () override;
150 
156  virtual std::unique_ptr<NumericVector<T>> zero_clone () const override;
157 
163  virtual std::unique_ptr<NumericVector<T>> clone () const override;
164 
173  virtual void init (const numeric_index_type N,
174  const numeric_index_type n_local,
175  const bool fast=false,
176  const ParallelType type=AUTOMATIC) override;
177 
185  virtual void init (const numeric_index_type N,
186  const bool fast=false,
187  const ParallelType type=AUTOMATIC) override;
188 
198  virtual void init (const numeric_index_type N,
199  const numeric_index_type n_local,
200  const std::vector<numeric_index_type> & ghost,
201  const bool fast = false,
202  const ParallelType = AUTOMATIC) override;
203 
210  virtual void init (const NumericVector<T> & other,
211  const bool fast = false) override;
212 
220  virtual NumericVector<T> & operator= (const T s) override;
221 
229  virtual NumericVector<T> & operator= (const NumericVector<T> & v) override;
230 
238  virtual NumericVector<T> & operator= (const std::vector<T> & v) override;
239 
245  virtual Real min () const override;
246 
252  virtual Real max () const override;
253 
259  virtual T sum () const override;
260 
266  virtual Real l1_norm () const override;
267 
273  virtual Real l2_norm () const override;
274 
280  virtual Real linfty_norm () const override;
281 
287  virtual numeric_index_type size () const override;
288 
294  virtual numeric_index_type local_size() const override;
295 
301  virtual numeric_index_type first_local_index() const override;
302 
308  virtual numeric_index_type last_local_index() const override;
309 
317  virtual T operator() (const numeric_index_type i) const override;
318 
326  virtual NumericVector<T> & operator += (const NumericVector<T> & v) override;
327 
335  virtual NumericVector<T> & operator -= (const NumericVector<T> & v) override;
336 
344  virtual NumericVector<T> & operator *= (const NumericVector<T> & v) override;
345 
353  virtual NumericVector<T> & operator /= (const NumericVector<T> & v) override;
354 
358  virtual void reciprocal() override;
359 
363  virtual void conjugate() override;
364 
371  virtual void set (const numeric_index_type i, const T value) override;
372 
379  virtual void add (const numeric_index_type i, const T value) override;
380 
386  virtual void add (const T s) override;
387 
393  virtual void add (const NumericVector<T> & v) override;
394 
401  virtual void add (const T a, const NumericVector<T> & v) override;
402 
409  virtual void add_vector (const T * v,
410  const std::vector<numeric_index_type> & dof_indices) override;
411 
418  virtual void add_vector (const NumericVector<T> & v,
419  const SparseMatrix<T> & A) override;
420 
427  virtual void add_vector_transpose (const NumericVector<T> & v,
428  const SparseMatrix<T> & A) override;
429 
436  virtual void insert (const T * v,
437  const std::vector<numeric_index_type> & dof_indices) override;
438 
444  virtual void scale (const T factor) override;
445 
449  virtual void abs() override;
450 
458  virtual T dot(const NumericVector<T> & v) const override;
459 
465  virtual void localize (std::vector<T> & v_local) const override;
466 
472  virtual void localize (NumericVector<T> & v_local) const override;
473 
480  virtual void localize (NumericVector<T> & v_local,
481  const std::vector<numeric_index_type> & send_list) const override;
482 
489  virtual void localize (std::vector<T> & v_local,
490  const std::vector<numeric_index_type> & indices) const override;
491 
499  virtual void localize (const numeric_index_type first_local_idx,
500  const numeric_index_type last_local_idx,
501  const std::vector<numeric_index_type> & send_list) override;
502 
509  virtual void localize_to_one (std::vector<T> & v_local,
510  const processor_id_type proc_id=0) const override;
511 
518  virtual void pointwise_mult (const NumericVector<T> & vec1,
519  const NumericVector<T> & vec2) override;
520 
527  virtual void create_subvector (NumericVector<T> & subvector,
528  const std::vector<numeric_index_type> & rows) const override;
529 
535  virtual void swap (NumericVector<T> & v) override;
536 
542  virtual std::size_t max_allowed_id() const override;
543 
553  Epetra_Vector * vec () { libmesh_assert(_vec); return _vec; }
554 
555  private:
556 
560  Epetra_Vector * _vec;
561 
565  std::unique_ptr<Epetra_Map> _map;
566 
571 
572  // 以下代码从 Epetra_FEVector.h 复制(并稍作修改),以允许我们使用标准 Epetra_Vector,更兼容其他 Trilinos 包,如 NOX。所有这些代码最初都是在 LGPL 下编写的。
573 
583  int SumIntoGlobalValues(int numIDs,
584  const int * GIDs,
585  const double * values);
586 
595  int SumIntoGlobalValues(const Epetra_IntSerialDenseVector & GIDs,
596  const Epetra_SerialDenseVector & values);
597 
607  int ReplaceGlobalValues(int numIDs,
608  const int * GIDs,
609  const double * values);
610 
619  int ReplaceGlobalValues(const Epetra_IntSerialDenseVector & GIDs,
620  const Epetra_SerialDenseVector & values);
621 
632  int SumIntoGlobalValues(int numIDs,
633  const int * GIDs,
634  const int * numValuesPerID,
635  const double * values);
636 
647  int ReplaceGlobalValues(int numIDs,
648  const int * GIDs,
649  const int * numValuesPerID,
650  const double * values);
651 
661  int GlobalAssemble(Epetra_CombineMode mode = Add);
662 
668  void setIgnoreNonLocalEntries(bool flag)
669  {
670  ignoreNonLocalEntries_ = flag;
671  }
672 
678  void FEoperatorequals(const EpetraVector & source);
679 
690  int inputValues(int numIDs,
691  const int * GIDs,
692  const double * values,
693  bool accumulate);
694 
706  int inputValues(int numIDs,
707  const int * GIDs,
708  const int * numValuesPerID,
709  const double * values,
710  bool accumulate);
711 
721  int inputNonlocalValue(int GID,
722  double value,
723  bool accumulate);
724 
735  int inputNonlocalValues(int GID,
736  int numValues,
737  const double * values,
738  bool accumulate);
739 
743  void destroyNonlocalData();
744 
749 
754 
758  double * myCoefs_;
759 
764 
769 
774 
779 
783  double ** nonlocalCoefs_;
784 
789  unsigned char last_edit;
790 
795 };
796 
797 
798 /*----------------------- Inline functions ----------------------------------*/
799 
800 
801 
802 template <typename T>
803 inline
804 EpetraVector<T>::EpetraVector (const Parallel::Communicator & comm,
805  const ParallelType type) :
806  NumericVector<T>(comm, type),
807  _destroy_vec_on_exit(true),
808  myFirstID_(0),
809  myNumIDs_(0),
810  myCoefs_(nullptr),
811  nonlocalIDs_(nullptr),
812  nonlocalElementSize_(nullptr),
813  numNonlocalIDs_(0),
814  allocatedNonlocalLength_(0),
815  nonlocalCoefs_(nullptr),
816  last_edit(0),
817  ignoreNonLocalEntries_(false)
818 {
819  this->_type = type;
820 }
821 
822 
823 
824 template <typename T>
825 inline
826 EpetraVector<T>::EpetraVector (const Parallel::Communicator & comm,
827  const numeric_index_type n,
828  const ParallelType type) :
829  NumericVector<T>(comm, type),
830  _destroy_vec_on_exit(true),
831  myFirstID_(0),
832  myNumIDs_(0),
833  myCoefs_(nullptr),
834  nonlocalIDs_(nullptr),
835  nonlocalElementSize_(nullptr),
836  numNonlocalIDs_(0),
837  allocatedNonlocalLength_(0),
838  nonlocalCoefs_(nullptr),
839  last_edit(0),
840  ignoreNonLocalEntries_(false)
841 
842 {
843  this->init(n, n, false, type);
844 }
845 
846 
847 
848 template <typename T>
849 inline
850 EpetraVector<T>::EpetraVector (const Parallel::Communicator & comm,
851  const numeric_index_type n,
852  const numeric_index_type n_local,
853  const ParallelType type) :
854  NumericVector<T>(comm, type),
855  _destroy_vec_on_exit(true),
856  myFirstID_(0),
857  myNumIDs_(0),
858  myCoefs_(nullptr),
859  nonlocalIDs_(nullptr),
860  nonlocalElementSize_(nullptr),
861  numNonlocalIDs_(0),
862  allocatedNonlocalLength_(0),
863  nonlocalCoefs_(nullptr),
864  last_edit(0),
865  ignoreNonLocalEntries_(false)
866 {
867  this->init(n, n_local, false, type);
868 }
869 
870 
871 
872 
873 template <typename T>
874 inline
876  const Parallel::Communicator & comm) :
877  NumericVector<T>(comm, AUTOMATIC),
878  _destroy_vec_on_exit(false),
879  myFirstID_(0),
880  myNumIDs_(0),
881  myCoefs_(nullptr),
882  nonlocalIDs_(nullptr),
883  nonlocalElementSize_(nullptr),
884  numNonlocalIDs_(0),
885  allocatedNonlocalLength_(0),
886  nonlocalCoefs_(nullptr),
887  last_edit(0),
888  ignoreNonLocalEntries_(false)
889 {
890  _vec = &v;
891 
892  this->_type = PARALLEL; // FIXME - need to determine this from v!
893 
894  myFirstID_ = _vec->Map().MinMyGID();
895  myNumIDs_ = _vec->Map().NumMyElements();
896 
897  _map = std::make_unique<Epetra_Map>
898  (_vec->GlobalLength(),
899  _vec->MyLength(),
900  0, // IndexBase = 0 for C/C++, 1 for Fortran.
901  Epetra_MpiComm (this->comm().get()));
902 
903  // 目前施加NumVectors==1的限制,所以在调用ExtractView时不需要LDA参数。
904  // 因此才有了“dummy”这个词。
905  int dummy;
906  _vec->ExtractView(&myCoefs_, &dummy);
907 
908  this->_is_closed = true;
909  this->_is_initialized = true;
910 }
911 
912 
913 
914 template <typename T>
915 inline
916 EpetraVector<T>::EpetraVector (const Parallel::Communicator & comm,
917  const numeric_index_type n,
918  const numeric_index_type n_local,
919  const std::vector<numeric_index_type> & ghost,
920  const ParallelType type) :
921  NumericVector<T>(comm, AUTOMATIC),
922  _destroy_vec_on_exit(true),
923  myFirstID_(0),
924  myNumIDs_(0),
925  myCoefs_(nullptr),
926  nonlocalIDs_(nullptr),
927  nonlocalElementSize_(nullptr),
928  numNonlocalIDs_(0),
929  allocatedNonlocalLength_(0),
930  nonlocalCoefs_(nullptr),
931  last_edit(0),
932  ignoreNonLocalEntries_(false)
933 {
934  this->init(n, n_local, ghost, false, type);
935 }
936 
937 
938 
939 // 未实现虚影向量求解器包的默认实现。
940 template <class T>
942  const bool fast)
943 {
944  this->init(other.size(),other.local_size(),fast,other.type());
945 }
946 
947 
948 
949 template <typename T>
950 inline
952 {
953  this->clear ();
954 }
955 
956 
957 
958 template <typename T>
959 inline
961  const numeric_index_type n_local,
962  const bool fast,
963  const ParallelType type)
964 {
965  // We default to allocating n_local local storage
966  numeric_index_type my_n_local = n_local;
967 
968  if (type == AUTOMATIC)
969  {
970  if (n == n_local)
971  this->_type = SERIAL;
972  else
973  this->_type = PARALLEL;
974  }
975  else if (type == GHOSTED)
976  {
977  // We don't yet support GHOSTED Epetra vectors, so to get the
978  // same functionality we need a SERIAL vector with local
979  // storage allocated for every entry.
980  this->_type = SERIAL;
981  my_n_local = n;
982  }
983  else
984  this->_type = type;
985 
986  libmesh_assert ((this->_type==SERIAL && n==my_n_local) ||
987  this->_type==PARALLEL);
988 
989  _map = std::make_unique<Epetra_Map>
990  (static_cast<int>(n),
991  my_n_local,
992  0,
993  Epetra_MpiComm (this->comm().get()));
994 
995  _vec = new Epetra_Vector(*_map);
996 
997  myFirstID_ = _vec->Map().MinMyGID();
998  myNumIDs_ = _vec->Map().NumMyElements();
999 
1000  // Currently we impose the restriction that NumVectors==1, so we won't
1001  // need the LDA argument when calling ExtractView. Hence the "dummy" arg.
1002  int dummy;
1003  _vec->ExtractView(&myCoefs_, &dummy);
1004 
1005  this->_is_initialized = true;
1006  this->_is_closed = true;
1007  this->last_edit = 0;
1008 
1009  if (fast == false)
1010  this->zero ();
1011 }
1012 
1013 
1014 template <typename T>
1015 inline
1017  const numeric_index_type n_local,
1018  const std::vector<numeric_index_type> & /*ghost*/,
1019  const bool fast,
1020  const ParallelType type)
1021 {
1022  // TODO: we shouldn't ignore the ghost sparsity pattern
1023  this->init(n, n_local, fast, type);
1024 }
1025 
1026 
1027 
1028 template <typename T>
1029 inline
1031  const bool fast,
1032  const ParallelType type)
1033 {
1034  this->init(n,n,fast,type);
1035 }
1036 
1037 
1038 
1039 template <typename T>
1040 inline
1042 {
1043  libmesh_assert (this->initialized());
1044 
1045  // Are we adding or inserting?
1046  unsigned char global_last_edit = last_edit;
1047  this->comm().max(global_last_edit);
1048  libmesh_assert(!last_edit || last_edit == global_last_edit);
1049 
1050  if (global_last_edit == 1)
1051  this->GlobalAssemble(Insert);
1052  else if (global_last_edit == 2)
1053  this->GlobalAssemble(Add);
1054  else
1055  libmesh_assert(!global_last_edit);
1056 
1057  this->_is_closed = true;
1058  this->last_edit = 0;
1059 }
1060 
1061 
1062 
1063 template <typename T>
1064 inline
1065 void EpetraVector<T>::clear () noexcept
1066 {
1067  if (this->initialized())
1068  {
1069  // We might just be an interface to a user-provided _vec
1070  if (this->_destroy_vec_on_exit)
1071  {
1072  delete _vec;
1073  _vec = nullptr;
1074  }
1075 
1076  // But we currently always own our own _map
1077  _map.reset();
1078  }
1079 
1080  this->_is_closed = this->_is_initialized = false;
1081 }
1082 
1083 
1084 
1085 template <typename T>
1086 inline
1088 {
1089  libmesh_assert (this->initialized());
1090  libmesh_assert (this->closed());
1091 
1092  _vec->PutScalar(0.0);
1093 }
1094 
1095 
1096 
1097 template <typename T>
1098 inline
1099 std::unique_ptr<NumericVector<T>> EpetraVector<T>::zero_clone () const
1100 {
1101  NumericVector<T> * cloned_vector = new EpetraVector<T>(this->comm(), AUTOMATIC);
1102  cloned_vector->init(*this);
1103  return std::unique_ptr<NumericVector<T>>(cloned_vector);
1104 }
1105 
1106 
1107 
1108 template <typename T>
1109 inline
1110 std::unique_ptr<NumericVector<T>> EpetraVector<T>::clone () const
1111 {
1112  NumericVector<T> * cloned_vector = new EpetraVector<T>(this->comm(), AUTOMATIC);
1113  cloned_vector->init(*this, true);
1114  *cloned_vector = *this;
1115  return std::unique_ptr<NumericVector<T>>(cloned_vector);
1116 }
1117 
1118 
1119 
1120 template <typename T>
1121 inline
1123 {
1124  libmesh_assert (this->initialized());
1125 
1126  return _vec->GlobalLength();
1127 }
1128 
1129 
1130 
1131 template <typename T>
1132 inline
1134 {
1135  libmesh_assert (this->initialized());
1136 
1137  return _vec->MyLength();
1138 }
1139 
1140 template <typename T>
1141 inline
1143 {
1144  libmesh_assert (this->initialized());
1145 
1146  return _vec->Map().MinMyGID();
1147 }
1148 
1149 
1150 
1151 template <typename T>
1152 inline
1154 {
1155  libmesh_assert (this->initialized());
1156 
1157  return _vec->Map().MaxMyGID()+1;
1158 }
1159 
1160 
1161 template <typename T>
1162 inline
1164 {
1165  libmesh_assert (this->initialized());
1166  libmesh_assert ( ((i >= this->first_local_index()) &&
1167  (i < this->last_local_index())) );
1168 
1169  return (*_vec)[i-this->first_local_index()];
1170 }
1171 
1172 
1173 
1174 template <typename T>
1175 inline
1177 {
1178  libmesh_assert (this->initialized());
1179 
1180  T value;
1181 
1182  _vec->MinValue(&value);
1183 
1184  return value;
1185 }
1186 
1187 
1188 
1189 template <typename T>
1190 inline
1192 {
1193  libmesh_assert (this->initialized());
1194 
1195  T value;
1196 
1197  _vec->MaxValue(&value);
1198 
1199  return value;
1200 }
1201 
1202 
1203 
1204 template <typename T>
1205 inline
1207 {
1208  NumericVector<T>::swap(other);
1209 
1210  EpetraVector<T> & v = cast_ref<EpetraVector<T> &>(other);
1211 
1212  std::swap(_vec, v._vec);
1213  _map.swap(v._map);
1214  std::swap(_destroy_vec_on_exit, v._destroy_vec_on_exit);
1215  std::swap(myFirstID_, v.myFirstID_);
1216  std::swap(myNumIDs_, v.myNumIDs_);
1217  std::swap(myCoefs_, v.myCoefs_);
1218  std::swap(nonlocalIDs_, v.nonlocalIDs_);
1219  std::swap(nonlocalElementSize_, v.nonlocalElementSize_);
1220  std::swap(numNonlocalIDs_, v.numNonlocalIDs_);
1221  std::swap(allocatedNonlocalLength_, v.allocatedNonlocalLength_);
1222  std::swap(nonlocalCoefs_, v.nonlocalCoefs_);
1223  std::swap(last_edit, v.last_edit);
1224  std::swap(ignoreNonLocalEntries_, v.ignoreNonLocalEntries_);
1225 }
1226 
1227 
1228 
1229 template <typename T>
1230 inline
1232 {
1233  // Epetra_Vector seems to use hard-coded ints in its various indexing routines.
1234  return std::numeric_limits<int>::max();
1235 }
1236 
1237 
1238 
1239 // Trilinos only got serious about const in version 10.4
1240 inline
1242 {
1243  return reinterpret_cast<int *>(const_cast<numeric_index_type *>(p));
1244 }
1245 
1246 } // namespace libMesh
1247 
1248 
1249 #endif // #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
1250 #endif // LIBMESH_TRILINOS_EPETRA_VECTOR_H
double ** nonlocalCoefs_
非本地系数的指针数组。
int myFirstID_
保存向量的第一个全局 ID。
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:268
此类提供了对Trilinos Epetra_Vector对象的友好接口。所有重写的虚拟函数在numeric_vector.h中都有文档。
virtual T operator()(const numeric_index_type i) const override
获取矢量中索引i处的值。
std::unique_ptr< Epetra_Map > _map
持有分布式映射。
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
计算当前矢量与另一个矢量的逐元素乘积。
int allocatedNonlocalLength_
已分配的非本地长度。
virtual void reciprocal() override
计算当前矢量的逐元素倒数。
virtual numeric_index_type last_local_index() const override
获取矢量的最后一个本地索引。
virtual void add(const numeric_index_type i, const T value) override
将索引i处的值增加value。
virtual void close() override
关闭矢量,使其无法再次修改。
virtual std::unique_ptr< NumericVector< T > > zero_clone() const override
创建零克隆矢量。
double * myCoefs_
保存系数的指针数组。
virtual numeric_index_type size() const =0
获取向量的大小。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual void localize_to_one(std::vector< T > &v_local, const processor_id_type proc_id=0) const override
将所有值本地化到一个本地矢量中,仅保留一个处理器上的值。
virtual void set(const numeric_index_type i, const T value) override
设置索引i处的值为value。
提供了不同线性代数库的向量存储方案的统一接口。
Definition: dof_map.h:67
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices) override
使用特定的自由度索引将一个值数组插入到当前矢量中。
int myNumIDs_
保存向量的全局 ID 数量。
int inputNonlocalValues(int GID, int numValues, const double *values, bool accumulate)
输入非本地值到向量中,覆盖或累积到指定 GID 的已存在的任何值。
bool _is_initialized
在调用 init() 后设置为 true。
virtual void conjugate() override
计算当前矢量的逐元素共轭。
virtual Real max() const override
获取矢量中的最大值。
const Number zero
.
Definition: libmesh.h:248
virtual void zero() override
将所有元素置零。
int * nonlocalElementSize_
非本地元素大小数组。
virtual T sum() const override
计算矢量中所有元素的总和。
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 ini...
int GlobalAssemble(Epetra_CombineMode mode=Add)
将所有重叠/共享数据收集到由 Map 在构造函数中传递给该向量定义的非重叠分区中。 从其他处理器导入的数据以“sumInto”或累积操作存储在拥有处理器上。这是一种集体方法, 每个处理器在任何处理器完成...
virtual numeric_index_type size() const override
获取矢量的全局大小。
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A) override
使用稀疏矩阵A的转置乘积将另一个矢量v添加到当前矢量中。
uint8_t processor_id_type
Definition: id_types.h:104
int ReplaceGlobalValues(int numIDs, const int *GIDs, const double *values)
将值复制到向量中,覆盖指定索引已存在的任何值。
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
输入值到向量中,覆盖或累积到指定索引的已存在的任何值。
这是一个通用的稀疏矩阵类。该类包含了必须在派生类中覆盖的纯虚拟成员。 使用一个公共的基类允许从不同的求解器包中以不同的格式统一访问稀疏矩阵。
Definition: dof_map.h:66
bool _destroy_vec_on_exit
此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。
void setIgnoreNonLocalEntries(bool flag)
设置是否应忽略非本地数据值。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
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:242
EpetraVector(const Parallel::Communicator &comm, const ParallelType type=AUTOMATIC)
构造函数。创建一个维度为0的虚拟矢量。
int * nonlocalIDs_
非本地 ID 数组。
virtual Real l1_norm() const override
计算矢量的L1范数。
virtual void abs() override
计算矢量的绝对值。
int inputNonlocalValue(int GID, double value, bool accumulate)
输入非本地值到向量中,覆盖或累积到指定 GID 的已存在的任何值。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
virtual Real min() const override
获取矢量中的最小值。
virtual Real linfty_norm() const override
计算矢量的L∞范数。
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
初始化矢量。
virtual std::size_t max_allowed_id() const override
获取允许的最大ID大小。
ParallelType _type
向量的类型。
void destroyNonlocalData()
销毁非本地数据。
int numNonlocalIDs_
非本地 ID 数量。
virtual void localize(std::vector< T > &v_local) const override
将当前矢量的值本地化到一个本地矢量中。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void clear() noexceptoverride
清除矢量,析构函数中会调用此函数,因此不应抛出异常。
virtual void swap(NumericVector< T > &v)
交换该向量的内容与向量 v 的内容。子类应提供足够的间接性以使此操作成为 O(1) 的头部交换操作。
virtual T dot(const NumericVector< T > &v) const override
计算当前矢量与另一个矢量的点积。
int SumIntoGlobalValues(int numIDs, const int *GIDs, const double *values)
将值累积到向量中,将它们添加到指定索引已存在的任何值中。
virtual Real l2_norm() const override
计算矢量的L2范数。
virtual numeric_index_type local_size() const =0
获取向量的本地大小,即 index_stop - index_start。
virtual void create_subvector(NumericVector< T > &subvector, const std::vector< numeric_index_type > &rows) const override
创建当前矢量的子矢量,包含指定行的值。
ParallelType type() const
获取向量的类型。
virtual numeric_index_type first_local_index() const override
获取矢量的第一个本地索引。
void FEoperatorequals(const EpetraVector &source)
从另一个 EpetraVector 对象中复制操作符。
virtual void swap(NumericVector< T > &v) override
交换当前矢量与另一个矢量的值。
virtual std::unique_ptr< NumericVector< T > > clone() const override
创建矢量克隆。
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:261
int * numeric_trilinos_cast(const numeric_index_type *p)
virtual void scale(const T factor) override
缩放矢量的所有元素。
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices) override
使用特定的自由度索引添加一个值数组到当前矢量中。
Epetra_Vector * vec()
返回原始的 Epetra_Vector 指针。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
virtual numeric_index_type local_size() const override
获取矢量的本地大小。
EpetraVector & operator=(const EpetraVector &)=delete