deal.II version GIT relicensing-2287-g6548a49e0a 2024-12-20 18:30:00+00:00
\(\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
Public Types | Private Member Functions | Private Attributes | List of all members
TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload Class Reference

#include <deal.II/lac/trilinos_sparse_matrix.h>

Inheritance diagram for TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload:
Inheritance graph
[legend]

Public Types

using VectorType = Epetra_MultiVector
 
using Range = VectorType
 
using Domain = VectorType
 
using size_type = ::types::global_dof_index
 

Public Member Functions

Constructors / destructor
 TrilinosPayload ()
 
 TrilinosPayload (const TrilinosWrappers::SparseMatrix &matrix_exemplar, const TrilinosWrappers::SparseMatrix &matrix)
 
 TrilinosPayload (const TrilinosPayload &payload_exemplar, const TrilinosWrappers::SparseMatrix &matrix)
 
 TrilinosPayload (const TrilinosWrappers::SparseMatrix &matrix_exemplar, const TrilinosWrappers::PreconditionBase &preconditioner)
 
 TrilinosPayload (const TrilinosWrappers::PreconditionBase &preconditioner_exemplar, const TrilinosWrappers::PreconditionBase &preconditioner)
 
 TrilinosPayload (const TrilinosPayload &payload_exemplar, const TrilinosWrappers::PreconditionBase &preconditioner)
 
 TrilinosPayload (const TrilinosPayload &payload)
 
 TrilinosPayload (const TrilinosPayload &first_op, const TrilinosPayload &second_op)
 
virtual ~TrilinosPayload () override=default
 
TrilinosPayload identity_payload () const
 
TrilinosPayload null_payload () const
 
TrilinosPayload transpose_payload () const
 
template<typename Solver , typename Preconditioner >
std::enable_if_t< std::is_base_of_v< TrilinosWrappers::SolverBase, Solver > &&std::is_base_of_v< TrilinosWrappers::PreconditionBase, Preconditioner >, TrilinosPayloadinverse_payload (Solver &, const Preconditioner &) const
 
template<typename Solver , typename Preconditioner >
std::enable_if_t< !(std::is_base_of_v< TrilinosWrappers::SolverBase, Solver > &&std::is_base_of_v< TrilinosWrappers::PreconditionBase, Preconditioner >), TrilinosPayloadinverse_payload (Solver &, const Preconditioner &) const
 
Core Epetra_Operator functionality
virtual bool UseTranspose () const override
 
virtual int SetUseTranspose (bool UseTranspose) override
 
virtual int Apply (const VectorType &X, VectorType &Y) const override
 
virtual int ApplyInverse (const VectorType &Y, VectorType &X) const override
 
Additional Epetra_Operator functionality
virtual const char * Label () const override
 
virtual const Epetra_Comm & Comm () const override
 
virtual const Epetra_Map & OperatorDomainMap () const override
 
virtual const Epetra_Map & OperatorRangeMap () const override
 

Private Member Functions

template<typename EpetraOpType >
 TrilinosPayload (EpetraOpType &op, const bool supports_inverse_operations, const bool use_transpose, const MPI_Comm mpi_communicator, const IndexSet &locally_owned_domain_indices, const IndexSet &locally_owned_range_indices)
 
virtual bool HasNormInf () const override
 
virtual double NormInf () const override
 

Private Attributes

bool use_transpose
 
Epetra_MpiComm communicator
 
Epetra_Map domain_map
 
Epetra_Map range_map
 

LinearOperator functionality

std::function< void(VectorType &, const VectorType &)> vmult
 
std::function< void(VectorType &, const VectorType &)> Tvmult
 
std::function< void(VectorType &, const VectorType &)> inv_vmult
 
std::function< void(VectorType &, const VectorType &)> inv_Tvmult
 
IndexSet locally_owned_domain_indices () const
 
IndexSet locally_owned_range_indices () const
 
MPI_Comm get_mpi_communicator () const
 
void transpose ()
 

Detailed Description

This is an extension class to LinearOperators for Trilinos sparse matrix and preconditioner types. It provides the interface to performing basic operations (vmult and Tvmult) on Trilinos vector types. It fulfills the requirements necessary for wrapping a Trilinos solver, which calls Epetra_Operator functions, as a LinearOperator.

Note
The TrilinosWrappers::SparseMatrix or TrilinosWrappers::PreconditionBase that this payload wraps is passed by reference to the vmult and Tvmult functions. This object is not thread-safe when the transpose flag is set on it or the Trilinos object to which it refers. See the documentation for the TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::SetUseTranspose() function for further details.

Definition at line 2069 of file trilinos_sparse_matrix.h.

Member Typedef Documentation

◆ VectorType

Definition for the internally supported vector type.

Definition at line 2075 of file trilinos_sparse_matrix.h.

◆ Range

Definition for the vector type for the domain space of the operator.

Definition at line 2080 of file trilinos_sparse_matrix.h.

◆ Domain

Definition for the vector type for the range space of the operator.

Definition at line 2085 of file trilinos_sparse_matrix.h.

◆ size_type

Index of the referenced element of the vector.

Definition at line 2090 of file trilinos_sparse_matrix.h.

Constructor & Destructor Documentation

◆ TrilinosPayload() [1/9]

TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( )

Default constructor

Note
By design, the resulting object is inoperable since there is insufficient information with which to construct the domain and range maps.

Definition at line 2325 of file trilinos_sparse_matrix.cc.

◆ TrilinosPayload() [2/9]

TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( const TrilinosWrappers::SparseMatrix matrix_exemplar,
const TrilinosWrappers::SparseMatrix matrix 
)

Constructor for a sparse matrix based on an exemplary matrix

Definition at line 2358 of file trilinos_sparse_matrix.cc.

◆ TrilinosPayload() [3/9]

TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( const TrilinosPayload payload_exemplar,
const TrilinosWrappers::SparseMatrix matrix 
)

Constructor for a sparse matrix based on an exemplary payload

Definition at line 2372 of file trilinos_sparse_matrix.cc.

◆ TrilinosPayload() [4/9]

TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( const TrilinosWrappers::SparseMatrix matrix_exemplar,
const TrilinosWrappers::PreconditionBase preconditioner 
)

Constructor for a preconditioner based on an exemplary matrix

Definition at line 2387 of file trilinos_sparse_matrix.cc.

◆ TrilinosPayload() [5/9]

TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( const TrilinosWrappers::PreconditionBase preconditioner_exemplar,
const TrilinosWrappers::PreconditionBase preconditioner 
)

Constructor for a preconditioner based on an exemplary preconditioner

Definition at line 2400 of file trilinos_sparse_matrix.cc.

◆ TrilinosPayload() [6/9]

TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( const TrilinosPayload payload_exemplar,
const TrilinosWrappers::PreconditionBase preconditioner 
)

Constructor for a preconditioner based on an exemplary payload

Definition at line 2414 of file trilinos_sparse_matrix.cc.

◆ TrilinosPayload() [7/9]

TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( const TrilinosPayload payload)

Default copy constructor

Definition at line 2427 of file trilinos_sparse_matrix.cc.

◆ TrilinosPayload() [8/9]

TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( const TrilinosPayload first_op,
const TrilinosPayload second_op 
)

Composite copy constructor

This is required for PackagedOperations as it sets up the domain and range maps, and composite vmult and Tvmult operations based on the combined operation of both operations

Definition at line 2442 of file trilinos_sparse_matrix.cc.

◆ ~TrilinosPayload()

virtual TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::~TrilinosPayload ( )
overridevirtualdefault

Destructor

◆ TrilinosPayload() [9/9]

template<typename EpetraOpType >
TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::TrilinosPayload ( EpetraOpType &  op,
const bool  supports_inverse_operations,
const bool  use_transpose,
const MPI_Comm  mpi_communicator,
const IndexSet locally_owned_domain_indices,
const IndexSet locally_owned_range_indices 
)
private

A generic constructor.

This constructor allows the payload to be configured from any objects that can be cast to an Epetra operation. The supports_inverse_operations flag indicates that the op can be used to compute inverse operations; preconditioners have such a facility.

Member Function Documentation

◆ identity_payload()

TrilinosPayload TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::identity_payload ( ) const

Return a payload configured for identity operations

Definition at line 2455 of file trilinos_sparse_matrix.cc.

◆ null_payload()

TrilinosPayload TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::null_payload ( ) const

Return a payload configured for null operations

Definition at line 2481 of file trilinos_sparse_matrix.cc.

◆ transpose_payload()

TrilinosPayload TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::transpose_payload ( ) const

Return a payload configured for transpose operations

Definition at line 2521 of file trilinos_sparse_matrix.cc.

◆ inverse_payload() [1/2]

template<typename Solver , typename Preconditioner >
std::enable_if_t< std::is_base_of_v< TrilinosWrappers::SolverBase, Solver > && std::is_base_of_v< TrilinosWrappers::PreconditionBase, Preconditioner >, TrilinosPayload > TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::inverse_payload ( Solver &  ,
const Preconditioner &   
) const

Return a payload configured for inverse operations

Invoking this factory function will configure two additional functions, namely inv_vmult and inv_Tvmult, both of which wrap inverse operations. The vmult and Tvmult operations retain the standard definitions inherited from op.

Note
This function is enabled only if the solver and preconditioner derive from the respective TrilinosWrappers base classes. The C++ compiler will therefore only consider this function if the following criterion are satisfied:
  1. the Solver derives from TrilinosWrappers::SolverBase, and
  2. the Preconditioner derives from TrilinosWrappers::PreconditionBase.

◆ inverse_payload() [2/2]

template<typename Solver , typename Preconditioner >
std::enable_if_t< !(std::is_base_of_v< TrilinosWrappers::SolverBase, Solver > && std::is_base_of_v< TrilinosWrappers::PreconditionBase, Preconditioner >), TrilinosPayload > TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::inverse_payload ( Solver &  ,
const Preconditioner &   
) const

Return a payload configured for inverse operations

Invoking this factory function will configure two additional functions, namely inv_vmult and inv_Tvmult, both of which are disabled because the Solver or Preconditioner are not compatible with Epetra_MultiVector. The vmult and Tvmult operations retain the standard definitions inherited from op.

Note
The C++ compiler will only consider this function if the following criterion are satisfied:
  1. the Solver does not derive from TrilinosWrappers::SolverBase, and
  2. the Preconditioner does not derive from TrilinosWrappers::PreconditionBase.

◆ locally_owned_domain_indices()

IndexSet TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::locally_owned_domain_indices ( ) const

Return an IndexSet that defines the partitioning of the domain space of this matrix, i.e., the partitioning of the vectors this matrix has to be multiplied with / operate on.

Definition at line 2531 of file trilinos_sparse_matrix.cc.

◆ locally_owned_range_indices()

IndexSet TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::locally_owned_range_indices ( ) const

Return an IndexSet that defines the partitioning of the range space of this matrix, i.e., the partitioning of the vectors that result from matrix-vector products.

Definition at line 2539 of file trilinos_sparse_matrix.cc.

◆ get_mpi_communicator()

MPI_Comm TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::get_mpi_communicator ( ) const

Return the MPI communicator object in use with this Payload.

Definition at line 2547 of file trilinos_sparse_matrix.cc.

◆ transpose()

void TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::transpose ( )

Sets an internal flag so that all operations performed by the matrix, i.e., multiplications, are done in transposed order.

Note
This does not reshape the matrix to transposed form directly, so care should be taken when using this flag.

Definition at line 2555 of file trilinos_sparse_matrix.cc.

◆ UseTranspose()

bool TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::UseTranspose ( ) const
overridevirtual

Return the status of the transpose flag for this operator

This overloads the same function from the Trilinos class Epetra_Operator.

Definition at line 2563 of file trilinos_sparse_matrix.cc.

◆ SetUseTranspose()

int TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::SetUseTranspose ( bool  UseTranspose)
overridevirtual

Sets an internal flag so that all operations performed by the matrix, i.e., multiplications, are done in transposed order.

This overloads the same function from the Trilinos class Epetra_Operator.

Note
This does not reshape the matrix to transposed form directly, so care should be taken when using this flag. When the flag is set to true (either here or directly on the underlying Trilinos object itself), this object is no longer thread-safe. In essence, it is not possible ensure that the transposed state of the LinearOperator and the underlying Trilinos object remain synchronized throughout all operations that may occur on different threads simultaneously.

Definition at line 2571 of file trilinos_sparse_matrix.cc.

◆ Apply()

int TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::Apply ( const VectorType X,
VectorType Y 
) const
overridevirtual

Apply the vmult operation on a vector X (of internally defined type VectorType) and store the result in the vector Y.

This overloads the same function from the Trilinos class Epetra_Operator.

Note
The intended operation depends on the status of the internal transpose flag. If this flag is set to true, the result will be the equivalent of performing a Tvmult operation.

Definition at line 2586 of file trilinos_sparse_matrix.cc.

◆ ApplyInverse()

int TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::ApplyInverse ( const VectorType Y,
VectorType X 
) const
overridevirtual

Apply the vmult inverse operation on a vector X (of internally defined type VectorType) and store the result in the vector Y.

In practise, this function is only called from a Trilinos solver if the wrapped object is to act as a preconditioner.

This overloads the same function from the Trilinos class Epetra_Operator.

Note
This function will only be operable if the payload has been initialized with an InverseOperator, or is a wrapper to a preconditioner. If not, then using this function will lead to an error being thrown.
The intended operation depends on the status of the internal transpose flag. If this flag is set to true, the result will be the equivalent of performing a Tvmult operation.

Definition at line 2597 of file trilinos_sparse_matrix.cc.

◆ Label()

const char * TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::Label ( ) const
overridevirtual

Return a label to describe this class.

This overloads the same function from the Trilinos class Epetra_Operator.

Definition at line 2608 of file trilinos_sparse_matrix.cc.

◆ Comm()

const Epetra_Comm & TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::Comm ( ) const
overridevirtual

Return a reference to the underlying MPI communicator for this object.

This overloads the same function from the Trilinos class Epetra_Operator.

Definition at line 2616 of file trilinos_sparse_matrix.cc.

◆ OperatorDomainMap()

const Epetra_Map & TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::OperatorDomainMap ( ) const
overridevirtual

Return the partitioning of the domain space of this matrix, i.e., the partitioning of the vectors this matrix has to be multiplied with.

This overloads the same function from the Trilinos class Epetra_Operator.

Definition at line 2624 of file trilinos_sparse_matrix.cc.

◆ OperatorRangeMap()

const Epetra_Map & TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::OperatorRangeMap ( ) const
overridevirtual

Return the partitioning of the range space of this matrix, i.e., the partitioning of the vectors that are result from matrix-vector products.

This overloads the same function from the Trilinos class Epetra_Operator.

Definition at line 2632 of file trilinos_sparse_matrix.cc.

◆ HasNormInf()

bool TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::HasNormInf ( ) const
overrideprivatevirtual

Return a flag that describes whether this operator can return the computation of the infinity norm. Since in general this is not the case, this always returns a negative result.

This overloads the same function from the Trilinos class Epetra_Operator.

Definition at line 2640 of file trilinos_sparse_matrix.cc.

◆ NormInf()

double TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::NormInf ( ) const
overrideprivatevirtual

Return the infinity norm of this operator. Throws an error since, in general, we cannot compute this value.

This overloads the same function from the Trilinos class Epetra_Operator.

Definition at line 2648 of file trilinos_sparse_matrix.cc.

Member Data Documentation

◆ vmult

std::function<void(VectorType &, const VectorType &)> TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::vmult

The standard matrix-vector operation to be performed by the payload when Apply is called.

Note
This is not called by a LinearOperator, but rather by Trilinos functions that expect this to mimic the action of the LinearOperator.

Definition at line 2271 of file trilinos_sparse_matrix.h.

◆ Tvmult

std::function<void(VectorType &, const VectorType &)> TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::Tvmult

The standard transpose matrix-vector operation to be performed by the payload when Apply is called.

Note
This is not called by a LinearOperator, but rather by Trilinos functions that expect this to mimic the action of the LinearOperator.

Definition at line 2280 of file trilinos_sparse_matrix.h.

◆ inv_vmult

std::function<void(VectorType &, const VectorType &)> TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::inv_vmult

The inverse matrix-vector operation to be performed by the payload when ApplyInverse is called.

Note
This is not called by a LinearOperator, but rather by Trilinos functions that expect this to mimic the action of the InverseOperator.

Definition at line 2290 of file trilinos_sparse_matrix.h.

◆ inv_Tvmult

std::function<void(VectorType &, const VectorType &)> TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::inv_Tvmult

The inverse transpose matrix-vector operation to be performed by the payload when ApplyInverse is called.

Note
This is not called by a LinearOperator, but rather by Trilinos functions that expect this to mimic the action of the InverseOperator.

Definition at line 2300 of file trilinos_sparse_matrix.h.

◆ use_transpose

bool TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::use_transpose
private

A flag recording whether the operator is to perform standard matrix-vector multiplication, or the transpose operation.

Definition at line 2440 of file trilinos_sparse_matrix.h.

◆ communicator

Epetra_MpiComm TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::communicator
private

Internal communication pattern in case the matrix needs to be copied from deal.II format.

Definition at line 2446 of file trilinos_sparse_matrix.h.

◆ domain_map

Epetra_Map TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::domain_map
private

Epetra_Map that sets the partitioning of the domain space of this operator.

Definition at line 2452 of file trilinos_sparse_matrix.h.

◆ range_map

Epetra_Map TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload::range_map
private

Epetra_Map that sets the partitioning of the range space of this operator.

Definition at line 2458 of file trilinos_sparse_matrix.h.


The documentation for this class was generated from the following files: