DUNE-FEM (unstable)

petsccommon.hh
1#ifndef DUNE_FEM_PETSCCOMMON_HH
2#define DUNE_FEM_PETSCCOMMON_HH
3
4/*
5 * This file should be the first include in every dune-fem-petsc related header
6 * It contains some common code in order to deal with PETSc in a consistent, object oriented
7 * fashion
8 */
9
10#include <string>
11#include <iostream>
12#include <iomanip>
13
17
18#if HAVE_PETSC
19
20 /*
21 * This turns off PETSc logging of MPI calls. If it is on, PETSc redifines MPI functions as macros,
22 * which breaks some code. E.g. MPI_Allreduce is redefined
23 */
24#define PETSC_HAVE_BROKEN_RECURSIVE_MACRO
25
26#include <petsc.h>
27
28// newer versions of PETSc use PETSC_NULLPTR instread of PETSC_NULL
29#ifndef PETSC_NULLPTR
30#define PETSC_NULLPTR PETSC_NULL
31#endif
32
33namespace Dune
34{
35
36 namespace Petsc
37 {
38 // PETSc #defines VecType to be char* - this can cause problems with e.g. ALUGrid 1.50. So we #undef
39 // it here and use a typedef instead. The following trick is really nasty, but conforming to the standard and
40 // - most important of all - working :)
41 typedef VecType
42#undef VecType
43 VecType;
44
45 /*
46 * exceptions
47 */
48 class Exception : public Dune::Exception {};
49
50 /*
51 * types
52 */
53 typedef ::PetscErrorCode ErrorCode;
54
55
56
57 /* The following 2 methods are needed to make the code work with the CHKERRQ
58 * macro (which we want to use because it can print useful diagnostic output in
59 * case of errors)
60 */
61 inline static ErrorCode ErrorCheckHelper ( ErrorCode errorCode ) { CHKERRQ( errorCode ); return 0; }
62
63 inline ErrorCode ErrorHandler ( MPI_Comm comm, int line, const char *function, const char *file,
64#if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 5
65 const char *dir,
66#endif
67 ErrorCode errorCode, PetscErrorType p, const char *message, void *context )
68 {
69 std::ostringstream msgout;
70 msgout << "PETSc Error in the PETSc function '" << function << "' at " << file << ":" << line << ":";
71
72 const char *text;
73 PetscErrorMessage( errorCode, &text, PETSC_NULLPTR );
74 if( text )
75 msgout << " '" << text << "'. Error message: '" << message << "'";
76 else
77 msgout << " Unable to retrieve error text";
78
79 DUNE_THROW( Exception, msgout.str() );
80
81 return errorCode;
82 }
83
84 inline static void ErrorCheck ( ErrorCode errorCode )
85 {
86 if( errorCode )
87 {
88 DUNE_THROW( Exception, "Generic PETSC exception" );
89 }
90 }
91
92 /*
93 * This should be called right after the initialization of the MPI manager. It expects the same arguments
94 * as PetscInitialize
95 */
96 inline bool initialize( const bool verbose, int &argc, char **&args, const char file[] = 0 , const char help[] = 0, bool ownHandler = true )
97 {
98 bool wasInitializedHere = false ;
99 PetscBool petscInitialized = PETSC_FALSE;
100
101 // check whether PETSc had been initialized elsewhere
102 ::PetscInitialized( &petscInitialized );
103
104 if( ! petscInitialized )
105 {
106 ::PetscInitialize( &argc, &args, file, help );
107 wasInitializedHere = true;
108 }
109
110 if( ownHandler )
111 {
112 // set up our error handler
113 if( verbose )
114 {
115 dverb << "INFORMATION: Setting up an own error handler for PETSc errors. If you want the default PETSc handler,\n"
116 << "INFORMATION: set the last argument of Dune::Petsc::initialize(...) to 'false'.\n";
117 }
118 ::PetscPushErrorHandler( &ErrorHandler, 0 );
119 }
120 return wasInitializedHere;
121 }
122
123 /*
124 * This should be called just before the termination of the program.
125 */
126 inline void finalize ()
127 {
128 // TODO: test here if we are using our own handler
129 ::PetscPopErrorHandler();
130 PetscBool finalized = PETSC_FALSE;
131 ErrorCheck( ::PetscFinalized( &finalized ) );
132
133 if( ! finalized )
134 {
135 ::PetscFinalize();
136 }
137 }
138
139 template <class Comm>
140 inline auto castToPetscComm( const Comm& comm )
141 {
142 // this is needed because Dune::No_Comm or
143 // Dune::Communication< No_Comm > does not cast into MPI_Comm
144 if constexpr ( std::is_same< Dune::No_Comm, Comm > :: value ||
145 std::is_same< Dune::Communication< No_Comm >, Comm >::value )
146 {
147 return PETSC_COMM_SELF;
148 }
149 else
150 {
151 return comm;
152 }
153 }
154
155 /*
156 * ==================================================
157 * These are simple mappings to PETSc's C-routines. (Maybe some of them are not needed...).
158 *
159 * The PETSC_VERSION_... customizations are not very well tested yet
160 */
161 template <class Comm>
162 inline static void KSPCreate ( const Comm& comm, KSP *inksp )
163 {
164 ErrorCheck( ::KSPCreate( castToPetscComm( comm ), inksp ) );
165 }
166
167 inline static void KSPDestroy ( KSP *ksp ) {
168#if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
169 ErrorCheck( ::KSPDestroy( *ksp ) );
170#else
171 ErrorCheck( ::KSPDestroy( ksp ) );
172#endif // PETSC_PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
173 }
174 inline static void KSPGetPC ( KSP ksp, PC *pc ) { ErrorCheck( ::KSPGetPC( ksp, pc ) ); }
175 inline static void KSPSetFromOptions ( KSP ksp ) { ErrorCheck( ::KSPSetFromOptions( ksp ) ); }
176 inline static void KSPSetUp ( KSP ksp ) { ErrorCheck( ::KSPSetUp( ksp ) ); }
177 inline static void KSPSetType ( KSP ksp, const KSPType type ) { ErrorCheck( ::KSPSetType( ksp, type ) ); }
178 inline static void KSPGMRESSetRestart ( KSP ksp, PetscInt restart ) { ErrorCheck( ::KSPGMRESSetRestart( ksp, restart ) ); }
179
180 template <class Comm>
181 inline static void KSPView ( const Comm& comm,
182 KSP ksp,
183 PetscViewer viewer )
184 {
185 ErrorCheck( ::KSPView( ksp, viewer ) );
186 }
187
188 template <class Comm>
189 inline static void KSPView ( const Comm& comm,
190 KSP ksp )
191 {
192 KSPView( comm, ksp, PETSC_VIEWER_STDOUT_( castToPetscComm(comm) ) );
193 }
194
195 inline static void KSPMonitorSet (KSP ksp, PetscErrorCode (*monitor)(KSP,PetscInt,PetscReal,void*),
196#if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
197 void *mctx,PetscErrorCode (*monitordestroy)(void*)
198#elif PETSC_VERSION_MAJOR >=3 && PETSC_VERSION_MINOR < 25 // PETSc 3.2 to 3.24
199 void *mctx,PetscErrorCode (*monitordestroy)(void**)
200#else // PETSc 3.25 and beyond
201 PetscCtx mctx, PetscCtxDestroyFn *monitordestroy
202#endif
203 )
204 {
205 ErrorCheck( ::KSPMonitorSet( ksp, monitor, mctx, monitordestroy ) );
206 }
207 inline static void KSPGetIterationNumber( KSP ksp, PetscInt* its )
208 { ErrorCheck( ::KSPGetIterationNumber( ksp, its ) ); }
209 inline static void KSPGetConvergedReason(KSP ksp, KSPConvergedReason *reason)
210 { ErrorCheck( ::KSPGetConvergedReason( ksp, reason ) ); }
211
212
213#if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 5
214 inline static void KSPSetOperators (KSP ksp, Mat Amat, Mat Pmat, MatStructure flag ) { ErrorCheck( ::KSPSetOperators( ksp, Amat, Pmat, flag ) ); }
215#else
216 inline static void KSPSetOperators (KSP ksp, Mat Amat, Mat Pmat ) { ErrorCheck( ::KSPSetOperators( ksp, Amat, Pmat ) ); }
217#endif
218 inline static void KSPSetTolerances ( KSP ksp, PetscReal rtol, PetscReal abstol, PetscReal dtol, PetscInt maxits )
219 { ErrorCheck( ::KSPSetTolerances( ksp, rtol, abstol, dtol, maxits ) ); }
220 inline static void KSPSetInitialGuessNonzero( KSP ksp, PetscBool flg ) { ErrorCheck( ::KSPSetInitialGuessNonzero( ksp, flg ) ); };
221 inline static void KSPSetInitialGuessKnoll( KSP ksp, PetscBool flg ) { ErrorCheck( ::KSPSetInitialGuessKnoll( ksp, flg ) ); };
222 inline static void KSPSolve ( KSP ksp, Vec b, Vec x ) { ErrorCheck( ::KSPSolve( ksp, b, x ) ); }
223 inline static void KSPSetPC ( KSP ksp, PC pc ) { ErrorCheck( ::KSPSetPC( ksp, pc ) ); }
224
225 // preconditioning
226 template <class Comm>
227 inline static void PCCreate ( const Comm& comm, PC* pc)
228 {
229 ErrorCheck( ::PCCreate( castToPetscComm( comm ), pc ) );
230 }
231
232 inline static void PCDestroy ( PC* pc) {
233#if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
234 ErrorCheck( ::PCDestroy( *pc ) );
235#else
236 ErrorCheck( ::PCDestroy( pc ) );
237#endif
238 }
239 inline static void PCSetType ( PC pc, const PCType type ) { ErrorCheck( ::PCSetType( pc, type ) ); }
240 inline static void PCSetFromOptions ( PC pc ) { ErrorCheck( ::PCSetFromOptions( pc ) ); }
241 inline static void PCSetUp ( PC pc ) { ErrorCheck( ::PCSetUp( pc ) ); }
242 inline static void PCFactorSetLevels( PC pc, PetscInt level ) { ErrorCheck( ::PCFactorSetLevels( pc, level ) ); }
243 inline static void PCSORSetOmega( PC pc, PetscReal omega ) { ErrorCheck( ::PCSORSetOmega( pc, omega ) ); }
244 inline static void PCSORSetSymmetric( PC pc, MatSORType flag ) { ErrorCheck( ::PCSORSetSymmetric( pc, flag ) ); }
245#if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 9
246 inline static void PCFactorSetMatSolverPackage( PC pc, const MatSolverPackage type )
247 {
248 ErrorCheck( ::PCFactorSetMatSolverPackage( pc, type ) );
249 }
250#else
251 inline static void PCFactorSetMatSolverPackage( PC pc, const MatSolverType type )
252 {
253 ErrorCheck( ::PCFactorSetMatSolverType( pc, type ) );
254 }
255#endif
256 inline static void PCHYPRESetType( PC pc, const char* type )
257 {
258 ErrorCheck( ::PCHYPRESetType( pc, type ) );
259 }
260
261 // matrix routines
262 inline static void MatAssemblyBegin ( Mat mat, MatAssemblyType type ) { ErrorCheck( ::MatAssemblyBegin( mat, type ) ); }
263 inline static void MatAssemblyEnd ( Mat mat, MatAssemblyType type ) { ErrorCheck( ::MatAssemblyEnd( mat, type ) ); }
264 inline static void MatAssembled( Mat mat, PetscBool* assembled ) { ErrorCheck( ::MatAssembled( mat, assembled ) ); }
265
266 template <class Comm>
267 inline static void MatCreate ( const Comm& comm, Mat *A )
268 {
269 ErrorCheck( ::MatCreate( castToPetscComm( comm ), A) );
270 }
271
272 template <class Comm>
273 inline static void MatCreateBlockMat ( const Comm& comm,
274 Mat *A,
275 PetscInt m, PetscInt n, PetscInt bs, PetscInt nz, PetscInt* nnz )
276 {
277 ErrorCheck( ::MatCreateBlockMat( castToPetscComm( comm ), n, m, bs, nz, nnz, A) );
278 }
279 inline static void MatDestroy ( Mat *A ) {
280 #if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
281 ErrorCheck( ::MatDestroy( *A ) );
282 #else
283 ErrorCheck( ::MatDestroy( A ) );
284 #endif // PETSC_PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
285 }
286 inline static void MatSetUp( Mat mat )
287 {
288 ErrorCheck( ::MatSetUp(mat));
289 }
290 inline static void MatSetUp( Mat mat, PetscInt bs, PetscInt nz )
291 {
292 if (bs == 1)
293 {
294 ErrorCheck( ::MatSeqAIJSetPreallocation(mat,nz,PETSC_NULLPTR) );
295 ErrorCheck( ::MatMPIAIJSetPreallocation(mat,nz,PETSC_NULLPTR,nz/2,PETSC_NULLPTR) );
296 }
297 else
298 {
299 ErrorCheck( ::MatSeqBAIJSetPreallocation(mat,bs,nz,PETSC_NULLPTR) );
300 ErrorCheck( ::MatMPIBAIJSetPreallocation(mat,bs,nz,PETSC_NULLPTR,nz/2,PETSC_NULLPTR) );
301 }
302 // the following seems not to work for block matrix
303 ErrorCheck( ::MatSetOption(mat, MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE) );
304 // the following only works for block matrix
305 // but should be used with MAT_NEW_NONZERO_LOCATIONS...
306 // ErrorCheck( ::MatSetOption(mat, MAT_USE_HASH_TABLE,PETSC_FALSE) );
307 ErrorCheck( ::MatSetUp(mat));
308 }
309 inline static void MatSetUp( Mat mat, PetscInt bs, const PetscInt *d_nnz, const PetscInt *o_nnz )
310 {
311 if (bs == 1)
312 {
313 ErrorCheck( ::MatSeqAIJSetPreallocation(mat,0,d_nnz ) );
314 ErrorCheck( ::MatMPIAIJSetPreallocation(mat,0,d_nnz,5,o_nnz) );
315 }
316 else
317 {
318 ErrorCheck( ::MatSeqBAIJSetPreallocation(mat,bs,0,d_nnz ) );
319 ErrorCheck( ::MatMPIBAIJSetPreallocation(mat,bs,0,d_nnz,5,PETSC_NULLPTR) );
320 }
321 // see previous comments
322 ErrorCheck( ::MatSetOption(mat, MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE) );
323 ErrorCheck( ::MatSetUp(mat));
324 }
325
326 inline static void MatGetOwnershipRange ( Mat mat, PetscInt *m, PetscInt* n ) { ErrorCheck( ::MatGetOwnershipRange( mat, m, n ) ); }
327 inline static void MatGetSize ( Mat mat, PetscInt *m, PetscInt* n ) { ErrorCheck( ::MatGetSize( mat, m, n ) ); }
328 inline static void MatMult ( Mat mat, Vec x, Vec y ) { ErrorCheck( ::MatMult( mat, x, y ) ); }
329 inline static void MatSetBlockSize ( Mat A, PetscInt bs ) { ErrorCheck( ::MatSetBlockSize( A, bs ) ); }
330 inline static void MatSetSizes ( Mat A, PetscInt m, PetscInt n, PetscInt M, PetscInt N ) { ErrorCheck( ::MatSetSizes( A, m, n, M, N ) ); }
331 inline static void MatSetFromOptions ( Mat B ) { ErrorCheck( ::MatSetFromOptions( B ) ); }
332 inline static void MatSetType ( Mat mat, const MatType matype ) { ErrorCheck( ::MatSetType( mat, matype ) ); }
333
334 inline static void MatSetValue ( Mat v, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode )
335 {
336#ifdef _OPENMP
337#pragma omp critical
338#endif
339 {
340 ErrorCheck( ::MatSetValue( v, i, j, va, mode ) );
341 }
342 }
343
344 inline static void MatSetValues ( Mat mat, PetscInt m, const PetscInt idxm[], PetscInt n, const PetscInt idxn[], const PetscScalar v[], InsertMode addv )
345 {
346#ifdef _OPENMP
347#pragma omp critical
348#endif
349 {
350 ErrorCheck( ::MatSetValues( mat, m, idxm, n, idxn, v, addv ) );
351 }
352 }
353
354 inline static void MatSetValuesBlocked ( Mat mat, PetscInt m, const PetscInt idxm[], PetscInt n, const PetscInt idxn[], const PetscScalar v[], InsertMode addv )
355 {
356#ifdef _OPENMP
357#pragma omp critical
358#endif
359 {
360 ErrorCheck( ::MatSetValuesBlocked( mat, m, idxm, n, idxn, v, addv ) );
361 }
362 }
363
364 inline static void MatGetValues ( Mat mat, PetscInt m, const PetscInt idxm[], PetscInt n, const PetscInt idxn[], PetscScalar v[] )
365 { ErrorCheck( ::MatGetValues( mat, m, idxm, n, idxn, v ) ); }
366
367 inline static void MatZeroRows ( Mat mat, PetscInt m, const PetscInt idxm[], const PetscScalar v )
368 {
369#ifdef _OPENMP
370#pragma omp critical
371#endif
372 {
373 ErrorCheck( ::MatZeroRows( mat, m, idxm, v, 0, 0 ) );
374 }
375 }
376
377 inline static void MatView ( Mat mat, PetscViewer viewer ) { ErrorCheck( ::MatView( mat, viewer ) ); }
378 inline static void MatZeroEntries ( Mat mat )
379 {
380#ifdef _OPENMP
381#pragma omp critical
382#endif
383 {
384 ErrorCheck( ::MatZeroEntries( mat ) );
385 }
386 }
387
388 inline static void PetscOptionsSetValue(const std::string& key, const std::string& value)
389 {
390 // add parameter to global data base (nullptr)
391 // TODO, add PetscOptions object to have several data bases
392 ErrorCheck( ::PetscOptionsSetValue(PETSC_NULLPTR, key.c_str(), value.c_str() ));
393 }
394
395 inline static void PetscOptionsClear()
396 {
397 // clear global data base (nullptr)
398 // TODO, add PetscOptions object to have several data bases
399 ErrorCheck( ::PetscOptionsClear(PETSC_NULLPTR) );
400 }
401
402 inline static void PetscBarrier ( PetscObject obj ) { ErrorCheck( ::PetscBarrier( obj ) ); }
403 inline static void PetscFinalize () { ErrorCheck( ::PetscFinalize() ); }
404 inline static void PetscInitialize( int *argc, char ***args, const char file[], const char help[] ) { ErrorCheck( ::PetscInitialize( argc, args, file, help ) ); }
405 inline static void PetscViewerASCIIOpen ( MPI_Comm comm, const char name[], PetscViewer *lab ) { ErrorCheck( ::PetscViewerASCIIOpen( comm, name, lab ) ); }
406 inline static void PetscViewerDestroy ( PetscViewer *viewer ) {
407 #if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
408 ErrorCheck( ::PetscViewerDestroy( *viewer ) );
409 #else
410 ErrorCheck( ::PetscViewerDestroy( viewer ) );
411 #endif
412 }
413 inline static void PetscViewerSetFormat ( PetscViewer viewer, PetscViewerFormat format )
414 {
415 #if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 5
416 ErrorCheck( ::PetscViewerSetFormat( viewer, format ) );
417 #else
418 ErrorCheck( ::PetscViewerPushFormat( viewer, format ) );
419 #endif
420 }
421 inline static void VecAssemblyBegin ( Vec vec ) { ErrorCheck( ::VecAssemblyBegin( vec ) ); }
422 inline static void VecAssemblyEnd ( Vec vec ) { ErrorCheck( ::VecAssemblyEnd( vec ) ); }
423 inline static void VecAXPY ( Vec y, PetscScalar alpha, Vec x) { ErrorCheck( ::VecAXPY( y, alpha, x ) ); }
424 inline static void VecCopy ( Vec x, Vec y ) { ErrorCheck( ::VecCopy( x, y ) ); }
425
426 template <class Comm>
427 inline static void VecCreate ( const Comm& comm, Vec *vec )
428 {
429 ErrorCheck( ::VecCreate( castToPetscComm( comm ), vec ) );
430 }
431
432 template <class Comm>
433 inline static void VecCreateGhost ( const Comm& comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[], Vec *vv )
434 { ErrorCheck( ::VecCreateGhost( castToPetscComm( comm ), n, N, nghost, ghosts, vv ) ); }
435
436 template <class Comm>
437 inline static void VecCreateGhostBlock ( const Comm& comm, PetscInt bs, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[], Vec *vv )
438 {
439#if PETSC_VERSION_MAJOR < 3 || (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR <= 2)
440 std::unique_ptr< PetscInt[] > ghostsCopy( new PetscInt[ nghost * bs ] );
441 for( PetscInt i = 0; i < nghost; ++i )
442 {
443 for( PetscInt j = 0; j < bs; ++j )
444 ghostsCopy[ i*bs + j ] = ghosts[ i ]*bs + j;
445 }
446 VecCreateGhost( n, N, nghost * bs, ghostsCopy.get(), vv );
447#else // #if PETSC_VERSION_MAJOR < 3 || (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR <= 2)
448 ErrorCheck( ::VecCreateGhostBlock( castToPetscComm( comm ), bs, n, N, nghost, ghosts, vv ) );
449#endif // #else // #if PETSC_VERSION_MAJOR < 3 || (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR <= 2)
450 }
451
452 inline static void VecDestroy ( Vec *v ) {
453 #if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
454 ErrorCheck( ::VecDestroy( *v ) );
455 #else
456 ErrorCheck( ::VecDestroy( v ) );
457 #endif // PETSC_PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 2
458 }
459 inline static void VecDot ( Vec x, Vec y, PetscScalar *val ) { ErrorCheck( ::VecDot( x, y, val ) ); }
460 inline static void VecDuplicate ( Vec v, Vec *newv ) { ErrorCheck( ::VecDuplicate( v, newv ) ); }
461 inline static void VecGetBlockSize ( Vec x, PetscInt* bs ) { ErrorCheck( ::VecGetBlockSize( x, bs ) ); }
462 inline static void VecGetLocalSize ( Vec x, PetscInt *size ) { ErrorCheck( ::VecGetLocalSize( x, size ) ); }
463 inline static void VecGetOwnershipRange ( Vec x, PetscInt *low, PetscInt *high ) { ErrorCheck( ::VecGetOwnershipRange( x, low, high ) ); }
464 inline static void VecGetSize ( Vec x, PetscInt *size ) { ErrorCheck( ::VecGetSize( x, size ) ); }
465 inline static void VecGetValues ( Vec x, PetscInt ni, const PetscInt ix[], PetscScalar y[] ) { ErrorCheck( ::VecGetValues( x, ni, ix, y ) ); }
466 inline static void VecGhostGetLocalForm ( Vec g, Vec *l ) { ErrorCheck( ::VecGhostGetLocalForm( g, l ) ); }
467 inline static void VecGhostRestoreLocalForm ( Vec g, Vec *l ) { ErrorCheck( ::VecGhostRestoreLocalForm( g, l ) ); }
468 inline static void VecGhostUpdateBegin ( Vec g, InsertMode insertmode, ScatterMode scattermode ) { ErrorCheck( ::VecGhostUpdateBegin( g, insertmode, scattermode ) ); }
469 inline static void VecGhostUpdateEnd ( Vec g, InsertMode insertmode, ScatterMode scattermode ) { ErrorCheck( ::VecGhostUpdateEnd( g, insertmode, scattermode ) ); }
470 inline static void VecNorm ( Vec x, NormType type, PetscReal *val ) { ErrorCheck( ::VecNorm( x, type, val ) ); }
471 inline static void VecScale ( Vec x, PetscScalar alpha ) { ErrorCheck( ::VecScale( x, alpha ) ); }
472 inline static void VecSet ( Vec x, PetscScalar alpha ) { ErrorCheck( ::VecSet( x, alpha ) ); }
473 inline static void VecSetBlockSize ( Vec x, PetscInt bs ) { ErrorCheck( ::VecSetBlockSize( x, bs ) ); }
474 inline static void VecSetFromOptions ( Vec vec ) { ErrorCheck( ::VecSetFromOptions( vec ) ); }
475 inline static void VecSetType ( Vec vec, const VecType method ) { ErrorCheck( ::VecSetType( vec, method ) ); }
476 inline static void VecSetSizes ( Vec v, PetscInt n, PetscInt N ) { ErrorCheck( ::VecSetSizes( v, n, N ) ); }
477 inline static void VecSetValue ( Vec v, int row, PetscScalar value, InsertMode mode ) { ErrorCheck( ::VecSetValue( v, row, value, mode ) ); }
478 inline static void VecSetValuesBlocked ( Vec v, PetscInt ni, const PetscInt xi[], const PetscScalar values[], InsertMode mode ) { ErrorCheck( ::VecSetValuesBlocked( v, ni, xi, values, mode ) ); }
479 inline static void VecView ( Vec vec, PetscViewer viewer ) { ErrorCheck( ::VecView( vec, viewer ) ); }
480
481 } // namespace Petsc
482
483} // namespace Dune
484
485#endif // #if HAVE_PETSC
486
487#endif // DUNE_FEM_PETSCCOMMON_HH
Base class for Dune-Exceptions.
Definition: exceptions.hh:98
Implements an utility class that provides collective communication methods for sequential programs.
A few common exception classes.
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
constexpr GeometryType line
GeometryType representing a line.
Definition: type.hh:498
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition: stdstreams.hh:117
Dune namespace
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Standard Dune debug streams.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (May 9, 22:32, 2026)