-- FreeFem++ v 3.310001 (date Jeu 10 jul 2014 21:47:51 CEST) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // massmatrix.edp 2 : // 3 : // Discussion: 4 : // 5 : // Construct the mass matrix for the Poisson equation on the unit disk. 6 : // 7 : // Print out the mass matrix, and notice that certain entries have unexpected values. 8 : // 9 : // Show that these values are associated with boundary nodes having Dirichlet 10 : // boundary conditions. 11 : // 12 : // Modified: 13 : // 14 : // 29 June 2015 15 : // 16 : // Author: 17 : // 18 : // John Burkardt 19 : // 20 : cout << "\n"; 21 : cout << "MASSMATRIX:\n"; 22 : cout << " FreeFem++ version:\n"; 23 : cout << "\n"; 24 : cout << " Mass matrix definition:\n"; 25 : cout << " M(i,j) = Integral Phi(i) Phi(j)\n"; 26 : cout << "\n"; 27 : cout << " For technical reasons, rows of M corresponding ... : to Dirichlet\n"; 28 : cout << " boundary conditions will have a huge number on ... : diagonal.\n"; 29 : cout << "\n"; 30 : cout << " If you don't know this, it may surprise you, or ... : cause your\n"; 31 : cout << " calculations to go astray.\n"; 32 : // 33 : // Define the mesh. 34 : // 35 : mesh Th = square ( 3, 3 ); 36 : // 37 : // Plot the mesh. 38 : // 39 : plot ( Th, ps = "massmatrix_mesh.ps" ); 40 : // 41 : // Define the finite element space. 42 : // 43 : fespace Vh ( Th, P1 ); 44 : Vh uh; 45 : Vh vh; 46 : // 47 : // Define bilinear forms for Dirichlet and Neumann problems. 48 : // 49 : varf bid ( uh, vh ) = int2d ( Th ) ( uh * vh ) + on ( 1, 2, 3, 4, uh = 0.0 ); 50 : varf bin ( uh, vh ) = int2d ( Th ) ( uh * vh ); 51 : // 52 : // Create the corresponding mass matrices. 53 : // 54 : matrix ad = bid ( Vh, Vh ); 55 : matrix an = bin ( Vh, Vh ); 56 : // 57 : // Print the matrices. 58 : // 59 : cout << "\n"; 60 : cout << " Matrix AD:\n"; 61 : cout << " Mass matrix for system with Dirichlet condition ... : s.\n"; 62 : cout << "\n"; 63 : cout << ad; 64 : cout << "\n"; 65 : cout << " Matrix AN:\n"; 66 : cout << " Mass matrix for system with Neumann conditions. ... : \n"; 67 : cout << "\n"; 68 : cout << an; 69 : // 70 : // Terminate. 71 : // 72 : cout << "\n"; 73 : cout << "MASSMATRIX:\n"; 74 : cout << " Normal end of execution.\n"; 75 : 76 : sizestack + 1024 =1568 ( 544 ) MASSMATRIX: FreeFem++ version: Mass matrix definition: M(i,j) = Integral Phi(i) Phi(j) For technical reasons, rows of M corresponding to Dirichlet boundary conditions will have a huge number on diagonal. If you don't know this, it may surprise you, or cause your calculations to go astray. -- Square mesh : nb vertices =16 , nb triangles = 18 , nb boundary edges 12 Matrix AD: Mass matrix for system with Dirichlet conditions. # Sparse Matrix (Morse) # first line: n m (is symmetic) nbcoef # after for each nonzero coefficient: i j a_ij where (i,j) \in {1,...,n}x{1,...,m} 16 16 0 82 1 1 1.0000000000000000199e+30 1 2 0.00462962962962963024 1 5 0.00462962962962963024 1 6 0.00925925925925926048 2 1 0.0046296296296296311074 2 2 1.0000000000000000199e+30 2 3 0.00462962962962963024 2 6 0.0092592592592592587453 2 7 0.00925925925925926048 3 2 0.0046296296296296311074 3 3 1.0000000000000000199e+30 3 4 0.0046296296296296311074 3 7 0.00925925925925926048 3 8 0.0092592592592592622147 4 3 0.0046296296296296311074 4 4 1.0000000000000000199e+30 4 8 0.00462962962962963024 5 1 0.00462962962962963024 5 5 1.0000000000000000199e+30 5 6 0.0092592592592592587453 5 9 0.00462962962962963024 5 10 0.00925925925925926048 6 1 0.0092592592592592622147 6 2 0.0092592592592592587453 6 5 0.00925925925925926048 6 6 0.055555555555555538594 6 7 0.0092592592592592587453 6 10 0.0092592592592592587453 6 11 0.00925925925925926048 7 2 0.0092592592592592622147 7 3 0.00925925925925926048 7 6 0.00925925925925926048 7 7 0.055555555555555552472 7 8 0.00925925925925926048 7 11 0.00925925925925926048 7 12 0.0092592592592592622147 8 3 0.0092592592592592622147 8 4 0.0046296296296296293726 8 7 0.0092592592592592622147 8 8 1.0000000000000000199e+30 8 12 0.00462962962962963024 9 5 0.00462962962962963024 9 9 1.0000000000000000199e+30 9 10 0.00925925925925926048 9 13 0.0046296296296296311074 9 14 0.0092592592592592622147 10 5 0.0092592592592592622147 10 6 0.0092592592592592587453 10 9 0.00925925925925926048 10 10 0.055555555555555538594 10 11 0.00925925925925926048 10 14 0.0092592592592592622147 10 15 0.0092592592592592622147 11 6 0.0092592592592592622147 11 7 0.00925925925925926048 11 10 0.00925925925925926048 11 11 0.05555555555555555941 11 12 0.0092592592592592622147 11 15 0.0092592592592592622147 11 16 0.0092592592592592622147 12 7 0.0092592592592592622147 12 8 0.0046296296296296293726 12 11 0.0092592592592592622147 12 12 1.0000000000000000199e+30 12 16 0.00462962962962963024 13 9 0.0046296296296296311074 13 13 1.0000000000000000199e+30 13 14 0.0046296296296296293726 14 9 0.0092592592592592622147 14 10 0.00925925925925926048 14 13 0.00462962962962963024 14 14 1.0000000000000000199e+30 14 15 0.0046296296296296293726 15 10 0.0092592592592592622147 15 11 0.00925925925925926048 15 14 0.00462962962962963024 15 15 1.0000000000000000199e+30 15 16 0.00462962962962963024 16 11 0.0092592592592592622147 16 12 0.00462962962962963024 16 15 0.00462962962962963024 16 16 1.0000000000000000199e+30 Matrix AN: Mass matrix for system with Neumann conditions. # Sparse Matrix (Morse) # first line: n m (is symmetic) nbcoef # after for each nonzero coefficient: i j a_ij where (i,j) \in {1,...,n}x{1,...,m} 16 16 0 82 1 1 0.01851851851851852096 1 2 0.00462962962962963024 1 5 0.00462962962962963024 1 6 0.00925925925925926048 2 1 0.0046296296296296311074 2 2 0.027777777777777776236 2 3 0.00462962962962963024 2 6 0.0092592592592592587453 2 7 0.00925925925925926048 3 2 0.0046296296296296311074 3 3 0.027777777777777779705 3 4 0.0046296296296296311074 3 7 0.00925925925925926048 3 8 0.0092592592592592622147 4 3 0.0046296296296296311074 4 4 0.0092592592592592587453 4 8 0.00462962962962963024 5 1 0.00462962962962963024 5 5 0.027777777777777776236 5 6 0.0092592592592592587453 5 9 0.00462962962962963024 5 10 0.00925925925925926048 6 1 0.0092592592592592622147 6 2 0.0092592592592592587453 6 5 0.00925925925925926048 6 6 0.055555555555555538594 6 7 0.0092592592592592587453 6 10 0.0092592592592592587453 6 11 0.00925925925925926048 7 2 0.0092592592592592622147 7 3 0.00925925925925926048 7 6 0.00925925925925926048 7 7 0.055555555555555552472 7 8 0.00925925925925926048 7 11 0.00925925925925926048 7 12 0.0092592592592592622147 8 3 0.0092592592592592622147 8 4 0.0046296296296296293726 8 7 0.0092592592592592622147 8 8 0.027777777777777776236 8 12 0.00462962962962963024 9 5 0.00462962962962963024 9 9 0.027777777777777779705 9 10 0.00925925925925926048 9 13 0.0046296296296296311074 9 14 0.0092592592592592622147 10 5 0.0092592592592592622147 10 6 0.0092592592592592587453 10 9 0.00925925925925926048 10 10 0.055555555555555538594 10 11 0.00925925925925926048 10 14 0.0092592592592592622147 10 15 0.0092592592592592622147 11 6 0.0092592592592592622147 11 7 0.00925925925925926048 11 10 0.00925925925925926048 11 11 0.05555555555555555941 11 12 0.0092592592592592622147 11 15 0.0092592592592592622147 11 16 0.0092592592592592622147 12 7 0.0092592592592592622147 12 8 0.0046296296296296293726 12 11 0.0092592592592592622147 12 12 0.027777777777777776236 12 16 0.00462962962962963024 13 9 0.0046296296296296311074 13 13 0.0092592592592592570105 13 14 0.0046296296296296293726 14 9 0.0092592592592592622147 14 10 0.00925925925925926048 14 13 0.00462962962962963024 14 14 0.027777777777777776236 14 15 0.0046296296296296293726 15 10 0.0092592592592592622147 15 11 0.00925925925925926048 15 14 0.00462962962962963024 15 15 0.027777777777777776236 15 16 0.00462962962962963024 16 11 0.0092592592592592622147 16 12 0.00462962962962963024 16 15 0.00462962962962963024 16 16 0.018518518518518517491 MASSMATRIX: Normal end of execution. times: compile 0.006666s, execution 0.001202s, mpirank:0 CheckPtr: Warning memory leak with malloc = -400 CodeAlloc : nb ptr 2543, size :330896 mpirank: 0 Ok: Normal End