| 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 |
|
|---|
| 10 | typedef 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 |
|
|---|
| 25 | PetscErrorCode FormFunctionLocal(DMDALocalInfo *,PetscScalar **,PetscScalar **,AppCtx *);
|
|---|
| 26 |
|
|---|
| 27 | int 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 | }
|
|---|