source: CIVL/examples/accuracy/laplace2d.cvl@ a6d2043

1.23 2.0 main test-branch
Last change on this file since a6d2043 was d980649, checked in by Manchun Zheng <zmanchun@…>, 10 years ago

fixed extra parenthesis.

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

  • Property mode set to 100644
File size: 724 bytes
Line 
1/* Commandline execution:
2 * civl verify -inputrows=3 -inputcols=3 laplace.cvl
3 * */
4#include <civlc.cvh>
5
6$input double h;
7$input int rows = 3;
8$input int cols = 3;
9$input double u[rows][cols];
10double result[rows][cols];
11$assume(h > 0);
12$abstract $contin(4) $real phi($real x, $real y);
13$assume($forall {m=0 .. rows-1} $forall {n=0 .. cols-1} u[m][n] == phi(m*h, n*h));
14
15void laplace() {
16 for (int i = 1; i < rows-1; i++) {
17 for (int j = 1; j < cols-1; j++) {
18 result[i][j] = (u[i-1][j]+u[i][j-1]-4*u[i][j]+u[i+1][j]+u[i][j+1])/(h*h);
19 }
20 }
21 $assert($uniform {i=1 .. rows-2} $uniform {j=1 .. cols-2} result[i][j] - ($D[phi,{x,2}](i*h,j*h)+$D[phi,{y,2}](i*h,j*h)) == $O(h*h));
22}
23
24void main() {
25 laplace();
26}
Note: See TracBrowser for help on using the repository browser.