MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
mfem::OperatorHandle Class Reference

Pointer to an Operator of a specified type. More...

#include <handle.hpp>

Collaboration diagram for mfem::OperatorHandle:
[legend]

Public Member Functions

 OperatorHandle ()
 Create an OperatorHandle with type id = Operator::MFEM_SPARSEMAT without allocating the actual matrix.
 
 OperatorHandle (Operator::Type tid)
 Create a OperatorHandle with a specified type id, tid, without allocating the actual matrix.
 
template<typename OpType >
 OperatorHandle (OpType *A, bool own_A=true)
 Create an OperatorHandle for the given OpType pointer, A.
 
 OperatorHandle (const OperatorHandle &other)
 Shallow copy. The ownership flag of the target is set to false.
 
 ~OperatorHandle ()
 
OperatorHandleoperator= (const OperatorHandle &master)
 Shallow copy. The ownership flag of the target is set to false.
 
OperatorPtr () const
 Access the underlying Operator pointer.
 
Operatoroperator-> () const
 Support the use of -> to call methods of the underlying Operator.
 
Operatoroperator* ()
 Access the underlying Operator.
 
const Operatoroperator* () const
 Access the underlying Operator.
 
Operator::Type Type () const
 Get the currently set operator type id.
 
template<typename OpType >
OpType * As () const
 Return the Operator pointer statically cast to a specified OpType. Similar to the method Get().
 
template<typename OpType >
OpType * Is () const
 Return the Operator pointer dynamically cast to a specified OpType.
 
template<typename OpType >
void Get (OpType *&A) const
 Return the Operator pointer statically cast to a given OpType.
 
bool OwnsOperator () const
 Return true if the OperatorHandle owns the held Operator.
 
void SetOperatorOwner (bool own=true)
 Set the ownership flag for the held Operator.
 
void Clear ()
 Clear the OperatorHandle, deleting the held Operator (if owned), while leaving the type id unchanged.
 
void SetType (Operator::Type tid)
 Invoke Clear() and set a new type id.
 
template<typename OpType >
void Reset (OpType *A, bool own_A=true)
 Reset the OperatorHandle to the given OpType pointer, A.
 
void MakeSquareBlockDiag (MPI_Comm comm, HYPRE_BigInt glob_size, HYPRE_BigInt *row_starts, SparseMatrix *diag)
 Reset the OperatorHandle to hold a parallel square block-diagonal matrix using the currently set type id.
 
void MakeRectangularBlockDiag (MPI_Comm comm, HYPRE_BigInt glob_num_rows, HYPRE_BigInt glob_num_cols, HYPRE_BigInt *row_starts, HYPRE_BigInt *col_starts, SparseMatrix *diag)
 Reset the OperatorHandle to hold a parallel rectangular block-diagonal matrix using the currently set type id.
 
void MakePtAP (OperatorHandle &A, OperatorHandle &P)
 Reset the OperatorHandle to hold the product P^t A P.
 
void MakeRAP (OperatorHandle &Rt, OperatorHandle &A, OperatorHandle &P)
 Reset the OperatorHandle to hold the product R A P, where R = Rt^t.
 
void ConvertFrom (OperatorHandle &A)
 Convert the given OperatorHandle A to the currently set type id.
 
template<typename OpType >
void ConvertFrom (OpType *A)
 Convert the given OpType pointer, A, to the currently set type id.
 
void EliminateRowsCols (OperatorHandle &A, const Array< int > &ess_dof_list)
 Reset the OperatorHandle to be the eliminated part of A after elimination of the essential dofs ess_dof_list.
 
void EliminateRows (const Array< int > &ess_dof_list)
 Eliminate the rows corresponding to the essential dofs ess_dof_list.
 
void EliminateCols (const Array< int > &ess_dof_list)
 Eliminate columns corresponding to the essential dofs ess_dof_list.
 
void EliminateBC (const OperatorHandle &A_e, const Array< int > &ess_dof_list, const Vector &X, Vector &B) const
 Eliminate essential dofs from the solution X into the r.h.s. B.
 

Protected Member Functions

Operator::Type CheckType (Operator::Type tid)
 
template<typename OpType >
void pSet (OpType *A, bool own_A=true)
 

Protected Attributes

Operatoroper
 
Operator::Type type_id
 
bool own_oper
 

Static Protected Attributes

static const char not_supported_msg []
 

Detailed Description

Pointer to an Operator of a specified type.

This class provides a common interface for global, matrix-type operators to be used in bilinear forms, gradients of nonlinear forms, static condensation, hybridization, etc. The following backends are currently supported:

