Actual source code: example3.edp
 1 /*******************************************************
 2  *  This file is part of the FreeFEM tutorial made by  *
 3  *      Pierre Jolivet <pierre@joliv.et>               *
 4  *                                                     *
 5  *  See https://joliv.et/FreeFem-tutorial for more     *
 6  *                                                     *
 7  *   Description: fespace manipulation                 *
 8  *******************************************************/
  
10 mesh sq = square(10, 10);
11 plot(sq, wait = true);
 
13 fespace Vh(sq, P1);
14 cout << "number of degrees of freedom: " << Vh.ndof << endl;
15 sq = trunc(sq, 1, split = 2);
16 cout << "number of degrees of freedom: " << Vh.ndof << endl;
 
18 Vh myFunction = x + cos(y);
19 plot(myFunction, wait = true);
20 cout << "value of my function at (x,y) = (0.5,0.5): " << myFunction(0.5, 0.5) << endl;
21 cout << "value of the 12th degree of freedom of my function: " << myFunction[][11] << endl;
 
23 fespace Ph(sq, P0);
24 Ph myPiecewiseConstantFunction = myFunction;
25 plot(myPiecewiseConstantFunction);