-- FreeFem++ v4.14 (mer. 06 mars 2024 16:59:04 CET - git v4.14-1-g2b2052ae) file : mesh_construction.edp Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // mesh_construction.edp 2 : // 3 : // Discussion: 4 : // 5 : // Construct a mesh for a contraction flow problem. 6 : // 7 : // Licensing: 8 : // 9 : // This code is distributed under the MIT license. 10 : // 11 : // Modified: 12 : // 13 : // 25 May 2020 14 : // 15 : // Reference: 16 : // 17 : // John Chrispell, Jason Howell, 18 : // Finite Element Approximation of Partial Differential Equations 19 : // Using FreeFem++, or, How I Learned to Stop Worrying and Love 20 : // Numerical Analysis. 21 : // 22 : // Frederic Hecht, 23 : // New development in FreeFem++, 24 : // Journal of Numerical Mathematics, 25 : // Volume 20, Number 3-4, 2012, pages 251-265. 26 : // 27 : cout << "\n"; 28 : cout << "mesh_construction():\n"; 29 : cout << " FreeFem++ version\n"; 30 : cout << " Demonstrate how to define a region with line se ... : gments,\n"; 31 : cout << " and then mesh it.\n"; 32 : // 33 : // Use N to control the relative fineness of the mesh. 34 : // N = 1 will be the coarsest possible mesh. 35 : // 36 : int n = 3; 37 : // 38 : // Define line segments that form the boundary. 39 : // We break up each line so that we can force parts to have a finer mesh. 40 : // 41 : // Bottom edge. 42 : // 43 : border l00 ( t = 0, 1 ) { x = 0.0 + 2.0 * t; y = 0.0; label = 1; }; 44 : border l01 ( t = 0, 1 ) { x = 2.0 + 1.5 * t; y = 0.0; label = 1; }; 45 : border l02 ( t = 0, 1 ) { x = 3.5 + 1.0 * t; y = 0.0; label = 1; }; 46 : border l03 ( t = 0, 1 ) { x = 4.5 + 3.5 * t; y = 0.0; label = 1; }; 47 : // 48 : // Outflow edge 49 : // 50 : border l04 ( t = 0, 1 ) { x = 8.0; y = 0.0 + 0.125 * t; label = 2; }; 51 : border l05 ( t = 0, 1 ) { x = 8.0; y = 0.125 + 0.125 * t; label = 2; }; 52 : // 53 : // Top of contraction channel 54 : // 55 : border l06 ( t = 0, 1 ) { x = 8.0 - 3.5 * t; y = 0.250; label = 3; }; 56 : border l07 ( t = 0, 1 ) { x = 4.5 - 0.5 * t; y = 0.250; label = 3; }; 57 : // 58 : // Contraction wall 59 : // 60 : border l08 ( t = 0, 1 ) { x = 4.0; y = 0.250 + 0.125 * t; label = 4; }; 61 : border l09 ( t = 0, 1 ) { x = 4.0; y = 0.375 + 0.250 * t; label = 4; }; 62 : border l10 ( t = 0, 1 ) { x = 4.0; y = 0.625 + 0.375 * t; label = 4; }; 63 : // 64 : // Top of inflow channel 65 : // 66 : border l11 ( t = 0, 1 ) { x = 4.0 - 0.5 * t; y = 1.0; label = 5; }; 67 : border l12 ( t = 0, 1 ) { x = 3.5 - 1.5 * t; y = 1.0; label = 5; }; 68 : border l13 ( t = 0, 1 ) { x = 2.0 - 2.0 * t; y = 1.0; label = 5; }; 69 : // 70 : // Inflow walls. 71 : // 72 : border l14 ( t = 0, 1 ) { x = 0.0; y = 1.000 - 0.375 * t; label = 6; }; 73 : border l15 ( t = 0, 1 ) { x = 0.0; y = 0.625 - 0.250 * t; label = 6; }; 74 : border l16 ( t = 0, 1 ) { x = 0.0; y = 0.375 - 0.250 * t; label = 6; }; 75 : border l17 ( t = 0, 1 ) { x = 0.0; y = 0.125 - 0.125 * t; label = 6; }; 76 : // 77 : // Build the mesh. 78 : // We particularly want a fine mesh near the transition region at x = 4.0. 79 : // 80 : mesh Th = buildmesh 81 : ( 82 : l00 ( 4 * n ) // Bottom edge 83 : + l01 ( 4 * n ) 84 : + l02 ( 8 * n ) 85 : + l03 ( 10 * n ) 86 : + l04 ( 4 * n ) // Outflow edge 87 : + l05 ( 4 * n ) 88 : + l06 ( 10 * n ) // Top of contraction channel 89 : + l07 ( 4 * n ) 90 : + l08 ( 4 * n ) // Contraction wall 91 : + l09 ( 4 * n ) 92 : + l10 ( 4 * n ) 93 : + l11 ( 4 * n ) // Top of inflow channel 94 : + l12 ( 4 * n ) 95 : + l13 ( 4 * n ) 96 : + l14 ( 4 * n ) // Inflow walls. 97 : + l15 ( 4 * n ) 98 : + l16 ( 8 * n ) 99 : + l17 ( 2 * n ) 100 : ); 101 : // 102 : // Display the mesh. 103 : // 104 : plot ( Th, wait = true, ps = "mesh_construction.ps" ); 105 : // 106 : // Terminate. 107 : // 108 : cout << "\n"; 109 : cout << "mesh_construction():\n"; 110 : cout << " Normal end of execution.\n"; 111 : 112 : exit ( 0 ); 113 : sizestack + 1024 =1552 ( 528 ) mesh_construction(): FreeFem++ version Demonstrate how to define a region with line segments, and then mesh it. -- mesh: Nb of Triangles = 1776, Nb of Vertices 1024 mesh_construction(): Normal end of execution. current line = 112 exit(0) err code 0 , mpirank 0 CodeAlloc : nb ptr 4370, size :538800 mpirank: 0 Ok: Normal End