source: CIVL/examples/compare/PETSc/ex2Driver.c@ 3820281

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since 3820281 was 12346a7, checked in by Si Li <sili@…>, 10 years ago

add some changes

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

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/* PETSc example driver for ex2a.c, ex2b.c,ex2c.c,ex2d.c,
2 * https://repo.anl-external.org/repos/provesa/codes/mxm/
3 * command: civl verify ex2Driver.c ex2a.c
4 */
5
6#include <civlc.cvh>
7#include <stdlib.h>
8#include "petsc.h"
9
10typedef struct {
11 PassiveReal param; /* test problem parameter */
12} AppCtx;
13
14$input int M = 5;
15$input int N = 5;
16//$assume(M>=0 && M < 5);
17//$assume(N>=0 && N < 5);
18$input PetscScalar x_data[M][N];
19$output PetscScalar f_data[M][N];
20$input AppCtx user;
21
22$input int xs, ys;
23DMDALocalInfo info;
24info.xs=xs;
25info.ys=ys;
26
27$assume(info.ys >=0 && info.ys+info.ym < M);
28$assume(info.xs >=0 && info.xs+info.xm < N);
29
30PetscErrorCode FormFunctionLocal(DMDALocalInfo *,PetscScalar **,PetscScalar **,AppCtx *);
31
32int main() {
33 PetscScalar **x, **f;
34
35 x = (double **)malloc(M*sizeof(double *));
36 for (int i = 0; i < M ; i++) {
37 x[i] = (double *)malloc(N*sizeof(double));
38 //x[i] = $havoc(&x[i])
39 }
40
41 f = (double **)malloc(M*sizeof(double *));
42 for (int i = 0; i < M ; i++) {
43 f[i] = (double *)malloc(N*sizeof(double));
44 }
45
46 for (int i = 0; i < M ; i++)
47 for (int j = 0; j < N ; j++) {
48 x[i][j] = x_data[i][j];
49 }
50
51 FormFunctionLocal(&info, x, f, &user);
52
53 for (int i = 0; i < M ; i++)
54 for (int j = 0; j < N ; j++) {
55 f_data[i][j] = f[i][j];
56 }
57
58 for(int i = 0; i< M; i++) {
59 free(x[i]);
60 free(f[i]);
61 }
62 free(x);
63 free(f);
64}
Note: See TracBrowser for help on using the repository browser.