libMesh
Loading...
Searching...
No Matches
wrapped_petsc.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18#include "libmesh/libmesh_config.h"
19
20#ifdef LIBMESH_HAVE_PETSC
21
22// libMesh includes
23#include "libmesh/wrapped_petsc.h"
24#include "libmesh/petsc_macro.h"
25#include "libmesh/petsc_solver_exception.h"
26
27// PETSc includes
28#ifdef I
29#define LIBMESH_SAW_I
30#endif
31
32#include <petscksp.h>
33#include <petscvec.h>
34#include <petscis.h>
35#include <petscmat.h>
36#include <petscviewer.h>
37#include <petscpc.h>
38#include <petscsnes.h>
39#include <petscdm.h>
40#include <petscsf.h>
41// PetscSection got its own header file in 3.12, prior to that it was
42// defined in petscis.h
43#if !PETSC_VERSION_LESS_THAN(3, 12, 0)
44#include <petscsection.h>
45#endif
46
47#ifndef LIBMESH_SAW_I
48#undef I // Avoid complex.h contamination
49#endif
50
51namespace libMesh
52{
53// Specializations of the destroy() method for different PETSc classes
54// This could also be macro-ized, but maybe it's not necessary?
55template <>
56void
58{
59 LibmeshPetscCallA(PETSC_COMM_SELF, VecDestroy(&obj));
60}
61
62template <>
63void
65{
66 LibmeshPetscCallA(PETSC_COMM_SELF, KSPDestroy(&obj));
67}
68
69template <>
70void
72{
73 LibmeshPetscCallA(PETSC_COMM_SELF, ISDestroy(&obj));
74}
75
76template <>
77void
79{
80 LibmeshPetscCallA(PETSC_COMM_SELF, MatDestroy(&obj));
81}
82
83template <>
84void
86{
87 LibmeshPetscCallA(PETSC_COMM_SELF, VecScatterDestroy(&obj));
88}
89
90template <>
91void
93{
94 LibmeshPetscCallA(PETSC_COMM_SELF, PetscViewerDestroy(&obj));
95}
96
97template <>
98void
100{
101 LibmeshPetscCallA(PETSC_COMM_SELF, MatNullSpaceDestroy(&obj));
102}
103
104template <>
105void
107{
108 LibmeshPetscCallA(PETSC_COMM_SELF, DMDestroy(&obj));
109}
110
111template <>
112void
114{
115 LibmeshPetscCallA(PETSC_COMM_SELF, MatPartitioningDestroy(&obj));
116}
117
118template <>
119void
121{
122 LibmeshPetscCallA(PETSC_COMM_SELF, SNESDestroy(&obj));
123}
124
125template <>
126void
128{
129 LibmeshPetscCallA(PETSC_COMM_SELF, PCDestroy(&obj));
130}
131
132template <>
133void
135{
136 LibmeshPetscCallA(PETSC_COMM_SELF, PetscSectionDestroy(&obj));
137}
138}
139
140#endif // LIBMESH_HAVE_PETSC
The libMesh namespace provides an interface to certain functionality in the library.
void destroy()
Must be specialized to call the appropriate XXXDestroy() routine in order for a WrappedPetsc<T> objec...