-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // Location: 2 : // 3 : // http://people.sc.fsu.edu/~jburkardt/freefem_src/driven_cavity_stokes/driven_cavity_stokes.edp 4 : // 5 : // Discussion: 6 : // 7 : // Steady Stokes problem in a cavity. 8 : // 9 : // - uxx - uyy + px = uf 10 : // - vxx - vyy + py = vf 11 : // ux + vy = pf 12 : // 13 : // u = 1 along top wall. 14 : // 15 : // Licensing: 16 : // 17 : // This code is distributed under the GNU LGPL license. 18 : // 19 : // Modified: 20 : // 21 : // 22 May 2020 22 : // 23 : // Reference: 24 : // 25 : // John Chrispell, Jason Howell, 26 : // Finite Element Approximation of Partial Differential Equations 27 : // Using FreeFem++, or, How I Learned to Stop Worrying and Love 28 : // Numerical Analysis. 29 : // 30 : // Frederic Hecht, 31 : // New development in FreeFem++, 32 : // Journal of Numerical Mathematics, 33 : // Volume 20, Number 3-4, 2012, pages 251-265. 34 : // 35 : cout << "\n"; 36 : cout << "driven_cavity_stokes:\n"; 37 : cout << " FreeFem++ version.\n"; 38 : // 39 : // eps: the penalty coefficient for the continuity equation. 40 : // 41 : real eps = 1.0E-10; 42 : // 43 : // n: the number of nodes in each spatial direction. 44 : // 45 : int n = 30; 46 : // 47 : // Th: the triangulation of the square. 48 : // 49 : mesh Th = square ( n, n ); 50 : // 51 : // Vh: the finite element space for 2D velocity vector (piecewise linear "bubble") 52 : // 53 : fespace Vh ( Th, P1b ); 54 : // 55 : // Qh: the finite element space for the scalar pressure (piecewise linear). 56 : // 57 : fespace Qh ( Th, P1 ); 58 : // 59 : // u1, u2: velocity trial functions. 60 : // 61 : Vh u1, u2; 62 : // 63 : // p: pressure trial function. 64 : // 65 : Qh p; 66 : // 67 : // v1, v2: velocity test functions. 68 : // 69 : Vh v1, v2; 70 : // 71 : // q: pressure test function. 72 : // 73 : Qh q; 74 : // 75 : // Define and solve the problem. 76 : // 77 : solve Stokes ( [u1,u2,p], [v1,v2,q] ) 78 : = int2d ( Th, qforder = 3 ) 79 : ( 80 : dx(u1) * dx(v1) 81 : + dy(u1) * dy(v1) 82 : + dx(p) * v1 83 : + dx(u2) * dx(v2) 84 : + dy(u2) * dy(v2) 85 : + dy(p) * v2 86 : + dx(u1) * q 87 : + dy(u2) * q 88 : - eps * p * q 89 : ) 90 : + on ( 1, 2, 4, u1 = 0 ) 91 : + on ( 3, u1 = 1 ) 92 : + on ( 1, 2, 3, 4, u2 = 0 ); 93 : // 94 : // Plot the velocity vectors, using 1 color for the vectors. 95 : // 96 : plot ( [ u1, u2 ], nbarrow = 1, ps = "driven_cavity_stokes_velocity.ps" ); 97 : // 98 : // Plot the pressure. 99 : // 100 : plot ( p, ps = "driven_cavity_stokes_pressure.ps" ); 101 : // 102 : // Terminate. 103 : // 104 : cout << "\n"; 105 : cout << "driven_cavity_stokes:\n"; 106 : cout << " Normal end of execution.\n"; 107 : 108 : sizestack + 1024 =1904 ( 880 ) driven_cavity_stokes: FreeFem++ version. -- Square mesh : nb vertices =961 , nb triangles = 1800 , nb boundary edges 120 -- Solve : min -0.190866 max 1 min -0.326409 max 0.313182 min -487.151 max 399.511 driven_cavity_stokes: Normal end of execution. times: compile 0.004163s, execution 1.45795s, mpirank:0 CodeAlloc : nb ptr 3560, size :475920 mpirank: 0 Ok: Normal End