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