-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // Discussion: 2 : // 3 : // This example solves equations related to a model of a microwave cooker. 4 : // 5 : // Location: 6 : // 7 : // http://people.sc.fsu.edu/~jburkardt/examples/freefem++/microwave.edp 8 : // 9 : // Licensing: 10 : // 11 : // This code is distributed under the GNU LGPL license. 12 : // 13 : // Modified: 14 : // 15 : // 18 February 2015 16 : // 17 : // Author: 18 : // 19 : // An example from the FreeFem++ manual. 20 : // Modifications and comments by John Burkardt. 21 : // 22 : // Reference: 23 : // 24 : // Frederic Hecht, 25 : // Freefem++, 26 : // Third Edition, version 3.22 27 : // 28 : cout << "\n"; 29 : cout << "microwave\n"; 30 : cout << " FreeFem++ version\n"; 31 : cout << " Simulation of a microwave food processor.\n"; 32 : // 33 : // These parameters are used to define the boundaries. 34 : // 35 : real a = 20.0; 36 : real b = 20.0; 37 : real c = 15.0; 38 : real d = 8.0; 39 : real e = 2.0; 40 : real l = 12.0; 41 : real f = 2.0; 42 : real g = 2.0; 43 : // 44 : // Define the line segments A0, A1, A2, A3, A4, A5 of the external boundary. 45 : // Segment A4 (label = 2 ) is where the nonzero wave will be emitted. 46 : // 47 : // Y 48 : // | 49 : // 20 +--------A2------------+ 50 : // | | | 51 : // | A3 | 52 : // | | | 53 : // | A4 A1 54 : // | | | 55 : // | A5 | 56 : // | | | 57 : // 0 +--------A0------------+ 58 : // | 59 : // +--0---------------------20----X 60 : // 61 : border a0 (t=0,1) { x=a*t; y=0.0; label=1; } 62 : border a1 (t=1,2) { x=a; y=b*(t-1.0); label=1; } 63 : border a2 (t=2,3) { x=a*(3.0-t); y=b; label=1; } 64 : border a3 (t=3,4) { x=0.0; y=b-(b-c)*(t-3.0); label=1; } 65 : border a4 (t=4,5) { x=0.0; y=c-(c-d)*(t-4.0); label=2; } 66 : border a5 (t=5,6) { x=0.0; y=d*(6.0-t); label=1; } 67 : // 68 : // Define the line segments B0, B1, B2, B3, of the internal interface. 69 : // 70 : // Y 71 : // | 72 : // 20 +----------------------+ 73 : // | | | 74 : // | | | 75 : // 14 | +B2+ | 76 : // | | B3 | | 77 : // | | | B1 | 78 : // 2 | +B0+ | 79 : // | | | 80 : // 0 +----------------------+ 81 : // | 82 : // +--0---------------16-18-20----X 83 : // 84 : border b0 (t=0,1) { x=a-f+e*(t-1.0); y=g; label=3; } 85 : border b1 (t=1,4) { x=a-f; y=g+l*(t-1.0)/3.0; label=3; } 86 : border b2 (t=4,5) { x=a-f-e*(t-4.0); y=l+g; label=3; } 87 : border b3 (t=5,8) { x=a-e-f; y= l+g-l*(t-5.0)/3.0; label=3; } 88 : // 89 : // Compute a mesh by filling in the line segments with a given number of 90 : // points. The value of N controls how fine the lines are. 91 : // 92 : int n = 2; 93 : mesh Th = buildmesh ( 94 : a0 ( 10 * n ) + a1 ( 10 * n) + a2 ( 10 * n ) + a3 ( 10 * n ) 95 : + a4 ( 10 * n ) + a5 ( 10 * n ) 96 : + b0 ( 5 * n ) + b1 ( 10 * n ) + b2 ( 5 * n ) + b3 ( 10 * n ) ); 97 : // 98 : // Plot the mesh. 99 : // 100 : plot ( Th, ps = "microwave_mesh.ps", wait = 1 ); 101 : // 102 : // Use a finite element space of piecewise linear functions on mesh Th. 103 : // 104 : fespace Vh ( Th, P1 ); 105 : // 106 : // The mesh is naturally divided into two regions. 107 : // We can request a "label" for a region by specifying a point inside that region. 108 : // The command 109 : // "meat = Th ( xm, ym ).region" 110 : // returns, as the value "meat", the label that FreeFem++ uses to identify 111 : // the portion of the mesh that contains (xm,ym), which happens to be the 112 : // region we think of as the meat. Similarly, we can choose a point (xa,ya) 113 : // that lies in the other region, to get the label for the "air" portion 114 : // of our problem. 115 : // 116 : real xm = 17.0; 117 : real ym = 8.0; 118 : real meat = Th ( xm, ym ).region; 119 : 120 : real xa = 0.01; 121 : real ya = 0.01; 122 : real air = Th ( xa, ya ).region; 123 : // 124 : // Now that we have the numeric labels "meat" and "air", we can 125 : // define R, a finite element interpolant function, which will be 126 : // 1 in the meat region and 0 in the air region: 127 : // 128 : Vh R = ( region - air ) / ( meat - air ); 129 : // 130 : // Our unknown electromagnetic function is complex valued. 131 : // U1 will be our solution function, and V1 our test function. 132 : // 133 : Vh u1; 134 : Vh v1; 135 : // 136 : // Solve for the electromagnetic function U1. 137 : // The boundary condition is mostly zero, but over the boundary segment 138 : // with label 2, there is a real-valued sinusoidal boundary condition. 139 : // 140 : solve muwave ( u1, v1 ) = 141 : int2d(Th) ( u1 * v1 * ( 1.0 + R ) 142 : - ( dx(u1)*dx(v1)+dy(u1)*dy(v1)) * ( 1.0 - 0.5i) ) 143 : + on ( 1, u1 = 0.0 ) 144 : + on ( 2, u1 = sin(pi*(y-c)/(c-d)) ); 145 : // 146 : // Define the real and imaginary parts of U1, so we can plot them, 147 : // and so we can write a formula for the magnitude of the signal. 148 : // 149 : Vh u1r = real ( u1 ); 150 : Vh u1i = imag ( u1 ); 151 : // 152 : // Plot the real and imaginary portions of the solution. 153 : // 154 : plot ( u1r, wait = 1, ps = "microwave_r.ps", fill = true ); 155 : plot ( u1i, wait = 1, ps = "microwave_i.ps", fill = true ); 156 : // 157 : // Now we use the microwave solution to solve the second problem, 158 : // for the temperature distribution over the region. 159 : // 160 : fespace Uh ( Th, P1 ); 161 : // 162 : // U2 is our solution, and V2 is our test function. 163 : // 164 : Uh u2; 165 : Uh v2; 166 : // 167 : // The right hand side of the equations is FF, which is proportional to 168 : // the square of the signal intensity. However, FF is only nonzero within 169 : // the meat region, so we multiply by R, the function that is 0 outside 170 : // the meat. 171 : // 172 : Uh ff = 100000.0 * ( u1r^2 + u1i^2 ) * R; 173 : // 174 : // Now we can solve the usual heat equation over the whole microwave 175 : // region, using a right hand side that is squelched outside the meat region. 176 : // 177 : solve temperature ( u2, v2 ) = 178 : int2d(Th) ( dx(u2)* dx(v2) + dy(u2)* dy(v2) ) 179 : - int2d(Th) ( ff * v2 ) 180 : + on ( 1, u2 = 0.0 ) 181 : + on ( 2, u2 = 0.0 ); 182 : // 183 : // Plot the temperature. 184 : // 185 : plot ( u2, wait = 1, ps = "microwave_t.ps", fill = true ); 186 : // 187 : // Terminate. 188 : // 189 : cout << "\n"; 190 : cout << "microwave\n"; 191 : cout << " Normal end of execution.\n"; 192 : sizestack + 1024 =4192 ( 3168 ) microwave FreeFem++ version Simulation of a microwave food processor. -- mesh: Nb of Triangles = 2622, Nb of Vertices 1372 -- Solve : min (-0.999958,-0.612153) max (0.353414,0.211093) -- Solve : min 2.37625e-62 max 13.8706 microwave Normal end of execution. times: compile 0.005704s, execution 1.60633s, mpirank:0 CodeAlloc : nb ptr 4046, size :496000 mpirank: 0 Ok: Normal End