No Matches
Public Types | 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 >:
Collaboration diagram for MoFEM::SmartPetscObj< OBJ >:

Public Types

using Derived = boost::intrusive_ptr< typename std::remove_pointer< OBJ >::type >

Public Member Functions

 SmartPetscObj (std::nullptr_t ptr)
 SmartPetscObj (OBJ o, bool add_ref=false)
 Construct a new Smart Petsc Obj object. More...
 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.

auto createSmartGhostVector(MPI_Comm comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[])
Create smart ghost vector.
intrusive_ptr for managing petsc objects
Template Parameters
EshelbianOperators.cpp, EshelbianPlasticity.cpp, HookeElement.cpp, approx_sphere.cpp, build_large_problem.cpp, child_and_parent.cpp, contact.cpp, dm_build_partitioned_mesh.cpp, eigen_elastic.cpp, elasticity.cpp, ep.cpp, free_surface.cpp, hanging_node_approx.cpp, heat_equation.cpp, higher_derivatives.cpp, level_set.cpp, mixed_poisson.cpp, navier_stokes.cpp, nonlinear_elastic.cpp, operators_tests.cpp, petsc_smart_ptr_objects.cpp, photon_diffusion.cpp, plastic.cpp, prism_polynomial_approximation.cpp, quad_polynomial_approximation.cpp, reaction_diffusion.cpp, remove_entities_from_problem.cpp, remove_entities_from_problem_not_partitioned.cpp, shallow_wave.cpp, simple_contact.cpp, simple_contact_thermal.cpp, test_cache_on_entities.cpp, test_jacobian_of_simple_contact_element.cpp, and wave_equation.cpp.

Definition at line 80 of file PetscSmartObj.hpp.

Member Typedef Documentation

◆ Derived

template<typename OBJ >
using MoFEM::SmartPetscObj< OBJ >::Derived = boost::intrusive_ptr<typename std::remove_pointer<OBJ>::type>

Definition at line 83 of file PetscSmartObj.hpp.

Constructor & Destructor Documentation

◆ SmartPetscObj() [1/2]

template<typename OBJ >
MoFEM::SmartPetscObj< OBJ >::SmartPetscObj ( std::nullptr_t  ptr)

Definition at line 87 of file PetscSmartObj.hpp.

87: SmartPetscObj() {}
SmartPetscObj(std::nullptr_t ptr)

◆ SmartPetscObj() [2/2]

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

Construct a new Smart Petsc Obj object.

If add_red is set to true, you have to destroy OBJ.
add_ref// if false ownership of OBJ is taken by SmartPetscObj

Definition at line 97 of file PetscSmartObj.hpp.

98 : boost::intrusive_ptr<typename std::remove_pointer<OBJ>::type>(o,
99 add_ref) {
100 }
static Index< 'o', 3 > o

Member Function Documentation

◆ operator OBJ()

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

Definition at line 102 of file PetscSmartObj.hpp.

102{ return this->get(); }

◆ operator PetscObject()

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

Definition at line 103 of file PetscSmartObj.hpp.

103 {
104 return reinterpret_cast<PetscObject>(this->get());
105 }

◆ use_count()

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

Definition at line 107 of file PetscSmartObj.hpp.

107 {
108 if (this->get()) {
109 int cnt;
110 ierr = PetscObjectGetReference(getPetscObject(this->get()), &cnt);
111 CHKERRABORT(PetscObjectComm(getPetscObject(this->get())), ierr);
112 return cnt;
113 } else
114 return 0;
115 }
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
PetscObject getPetscObject(T obj)

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