source: CIVL/examples/compare/PETSc/petsc.h

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * Defined petsc.h header for provesa PETSc examples: ex2a.c, ex2b.c,
3 * ex2c.c,ex2d.c. This header is used for verifying the equivalence of those
4 * examples by using CIVL. This header is made based on the functions and
5 * types which is used in those PETSc examples. The definition of types and
6 * funcitons comes from PETSc home page: https://www.mcs.anl.gov/petsc/
7 * PETSc examples: https://repo.anl-external.org/repos/provesa/codes/mxm/
8 *
9 * Author: Si Li <sili@udel.edu>
10 */
11
12#ifndef _PETSC_
13#define _PETSC_
14
15#include <math.h>
16#define PetscExpScalar(x) exp(x)
17
18/* -------Types------- */
19
20/* PetscErrorCode - datatype used for return error code from almost
21 * all PETSc functions */
22typedef int PetscErrorCode;
23
24/* PETSc type that represents a PetscReal.
25 * This is the same as a PetscReal except in code that is automatically
26 * differentiated it is treated as a constant (not an indendent or
27 * dependent variable)
28 */
29typedef double PassiveReal;
30
31/* PETSc type that represents integer - used primarily to represent size
32 * of arrays and indexing into arrays. Its size can be * configured with
33 * the option-with-64-bit-indices - to be either
34 * 32bit or 64bit [default 32 bit ints]
35 */
36typedef int PetscInt;
37
38/* PetscReal - PETSc type that represents a real number version of
39 * PetscScalar */
40typedef double PetscReal;
41
42/* PetscScalar - PETSc type that represents either a double precision
43 * real number, a double precision complex number, a single precision
44 * real number, a long double or an int - if the code is configured
45 * with --with-scalar-type=real, complex --with-precision=single,
46 * double,__float128
47 */
48typedef double PetscScalar;
49
50/* C struct that contains information about a structured grid and
51 a processors logical location in it. */
52typedef struct DMDALocalInfo { /* using distributed arrays */
53 PetscInt dim,dof,sw;
54 PetscInt mx,my,mz; /* global number of grid points in each direction */
55 PetscInt xs,ys,zs; /* starting point of this processor, excluding ghosts */
56 PetscInt xm,ym,zm; /* number of grid points on this processor, excluding ghosts */
57 PetscInt gxs,gys,gzs; /* starting point of this processor including ghosts */
58 PetscInt gxm,gym,gzm; /* number of grid points on this processor including ghosts */
59} DMDALocalInfo;
60
61/* ----------Functions---------- */
62
63/* First executable line of each PETSc function, used for error handling.
64 * Final line of PETSc functions should be PetscFunctionReturn(0);
65 */
66#define PetscFunctionBegin
67
68/* Last executable line of each PETSc function used for error handling.
69 * Replaces return() */
70#define PetscFunctionReturn(x) return(x)
71
72/* Adds floating point operations to the global counter. */
73PetscErrorCode PetscLogFlops(double );
74
75/* Checks error code, if non-zero it calls the error handler and then
76 * returns */
77PetscErrorCode CHKERRQ(PetscErrorCode );
78
79/*
80#undef __FUNCT__
81#define __FUNCT__ "PetscLogFlops"
82PETSC_STATIC_INLINE PetscErrorCode PetscLogFlops(PetscLogDouble n)
83{
84 PetscFunctionBegin;
85#if defined(PETSC_USE_DEBUG)
86 if (n < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Cannot log negative flops");
87#endif
88 petsc_TotalFlops += PETSC_FLOPS_PER_OP*n;
89 PetscFunctionReturn(0);
90}
91*/
92
93#endif
Note: See TracBrowser for help on using the repository browser.