// -*- FreeFem++ -*- // Time-stamp: "2020-07-19 00:42:35 fujiwara" // Original : https://modules.freefem.org/modules/poisson/ include "cube.idp" // Parameters func f = 1.; // Mesh int nn = 2; mesh3 Th = cube(nn, nn, nn); // Fespace //func Pk = P2; load "Element_CR" func Pk = CR3d; fespace Uh(Th, Pk); Uh u; // Macro macro grad(A) [dx(A), dy(A), dz(A)] // // Problem varf vPoisson (u, uh) = int3d(Th)( grad(u)' * grad(uh) ) + int3d(Th)( f * uh ) + on(1, 2, 3, 4, 5, 6, u=0) ; matrix Poisson = vPoisson(Uh, Uh, solver=sparsesolver); real[int] PoissonBoundary = vPoisson(0, Uh); u[] = Poisson^-1 * PoissonBoundary; // plot plot(u, nbiso=30, fill=true, value=true, cmm="A"); cout << "Number of unknowns (Uh.ndof): " << Uh.ndof << endl; //cout << "u[]=" << u[] << endl; load "iovtk" savevtk("Poisson3d_CR.vtk", Th, u, bin=false); //---------------------------------------------------------------------- // End of file //----------------------------------------------------------------------