v0.10.0
Public Member Functions | List of all members
MoFEM::SmartPetscObj< OBJ > Struct Template Reference

intrusive_ptr for managing petsc objects More...

#include <include/PetscSmartObj.hpp>

Inheritance diagram for MoFEM::SmartPetscObj< OBJ >:
[legend]

Public Member Functions

 SmartPetscObj ()
 
 SmartPetscObj (OBJ o, bool add_ref=false)
 
 operator OBJ ()
 
 operator PetscObject ()
 
int use_count () const
 

Detailed Description

template<typename OBJ>
struct MoFEM::SmartPetscObj< OBJ >

intrusive_ptr for managing petsc objects

It manages destruction, referencing and dereferencing petsc objects. It is similar how smart_ptr pointers works, but applied for petsc objects like Vec, DM, Mat, etc.

SmartPetscObj<Vec> smart_vec = createSmartGhostVector(...);
auto createSmartGhostVector
Create smart ghost vector.
Template Parameters
OBJ

Definition at line 83 of file PetscSmartObj.hpp.

Constructor & Destructor Documentation

◆ SmartPetscObj() [1/2]

template<typename OBJ >
MoFEM::SmartPetscObj< OBJ >::SmartPetscObj ( )

◆ SmartPetscObj() [2/2]

template<typename OBJ >
MoFEM::SmartPetscObj< OBJ >::SmartPetscObj ( OBJ  o,
bool  add_ref = false 
)

Definition at line 88 of file PetscSmartObj.hpp.

90  add_ref) {
91  }
static Index< 'o', 3 > o

Member Function Documentation

◆ operator OBJ()

template<typename OBJ >
MoFEM::SmartPetscObj< OBJ >::operator OBJ ( )

Definition at line 92 of file PetscSmartObj.hpp.

92 { return this->get(); }

◆ operator PetscObject()

template<typename OBJ >
MoFEM::SmartPetscObj< OBJ >::operator PetscObject ( )
explicit

Definition at line 93 of file PetscSmartObj.hpp.

93  {
94  return reinterpret_cast<PetscObject>(this->get());
95  }

◆ use_count()

template<typename OBJ >
int MoFEM::SmartPetscObj< OBJ >::use_count ( ) const

Definition at line 97 of file PetscSmartObj.hpp.

97  {
98  if (this->get()) {
99  int cnt;
100  ierr = PetscObjectGetReference(getPetscObject(this->get()), &cnt);
101  CHKERRABORT(PetscObjectComm(getPetscObject(this->get())), ierr);
102  return cnt;
103  } else
104  return 0;
105  }
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
PetscObject getPetscObject(T obj)

The documentation for this struct was generated from the following file: