Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
feelpetsc.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*-
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2011-11-13
7 
8  Copyright (C) 2011 Université Joseph Fourier (Grenoble I)
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 2.1 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __FeelPETSc_H
30 #define __FeelPETSc_H 1
31 
32 #include <feel/feelcore/feel.hpp>
33 
34 #if defined( FEELPP_HAS_PETSC_H )
35 #include <petsc.h>
36 #include <petscerror.h>
37 #if defined( FEELPP_HAS_SLEPC )
38 # include <slepc.h>
39 #endif /* FEELPP_HAS_SLEPC */
40 
41 #endif /* FEELPP_HAS_PETSC_H */
42 
43 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
44 typedef PetscBool PetscTruth;
45 #else
46 typedef PetscTruth PetscBool;
47 #endif
48 
49 #define PETSC_VERSION_LESS_THAN(major,minor,subminor) \
50  ((PETSC_VERSION_MAJOR < (major) || \
51  (PETSC_VERSION_MAJOR == (major) && (PETSC_VERSION_MINOR < (minor) || \
52  (PETSC_VERSION_MINOR == (minor) && \
53  PETSC_VERSION_SUBMINOR < (subminor))))) ? 1 : 0)
54 
55 #define PETSC_VERSION_GREATER_THAN(major,minor,subminor) \
56  ((PETSC_VERSION_MAJOR > (major) || \
57  (PETSC_VERSION_MAJOR == (major) && (PETSC_VERSION_MINOR > (minor) || \
58  (PETSC_VERSION_MINOR == (minor) && \
59  PETSC_VERSION_SUBMINOR > (subminor))))) ? 1 : 0)
60 
61 #define PETSC_VERSION_GREATER_OR_EQUAL_THAN(major,minor,subminor) \
62  ((PETSC_VERSION_MAJOR > (major) || \
63  (PETSC_VERSION_MAJOR == (major) && (PETSC_VERSION_MINOR >= (minor) || \
64  (PETSC_VERSION_MINOR == (minor) && \
65  PETSC_VERSION_SUBMINOR >= (subminor))))) ? 1 : 0)
66 
67 namespace Feel
68 {
69 namespace PETSc
70 {
71 FEELPP_STRONG_INLINE int VecDestroy( Vec& vec )
72 {
73 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
74  return ::VecDestroy( &vec );
75 #else
76  return ::VecDestroy( vec );
77 #endif
78 }
79 FEELPP_STRONG_INLINE int VecScatterDestroy( VecScatter& scatter )
80 {
81 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
82  return ::VecScatterDestroy( &scatter );
83 #else
84  return ::VecScatterDestroy( scatter );
85 #endif
86 
87 
88 }
89 FEELPP_STRONG_INLINE int MatDestroy( Mat& mat )
90 {
91 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
92  return ::MatDestroy( &mat );
93 #else
94  return ::MatDestroy( mat );
95 #endif
96 }
97 
98 FEELPP_STRONG_INLINE int ISDestroy( IS& is )
99 {
100 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
101  return ::ISDestroy( &is );
102 #else
103  return ::ISDestroy( is );
104 #endif
105 }
106 FEELPP_STRONG_INLINE int KSPDestroy ( KSP& ksp )
107 {
108 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
109  return ::KSPDestroy( &ksp );
110 #else
111  return ::KSPDestroy( ksp );
112 #endif
113 }
114 FEELPP_STRONG_INLINE int PCDestroy ( PC& pc )
115 {
116 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
117  return ::PCDestroy( &pc );
118 #else
119  return ::PCDestroy( pc );
120 #endif
121 }
122 
123 FEELPP_STRONG_INLINE int MatNullSpaceDestroy( MatNullSpace& nullsp )
124 {
125 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
126  return ::MatNullSpaceDestroy( &nullsp );
127 #else
128  return ::MatNullSpaceDestroy( nullsp );
129 #endif
130 }
131 FEELPP_STRONG_INLINE int SNESDestroy ( SNES& snes )
132 {
133 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
134  return ::SNESDestroy( &snes );
135 #else
136  return ::SNESDestroy( snes );
137 #endif
138 }
139 
140 FEELPP_STRONG_INLINE int PetscViewerDestroy ( PetscViewer& petsc_viewer )
141 {
142 #if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
143  return ::PetscViewerDestroy( &petsc_viewer );
144 #else
145  return ::PetscViewerDestroy( petsc_viewer );
146 #endif
147 }
148 
149 
150 } // PETSc
151 } // Feel
152 
153 #endif /* __FeelPETSc_H */

Generated on Fri Oct 25 2013 14:24:10 for Feel++ by doxygen 1.8.4