7#ifndef __PETSCSPARTOBJ_HPP__
8#define __PETSCSPARTOBJ_HPP__
12 return reinterpret_cast<PetscObject
>(obj);
48 ierr = PetscObjectDestroy(
reinterpret_cast<PetscObject *
>(&obj));
52 CHKERRABORT(comm,
ierr);
79template <
typename OBJ>
81 :
public boost::intrusive_ptr<typename std::remove_pointer<OBJ>::type> {
83 using Derived = boost::intrusive_ptr<typename std::remove_pointer<OBJ>::type>;
85 using Derived::Derived;
98 : boost::intrusive_ptr<typename
std::remove_pointer<OBJ>::type>(
o,
102 operator OBJ() {
return this->get(); }
103 explicit operator PetscObject() {
104 return reinterpret_cast<PetscObject
>(this->get());
155 "Failed to get comm from PETSc object");
172 PetscInt nghost,
const PetscInt ghosts[]) {
175 "Failed to create ghosted Vec");
219 "Failed to duplicate Mat");
224 MatDuplicateOption op) {
228 "Failed to duplicate Mat");
272 PetscCopyMode mode) {
292 "Failed to create AO");
309 const PetscInt myapp[],
const PetscInt mypetsc[]) {
void intrusive_ptr_release< TS >(TS obj)
void intrusive_ptr_release< AO >(AO obj)
void intrusive_ptr_release< KSP >(KSP obj)
void intrusive_ptr_release< Vec >(Vec obj)
void intrusive_ptr_release< DM >(DM obj)
void intrusive_ptr_release< IS >(IS obj)
void intrusive_ptr_add_ref(OBJ obj)
It is used by intrusive_ptr to bump reference.
void intrusive_ptr_release< SNES >(SNES obj)
void intrusive_ptr_release< Mat >(Mat obj)
void intrusive_ptr_release(OBJ obj)
It is used by intrusive_ptr to dereference and destroy petsc object.
static PetscErrorCode ierr
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
FTensor::Index< 'n', SPACE_DIM > n
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
implementation of Data Operators for Forces and Sources
SmartPetscObj< Mat > smartMatDuplicate(Mat &mat, MatDuplicateOption op)
MPI_Comm getCommFromPetscObject(PetscObject obj)
Get the Comm From Petsc Object object.
auto createKSP(MPI_Comm comm)
auto createSmartVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
auto createSNES(MPI_Comm comm)
auto createSmartDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
auto 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 createAOMapping(MPI_Comm comm, PetscInt napp, const PetscInt myapp[], const PetscInt mypetsc[])
Creates an application mapping using two integer arrays.
SmartPetscObj< Vec > smartVectorDuplicate(SmartPetscObj< Vec > &vec)
Create duplicate vector of smart vector.
auto createTS(MPI_Comm comm)
auto createPC(MPI_Comm comm)
auto createSmartGhostVector(MPI_Comm comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[])
Create smart ghost vector.
auto createAOMappingIS(IS isapp, IS ispetsc)
Creates an application mapping using two index sets.
PetscObject getPetscObject(T obj)
intrusive_ptr for managing petsc objects
SmartPetscObj(std::nullptr_t ptr)
SmartPetscObj(OBJ o, bool add_ref=false)
Construct a new Smart Petsc Obj object.
boost::intrusive_ptr< typename std::remove_pointer< OBJ >::type > Derived