File: lap3-cpu.edp

package info (click to toggle)
freefem%2B%2B 3.61.1%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 17,108 kB
  • sloc: cpp: 141,214; ansic: 28,664; sh: 4,925; makefile: 3,142; fortran: 1,171; perl: 844; awk: 290; php: 199; pascal: 41; f90: 32
file content (80 lines) | stat: -rw-r--r-- 3,314 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//  a example to test the level of optimisation
// --------------------------------------------
int nn=300;
 mesh Th=square(nn,nn);
verbosity=5;
 fespace Vh(Th,P1);     // P1 FE space
 Vh uh,vh;              // unkown and test function. 
 func f=1;                 //  right hand side function 
 func g=0;                 //  boundary condition function

 problem laplace0(uh,vh,solver=Cholesky,tgv=1e30) =                    //  definion of  the problem 
    int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) //  bilinear form
  + int1d(Th,1)( uh*vh) 
  + int1d(Th,1)( - vh)
  + int2d(Th)( -f*vh )                          //  linear form
  + on(2,3,4,uh=g) ;                      //  boundary condition form

 problem laplace1(uh,vh,solver=CG,tgv=1e30) =                    //  definion of  the problem 
    int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) //  bilinear form
  + int1d(Th,1)( uh*vh) 
  + int1d(Th,1)( - vh)
  + int2d(Th)( -f*vh )                          //  linear form
  + on(2,3,4,uh=g) ;                      //  boundary condition form

 problem laplaceLU(uh,vh,solver=LU,tgv=1e30) =                    //  definion of  the problem 
    int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) //  bilinear form
  + int1d(Th,1)( uh*vh) 
  + int1d(Th,1)( - vh)
  + int2d(Th)( -f*vh )                          //  linear form
  + on(2,3,4,uh=g) ;                      //  boundary condition form

 problem laplaceCrout(uh,vh,solver=Crout,tgv=1e30) =                    //  definion of  the problem 
    int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) //  bilinear form
  + int1d(Th,1)( uh*vh) 
  + int1d(Th,1)( - vh)
  + int2d(Th)( -f*vh )                          //  linear form
  + on(2,3,4,uh=g) ;                      //  boundary condition form

real cpu=clock() ;
laplace0; // solve the problem plot(uh); // to see the result
cout << "-- lap Cholesky " << nn << "x" << nn << "  : " <<  -cpu+clock() << " s,  max =" << uh[].max << endl;
uh=0;
cpu=clock() ;
laplace1; // solve the problem plot(uh); // to see the result
cout << "-- lap CG       " << nn << "x" << nn << "  : " <<  -cpu+clock() << " s,  max =" << uh[].max << endl;
uh=0;

cpu=clock() ;
laplaceLU; // solve the problem plot(uh); // to see the result
cout << "-- lap LU       " << nn << "x" << nn << "  : " <<  -cpu+clock() << " s,  max =" << uh[].max << endl;
uh=0;

cpu=clock() ;
laplaceCrout; // solve the problem plot(uh); // to see the result
cout << "-- lap Crout    " << nn << "x" << nn << "  : " <<  -cpu+clock() << " s,  max =" << uh[].max << endl;

// FFCS: reference value for regression tests
real regtest=uh[].max;

uh=0;

if(HaveUMFPACK){
  problem laplace2(uh,vh,solver=UMFPACK,tgv=1e30) =                    //  definion of  the problem 
    int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) //  bilinear form
    + int1d(Th,1)( uh*vh) 
    + int1d(Th,1)( - vh)
    + int2d(Th)( -f*vh )                          //  linear form
    + on(2,3,4,uh=g) ;                      //  boundary condition form

  cpu=clock(); 
  laplace2; // solve the problem plot(uh); // to see the result
  cout << "-- lap UMFPACK  " << nn << "x" << nn << "  : "
       <<  -cpu+clock() << " s,  max =" << uh[].max << endl;
}
else{
  cout << "-- lap UMFPACK  " << nn << "x" << nn << "  : "
       <<  "not available" << endl;
}

//  plot(uh,ps="lap1-cpu.eps",value=true);