18#ifndef LIBMESH_PETSC_MACRO_H
19#define LIBMESH_PETSC_MACRO_H
22#include "libmesh/libmesh_config.h"
24#ifdef LIBMESH_HAVE_PETSC
26#include <petscversion.h>
30#define PETSC_VERSION_LESS_THAN(major,minor,subminor) \
31 PETSC_VERSION_LT(major,minor,subminor)
33#define PETSC_VERSION_EQUALS(major,minor,subminor) \
34 PETSC_VERSION_EQ(major,minor,subminor)
40#define EXTERN_C_FOR_PETSC_BEGIN
41#define EXTERN_C_FOR_PETSC_END
45#include <libmesh/ignore_warnings.h>
53#include <libmesh/restore_warnings.h>
57#define LibMeshVecDestroy(x) VecDestroy(x)
58#define LibMeshVecScatterDestroy(x) VecScatterDestroy(x)
59#define LibMeshMatDestroy(x) MatDestroy(x)
60#define LibMeshISDestroy(x) ISDestroy(x)
61#define LibMeshKSPDestroy(x) KSPDestroy(x)
62#define LibMeshSNESDestroy(x) SNESDestroy(x)
63#define LibMeshPetscViewerDestroy(x) PetscViewerDestroy(x)
64#define LibMeshPCDestroy(x) PCDestroy(x)
70#define LibMeshVecScatterCreate(xin,ix,yin,iy,newctx) VecScatterCreate(xin,ix,yin,iy,newctx)
71#define ISCreateLibMesh(comm,n,idx,mode,is) ISCreateGeneral((comm),(n),(idx),(mode),(is))
74#if PETSC_VERSION_LESS_THAN(3,8,0)
75# define LibMeshCreateSubMatrix MatGetSubMatrix
77# define LibMeshCreateSubMatrix MatCreateSubMatrix
82#if PETSC_VERSION_LESS_THAN(3,17,0)
83# define LIBMESH_SETERRQ1 SETERRQ1
84# define LIBMESH_SETERRQ2 SETERRQ2
85# define LIBMESH_SETERRQ3 SETERRQ3
87# define LIBMESH_SETERRQ1 SETERRQ
88# define LIBMESH_SETERRQ2 SETERRQ
89# define LIBMESH_SETERRQ3 SETERRQ
94#if PETSC_VERSION_LESS_THAN(3,8,0)
95# define LIBMESH_PETSCINT_FMT "D"
97# define LIBMESH_PETSCINT_FMT PetscInt_FMT
101#if PETSC_VERSION_LESS_THAN(3,19,0)
102# define LIBMESH_PETSC_NULLPTR PETSC_NULL
103# define LIBMESH_PETSC_SUCCESS static_cast<PetscErrorCode>(0)
105# define LIBMESH_PETSC_NULLPTR PETSC_NULLPTR
106# define LIBMESH_PETSC_SUCCESS PETSC_SUCCESS
112#ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
113# include <boost/multiprecision/float128.hpp>
122#if BOOST_VERSION < 107000
124std::ostream &
operator<< (std::ostream & os,
const PetscScalar in)
126 os << (boost::multiprecision::float128(in));
170 return val.backend().value();
176 return &(ptr->backend().value());
180const PetscScalar *
pPS(
const T * ptr)
182 return &(ptr->backend().value());
188 return &(ptr->backend().value());
192const PetscReal *
pPR(
const T * ptr)
194 return &(ptr->backend().value());
209PetscScalar *
pPS(T * ptr)
215const PetscScalar *
pPS(
const T * ptr)
221PetscReal *
pPR(T * ptr)
227const PetscReal *
pPR(
const T * ptr)
237#define PETSC_VERSION_LESS_THAN(major,minor,subminor) 1
238#define PETSC_VERSION_EQUALS(major,minor,revision) 0
242#define PETSC_RELEASE_LESS_THAN(major, minor, subminor) \
243 PETSC_VERSION_LESS_THAN(major, minor, subminor)
244#define PETSC_RELEASE_EQUALS(major, minor, subminor) \
245 PETSC_VERSION_EQUALS(major, minor, subminor)
247#define PETSC_RELEASE_LESS_EQUALS(major, minor, subminor) \
248 (PETSC_RELEASE_LESS_THAN(major, minor, subminor) || PETSC_RELEASE_EQUALS(major, minor, subminor))
250#define PETSC_RELEASE_GREATER_EQUALS(major, minor, subminor) \
251 (0 == PETSC_RELEASE_LESS_THAN(major, minor, subminor))
253#define PETSC_RELEASE_GREATER_THAN(major, minor, subminor) \
254 (0 == PETSC_RELEASE_LESS_EQUALS(major, minor, subminor))
The libMesh namespace provides an interface to certain functionality in the library.
PetscScalar * pPS(T *ptr)
std::ostream & operator<<(std::ostream &os, const PetscScalar in)