v0.14.0
Classes | Namespaces | Functions
PetscSmartObj.hpp File Reference

Petsc smart obj declarations. More...

Go to the source code of this file.

Classes

struct  MoFEM::SmartPetscObj< OBJ >
 intrusive_ptr for managing petsc objects More...
 

Namespaces

 MoFEM
 implementation of Data Operators for Forces and Sources
 

Functions

template<typename T >
PetscObject MoFEM::getPetscObject (T obj)
 
template<typename OBJ >
void intrusive_ptr_add_ref (OBJ obj)
 It is used by intrusive_ptr to bump reference. More...
 
template<typename OBJ >
void intrusive_ptr_release (OBJ obj)
 It is used by intrusive_ptr to dereference and destroy petsc object. More...
 
template<>
void intrusive_ptr_release< Vec > (Vec obj)
 
template<>
void intrusive_ptr_release< Mat > (Mat obj)
 
template<>
void intrusive_ptr_release< DM > (DM obj)
 
template<>
void intrusive_ptr_release< IS > (IS obj)
 
template<>
void intrusive_ptr_release< AO > (AO obj)
 
template<>
void intrusive_ptr_release< KSP > (KSP obj)
 
template<>
void intrusive_ptr_release< SNES > (SNES obj)
 
template<>
void intrusive_ptr_release< TS > (TS obj)
 
auto MoFEM::createDM (MPI_Comm comm, const std::string dm_type_name)
 Creates smart DM object. More...
 
DEPRECATED auto MoFEM::createSmartDM (MPI_Comm comm, const std::string dm_type_name)
 
MPI_Comm MoFEM::getCommFromPetscObject (PetscObject obj)
 Get the Comm From Petsc Object object. More...
 
auto MoFEM::createGhostVector (MPI_Comm comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[])
 Create smart ghost vector. More...
 
DEPRECATED auto MoFEM::createSmartGhostVector (MPI_Comm comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[])
 
auto MoFEM::createVectorMPI (MPI_Comm comm, PetscInt n, PetscInt N)
 Create MPI Vector. More...
 
DEPRECATED auto MoFEM::createSmartVectorMPI (MPI_Comm comm, PetscInt n, PetscInt N)
 
SmartPetscObj< Vec > MoFEM::vectorDuplicate (Vec vec)
 Create duplicate vector of smart vector. More...
 
DEPRECATED SmartPetscObj< Vec > MoFEM::smartVectorDuplicate (Vec vec)
 
SmartPetscObj< Mat > MoFEM::matDuplicate (Mat mat, MatDuplicateOption op)
 
DEPRECATED SmartPetscObj< Mat > MoFEM::smartMatDuplicate (Mat mat, MatDuplicateOption op)
 
auto MoFEM::createTS (MPI_Comm comm)
 
auto MoFEM::createSNES (MPI_Comm comm)
 
auto MoFEM::createKSP (MPI_Comm comm)
 
auto MoFEM::createPC (MPI_Comm comm)
 
auto MoFEM::createISGeneral (MPI_Comm comm, PetscInt n, const PetscInt idx[], PetscCopyMode mode)
 Creates a data structure for an index set containing a list of integers. More...
 
auto MoFEM::isAllGather (IS is)
 IS All gather. More...
 
auto MoFEM::createAOMappingIS (IS isapp, IS ispetsc)
 Creates an application mapping using two index sets. More...
 
auto MoFEM::createAOMapping (MPI_Comm comm, PetscInt napp, const PetscInt myapp[], const PetscInt mypetsc[])
 Creates an application mapping using two integer arrays. More...
 
auto MoFEM::createVecScatter (Vec x, IS ix, Vec y, IS iy)
 Create a Vec Scatter object. More...
 
auto MoFEM::isDifference (IS is1, IS is2)
 Get ISDifference. More...
 
auto MoFEM::createISLocalToGlobalMapping (IS is)
 
auto MoFEM::matCreateVecs (Mat mat)
 
auto MoFEM::isDuplicate (IS is)
 

Detailed Description

Petsc smart obj declarations.

Definition in file PetscSmartObj.hpp.

Function Documentation

◆ intrusive_ptr_add_ref()

template<typename OBJ >
void intrusive_ptr_add_ref ( OBJ  obj)

It is used by intrusive_ptr to bump reference.

Note
It should not be used directly, it is internally called by intrusive_ptr
Template Parameters
OBJ
Parameters
obj

Definition at line 23 of file PetscSmartObj.hpp.

23  {
24  if (obj) {
25  PetscErrorCode ierr = PetscObjectReference(MoFEM::getPetscObject(obj));
26  CHKERRABORT(PetscObjectComm(MoFEM::getPetscObject(obj)), ierr);
27  }
28 }