Definition at line 33 of file handle.hpp.

Constructor & Destructor Documentation

◆ OperatorHandle() [1/4]

mfem::OperatorHandle::OperatorHandle ( )
inline

Create an OperatorHandle with type id = Operator::MFEM_SPARSEMAT without allocating the actual matrix.

Definition at line 55 of file handle.hpp.

◆ OperatorHandle() [2/4]

mfem::OperatorHandle::OperatorHandle ( Operator::Type  tid)
inlineexplicit

Create a OperatorHandle with a specified type id, tid, without allocating the actual matrix.

Definition at line 60 of file handle.hpp.

◆ OperatorHandle() [3/4]

template<typename OpType >
mfem::OperatorHandle::OperatorHandle ( OpType *  A,
bool  own_A = true 
)
inlineexplicit

Create an OperatorHandle for the given OpType pointer, A.

Presently, OpType can be SparseMatrix, HypreParMatrix, or PetscParMatrix.

The operator ownership flag is set to the value of own_A.

It is expected that A points to a valid object.

Definition at line 70 of file handle.hpp.

◆ OperatorHandle() [4/4]

mfem::OperatorHandle::OperatorHandle ( const OperatorHandle other)
inline

Shallow copy. The ownership flag of the target is set to false.

Definition at line 73 of file handle.hpp.

◆ ~OperatorHandle()

mfem::OperatorHandle::~OperatorHandle ( )
inline

Definition at line 77 of file handle.hpp.

Member Function Documentation

◆ As()

template<typename OpType >
OpType * mfem::OperatorHandle::As ( ) const
inline

Return the Operator pointer statically cast to a specified OpType. Similar to the method Get().

Definition at line 104 of file handle.hpp.

◆ CheckType()

Operator::Type mfem::OperatorHandle::CheckType ( Operator::Type  tid)
protected

Definition at line 32 of file handle.cpp.

◆ Clear()

void mfem::OperatorHandle::Clear ( )
inline

Clear the OperatorHandle, deleting the held Operator (if owned), while leaving the type id unchanged.

Definition at line 124 of file handle.hpp.

◆ ConvertFrom() [1/2]

void mfem::OperatorHandle::ConvertFrom ( OperatorHandle A)

Convert the given OperatorHandle A to the currently set type id.

The operator ownership flag is set to false if the object held by A will be held by this object as well, e.g. when the source and destination types are the same; otherwise it is set to true.

Definition at line 200 of file handle.cpp.

◆ ConvertFrom() [2/2]

template<typename OpType >
void mfem::OperatorHandle::ConvertFrom ( OpType *  A)
inline

Convert the given OpType pointer, A, to the currently set type id.

This method creates a temporary OperatorHandle for A and invokes ConvertFrom(OperatorHandle &) with it.

Definition at line 187 of file handle.hpp.

◆ EliminateBC()

void mfem::OperatorHandle::EliminateBC ( const OperatorHandle A_e,
const Array< int > &  ess_dof_list,
const Vector X,
Vector B 
) const

Eliminate essential dofs from the solution X into the r.h.s. B.

The argument A_e is expected to be the result of the method EliminateRowsCols().

Definition at line 340 of file handle.cpp.

◆ EliminateCols()

void mfem::OperatorHandle::EliminateCols ( const Array< int > &  ess_dof_list)

Eliminate columns corresponding to the essential dofs ess_dof_list.

Definition at line 321 of file handle.cpp.

◆ EliminateRows()

void mfem::OperatorHandle::EliminateRows ( const Array< int > &  ess_dof_list)

Eliminate the rows corresponding to the essential dofs ess_dof_list.

Definition at line 303 of file handle.cpp.

◆ EliminateRowsCols()

void mfem::OperatorHandle::EliminateRowsCols ( OperatorHandle A,
const Array< int > &  ess_dof_list 
)

Reset the OperatorHandle to be the eliminated part of A after elimination of the essential dofs ess_dof_list.

Definition at line 252 of file handle.cpp.

◆ Get()

template<typename OpType >
void mfem::OperatorHandle::Get ( OpType *&  A) const
inline

Return the Operator pointer statically cast to a given OpType.

Similar to the method As(), however the template type OpType can be derived automatically from the argument A.

Definition at line 114 of file handle.hpp.

◆ Is()

template<typename OpType >
OpType * mfem::OperatorHandle::Is ( ) const
inline

Return the Operator pointer dynamically cast to a specified OpType.

Definition at line 108 of file handle.hpp.

◆ MakePtAP()

