v0.15.0
Loading...
Searching...
No Matches
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

namespace  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.
 
template<typename OBJ >
void intrusive_ptr_release (OBJ obj)
 It is used by intrusive_ptr to dereference and destroy petsc object.
 
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)
 
template<>
void intrusive_ptr_release< Tao > (Tao obj)
 
auto MoFEM::createDM (MPI_Comm comm, const std::string dm_type_name)
 Creates smart DM object.
 
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.
 
auto MoFEM::createGhostVector (MPI_Comm comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[])
 Create smart ghost vector.
 
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.
 
DEPRECATED auto MoFEM::createSmartVectorMPI (MPI_Comm comm, PetscInt n, PetscInt N)
 
SmartPetscObj< Vec > MoFEM::vectorDuplicate (Vec vec)
 Create duplicate vector of smart vector.
 
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::createTao (MPI_Comm comm)
 
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.
 
auto MoFEM::isAllGather (IS is)
 IS All gather.
 
auto MoFEM::createAOMappingIS (IS isapp, IS ispetsc)
 Creates an application mapping using two index sets.
 
auto MoFEM::createAOMapping (MPI_Comm comm, PetscInt napp, const PetscInt myapp[], const PetscInt mypetsc[])
 Creates an application mapping using two integer arrays.
 
auto MoFEM::createVecScatter (Vec x, IS ix, Vec y, IS iy)
 Create a Vec Scatter object.
 
auto MoFEM::isDifference (IS is1, IS is2)
 Get ISDifference.
 
auto MoFEM::createISLocalToGlobalMapping (IS is)
 
auto MoFEM::matCreateVecs (Mat mat)
 
auto MoFEM::isDuplicate (IS is)
 

Detailed Description

Petsc smart obj declarations.

Author
Anonymous author(s) committing under MIT license

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 24 of file PetscSmartObj.hpp.

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

◆ 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 40 of file PetscSmartObj.hpp.

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

◆ intrusive_ptr_release< AO >()

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

Definition at line 59 of file PetscSmartObj.cpp.

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

◆ intrusive_ptr_release< DM >()

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

Definition at line 33 of file PetscSmartObj.cpp.

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

◆ intrusive_ptr_release< IS >()

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

Definition at line 46 of file PetscSmartObj.cpp.

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

◆ intrusive_ptr_release< KSP >()

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

Definition at line 72 of file PetscSmartObj.cpp.

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

◆ intrusive_ptr_release< Mat >()

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

Definition at line 20 of file PetscSmartObj.cpp.

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

◆ intrusive_ptr_release< SNES >()

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

Definition at line 85 of file PetscSmartObj.cpp.

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

◆ intrusive_ptr_release< Tao >()

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

Definition at line 111 of file PetscSmartObj.cpp.

111 {
112 int cnt = 0;
113 PetscErrorCode ierr =
114 PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
115 if (!ierr) {
116 if (cnt) {
117 ierr = TaoDestroy(&obj);
118 auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
119 CHKERRABORT(comm, ierr);
120 }
121 }
122}

◆ intrusive_ptr_release< TS >()

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

Definition at line 98 of file PetscSmartObj.cpp.

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

◆ intrusive_ptr_release< Vec >()

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

Definition at line 7 of file PetscSmartObj.cpp.

7 {
8 int cnt = 0;
9 PetscErrorCode ierr =
10 PetscObjectGetReference(MoFEM::getPetscObject(obj), &cnt);
11 if (!ierr) {
12 if (cnt) {
13 ierr = VecDestroy(&obj);
14 auto comm = PetscObjectComm(MoFEM::getPetscObject(obj));
15 CHKERRABORT(comm, ierr);
16 }
17 }
18}