◆ intrusive_ptr_release()

template<typename OBJ >
void intrusive_ptr_release ( OBJ  obj)

It is used by intrusive_ptr to dereference and destroy petsc object.

Note
It should not be used directly, it is internally called by intrusive_ptr
Template Parameters
OBJ
Parameters
obj

Definition at line 39 of file PetscSmartObj.hpp.

39  {
40  if (obj) {
41  int cnt = 0;
42  PetscErrorCode ierr =
43  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
44  if (!ierr) {
45  if (cnt) {
46  if (cnt > 1) {
47  ierr = PetscObjectDereference(MoFEM::getPetscObject(obj));
48  } else {
49  ierr = PetscObjectDestroy(reinterpret_cast<PetscObject *>(&obj));
50  }
51  }
52  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
53  CHKERRABORT(comm, ierr);
54  }
55  }
56 }

◆ intrusive_ptr_release< AO >()

template<>
void intrusive_ptr_release< AO > ( AO  obj)

Definition at line 55 of file PetscSmartObj.cpp.

55  {
56  int cnt = 0;
57  PetscErrorCode ierr =
58  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
59  if (!ierr) {
60  if (cnt) {
61  ierr = AODestroy(&obj);
62  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
63  CHKERRABORT(comm, ierr);
64  }
65  }
66 }

◆ intrusive_ptr_release< DM >()

template<>
void intrusive_ptr_release< DM > ( DM  obj)

Definition at line 29 of file PetscSmartObj.cpp.

29  {
30  int cnt = 0;
31  PetscErrorCode ierr =
32  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
33  if (!ierr) {
34  if (cnt) {
35  ierr = DMDestroy(&obj);
36  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
37  CHKERRABORT(comm, ierr);
38  }
39  }
40 }

◆ intrusive_ptr_release< IS >()

template<>
void intrusive_ptr_release< IS > ( IS  obj)

Definition at line 42 of file PetscSmartObj.cpp.

42  {
43  int cnt = 0;
44  PetscErrorCode ierr =
45  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
46  if (!ierr) {
47  if (cnt) {
48  ierr = ISDestroy(&obj);
49  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
50  CHKERRABORT(comm, ierr);
51  }
52  }
53 }

◆ intrusive_ptr_release< KSP >()

template<>
void intrusive_ptr_release< KSP > ( KSP  obj)

Definition at line 68 of file PetscSmartObj.cpp.

68  {
69  int cnt = 0;
70  PetscErrorCode ierr =
71  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
72  if (!ierr) {
73  if (cnt) {
74  ierr = KSPDestroy(&obj);
75  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
76  CHKERRABORT(comm, ierr);
77  }
78  }
79 }

◆ intrusive_ptr_release< Mat >()

template<>
void intrusive_ptr_release< Mat > ( Mat  obj)

Definition at line 16 of file PetscSmartObj.cpp.

16  {
17  int cnt = 0;
18  PetscErrorCode ierr =
19  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
20  if (!ierr) {
21  if (cnt) {
22  ierr = MatDestroy(&obj);
23  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
24  CHKERRABORT(comm, ierr);
25  }
26  }
27 }

◆ intrusive_ptr_release< SNES >()

template<>
void intrusive_ptr_release< SNES > ( SNES  obj)

Definition at line 81 of file PetscSmartObj.cpp.

81  {
82  int cnt = 0;
83  PetscErrorCode ierr =
84  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
85  if (!ierr) {
86  if (cnt) {
87  ierr = SNESDestroy(&obj);
88  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
89  CHKERRABORT(comm, ierr);
90  }
91  }
92 }

◆ intrusive_ptr_release< TS >()

template<>
void intrusive_ptr_release< TS > ( TS  obj)

Definition at line 94 of file PetscSmartObj.cpp.

94  {
95  int cnt = 0;
96  PetscErrorCode ierr =
97  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
98  if (!ierr) {
99  if (cnt) {
100  ierr = TSDestroy(&obj);
101  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
102  CHKERRABORT(comm, ierr);
103  }
104  }
105 }

◆ intrusive_ptr_release< Vec >()

template<>
void intrusive_ptr_release< Vec > ( Vec  obj)

Definition at line 3 of file PetscSmartObj.cpp.

3  {
4  int cnt = 0;
5  PetscErrorCode ierr =
6  PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
7  if (!ierr) {
8  if (cnt) {
9  ierr = VecDestroy(&obj);
10  auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
11  CHKERRABORT(comm, ierr);
12  }
13  }
14 }
MoFEM::getPetscObject
PetscObject getPetscObject(T obj)
Definition: PetscSmartObj.hpp:9
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76