MFEM  v3.3
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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. More...
 
 OperatorHandle (Operator::Type tid)
 Create a OperatorHandle with a specified type id, tid, without allocating the actual matrix. More...
 
template<typename OpType >
 OperatorHandle (OpType *A, bool own_A=true)
 Create an OperatorHandle for the given OpType pointer, A. More...
 
 ~OperatorHandle ()
 
OperatorHandleoperator= (const OperatorHandle &master)
 Shallow copy. The ownership flag of the target is set to false. More...
 
OperatorPtr () const
 Access the underlying Operator pointer. More...
 
Operator::Type Type () const
 Get the currently set operator type id. More...
 
template<typename OpType >
OpType * As () const
 Return the Operator pointer statically cast to a specified OpType. Similar to the method Get(). More...
 
template<typename OpType >
OpType * Is () const
 Return the Operator pointer dynamically cast to a specified OpType. More...
 
template<typename OpType >
void Get (OpType *&A) const
 Return the Operator pointer statically cast to a given OpType. More...
 
bool OwnsOperator () const
 Return true if the OperatorHandle owns the held Operator. More...
 
void SetOperatorOwner (bool own=true)
 Set the ownership flag for the held Operator. More...
 
void Clear ()
 Clear the OperatorHandle, deleting the held Operator (if owned), while leaving the type id unchanged. More...
 
void SetType (Operator::Type tid)
 Invoke Clear() and set a new type id. More...
 
template<typename OpType >
void Reset (OpType *A, bool own_A=true)
 Reset the OperatorHandle to the given OpType pointer, A. More...
 
void MakeSquareBlockDiag (MPI_Comm comm, HYPRE_Int glob_size, HYPRE_Int *row_starts, SparseMatrix *diag)
 Reset the OperatorHandle to hold a parallel square block-diagonal matrix using the currently set type id. More...
 
void MakeRectangularBlockDiag (MPI_Comm comm, HYPRE_Int glob_num_rows, HYPRE_Int glob_num_cols, HYPRE_Int *row_starts, HYPRE_Int *col_starts, SparseMatrix *diag)
 Reset the OperatorHandle to hold a parallel rectangular block-diagonal matrix using the currently set type id. More...
 
void MakePtAP (OperatorHandle &A, OperatorHandle &P)
 Reset the OperatorHandle to hold the product P^t A P. More...
 
void MakeRAP (OperatorHandle &Rt, OperatorHandle &A, OperatorHandle &P)
 Reset the OperatorHandle to hold the product R A P, where R = Rt^t. More...
 
void ConvertFrom (OperatorHandle &A)
 Convert the given OperatorHandle A to the currently set type id. More...
 
template<typename OpType >
void ConvertFrom (OpType *A)
 Convert the given OpType pointer, A, to the currently set type id. More...
 
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. More...
 
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. More...
 

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 34 of file handle.hpp.

Constructor & Destructor Documentation

mfem::OperatorHandle::OperatorHandle ( )
inline

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

Definition at line 56 of file handle.hpp.

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

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

Definition at line 61 of file handle.hpp.

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 71 of file handle.hpp.

mfem::OperatorHandle::~OperatorHandle ( )
inline

Definition at line 73 of file handle.hpp.

Member Function Documentation

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 91 of file handle.hpp.

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

Definition at line 21 of file handle.cpp.

void mfem::OperatorHandle::Clear ( )
inline

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

Definition at line 111 of file handle.hpp.

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 target type id is the same as the input; otherwise it is set to true.

Definition at line 163 of file handle.cpp.

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 173 of file handle.hpp.

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 236 of file handle.cpp.

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 194 of file handle.cpp.

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 101 of file handle.hpp.

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

Return the Operator pointer dynamically cast to a specified OpType.

Definition at line 95 of file handle.hpp.

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 98 of file handle.cpp.

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 130 of file handle.cpp.

void mfem::OperatorHandle::MakeRectangularBlockDiag ( MPI_Comm  comm,
HYPRE_Int  glob_num_rows,
HYPRE_Int  glob_num_cols,
HYPRE_Int *  row_starts,
HYPRE_Int *  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 72 of file handle.cpp.

void mfem::OperatorHandle::MakeSquareBlockDiag ( MPI_Comm  comm,
HYPRE_Int  glob_size,
HYPRE_Int *  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 48 of file handle.cpp.

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

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

Definition at line 76 of file handle.hpp.

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

Return true if the OperatorHandle owns the held Operator.

Definition at line 104 of file handle.hpp.

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

Definition at line 46 of file handle.hpp.

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

Access the underlying Operator pointer.

Definition at line 83 of file handle.hpp.

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 132 of file handle.hpp.

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

Set the ownership flag for the held Operator.

Definition at line 107 of file handle.hpp.

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

Invoke Clear() and set a new type id.

Definition at line 119 of file handle.hpp.

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

Get the currently set operator type id.

Definition at line 86 of file handle.hpp.

Member Data Documentation

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

Definition at line 37 of file handle.hpp.

Operator* mfem::OperatorHandle::oper
protected

Definition at line 39 of file handle.hpp.

bool mfem::OperatorHandle::own_oper
protected

Definition at line 41 of file handle.hpp.

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

Definition at line 40 of file handle.hpp.


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