libMesh
petscdmlibmesh.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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 
19 
20 #include "libmesh/petsc_solver_exception.h"
21 
22 #ifdef LIBMESH_HAVE_PETSC
23 
24 #if !PETSC_VERSION_LESS_THAN(3,6,0)
25 # include <petsc/private/petscimpl.h>
26 #else
27 # include <petsc-private/petscimpl.h>
28 #endif
29 
30 #include "libmesh/petscdmlibmesh.h"
31 
32 #undef __FUNCT__
33 #define __FUNCT__ "DMlibMeshSetSystem"
35 {
36  PetscErrorCode (*f)(DM,libMesh::NonlinearImplicitSystem &) = nullptr;
37 
38  PetscFunctionBegin;
39  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
40  LibmeshPetscCallQ(PetscObjectQueryFunction((PetscObject)dm,"DMlibMeshSetSystem_C",&f));
41  if (!f) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP, "DM has no implementation for DMlibMeshSetSystem");
42  LibmeshPetscCallQ((*f)(dm,sys));
43  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
44 }
45 
46 #undef __FUNCT__
47 #define __FUNCT__ "DMlibMeshGetSystem"
49 {
50  PetscErrorCode (*f)(DM,libMesh::NonlinearImplicitSystem *&) = nullptr;
51 
52  PetscFunctionBegin;
53  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
54  LibmeshPetscCallQ(PetscObjectQueryFunction((PetscObject)dm,"DMlibMeshGetSystem_C",&f));
55  if (!f) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP, "DM has no implementation for DMlibMeshGetSystem");
56  LibmeshPetscCallQ((*f)(dm,sys));
57  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
58 }
59 
60 #endif // LIBMESH_HAVE_PETSC
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
PetscErrorCode DMlibMeshSetSystem(DM dm, libMesh::NonlinearImplicitSystem &sys)
Any functional implementation of the DMlibMesh API must compose the following functions with the DM o...
LibmeshPetscCallQ(DMShellGetContext(dm, &ctx))
PetscErrorCode DMlibMeshGetSystem(DM dm, libMesh::NonlinearImplicitSystem *&sys)
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)