source: CIVL/examples/compare/petscBad/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.9 KB
Line 
1/*
2 * Self-defined petsc.h header for provesa examples: ex2a.c, ex2b.c,ex2c.c,ex2d.c.
3 * https://repo.anl-external.org/repos/provesa/codes/mxm/
4 * Full example from PETSc website: http://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex5.c.html
5 */
6
7#ifndef _PETSC_
8#define _PETSC_
9
10#include <math.h>
11#define PetscExpScalar(x) exp(x)
12
13/* -------Types------- */
14
15/* PetscErrorCode - datatype used for return error code from almost all PETSc functions */
16typedef int PetscErrorCode;
17
18/* PETSc type that represents a PetscReal.
19 * This is the same as a PetscReal except in code that is automatically differentiated it
20 * is treated as a constant (not an indendent or dependent variable)
21 */
22typedef double PassiveReal;
23
24/* PETSc type that represents integer - used primarily to represent size of arrays and indexing
25 * into arrays. Its size can be * configured with the option-with-64-bit-indices - to be either
26 * 32bit or 64bit [default 32 bit ints]
27 */
28typedef int PetscInt;
29
30/* PetscReal - PETSc type that represents a real number version of PetscScalar */
31typedef double PetscReal;
32
33/* PetscScalar - PETSc type that represents either a double precision real number, a double precision
34 * complex number, a single precision real number, a long double or an int - if the code is configured
35 * with --with-scalar-type=real, complex --with-precision=single,double,__float128
36 */
37typedef double PetscScalar;
38
39/* C struct that contains information about a structured grid and a processors logical location in it. */
40typedef struct DMDALocalInfo { /* using distributed arrays */
41 PetscInt dim,dof,sw;
42 PetscInt mx,my,mz; /* global number of grid points in each direction */
43 PetscInt xs,ys,zs; /* starting point of this processor, excluding ghosts */
44 PetscInt xm,ym,zm; /* number of grid points on this processor, excluding ghosts */
45 PetscInt gxs,gys,gzs; /* starting point of this processor including ghosts */
46 PetscInt gxm,gym,gzm; /* number of grid points on this processor including ghosts */
47} DMDALocalInfo;
48
49/* ----------Functions---------- */
50
51/* First executable line of each PETSc function, used for error handling. Final line of PETSc
52 * functions should be PetscFunctionReturn(0);
53 */
54#define PetscFunctionBegin
55
56/* Last executable line of each PETSc function used for error handling. Replaces return() */
57//void PetscFunctionReturn(0);
58#define PetscFunctionReturn(x) return(x)
59
60/* Adds floating point operations to the global counter. */
61PetscErrorCode PetscLogFlops(double ); //{return 0;}
62
63/* Checks error code, if non-zero it calls the error handler and then returns */
64PetscErrorCode CHKERRQ(PetscErrorCode ); // {return 0;}
65
66/*
67#undef __FUNCT__
68#define __FUNCT__ "PetscLogFlops"
69PETSC_STATIC_INLINE PetscErrorCode PetscLogFlops(PetscLogDouble n)
70{
71 PetscFunctionBegin;
72#if defined(PETSC_USE_DEBUG)
73 if (n < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Cannot log negative flops");
74#endif
75 petsc_TotalFlops += PETSC_FLOPS_PER_OP*n;
76 PetscFunctionReturn(0);
77}
78*/
79
80#endif
81
82/******************************************************************************************/
83/* about SFI Bratu equation */
84/* petsc-2.0.28/src/snes/examples/tutorial/ex5f.F
85 *
86 * command: mpirun -np <procs> ex5f [-help] [all PETSc options]
87 * -par <param>: SFI parameter lambda :0 <= lambda <= 6.81;
88 -mx <xg>
89 -my <yg>
90 -Nx <npx>
91 -Ny <npy>
92 */
93
94/* static char help[] = "Bratu nonlinear PDE in 2d.\n \
95 * We solve the Bratu (SFI - solid fuel ignition) problem in a 2D rectangular\n \
96 * domain, using distributed arrays (DMDAs) to partition the parallel grid.\n \
97 * The command line options include:\n \
98 * -par <parameter>, where <parameter> indicates the problem's nonlinearity\n\
99 * problem SFI: <parameter> = Bratu parameter (0 <= par <= 6.81)\n\n \
100 * -m_par/n_par <parameter>, where <parameter> indicates an integer\n \
101 * that MMS3 will be evaluated with 2^m_par, 2^n_par";
102*/
Note: See TracBrowser for help on using the repository browser.