void mfem::OperatorHandle::MakePtAP ( OperatorHandle A,
OperatorHandle P 
)

Reset the OperatorHandle to hold the product P^t A P.

The type id of the result is determined by that of A and P. The operator ownership flag is set to true.

Definition at line 123 of file handle.cpp.

◆ MakeRAP()

void mfem::OperatorHandle::MakeRAP ( OperatorHandle Rt,
OperatorHandle A,
OperatorHandle P 
)

Reset the OperatorHandle to hold the product R A P, where R = Rt^t.

The type id of the result is determined by that of Rt, A, and P. The operator ownership flag is set to true.

Definition at line 161 of file handle.cpp.

◆ MakeRectangularBlockDiag()

void mfem::OperatorHandle::MakeRectangularBlockDiag ( MPI_Comm  comm,
HYPRE_BigInt  glob_num_rows,
HYPRE_BigInt  glob_num_cols,
HYPRE_BigInt row_starts,
HYPRE_BigInt col_starts,
SparseMatrix diag 
)

Reset the OperatorHandle to hold a parallel rectangular block-diagonal matrix using the currently set type id.

The operator ownership flag is set to true.

Definition at line 90 of file handle.cpp.

◆ MakeSquareBlockDiag()

void mfem::OperatorHandle::MakeSquareBlockDiag ( MPI_Comm  comm,
HYPRE_BigInt  glob_size,
HYPRE_BigInt row_starts,
SparseMatrix diag 
)

Reset the OperatorHandle to hold a parallel square block-diagonal matrix using the currently set type id.

The operator ownership flag is set to true.

Definition at line 60 of file handle.cpp.

◆ operator*() [1/2]

Operator & mfem::OperatorHandle::operator* ( )
inline

Access the underlying Operator.

Definition at line 93 of file handle.hpp.

◆ operator*() [2/2]

const Operator & mfem::OperatorHandle::operator* ( ) const
inline

Access the underlying Operator.

Definition at line 96 of file handle.hpp.

◆ operator->()

Operator * mfem::OperatorHandle::operator-> ( ) const
inline

Support the use of -> to call methods of the underlying Operator.

Definition at line 90 of file handle.hpp.

◆ operator=()

OperatorHandle & mfem::OperatorHandle::operator= ( const OperatorHandle master)
inline

Shallow copy. The ownership flag of the target is set to false.

Definition at line 80 of file handle.hpp.

◆ OwnsOperator()

bool mfem::OperatorHandle::OwnsOperator ( ) const
inline

Return true if the OperatorHandle owns the held Operator.

Definition at line 117 of file handle.hpp.

◆ pSet()

template<typename OpType >
void mfem::OperatorHandle::pSet ( OpType *  A,
bool  own_A = true 
)
inlineprotected

Definition at line 45 of file handle.hpp.

◆ Ptr()

Operator * mfem::OperatorHandle::Ptr ( ) const
inline

Access the underlying Operator pointer.

Definition at line 87 of file handle.hpp.

◆ Reset()

template<typename OpType >
void mfem::OperatorHandle::Reset ( OpType *  A,
bool  own_A = true 
)
inline

Reset the OperatorHandle to the given OpType pointer, A.

Presently, OpType can be SparseMatrix, HypreParMatrix, or PetscParMatrix.

The operator ownership flag is set to the value of own_A.

It is expected that A points to a valid object.

Definition at line 145 of file handle.hpp.

◆ SetOperatorOwner()

void mfem::OperatorHandle::SetOperatorOwner ( bool  own = true)
inline

Set the ownership flag for the held Operator.

Definition at line 120 of file handle.hpp.

◆ SetType()

void mfem::OperatorHandle::SetType ( Operator::Type  tid)
inline

Invoke Clear() and set a new type id.

Definition at line 132 of file handle.hpp.

◆ Type()

Operator::Type mfem::OperatorHandle::Type ( ) const
inline

Get the currently set operator type id.

Definition at line 99 of file handle.hpp.

Member Data Documentation

◆ not_supported_msg

const char mfem::OperatorHandle::not_supported_msg
staticprotected
Initial value:
=
"Operator::Type is not supported: type_id = "

Definition at line 36 of file handle.hpp.

◆ oper

Operator* mfem::OperatorHandle::oper
protected

Definition at line 38 of file handle.hpp.

◆ own_oper

bool mfem::OperatorHandle::own_oper
protected

Definition at line 40 of file handle.hpp.

◆ type_id

Operator::Type mfem::OperatorHandle::type_id
protected

Definition at line 39 of file handle.hpp.


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