22 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA 47 libmesh_assert(this->_dof_map);
50 (sparsity_pattern.size());
54 const numeric_index_type n_l = this->_dof_map->n_dofs_on_processor(this->processor_id());
60 libmesh_assert_equal_to (n, m);
61 libmesh_assert_equal_to (n_l, m_l);
67 this->comm().sum (summed_m_l);
68 this->comm().sum (summed_n_l);
70 libmesh_assert_equal_to (m, summed_m_l);
71 libmesh_assert_equal_to (n, summed_n_l);
76 _map =
new Epetra_Map (static_cast<int>(m),
79 Epetra_MpiComm (this->comm().
get()));
81 libmesh_assert_equal_to (static_cast<numeric_index_type>(_map->NumGlobalPoints()), m);
82 libmesh_assert_equal_to (static_cast<numeric_index_type>(_map->MaxAllGID()+1), m);
84 const std::vector<numeric_index_type> & n_nz = this->_dof_map->get_n_nz();
85 const std::vector<numeric_index_type> & n_oz = this->_dof_map->get_n_oz();
88 libmesh_assert_equal_to (n_nz.size(), n_l);
89 libmesh_assert_equal_to (n_oz.size(), n_l);
92 std::vector<int> n_nz_tot; n_nz_tot.reserve(n_nz.size());
95 n_nz_tot.push_back(
std::min(n_nz[i] + n_oz[i], n));
100 _graph =
new Epetra_CrsGraph(Copy, *_map, n_nz_tot.data());
105 _graph->InsertGlobalIndices(_graph->GRID(i),
106 cast_int<numeric_index_type>(sparsity_pattern[i].size()),
107 const_cast<int *>(reinterpret_cast<const int *>(sparsity_pattern[i].
data())));
109 _graph->FillComplete();
119 template <
typename T>
128 if ((m==0) || (n==0))
136 libmesh_assert (!this->_mat);
137 libmesh_assert (!this->_map);
145 libmesh_assert_equal_to (n, m);
146 libmesh_assert_equal_to (n_l, m_l);
152 this->comm().sum (summed_m_l);
153 this->comm().sum (summed_n_l);
155 libmesh_assert_equal_to (m, summed_m_l);
156 libmesh_assert_equal_to (n, summed_n_l);
161 _map =
new Epetra_Map (static_cast<int>(m),
164 Epetra_MpiComm (this->comm().
get()));
166 libmesh_assert_equal_to (static_cast<numeric_index_type>(_map->NumGlobalPoints()), m);
167 libmesh_assert_equal_to (static_cast<numeric_index_type>(_map->MaxAllGID()+1), m);
169 _mat =
new Epetra_FECrsMatrix (Copy, *_map, nnz + noz);
175 template <
typename T>
178 libmesh_assert(this->_dof_map);
189 _mat =
new Epetra_FECrsMatrix (Copy, *_graph);
194 template <
typename T>
204 template <
typename T>
217 template <
typename T>
222 libmesh_assert(_mat);
224 return static_cast<Real>(_mat->NormOne());
229 template <
typename T>
235 libmesh_assert(_mat);
237 return static_cast<Real>(_mat->NormInf());
242 template <
typename T>
244 const std::vector<numeric_index_type> & rows,
245 const std::vector<numeric_index_type> & cols)
252 libmesh_assert_equal_to (rows.size(), m);
253 libmesh_assert_equal_to (cols.size(), n);
265 template <
typename T>
272 _mat->ExtractDiagonalCopy(*(epetra_dest->
vec()));
277 template <
typename T>
287 if (&epetra_dest !=
this)
288 libmesh_not_implemented();
296 template <
typename T>
299 _destroy_mat_on_exit(true),
300 _use_transpose(false)
306 template <
typename T>
310 _destroy_mat_on_exit(false),
311 _use_transpose(false)
320 template <
typename T>
328 template <
typename T>
331 libmesh_assert(_mat);
333 _mat->GlobalAssemble();
338 template <
typename T>
348 template <
typename T>
358 template <
typename T>
362 libmesh_assert(_map);
369 template <
typename T>
373 libmesh_assert(_map);
380 template <
typename T>
388 epetra_i =
static_cast<int>(i),
389 epetra_j = static_cast<int>(j);
391 T epetra_value =
value;
394 _mat->ReplaceGlobalValues (epetra_i, 1, &epetra_value, &epetra_j);
396 _mat->InsertGlobalValues (epetra_i, 1, &epetra_value, &epetra_j);
401 template <
typename T>
409 epetra_i =
static_cast<int>(i),
410 epetra_j = static_cast<int>(j);
412 T epetra_value =
value;
414 _mat->SumIntoGlobalValues (epetra_i, 1, &epetra_value, &epetra_j);
419 template <
typename T>
421 const std::vector<numeric_index_type> & dof_indices)
423 this->add_matrix (dm, dof_indices, dof_indices);
428 template <
typename T>
431 #ifdef LIBMESH_TRILINOS_HAVE_EPETRAEXT 436 libmesh_assert_equal_to (this->m(), X_in.
m());
437 libmesh_assert_equal_to (this->n(), X_in.
n());
440 cast_ptr<const EpetraMatrix<T> *> (&X_in);
442 EpetraExt::MatrixMatrix::Add (*X->_mat,
false, a_in, *_mat, 1.);
444 libmesh_error_msg(
"ERROR: EpetraExt is required for EpetraMatrix::add()!");
451 template <
typename T>
456 libmesh_assert(this->_mat);
457 libmesh_assert (this->_mat->MyGlobalRow(static_cast<int>(i)));
458 libmesh_assert_greater_equal (i, this->row_start());
459 libmesh_assert_less (i, this->row_stop());
466 _mat->ExtractMyRowView (i-this->row_start(),
473 int * index = std::lower_bound (row_indices, row_indices+row_length, j);
475 libmesh_assert_less (*index, row_length);
476 libmesh_assert_equal_to (static_cast<numeric_index_type>(row_indices[*index]), j);
480 return values[*index];
486 template <
typename T>
490 libmesh_assert(this->_mat);
492 return this->_mat->Filled();
496 template <
typename T>
507 template <
typename T>
511 libmesh_assert(_mat);
525 #endif // LIBMESH_TRILINOS_HAVE_EPETRA
virtual numeric_index_type row_stop() const override
virtual void get_transpose(SparseMatrix< T > &dest) const override
bool _destroy_mat_on_exit
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) override
virtual numeric_index_type n() const override
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override
virtual void init() override
dof_id_type numeric_index_type
virtual numeric_index_type m() const override
virtual numeric_index_type m() const =0
void init(triangulateio &t)
std::vector< T > & get_values()
virtual void clear() override
virtual numeric_index_type row_start() const override
virtual void close() override
virtual void print_personal(std::ostream &os=libMesh::out) const override
EpetraMatrix(const Parallel::Communicator &comm)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real l1_norm() const override
virtual Real linfty_norm() const override
virtual void get_diagonal(NumericVector< T > &dest) const override
void swap(Iterator &lhs, Iterator &rhs)
virtual bool closed() const override
virtual void zero() override
int * numeric_trilinos_cast(const numeric_index_type *p)
Epetra_FECrsMatrix * _mat
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override
A matrix object used for finite element assembly and numerics.
void swap(EpetraMatrix< T > &)
long double min(long double a, double b)
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
virtual void update_sparsity_pattern(const SparsityPattern::Graph &) override
virtual numeric_index_type n() const =0