source: CIVL/examples/compare/PETSc/ex2Driver.c@ 83c9238

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

add $output

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

  • Property mode set to 100644
File size: 1.3 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$input DMDALocalInfo info;
22$assume(info.ys >=0 && info.ys+info.ym < M);
23$assume(info.xs >=0 && info.xs+info.xm < N);
24
25PetscErrorCode FormFunctionLocal(DMDALocalInfo *,PetscScalar **,PetscScalar **,AppCtx *);
26
27int main() {
28 PetscScalar **x, **f;
29
30 x = (double **)malloc(M*sizeof(double *));
31 for (int i = 0; i < M ; i++) {
32 x[i] = (double *)malloc(N*sizeof(double));
33 //x[i] = $havoc(&x[i])
34 }
35
36 f = (double **)malloc(M*sizeof(double *));
37 for (int i = 0; i < M ; i++) {
38 f[i] = (double *)malloc(N*sizeof(double));
39 }
40
41 for (int i = 0; i < M ; i++)
42 for (int j = 0; j < N ; j++) {
43 x[i][j] = x_data[i][j];
44 }
45
46 FormFunctionLocal(&info, x, f, &user);
47
48 for (int i = 0; i < M ; i++)
49 for (int j = 0; j < N ; j++) {
50 f_data[i][j] = f[i][j];
51 }
52}
Note: See TracBrowser for help on using the repository browser.