Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
trilinos_tpetra_vector.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2018 - 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_trilinos_tpetra_vector_h
17#define dealii_trilinos_tpetra_vector_h
18
19
20#include <deal.II/base/config.h>
21
22#ifdef DEAL_II_TRILINOS_WITH_TPETRA
23
27
32
33# include <Teuchos_Comm.hpp>
34# include <Teuchos_OrdinalTraits.hpp>
35# include <Tpetra_Core.hpp>
36# include <Tpetra_Vector.hpp>
37# include <Tpetra_Version.hpp>
38
39# include <memory>
40
42
48template <typename Number>
49struct is_tpetra_type : std::false_type
50{};
51
52# ifdef HAVE_TPETRA_INST_FLOAT
53template <>
54struct is_tpetra_type<float> : std::true_type
55{};
56# endif
57
58# ifdef HAVE_TPETRA_INST_DOUBLE
59template <>
60struct is_tpetra_type<double> : std::true_type
61{};
62# endif
63
64# ifdef DEAL_II_WITH_COMPLEX_VALUES
65# ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
66template <>
67struct is_tpetra_type<std::complex<float>> : std::true_type
68{};
69# endif
70
71# ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
72template <>
73struct is_tpetra_type<std::complex<double>> : std::true_type
74{};
75# endif
76# endif
77
78namespace LinearAlgebra
79{
80 // Forward declaration
81# ifndef DOXYGEN
82 template <typename Number>
83 class ReadWriteVector;
84# endif
85
93 namespace TpetraWrappers
94 {
115 template <typename Number>
116 class Vector : public VectorSpaceVector<Number>, public Subscriptor
117 {
118 public:
119 using value_type = Number;
120
122
127
132 Vector(const Vector &V);
133
140 explicit Vector(const IndexSet &parallel_partitioner,
141 const MPI_Comm communicator);
142
149 void
150 reinit(const IndexSet &parallel_partitioner,
151 const MPI_Comm communicator,
152 const bool omit_zeroing_entries = false);
153
158 virtual void
160 const bool omit_zeroing_entries = false) override;
161
167 Vector &
168 operator=(const Vector &V);
169
174 virtual Vector &
175 operator=(const Number s) override;
176
185 virtual void
188 VectorOperation::values operation,
189 std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
190 communication_pattern = {}) override;
191
195 DEAL_II_DEPRECATED_EARLY
196 virtual void
197 import(const ReadWriteVector<Number> &V,
198 VectorOperation::values operation,
199 std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
200 communication_pattern = {}) override
201 {
202 import_elements(V, operation, communication_pattern);
203 }
204
208 virtual Vector &
209 operator*=(const Number factor) override;
210
214 virtual Vector &
215 operator/=(const Number factor) override;
216
220 virtual Vector &
222
226 virtual Vector &
228
233 virtual Number
234 operator*(const VectorSpaceVector<Number> &V) const override;
235
239 virtual void
240 add(const Number a) override;
241
246 virtual void
247 add(const Number a, const VectorSpaceVector<Number> &V) override;
248
253 virtual void
254 add(const Number a,
256 const Number b,
257 const VectorSpaceVector<Number> &W) override;
258
263 virtual void
264 sadd(const Number s,
265 const Number a,
266 const VectorSpaceVector<Number> &V) override;
267
274 virtual void
275 scale(const VectorSpaceVector<Number> &scaling_factors) override;
276
280 virtual void
281 equ(const Number a, const VectorSpaceVector<Number> &V) override;
282
286 virtual bool
287 all_zero() const override;
288
292 virtual Number
293 mean_value() const override;
294
300 l1_norm() const override;
301
307 l2_norm() const override;
308
314 linfty_norm() const override;
315
338 virtual Number
339 add_and_dot(const Number a,
341 const VectorSpaceVector<Number> &W) override;
346 bool
347 has_ghost_elements() const;
348
353 virtual size_type
354 size() const override;
355
362
368
380 virtual ::IndexSet
381 locally_owned_elements() const override;
382
387 const Tpetra::Vector<Number, int, types::signed_global_dof_index> &
389
394 Tpetra::Vector<Number, int, types::signed_global_dof_index> &
396
400 virtual void
401 print(std::ostream & out,
402 const unsigned int precision = 3,
403 const bool scientific = true,
404 const bool across = true) const override;
405
409 virtual std::size_t
410 memory_consumption() const override;
411
417
424
431 int,
432 << "An error with error number " << arg1
433 << " occurred while calling a Trilinos function");
434
435 private:
441 void
442 create_tpetra_comm_pattern(const IndexSet &source_index_set,
443 const MPI_Comm mpi_comm);
444
448 std::unique_ptr<
449 Tpetra::Vector<Number, int, types::signed_global_dof_index>>
451
456
461 std::shared_ptr<const TpetraWrappers::CommunicationPattern>
463 };
464
465
466 template <typename Number>
467 inline bool
469 {
470 return false;
471 }
472 } // namespace TpetraWrappers
473} // namespace LinearAlgebra
474
475
479template <typename Number>
480struct is_serial_vector<LinearAlgebra::TpetraWrappers::Vector<Number>>
481 : std::false_type
482{};
483
485
486#endif
487
488#endif
void create_tpetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm mpi_comm)
virtual void add(const Number a) override
virtual size_type size() const override
virtual Vector & operator=(const Number s) override
Tpetra::Vector< Number, int, types::signed_global_dof_index > & trilinos_vector()
virtual Number operator*(const VectorSpaceVector< Number > &V) const override
std::shared_ptr< const TpetraWrappers::CommunicationPattern > tpetra_comm_pattern
const Tpetra::Vector< Number, int, types::signed_global_dof_index > & trilinos_vector() const
typename VectorSpaceVector< Number >::size_type size_type
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type l1_norm() const override
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
virtual void add(const Number a, const VectorSpaceVector< Number > &V, const Number b, const VectorSpaceVector< Number > &W) override
virtual void add(const Number a, const VectorSpaceVector< Number > &V) override
virtual Number mean_value() const override
void reinit(const IndexSet &parallel_partitioner, const MPI_Comm communicator, const bool omit_zeroing_entries=false)
virtual void sadd(const Number s, const Number a, const VectorSpaceVector< Number > &V) override
virtual Vector & operator-=(const VectorSpaceVector< Number > &V) override
virtual ::IndexSet locally_owned_elements() const override
virtual void reinit(const VectorSpaceVector< Number > &V, const bool omit_zeroing_entries=false) override
virtual void scale(const VectorSpaceVector< Number > &scaling_factors) override
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type linfty_norm() const override
virtual void equ(const Number a, const VectorSpaceVector< Number > &V) override
std::unique_ptr< Tpetra::Vector< Number, int, types::signed_global_dof_index > > vector
virtual Number add_and_dot(const Number a, const VectorSpaceVector< Number > &V, const VectorSpaceVector< Number > &W) override
virtual LinearAlgebra::VectorSpaceVector< Number >::real_type l2_norm() const override
virtual Vector & operator*=(const Number factor) override
virtual Vector & operator+=(const VectorSpaceVector< Number > &V) override
Vector(const IndexSet &parallel_partitioner, const MPI_Comm communicator)
virtual void import_elements(const ReadWriteVector< Number > &V, VectorOperation::values operation, std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > communication_pattern={}) override
Vector & operator=(const Vector &V)
virtual std::size_t memory_consumption() const override
virtual bool all_zero() const override
virtual Vector & operator/=(const Number factor) override
typename numbers::NumberTraits< Number >::real_type real_type
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
#define DeclException0(Exception0)
Definition exceptions.h:465
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcDifferentParallelPartitioning()
#define DeclException1(Exception1, type1, outsequence)
Definition exceptions.h:510
static ::ExceptionBase & ExcVectorTypeNotCompatible()
STL namespace.