1 00:00:00,000 --> 00:00:00,499 2 00:00:00,499 --> 00:00:02,756 The following content is provided under a Creative 3 00:00:02,756 --> 00:00:03,610 Commons license. 4 00:00:03,610 --> 00:00:05,450 Your support will help MIT OpenCourseWare 5 00:00:05,450 --> 00:00:09,116 continue to offer high-quality educational resources for free. 6 00:00:09,116 --> 00:00:11,240 To make a donation, or to view additional materials 7 00:00:11,240 --> 00:00:15,710 from hundreds of MIT courses, visit MIT OpenCourseWare 8 00:00:15,710 --> 00:00:19,390 at ocw.mit.edu. 9 00:00:19,390 --> 00:00:24,330 PROFESSOR STRANG: So, let's see, you probably 10 00:00:24,330 --> 00:00:31,880 guessed on that quiz problem three, it wasn't what I meant. 11 00:00:31,880 --> 00:00:34,680 I get a zero for that problem. 12 00:00:34,680 --> 00:00:36,550 But you'll get probably good numbers, 13 00:00:36,550 --> 00:00:41,720 so that's an election gift if it comes out that way. 14 00:00:41,720 --> 00:00:46,130 So they're all in the hands of the TAs to be graded. 15 00:00:46,130 --> 00:00:48,560 We have a holiday Monday, I think. 16 00:00:48,560 --> 00:00:52,910 We come back to Fourier. 17 00:00:52,910 --> 00:00:57,700 Now, so we just have a concentrated shot at Fourier, 18 00:00:57,700 --> 00:01:01,550 just about eight or nine lectures in November. 19 00:01:01,550 --> 00:01:04,990 So stay with it and that'll be of course 20 00:01:04,990 --> 00:01:07,700 the subject of the third quiz. 21 00:01:07,700 --> 00:01:09,290 Which will have no mistakes. 22 00:01:09,290 --> 00:01:14,660 It'll be solved by the TAs in advance and we'll spot things. 23 00:01:14,660 --> 00:01:19,090 So, and if we have the quizzes to return to you by Wednesday 24 00:01:19,090 --> 00:01:20,030 that will be great. 25 00:01:20,030 --> 00:01:26,810 I hope so, but they have a big job. 26 00:01:26,810 --> 00:01:29,650 A little bit, looking far ahead, the end of Fourier, 27 00:01:29,650 --> 00:01:35,210 the quiz is December 4th, I think that's a Thursday. 28 00:01:35,210 --> 00:01:39,420 And that's the end of the course. 29 00:01:39,420 --> 00:01:40,440 So December 4th. 30 00:01:40,440 --> 00:01:45,940 So we'll be ending the course a little bit early. 31 00:01:45,940 --> 00:01:52,130 Because I'll be in Hong Kong, to tell the truth. 32 00:01:52,130 --> 00:01:55,960 And and we've done a lot, and with the review sessions 33 00:01:55,960 --> 00:01:57,890 we're really doing well. 34 00:01:57,890 --> 00:02:04,740 So, that's the future, Fourier. 35 00:02:04,740 --> 00:02:10,900 Today is an important day too, finite elements in 2-D, 36 00:02:10,900 --> 00:02:15,180 that's a major part of computational science 37 00:02:15,180 --> 00:02:17,880 and engineering. 38 00:02:17,880 --> 00:02:21,660 The finite element idea, the idea of using polynomials, 39 00:02:21,660 --> 00:02:24,620 you can find in some early papers 40 00:02:24,620 --> 00:02:28,940 by Courant, a mathematician in New York, 41 00:02:28,940 --> 00:02:34,890 and by a guy in China, neat guy named Feng Kang. 42 00:02:34,890 --> 00:02:38,610 But those papers were sort of, you 43 00:02:38,610 --> 00:02:41,440 could do it this way if you wanted. 44 00:02:41,440 --> 00:02:46,110 It was really the structural engineers in Berkeley 45 00:02:46,110 --> 00:02:50,910 and elsewhere who made it happen ten years later. 46 00:02:50,910 --> 00:02:54,570 And the whole idea has just blossomed. 47 00:02:54,570 --> 00:02:56,470 Continues to grow. 48 00:02:56,470 --> 00:03:00,190 So I had an early book, in the '70s, 49 00:03:00,190 --> 00:03:08,900 actually, about the mathematical underpinnings, the math basis 50 00:03:08,900 --> 00:03:11,460 for the finite element method. 51 00:03:11,460 --> 00:03:15,500 And many other finite element books have come. 52 00:03:15,500 --> 00:03:19,520 Professor Bathe you know, teaches a full of course 53 00:03:19,520 --> 00:03:20,460 on that. 54 00:03:20,460 --> 00:03:26,090 But, I think we can get the idea of finite elements here. 55 00:03:26,090 --> 00:03:30,350 We did them in 1-D, and now there's a MATLAB problem 56 00:03:30,350 --> 00:03:33,960 and I'd like to just describe that particular problem 57 00:03:33,960 --> 00:03:36,530 if I can, as an example. 58 00:03:36,530 --> 00:03:39,600 And, of course, you would use the code 59 00:03:39,600 --> 00:03:46,510 that's printed in the book, and that's available on the website 60 00:03:46,510 --> 00:03:48,850 just to download. 61 00:03:48,850 --> 00:03:53,030 But the problem is not on a square domain. 62 00:03:53,030 --> 00:03:58,570 It starts on a circle, so that the first lines of the code, 63 00:03:58,570 --> 00:04:09,160 calling the MATLAB command squaregrid, are not applicable. 64 00:04:09,160 --> 00:04:12,570 So you have to create, then, a mesh. 65 00:04:12,570 --> 00:04:15,810 Well, I have a suggested mesh so I'll draw that, 66 00:04:15,810 --> 00:04:18,480 and then from that you want to make 67 00:04:18,480 --> 00:04:23,020 a list of all the node points. 68 00:04:23,020 --> 00:04:32,750 A list, P, of-- So what the code needs is two lists. 69 00:04:32,750 --> 00:04:39,680 Well, let me draw a picture of, well, it's a circle. 70 00:04:39,680 --> 00:04:43,100 And I'm going to be solving Poisson's equation. 71 00:04:43,100 --> 00:04:51,360 The equation will be -u_xx-u_yy=4, in the circle. 72 00:04:51,360 --> 00:04:54,350 So it's Poisson but with a constant right-hand side. 73 00:04:54,350 --> 00:04:58,310 That will mean that all the integrals of f 74 00:04:58,310 --> 00:05:04,870 times v, the right-hand side of our discrete equation will be, 75 00:05:04,870 --> 00:05:09,500 the integrals are all easy because we just have a constant 76 00:05:09,500 --> 00:05:11,670 there times the trial function. 77 00:05:11,670 --> 00:05:16,170 OK, and then on the boundary it's going to be u=0. 78 00:05:16,170 --> 00:05:17,740 On the boundary. 79 00:05:17,740 --> 00:05:19,810 So it's a classic problem. 80 00:05:19,810 --> 00:05:23,020 And we can say what the solution is. 81 00:05:23,020 --> 00:05:25,700 So it's one with a known solution. 82 00:05:25,700 --> 00:05:30,020 I think it would be x squared-- No, I 83 00:05:30,020 --> 00:05:34,020 guess one, one minus x squared minus y squared. 84 00:05:34,020 --> 00:05:36,440 This should all be on the .086 site. 85 00:05:36,440 --> 00:05:38,970 I just didn't have a chance to look this morning 86 00:05:38,970 --> 00:05:40,700 to be sure it got up. 87 00:05:40,700 --> 00:05:42,380 So you can watch, here. 88 00:05:42,380 --> 00:05:44,940 So that, I hope, does solve the problem. 89 00:05:44,940 --> 00:05:49,160 Two x derivatives give us a two, two y derivatives another two, 90 00:05:49,160 --> 00:05:50,430 so we get four. 91 00:05:50,430 --> 00:05:53,700 So we know the answer; the question is, 92 00:05:53,700 --> 00:06:00,110 and I'm interested in this question, for research reasons 93 00:06:00,110 --> 00:06:10,250 too, is what's the error when you go to a polygon? 94 00:06:10,250 --> 00:06:15,680 You go to a-- These curved boundaries 95 00:06:15,680 --> 00:06:18,750 don't get correctly saved. 96 00:06:18,750 --> 00:06:22,520 You approximate them by straight lines. 97 00:06:22,520 --> 00:06:24,430 That would be the first idea. 98 00:06:24,430 --> 00:06:27,610 And with this, all this symmetry, 99 00:06:27,610 --> 00:06:31,250 let's keep the problem nice and use a regular polygon. 100 00:06:31,250 --> 00:06:35,060 So maybe I'll try to draw one with about eight sides, 101 00:06:35,060 --> 00:06:38,530 but-- OK. 102 00:06:38,530 --> 00:06:45,580 So we impose u=0 at these nodes. 103 00:06:45,580 --> 00:06:50,870 So u is zero at those nodes, and then we have a mesh. 104 00:06:50,870 --> 00:06:53,000 So we want to create a mesh. 105 00:06:53,000 --> 00:06:57,420 OK, so with all the symmetry here, 106 00:06:57,420 --> 00:07:09,980 the natural idea would be to start with eight pieces, or M 107 00:07:09,980 --> 00:07:13,650 pieces if I have, this is a regular M side, 108 00:07:13,650 --> 00:07:19,800 let's say, and I'll take M to be eight in this picture. 109 00:07:19,800 --> 00:07:24,990 And I think we can work on just one triangle. 110 00:07:24,990 --> 00:07:28,130 By rotational symmetry, all those triangles 111 00:07:28,130 --> 00:07:29,520 are going to be the same. 112 00:07:29,520 --> 00:07:35,070 So I think our domain is really this one triangle here. 113 00:07:35,070 --> 00:07:36,460 That's where we're working. 114 00:07:36,460 --> 00:07:43,200 And in that triangle, I think we have zero boundary conditions. 115 00:07:43,200 --> 00:07:50,970 And across this edge I think we have natural boundary 116 00:07:50,970 --> 00:07:51,620 conditions. 117 00:07:51,620 --> 00:07:55,420 Slope zero, if I see the picture correctly. 118 00:07:55,420 --> 00:07:57,900 The rotational symmetry would mean 119 00:07:57,900 --> 00:08:00,600 that things are not changing. 120 00:08:00,600 --> 00:08:02,450 That every triangle is the same. 121 00:08:02,450 --> 00:08:07,010 So I think on these boundaries it's the Neumann condition, 122 00:08:07,010 --> 00:08:07,510 dU/dn=0. 123 00:08:07,510 --> 00:08:10,490 124 00:08:10,490 --> 00:08:14,050 And I'm frankly not sure what to do at the origin, 125 00:08:14,050 --> 00:08:18,410 so I'll maybe just try both ways and see. 126 00:08:18,410 --> 00:08:22,790 OK, so there is a real problem. 127 00:08:22,790 --> 00:08:25,830 Of course, it's artificial in the sense 128 00:08:25,830 --> 00:08:27,300 that we know the answer. 129 00:08:27,300 --> 00:08:34,720 But it's a real open question of what does the error look like, 130 00:08:34,720 --> 00:08:36,480 from doing that. 131 00:08:36,480 --> 00:08:38,790 So that's the goal and let me just 132 00:08:38,790 --> 00:08:42,340 say the problem I'll ask you to do, 133 00:08:42,340 --> 00:08:47,910 and it probably is quite enough to be ready for next Friday, 134 00:08:47,910 --> 00:08:51,320 is to use piecewise linear elements. 135 00:08:51,320 --> 00:08:55,470 Which is what I'm going to do. 136 00:08:55,470 --> 00:09:00,010 What every discussion of finite elements will begin with, 137 00:09:00,010 --> 00:09:00,910 linear elements. 138 00:09:00,910 --> 00:09:06,790 Those pyramids that I spoke about at the end of last time. 139 00:09:06,790 --> 00:09:09,040 So that's what I hope, but actually I 140 00:09:09,040 --> 00:09:14,570 would be highly interested, if anybody got into the problem, 141 00:09:14,570 --> 00:09:16,990 to try quadratic elements. 142 00:09:16,990 --> 00:09:25,920 So I'll just say here, second-degree quadratic 143 00:09:25,920 --> 00:09:34,100 polynomials would be more accurate. 144 00:09:34,100 --> 00:09:36,830 Would be more accurate. 145 00:09:36,830 --> 00:09:42,670 So, in other words, this is a first type 146 00:09:42,670 --> 00:09:48,120 of finite element called P_1, for polynomials of degree one. 147 00:09:48,120 --> 00:09:52,990 These guys, I would call P_2, for polynomials of degree two. 148 00:09:52,990 --> 00:09:59,280 And I've mentioned here the possibility of using quads. 149 00:09:59,280 --> 00:10:04,270 Instead of triangles, if I had squares for example, 150 00:10:04,270 --> 00:10:08,380 the simplest element would be a Q_1. 151 00:10:08,380 --> 00:10:12,540 So these are-- If I manage today to tell you 152 00:10:12,540 --> 00:10:19,050 about how to use P_1 and P_2 and Q_1, you're on your way. 153 00:10:19,050 --> 00:10:23,190 And for the requirements of this course, 154 00:10:23,190 --> 00:10:27,410 P_1 is the first point to understand. 155 00:10:27,410 --> 00:10:28,430 OK. 156 00:10:28,430 --> 00:10:30,810 While I'm speaking about codes and meshes, 157 00:10:30,810 --> 00:10:38,310 let me draw the mesh I proposed in the homework problem. 158 00:10:38,310 --> 00:10:42,860 So I thought OK, we just have to have a simple mesh here. 159 00:10:42,860 --> 00:10:47,180 So let me draw that line in. 160 00:10:47,180 --> 00:10:48,840 I know all these points, right? 161 00:10:48,840 --> 00:10:52,300 This is (0, 0) here. 162 00:10:52,300 --> 00:10:57,800 And that point's on the circle. 163 00:10:57,800 --> 00:11:04,120 And so is this, that point might be, so what's the angle there? 164 00:11:04,120 --> 00:11:09,330 That angle is probably pi/8. 165 00:11:09,330 --> 00:11:12,670 The whole angle would be 2pi/8, and eight of them 166 00:11:12,670 --> 00:11:14,470 would go all the way around. 167 00:11:14,470 --> 00:11:17,460 So I think that angle is pi/8. 168 00:11:17,460 --> 00:11:23,180 And so this point would be (cos(pi/8), sin(pi/8)). 169 00:11:23,180 --> 00:11:29,790 We know where they are. 170 00:11:29,790 --> 00:11:32,470 But that's going to be what we have to list. 171 00:11:32,470 --> 00:11:35,090 We have to list where are the coordinates of all the mesh 172 00:11:35,090 --> 00:11:35,800 points. 173 00:11:35,800 --> 00:11:38,490 So let me describe the rest of the mesh points 174 00:11:38,490 --> 00:11:43,440 and then see what that list would look like. 175 00:11:43,440 --> 00:11:51,070 And once you've created the list, the code will take over. 176 00:11:51,070 --> 00:11:55,960 And then you plot the results and see what's going on. 177 00:11:55,960 --> 00:11:59,980 So let me suggest a mesh. 178 00:11:59,980 --> 00:12:01,800 It's pretty straightforward. 179 00:12:01,800 --> 00:12:09,030 I just divided this piece into N, this center thing 180 00:12:09,030 --> 00:12:15,550 into N-- So I called that distance h. 181 00:12:15,550 --> 00:12:20,820 So Nh gets me out to here. 182 00:12:20,820 --> 00:12:24,560 Whatever that is, that's cos(pi/8), I guess, 183 00:12:24,560 --> 00:12:27,410 that's the x coordinate of that line. 184 00:12:27,410 --> 00:12:31,850 So those are mesh points and then let me keep drawing these. 185 00:12:31,850 --> 00:12:34,390 So these will be mesh points too, 186 00:12:34,390 --> 00:12:37,990 and these will be mesh points too. 187 00:12:37,990 --> 00:12:44,850 So at this point, I've got probably 12 or 13 mesh points. 188 00:12:44,850 --> 00:12:47,460 But I've got quads, right? 189 00:12:47,460 --> 00:12:49,120 Well, I've got a couple of triangles 190 00:12:49,120 --> 00:12:51,930 here that I'm not going to touch, those are fine. 191 00:12:51,930 --> 00:12:56,460 But these are quads and they could 192 00:12:56,460 --> 00:13:00,430 be used with the Q_1 element, but I'm thinking 193 00:13:00,430 --> 00:13:02,340 let's stay with triangles. 194 00:13:02,340 --> 00:13:05,490 So I just suggested to put in triangles, 195 00:13:05,490 --> 00:13:10,060 put in these diagonals, keeping symmetry. 196 00:13:10,060 --> 00:13:13,590 And so there's the mesh. 197 00:13:13,590 --> 00:13:15,130 There's the mesh. 198 00:13:15,130 --> 00:13:19,200 And then what does the code ask for? 199 00:13:19,200 --> 00:13:22,220 So I've got 13 mesh points. 200 00:13:22,220 --> 00:13:24,380 And the code, first of all it wants 201 00:13:24,380 --> 00:13:27,360 a list of the coordinates of all those mesh points. 202 00:13:27,360 --> 00:13:32,440 So that the code will-- And I better number them, of course. 203 00:13:32,440 --> 00:13:35,230 So let me number them one, shall I number 204 00:13:35,230 --> 00:13:41,380 them the center guys first, one, two, three, four, five, 205 00:13:41,380 --> 00:13:43,430 and then up here six, seven, eight, nine, now 206 00:13:43,430 --> 00:13:45,760 I don't know if this is a good numbering. 207 00:13:45,760 --> 00:13:48,410 10, 11, 12, 13. 208 00:13:48,410 --> 00:13:57,830 Why don't we, just to have some consistency within plans, 209 00:13:57,830 --> 00:14:01,110 why don't you, you don't have to take N=4. 210 00:14:01,110 --> 00:14:06,280 I hope you'll take, what did I take N as four or five? 211 00:14:06,280 --> 00:14:08,160 Yeah, right. 212 00:14:08,160 --> 00:14:09,990 N is 4. 213 00:14:09,990 --> 00:14:13,370 But you'll want to try different N's. 214 00:14:13,370 --> 00:14:18,000 N=4 would be a good crude start to see what's going 215 00:14:18,000 --> 00:14:23,060 on, but then I hope you'll go higher and get better accuracy. 216 00:14:23,060 --> 00:14:28,230 And you can see how the accuracy improves, how you get closer 217 00:14:28,230 --> 00:14:31,620 to that, as N gets bigger. 218 00:14:31,620 --> 00:14:35,980 OK, we've got the nodes numbered. 219 00:14:35,980 --> 00:14:38,250 Oh, I better number the triangles. 220 00:14:38,250 --> 00:14:40,070 OK, how shall we number the triangles? 221 00:14:40,070 --> 00:14:43,070 Shall we do along the top, or this? 222 00:14:43,070 --> 00:14:44,610 I don't know. 223 00:14:44,610 --> 00:14:48,980 What do you want to do for the numbering of the triangles? 224 00:14:48,980 --> 00:14:50,790 Maybe run along the top, and then 225 00:14:50,790 --> 00:14:53,590 run along the bottom, because then it'll 226 00:14:53,590 --> 00:14:55,160 practically be a copy. 227 00:14:55,160 --> 00:14:59,710 So I didn't leave myself much space, but one, two, three, 228 00:14:59,710 --> 00:15:04,140 four, five, six, seven. 229 00:15:04,140 --> 00:15:07,950 Seven triangles along the top and seven along the bottom, 230 00:15:07,950 --> 00:15:14,340 so I have 14 triangles in this mesh. 231 00:15:14,340 --> 00:15:23,150 So it's a mesh with 14 triangles and 13 nodes. 232 00:15:23,150 --> 00:15:26,220 And I know the positions of everyone, right? 233 00:15:26,220 --> 00:15:29,210 I know the x,y coordinates of every one. 234 00:15:29,210 --> 00:15:34,740 So what the code will want is a list of those coordinates. 235 00:15:34,740 --> 00:15:39,920 So a list p, p will be a list of coordinates. 236 00:15:39,920 --> 00:15:50,810 The first guy will be-- Of the nodes so 13 rows, 3 columns. 237 00:15:50,810 --> 00:15:53,830 So it's a little 13 by 3 matrix that tells you 238 00:15:53,830 --> 00:15:55,580 where all the nodes are. 239 00:15:55,580 --> 00:16:01,330 So the first one on that list would be (0,0). 240 00:16:01,330 --> 00:16:03,330 That's for node one. 241 00:16:03,330 --> 00:16:06,800 And the second one would be whatever the coordinates 242 00:16:06,800 --> 00:16:11,940 of that are, something, zero. (h,0), I guess it is. 243 00:16:11,940 --> 00:16:18,610 The third one will be (2h,0), and so on, and then complete 244 00:16:18,610 --> 00:16:21,000 the list of 13 positions. 245 00:16:21,000 --> 00:16:28,860 So you have then told the code where all the nodes are. 246 00:16:28,860 --> 00:16:30,870 What else do you have to tell it? 247 00:16:30,870 --> 00:16:32,370 Not much. 248 00:16:32,370 --> 00:16:35,350 You now have to tell it about the triangles. 249 00:16:35,350 --> 00:16:39,620 So now for every, why do I say three columns? 250 00:16:39,620 --> 00:16:44,010 Maybe only two, is it? 251 00:16:44,010 --> 00:16:46,460 You see the point already. 252 00:16:46,460 --> 00:16:53,580 I've forgotten, maybe, yeah. 253 00:16:53,580 --> 00:16:58,510 I don't see why. 254 00:16:58,510 --> 00:17:01,560 Well for triangles, I'm going to need three, 255 00:17:01,560 --> 00:17:03,310 for nodes maybe it's only got two. 256 00:17:03,310 --> 00:17:07,250 Maybe it's 13 by 2. 257 00:17:07,250 --> 00:17:10,380 I don't see why I need three. 258 00:17:10,380 --> 00:17:11,460 But, anyway. 259 00:17:11,460 --> 00:17:15,830 Then the other list is triangles. 260 00:17:15,830 --> 00:17:19,890 So this will be the list t, and so it 261 00:17:19,890 --> 00:17:22,450 takes triangle number one. 262 00:17:22,450 --> 00:17:24,990 Which is right here. 263 00:17:24,990 --> 00:17:26,760 That very first triangle. 264 00:17:26,760 --> 00:17:31,690 And what does it have to tell us about triangle one? 265 00:17:31,690 --> 00:17:32,970 The three nodes. 266 00:17:32,970 --> 00:17:35,980 If it tells us the three node numbers, 267 00:17:35,980 --> 00:17:40,810 and this list, p, gave their positions, we've got it. 268 00:17:40,810 --> 00:17:45,380 So how many triangles did that I have? 269 00:17:45,380 --> 00:17:46,310 14? 270 00:17:46,310 --> 00:17:53,830 So t will be 14 by 3, and so the first guy 271 00:17:53,830 --> 00:18:00,750 will be just one, node number one, node number two, 272 00:18:00,750 --> 00:18:02,930 and node number six. 273 00:18:02,930 --> 00:18:06,580 That will tell us which is the first triangle. 274 00:18:06,580 --> 00:18:10,960 And the second triangle, I guess I've drawn from two 275 00:18:10,960 --> 00:18:14,510 to seven to six, right? 276 00:18:14,510 --> 00:18:18,160 That's a very skinny triangle up there 277 00:18:18,160 --> 00:18:21,240 but it's the one that started at node two, went up to seven 278 00:18:21,240 --> 00:18:22,620 and back to six. 279 00:18:22,620 --> 00:18:26,960 So a list like that. 280 00:18:26,960 --> 00:18:32,850 And then the code will do the rest. 281 00:18:32,850 --> 00:18:35,750 I hope. 282 00:18:35,750 --> 00:18:38,320 Almost all the rest. 283 00:18:38,320 --> 00:18:42,740 The code will create the matrix K. It'll create the matrix 284 00:18:42,740 --> 00:18:47,950 K with, it'll be singular. 285 00:18:47,950 --> 00:18:51,500 Boundary conditions won't yet be in there. 286 00:18:51,500 --> 00:18:54,480 And then a final step after that, K, 287 00:18:54,480 --> 00:18:57,910 or maybe we could call it K_0, is created, 288 00:18:57,910 --> 00:19:02,760 a final step will be to fix u. 289 00:19:02,760 --> 00:19:04,600 At least at these three points. 290 00:19:04,600 --> 00:19:08,370 So these three will be boundary nodes. 291 00:19:08,370 --> 00:19:12,750 And as I say, I'm not too sure about that one, I apologize. 292 00:19:12,750 --> 00:19:14,260 At those boundary nodes I'm going 293 00:19:14,260 --> 00:19:16,890 to take the values to be zero. 294 00:19:16,890 --> 00:19:21,010 So this is going to be zero along the whole edge, 295 00:19:21,010 --> 00:19:23,900 because if it's zero there, zero there, zero there and zero 296 00:19:23,900 --> 00:19:27,950 there, and if it's linear, it's zero. 297 00:19:27,950 --> 00:19:34,380 So the final sort of subroutine in the code, 298 00:19:34,380 --> 00:19:39,720 the final group of commands you want to impose, zeroes here, 299 00:19:39,720 --> 00:19:44,480 that should then make the matrix K invertible, 300 00:19:44,480 --> 00:19:49,300 and then you've got KU=F to solve. 301 00:19:49,300 --> 00:19:54,860 So what the code is doing is creating K and F. 302 00:19:54,860 --> 00:19:57,590 You see the overall picture? 303 00:19:57,590 --> 00:20:00,320 I jumped right into this particular mesh, 304 00:20:00,320 --> 00:20:06,540 particular problem, but now I really should back up 305 00:20:06,540 --> 00:20:09,740 to where it starts. 306 00:20:09,740 --> 00:20:14,010 This is going to be the weak form of Laplace, Poisson, 307 00:20:14,010 --> 00:20:24,420 maybe I'll make a little space to put in Poisson's name too. 308 00:20:24,420 --> 00:20:29,770 You have a picture already of what this weak form is about, 309 00:20:29,770 --> 00:20:32,550 so now I'm really backing up to the start. 310 00:20:32,550 --> 00:20:36,660 I take the equation and I get its weak form. 311 00:20:36,660 --> 00:20:39,140 And remember that's in the continuous case, 312 00:20:39,140 --> 00:20:41,730 as it was in the quiz problem. 313 00:20:41,730 --> 00:20:44,940 The first step is the continuous weak form, 314 00:20:44,940 --> 00:20:50,010 and then the second step is choose 315 00:20:50,010 --> 00:20:56,890 test functions and trial-- I'm sorry, gosh, I'm in bad shape 316 00:20:56,890 --> 00:20:59,620 here. 317 00:20:59,620 --> 00:21:02,360 Because they're the same. 318 00:21:02,360 --> 00:21:04,450 This isn't my worst error, today. 319 00:21:04,450 --> 00:21:11,881 But those are trial functions, and these are test functions. 320 00:21:11,881 --> 00:21:14,380 OK, questions at this point, because I've-- Yeah, thank you. 321 00:21:14,380 --> 00:21:15,220 Good. 322 00:21:15,220 --> 00:21:16,590 Let's look at this picture. 323 00:21:16,590 --> 00:21:22,830 AUDIENCE: [INAUDIBLE] 324 00:21:22,830 --> 00:21:30,010 PROFESSOR STRANG: Because-- We did. 325 00:21:30,010 --> 00:21:30,850 That's right. 326 00:21:30,850 --> 00:21:37,180 So because my question is what is-- 327 00:21:37,180 --> 00:21:42,560 The continuous problem I would like to solve has u=0 328 00:21:42,560 --> 00:21:44,930 on the polygon. 329 00:21:44,930 --> 00:21:50,600 So in a way you can forget the circle, 330 00:21:50,600 --> 00:21:52,490 where we know the answer. 331 00:21:52,490 --> 00:21:56,880 Now, we really are looking on the polygon, 332 00:21:56,880 --> 00:21:59,330 and I would like to know what's the solution 333 00:21:59,330 --> 00:22:01,810 like on that polygon. 334 00:22:01,810 --> 00:22:06,490 And then so there are two steps, the first step 335 00:22:06,490 --> 00:22:09,130 was start with a circle, we have the answer. 336 00:22:09,130 --> 00:22:14,180 Second step is go to a polygon, continuous problem, Poisson's 337 00:22:14,180 --> 00:22:16,120 equation in the polygon. 338 00:22:16,120 --> 00:22:18,930 How different is that from this? 339 00:22:18,930 --> 00:22:23,010 Because this will not satisfy the polygon 340 00:22:23,010 --> 00:22:24,480 boundary conditions. 341 00:22:24,480 --> 00:22:28,330 So that's the circle answer. 342 00:22:28,330 --> 00:22:32,460 Then the question is, what's the polygon answer. 343 00:22:32,460 --> 00:22:36,070 And I don't know that. 344 00:22:36,070 --> 00:22:39,070 You may say a regular polygon, you can't do that. 345 00:22:39,070 --> 00:22:41,270 I didn't think you can. 346 00:22:41,270 --> 00:22:44,490 It's amazing, but probably a triangle or a square. 347 00:22:44,490 --> 00:22:49,780 So if M is three or four, probably some formulas 348 00:22:49,780 --> 00:22:50,670 would be available. 349 00:22:50,670 --> 00:22:52,990 But I think once we get higher, I 350 00:22:52,990 --> 00:22:55,990 don't know the answer to the Dirichlet problem, 351 00:22:55,990 --> 00:23:00,890 to Poisson's equation on a polygon, on a regular polygon. 352 00:23:00,890 --> 00:23:03,830 And that's what I would really like to know more about. 353 00:23:03,830 --> 00:23:06,190 And how do I find out more about it? 354 00:23:06,190 --> 00:23:08,670 By finite elements. 355 00:23:08,670 --> 00:23:11,780 With your help. 356 00:23:11,780 --> 00:23:16,070 Taking that polygon, breaking it into a mesh, 357 00:23:16,070 --> 00:23:19,960 looking only at one triangle just for simplicity, 358 00:23:19,960 --> 00:23:24,510 and getting u finite elements. 359 00:23:24,510 --> 00:23:26,350 Well, I should say u_(P_1). 360 00:23:26,350 --> 00:23:30,750 361 00:23:30,750 --> 00:23:34,560 That's the finite element solution using linear. 362 00:23:34,560 --> 00:23:39,130 I would really like to know u_(P_2), 363 00:23:39,130 --> 00:23:43,470 the finite element solution which will be better, 364 00:23:43,470 --> 00:23:45,260 if I use quadratics. 365 00:23:45,260 --> 00:23:47,420 So now I get the fun of describing 366 00:23:47,420 --> 00:23:51,090 the linear elements, the quadratic elements, the quads. 367 00:23:51,090 --> 00:23:53,080 But did I answer that question OK? 368 00:23:53,080 --> 00:23:54,070 Yeah. 369 00:23:54,070 --> 00:23:59,630 So this is the problem I would like to know the answer to. 370 00:23:59,630 --> 00:24:04,170 If I have this equation, zero boundary 371 00:24:04,170 --> 00:24:07,970 conditions on a regular polygon with M sides, 372 00:24:07,970 --> 00:24:09,780 what's the answer? 373 00:24:09,780 --> 00:24:13,270 And it's going to be close to this, but it won't be the same. 374 00:24:13,270 --> 00:24:17,830 Because this does not vanish on the polygon edges. 375 00:24:17,830 --> 00:24:22,740 And I would like to compare the slopes, too. 376 00:24:22,740 --> 00:24:25,970 So the homework problem asked you not only to compare 377 00:24:25,970 --> 00:24:32,820 u_circle with u_(P_1), but also the slopes. 378 00:24:32,820 --> 00:24:35,380 The slopes here are easy, slopes here 379 00:24:35,380 --> 00:24:39,420 are easy because it's a bunch of flat functions. 380 00:24:39,420 --> 00:24:43,190 So the slopes are just constant in each triangle. 381 00:24:43,190 --> 00:24:48,720 OK, I'm guessing that the error gets smaller as you go in. 382 00:24:48,720 --> 00:24:50,810 I think that if you plot the error, 383 00:24:50,810 --> 00:24:53,920 it'll be largest out here and get small there. 384 00:24:53,920 --> 00:24:56,750 But remains to be seen. 385 00:24:56,750 --> 00:24:59,180 So I hope you enjoy-- yeah, good. 386 00:24:59,180 --> 00:25:05,930 AUDIENCE: [INAUDIBLE] 387 00:25:05,930 --> 00:25:07,480 PROFESSOR STRANG: Rather than seven. 388 00:25:07,480 --> 00:25:13,800 AUDIENCE: [INAUDIBLE] 389 00:25:13,800 --> 00:25:17,610 PROFESSOR STRANG: No, the middle. 390 00:25:17,610 --> 00:25:21,670 There's nothing magic about any particular mesh. 391 00:25:21,670 --> 00:25:24,750 I just chose this mesh as pretty good, 392 00:25:24,750 --> 00:25:34,737 and actually, I'm imagining M could get pretty big. 393 00:25:34,737 --> 00:25:35,820 That would be interesting. 394 00:25:35,820 --> 00:25:40,580 M=8 would be interesting, M=16, M=1,024, 395 00:25:40,580 --> 00:25:42,760 now then I'd really get interested. 396 00:25:42,760 --> 00:25:50,130 OK, but so if M is 1,024, then this side would be very small. 397 00:25:50,130 --> 00:25:52,060 Right? 398 00:25:52,060 --> 00:25:55,590 And I just wanted more triangles. 399 00:25:55,590 --> 00:25:58,590 Actually, I would like more than I've got. 400 00:25:58,590 --> 00:26:04,760 I'd like, if M was really big, then 401 00:26:04,760 --> 00:26:07,540 probably N should be at least that big. 402 00:26:07,540 --> 00:26:09,570 So I should have a thousand this way, 403 00:26:09,570 --> 00:26:11,100 if this is just a tiny bit. 404 00:26:11,100 --> 00:26:14,970 I just want little tiny h, and then, yeah. 405 00:26:14,970 --> 00:26:18,040 Actually, that might not be too bad. 406 00:26:18,040 --> 00:26:20,900 If M and N were roughly comparable, 407 00:26:20,900 --> 00:26:26,460 then that length would be roughly 408 00:26:26,460 --> 00:26:28,580 comparable to these lengths. 409 00:26:28,580 --> 00:26:33,610 And the triangles would be pretty good shapes. 410 00:26:33,610 --> 00:26:36,780 And that's what you're looking for. 411 00:26:36,780 --> 00:26:43,070 I think there's a lot of experiments to be done here. 412 00:26:43,070 --> 00:26:46,160 So, I'm thinking then of M and N. Here 413 00:26:46,160 --> 00:26:48,560 I took N to be just four. 414 00:26:48,560 --> 00:26:50,500 When M was eight. 415 00:26:50,500 --> 00:26:51,780 That's fine. 416 00:26:51,780 --> 00:26:55,240 But if you keep M and N roughly the same size, 417 00:26:55,240 --> 00:27:00,600 then you've got triangles that are not too long and skinny. 418 00:27:00,600 --> 00:27:04,130 I'll tell you when you might want. 419 00:27:04,130 --> 00:27:07,590 So generally you want nice shaped triangles. 420 00:27:07,590 --> 00:27:13,260 You don't want angles very small or very large, usually. 421 00:27:13,260 --> 00:27:18,410 But there would be, anybody in Course 16 422 00:27:18,410 --> 00:27:23,330 can imagine that if I am computing the flow 423 00:27:23,330 --> 00:27:31,120 field past a wing, that long, thin triangles in the direction 424 00:27:31,120 --> 00:27:33,030 of the wing are natural. 425 00:27:33,030 --> 00:27:41,390 I mean, somehow a problem like true aerodynamics 426 00:27:41,390 --> 00:27:43,210 is by no means isotropic. 427 00:27:43,210 --> 00:27:44,940 I mean, the direction of the wing 428 00:27:44,940 --> 00:27:49,410 is kind of critical to whether the plane flies, right? 429 00:27:49,410 --> 00:27:54,670 So don't make the wing vertical. 430 00:27:54,670 --> 00:27:56,430 And if you want accuracy, then you 431 00:27:56,430 --> 00:27:59,880 have long, thin triangles in the direction of the flow. 432 00:27:59,880 --> 00:28:02,140 But here we're not doing a flow problem. 433 00:28:02,140 --> 00:28:04,740 We haven't got shocks, or trailing edges, 434 00:28:04,740 --> 00:28:10,080 and other horrible stuff that makes planes fly. 435 00:28:10,080 --> 00:28:12,960 We just got Poisson's equation. 436 00:28:12,960 --> 00:28:13,720 OK. 437 00:28:13,720 --> 00:28:15,595 Thanks for those good questions, another one. 438 00:28:15,595 --> 00:28:18,582 AUDIENCE: [INAUDIBLE] 439 00:28:18,582 --> 00:28:20,790 PROFESSOR STRANG: What would the dimension look like? 440 00:28:20,790 --> 00:28:24,710 Ah, would you like me to show you something about quadratics? 441 00:28:24,710 --> 00:28:27,030 Yeah. 442 00:28:27,030 --> 00:28:30,980 Shall I jump into quadratics, it's kind of fun. 443 00:28:30,980 --> 00:28:36,700 Quadratics, so let me just do-- So I'll 444 00:28:36,700 --> 00:28:40,630 come back to the weak form, right it's totally-- 445 00:28:40,630 --> 00:28:41,730 Oh, I'll do it now. 446 00:28:41,730 --> 00:28:44,110 It's so simple I don't want to forget it. 447 00:28:44,110 --> 00:28:51,330 The weak form, so I write the equation down, -u_xx-u_yy=f. 448 00:28:51,330 --> 00:28:57,920 This is the continuous weak form, equal f(x,y), OK? 449 00:28:57,920 --> 00:29:00,400 So that's the strong form. 450 00:29:00,400 --> 00:29:04,780 And I've made it the Laplacian here to keep it simple, 451 00:29:04,780 --> 00:29:06,640 and any right-hand side. 452 00:29:06,640 --> 00:29:09,560 OK, how do I get to the weak form? 453 00:29:09,560 --> 00:29:14,940 Just remind me, I multiply both sides by any test function 454 00:29:14,940 --> 00:29:17,680 v(x,y). 455 00:29:17,680 --> 00:29:23,180 Multiply by v(x,y), and then what do I do? 456 00:29:23,180 --> 00:29:28,260 I integrate over the whole region. 457 00:29:28,260 --> 00:29:36,780 So that's the weak form, dxdy, this is for all v, all v(x,y), 458 00:29:36,780 --> 00:29:42,340 all, I'll say all admissible v(x,y). 459 00:29:42,340 --> 00:29:45,830 So that's the weak form. 460 00:29:45,830 --> 00:29:51,420 If this holds for this great family of v's, the idea behind 461 00:29:51,420 --> 00:29:56,060 it is, that if this holds for all these trial functions, 462 00:29:56,060 --> 00:30:00,740 test functions, v(x,y), the only way that can happen is for this 463 00:30:00,740 --> 00:30:03,560 to actually equal that. 464 00:30:03,560 --> 00:30:12,370 That's a fundamental lemma in this part of math, 465 00:30:12,370 --> 00:30:15,630 and of course it has to be spelled out 466 00:30:15,630 --> 00:30:17,280 more than I'm doing in words. 467 00:30:17,280 --> 00:30:22,120 But the idea is that if these hold for such a large class 468 00:30:22,120 --> 00:30:25,520 of v(x,y), then the only way that can happen is 469 00:30:25,520 --> 00:30:26,980 for the strong form to hold. 470 00:30:26,980 --> 00:30:29,260 For this to actually match this. 471 00:30:29,260 --> 00:30:31,290 OK, so that's the start. 472 00:30:31,290 --> 00:30:35,470 But then what's the next step in the weak form? 473 00:30:35,470 --> 00:30:37,790 I like the right-hand side but I'm not 474 00:30:37,790 --> 00:30:39,990 so crazy about the left-hand side. 475 00:30:39,990 --> 00:30:41,820 I'm not crazy about it because this 476 00:30:41,820 --> 00:30:47,940 has second derivatives of u, and my little roof functions, 477 00:30:47,940 --> 00:30:51,640 pyramid functions, haven't got second derivatives. 478 00:30:51,640 --> 00:30:54,150 So I would be dead in the water without doing 479 00:30:54,150 --> 00:30:58,530 the natural step that makes everything beautiful, which is? 480 00:30:58,530 --> 00:31:00,160 Integration by parts. 481 00:31:00,160 --> 00:31:01,320 Integrate by parts. 482 00:31:01,320 --> 00:31:07,540 Move derivatives off of u, onto v. One derivative onto v, 483 00:31:07,540 --> 00:31:12,320 off of u, so then u and v each have one derivative. 484 00:31:12,320 --> 00:31:17,180 I can use my piecewise linear, piecewise quadratic, 485 00:31:17,180 --> 00:31:20,080 all my finite elements are going to go fine. 486 00:31:20,080 --> 00:31:22,370 So I integrate by parts. 487 00:31:22,370 --> 00:31:28,000 So integrate by parts, and what is that mean in 2-D? 488 00:31:28,000 --> 00:31:30,830 Of course I have a double integral here. 489 00:31:30,830 --> 00:31:37,990 So integrate by parts, that mean you use the Green's formula. 490 00:31:37,990 --> 00:31:47,230 That was the key point of this Green, or Gauss-Green formula. 491 00:31:47,230 --> 00:32:01,630 Can I do it first in, this is -div(grad u), times v dxdy, 492 00:32:01,630 --> 00:32:03,740 we can write out all the terms. 493 00:32:03,740 --> 00:32:05,750 We can use vector notation. 494 00:32:05,750 --> 00:32:09,770 I could use that nabla, that upside down triangle notation, 495 00:32:09,770 --> 00:32:10,730 or whatever. 496 00:32:10,730 --> 00:32:13,710 But maybe good to see it a few different ways. 497 00:32:13,710 --> 00:32:15,220 So what's the point? 498 00:32:15,220 --> 00:32:20,220 When I integrate by parts, that minus disappears to a plus, 499 00:32:20,220 --> 00:32:26,080 I have a double integral then, and these derivatives move 500 00:32:26,080 --> 00:32:31,360 off of-- I'm taking one derivative off of here, 501 00:32:31,360 --> 00:32:35,540 the divergence moves over there, but when the divergence moves 502 00:32:35,540 --> 00:32:38,140 onto v it becomes? 503 00:32:38,140 --> 00:32:39,890 The transpose. 504 00:32:39,890 --> 00:32:40,890 It becomes gradient. 505 00:32:40,890 --> 00:32:52,520 And so this is gradient of u, gradient of v, dxdy. 506 00:32:52,520 --> 00:32:54,860 Plus boundary terms. 507 00:32:54,860 --> 00:32:58,700 The integral of, what is, let's see. 508 00:32:58,700 --> 00:33:02,730 509 00:33:02,730 --> 00:33:12,380 What do I have in this integral, I have grad u dot n, times v 510 00:33:12,380 --> 00:33:14,090 around the boundary. 511 00:33:14,090 --> 00:33:19,140 And with my boundary conditions that's going to be gone, 512 00:33:19,140 --> 00:33:20,720 so I can come back to that. 513 00:33:20,720 --> 00:33:25,410 Now, you all looked a little uncertain 514 00:33:25,410 --> 00:33:29,090 when I wrote Green's formula this way. 515 00:33:29,090 --> 00:33:33,630 For this problem I can write it more easily. 516 00:33:33,630 --> 00:33:36,770 This is my left side. 517 00:33:36,770 --> 00:33:39,160 I want to write the answer, I just 518 00:33:39,160 --> 00:33:44,960 want to write this weak form in a much simpler form. 519 00:33:44,960 --> 00:33:49,970 So let me say, what have I got here. 520 00:33:49,970 --> 00:33:53,390 Well, all I've got is one derivative 521 00:33:53,390 --> 00:33:57,320 is moving off of u and onto v. And the minus sign 522 00:33:57,320 --> 00:34:02,890 is disappearing, so I have du/dx times dv/dx. 523 00:34:02,890 --> 00:34:03,940 Right? 524 00:34:03,940 --> 00:34:08,390 One off of u, onto v. The other term, 525 00:34:08,390 --> 00:34:13,730 one y derivative, moving off of this and onto v. Minus sign 526 00:34:13,730 --> 00:34:15,640 again going to a plus. 527 00:34:15,640 --> 00:34:19,700 du/dy, dv/dy. 528 00:34:19,700 --> 00:34:20,770 That's the integral. 529 00:34:20,770 --> 00:34:22,860 That's it, that's cool. 530 00:34:22,860 --> 00:34:24,910 Easy to do. 531 00:34:24,910 --> 00:34:29,270 And on the right-hand side of course I have no change. 532 00:34:29,270 --> 00:34:34,410 The integral of f(x,y) v(x,y) dy. 533 00:34:34,410 --> 00:34:36,101 Now, that's the weak form. 534 00:34:36,101 --> 00:34:36,600 dxdy. 535 00:34:36,600 --> 00:34:44,420 536 00:34:44,420 --> 00:34:52,780 Here it is, weak form. 537 00:34:52,780 --> 00:34:55,210 That's pretty nice. 538 00:34:55,210 --> 00:34:58,050 Beautifully symmetric, so the matrix 539 00:34:58,050 --> 00:35:03,660 that comes up when we plug in finite specific trial functions 540 00:35:03,660 --> 00:35:06,310 and test functions is going to be a symmetric matrix 541 00:35:06,310 --> 00:35:11,050 K. And the integrals are of first derivatives, 542 00:35:11,050 --> 00:35:18,230 so as long as our functions, our trial functions and test 543 00:35:18,230 --> 00:35:24,270 functions are continuous, that is, they shouldn't jump. 544 00:35:24,270 --> 00:35:27,540 If the trial functions or test functions jump, 545 00:35:27,540 --> 00:35:31,180 then if I have a jump, then the derivative would be a delta. 546 00:35:31,180 --> 00:35:33,000 I'd have another delta here, I'd have 547 00:35:33,000 --> 00:35:37,010 an integral delta, a delta times delta, and I don't want that. 548 00:35:37,010 --> 00:35:39,720 That's infinite. 549 00:35:39,720 --> 00:35:44,960 Those discontinuous elements would not be conforming, 550 00:35:44,960 --> 00:35:48,800 and that's a whole new world of discontinuous Galerkin. 551 00:35:48,800 --> 00:35:50,940 I'd have to impose penalty stuff, 552 00:35:50,940 --> 00:35:54,070 and Professor Peraire I mentioned, 553 00:35:54,070 --> 00:36:00,720 and others, Professor Darmofal in aero, are experts on this. 554 00:36:00,720 --> 00:36:02,900 We're doing continuous Galerkin. 555 00:36:02,900 --> 00:36:04,930 CG. 556 00:36:04,930 --> 00:36:07,480 Our piecewise linear, piecewise quadratic, 557 00:36:07,480 --> 00:36:08,870 they'll be continuous. 558 00:36:08,870 --> 00:36:11,410 All I have to do is these derivatives. 559 00:36:11,410 --> 00:36:14,690 Integrate those things and that's what the code will do. 560 00:36:14,690 --> 00:36:19,980 OK, I've got to the weak form. 561 00:36:19,980 --> 00:36:22,650 That's the weak form. 562 00:36:22,650 --> 00:36:25,350 Now comes the finite element idea. 563 00:36:25,350 --> 00:36:28,980 So there is our weak form, now ready for the finite element 564 00:36:28,980 --> 00:36:31,310 idea. 565 00:36:31,310 --> 00:36:34,430 OK, so what was that idea? 566 00:36:34,430 --> 00:36:36,720 That's the continuous problem. 567 00:36:36,720 --> 00:36:47,600 Now, the finite element idea is, plug in U as a combination-- 568 00:36:47,600 --> 00:36:52,170 Let me write out the terms. 569 00:36:52,170 --> 00:36:55,160 You know what's coming here. 570 00:36:55,160 --> 00:36:57,260 If I'm using finite elements, I'm 571 00:36:57,260 --> 00:37:07,650 going to choose nice polynomials phi, say N of them. 572 00:37:07,650 --> 00:37:09,910 That would be like, one for every node, 573 00:37:09,910 --> 00:37:14,990 so I would have 13 functions here. 574 00:37:14,990 --> 00:37:18,670 I'm going to choose the V's to be the same as the phis. 575 00:37:18,670 --> 00:37:22,850 And then, I'm working then in 13 dimensions 576 00:37:22,850 --> 00:37:26,380 instead of infinite dimensions. 577 00:37:26,380 --> 00:37:29,040 So what do I do? 578 00:37:29,040 --> 00:37:33,430 For this limited subspace, this finite element subspace, 579 00:37:33,430 --> 00:37:37,290 this piecewise polynomial, piecewise linear subspace, 580 00:37:37,290 --> 00:37:41,080 I plug that into the weak form and I test it 581 00:37:41,080 --> 00:37:45,860 against 13 V's, which are phis. 582 00:37:45,860 --> 00:37:53,130 So I plug that in, so now what is K? 583 00:37:53,130 --> 00:37:59,580 Now let me just say, so I now have the integral of, 584 00:37:59,580 --> 00:38:03,430 yeah I guess I'd better plug it in. 585 00:38:03,430 --> 00:38:07,630 K_ij would then be the integral -- 586 00:38:07,630 --> 00:38:16,910 I'm just copying the weak form in -- Of dU/dx d-- no, sorry, 587 00:38:16,910 --> 00:38:22,360 I'd better just plug it in first. 588 00:38:22,360 --> 00:38:32,730 dU/dx*dV/dx plus dU/dy*dV/dy, those are the integrals I have 589 00:38:32,730 --> 00:38:33,270 to do. 590 00:38:33,270 --> 00:38:35,120 And on the right hand side I have 591 00:38:35,120 --> 00:38:40,460 to do the f-integral. fV dxdy. 592 00:38:40,460 --> 00:38:44,760 OK, plug that in. 593 00:38:44,760 --> 00:38:48,950 That's the integral over the whole domain. 594 00:38:48,950 --> 00:38:56,070 When I plug it in this U is a combination of known functions 595 00:38:56,070 --> 00:39:05,230 and the V's will be the same guys. 596 00:39:05,230 --> 00:39:08,850 So what am I going to get here? 597 00:39:08,850 --> 00:39:14,750 It's just as in 1-D. So no new ideas entering here. 598 00:39:14,750 --> 00:39:20,680 The new idea's going to enter when I construct these phis. 599 00:39:20,680 --> 00:39:23,230 Let me just say, though, one thing. 600 00:39:23,230 --> 00:39:27,970 In 1-D, we pretty much had a choice 601 00:39:27,970 --> 00:39:31,380 of-- When it was one dimension. 602 00:39:31,380 --> 00:39:34,600 Just remember that. 603 00:39:34,600 --> 00:39:39,540 In one dimension, when I had these hat functions, 604 00:39:39,540 --> 00:39:43,210 when I had these guys, integrated against these guys, 605 00:39:43,210 --> 00:39:45,410 I pretty much had a choice of did 606 00:39:45,410 --> 00:39:48,210 I want to think about integrating that hat 607 00:39:48,210 --> 00:39:50,390 function against that one. 608 00:39:50,390 --> 00:39:53,380 Or actually it was their derivatives. 609 00:39:53,380 --> 00:39:58,280 It was the integral of U, yeah. 610 00:39:58,280 --> 00:40:02,080 Of phi, what I needed was all the integrals 611 00:40:02,080 --> 00:40:06,530 of phi_i', phi_j'. 612 00:40:06,530 --> 00:40:13,700 Those are what I needed, these go into K. Into the matrix K. 613 00:40:13,700 --> 00:40:16,880 In fact, that's what equals K_ij, 614 00:40:16,880 --> 00:40:18,410 the integral of phi prime. 615 00:40:18,410 --> 00:40:21,950 In 1-D. OK. 616 00:40:21,950 --> 00:40:26,940 Now, what I was going to say, I could do it 617 00:40:26,940 --> 00:40:28,690 this way if I wanted. 618 00:40:28,690 --> 00:40:30,860 But you remember the other way to do it? 619 00:40:30,860 --> 00:40:33,890 Was element at a time. 620 00:40:33,890 --> 00:40:36,190 So this was one method here. 621 00:40:36,190 --> 00:40:43,980 That found the entries of K separately, one by one. 622 00:40:43,980 --> 00:40:47,840 The other way was take the elements, one by one. 623 00:40:47,840 --> 00:40:52,010 So the other way was take an element like this element. 624 00:40:52,010 --> 00:40:56,970 It's got two functions, two trial functions 625 00:40:56,970 --> 00:40:57,850 are involved there. 626 00:40:57,850 --> 00:41:02,530 There's a little two by two, so this is four. 627 00:41:02,530 --> 00:41:08,090 Two by two element matrices K_e. 628 00:41:08,090 --> 00:41:12,040 And the quiz recalled that part. 629 00:41:12,040 --> 00:41:13,550 That approach. 630 00:41:13,550 --> 00:41:16,240 So what I want to say is that's the right way 631 00:41:16,240 --> 00:41:18,510 to do it in two dimensions. 632 00:41:18,510 --> 00:41:20,240 A triangle at a time. 633 00:41:20,240 --> 00:41:22,710 That's the way the code will do it. 634 00:41:22,710 --> 00:41:25,600 It creates these little element matrices, 635 00:41:25,600 --> 00:41:32,500 and then it stamps them into the big matrix K. Alright. 636 00:41:32,500 --> 00:41:42,150 So I want to do this integral one triangle at a time. 637 00:41:42,150 --> 00:41:45,420 Is the good way. 638 00:41:45,420 --> 00:41:47,590 OK, and that's what the code will do. 639 00:41:47,590 --> 00:41:50,070 Actually, I think that the best way 640 00:41:50,070 --> 00:41:55,480 to learn these steps is just to read the lines of the code. 641 00:41:55,480 --> 00:41:59,520 You can read them in the book, page 303 or something. 642 00:41:59,520 --> 00:42:05,430 And you'll see it just doing all the steps that need to be done. 643 00:42:05,430 --> 00:42:07,930 One triangle at a time. 644 00:42:07,930 --> 00:42:11,280 So, now. 645 00:42:11,280 --> 00:42:12,540 Now comes the fun. 646 00:42:12,540 --> 00:42:15,910 I get to answer, what do these piecewise linear elements look 647 00:42:15,910 --> 00:42:16,410 like? 648 00:42:16,410 --> 00:42:18,750 What do the quadratic elements look like? 649 00:42:18,750 --> 00:42:24,340 What do the Q_1, quad elements look like? 650 00:42:24,340 --> 00:42:28,310 This was the golden age of finite elements, 651 00:42:28,310 --> 00:42:33,290 when people invented these ways to create 652 00:42:33,290 --> 00:42:35,490 piecewise polynomials. 653 00:42:35,490 --> 00:42:37,100 And it continues. 654 00:42:37,100 --> 00:42:41,680 People are still inventing, I had a email this week, 655 00:42:41,680 --> 00:42:44,750 somebody says I've got spectral elements. 656 00:42:44,750 --> 00:42:47,400 People are going higher and higher degrees. 657 00:42:47,400 --> 00:42:51,840 You, know sixth degree, eighth degree. 658 00:42:51,840 --> 00:42:53,700 In order to get more accuracy. 659 00:42:53,700 --> 00:42:57,400 OK, let's start with P_1. 660 00:42:57,400 --> 00:43:02,100 How do I describe a P_1 element inside a triangle? 661 00:43:02,100 --> 00:43:07,490 So in a triangle, the unknowns will 662 00:43:07,490 --> 00:43:11,910 be the value-- This has a height U_1, 663 00:43:11,910 --> 00:43:17,220 this has a height U_2, and a height U_3 at those nodes. 664 00:43:17,220 --> 00:43:24,531 Inside the triangle, the function U is linear. 665 00:43:24,531 --> 00:43:25,030 a+bx+cy. 666 00:43:25,030 --> 00:43:31,410 667 00:43:31,410 --> 00:43:37,670 Then, you see that if I know these three values, then 668 00:43:37,670 --> 00:43:39,770 I know these three numbers. 669 00:43:39,770 --> 00:43:40,820 And vice versa. 670 00:43:40,820 --> 00:43:43,550 There's a three by three matrix, right? 671 00:43:43,550 --> 00:43:46,480 There has to be a three by-- Any time you see pictures 672 00:43:46,480 --> 00:43:49,510 like this, like the good part of 18.085 673 00:43:49,510 --> 00:43:52,370 is to realize that if I have three numbers here, 674 00:43:52,370 --> 00:43:55,210 three values and I've got three coefficients, 675 00:43:55,210 --> 00:43:58,140 that there's some three by three matrix that connects them 676 00:43:58,140 --> 00:43:59,650 that you're going to need. 677 00:43:59,650 --> 00:44:04,430 That's like a meta-message of this course. 678 00:44:04,430 --> 00:44:13,550 Is, you've got to translate between the node values 679 00:44:13,550 --> 00:44:15,500 and the coefficients. 680 00:44:15,500 --> 00:44:19,760 Because the node values are the unknowns, right? 681 00:44:19,760 --> 00:44:22,260 These are the guys that are multiplying the pyramid 682 00:44:22,260 --> 00:44:25,370 function, this is multiplying a pyramid function 683 00:44:25,370 --> 00:44:30,920 with height one at that point, going down to zero. 684 00:44:30,920 --> 00:44:34,240 So this one will be a pyramid function of height U_2 685 00:44:34,240 --> 00:44:36,430 times one, going down to zero. 686 00:44:36,430 --> 00:44:38,080 And U_3. 687 00:44:38,080 --> 00:44:42,680 So we've got a flat function in here. 688 00:44:42,680 --> 00:44:44,970 And it looks exactly like that. 689 00:44:44,970 --> 00:44:46,840 OK? 690 00:44:46,840 --> 00:44:51,220 So what do I want to say? 691 00:44:51,220 --> 00:44:57,010 We know the positions of these three nodes from our list p, 692 00:44:57,010 --> 00:44:57,840 right? 693 00:44:57,840 --> 00:45:00,530 These were the crucial things we needed. 694 00:45:00,530 --> 00:45:05,240 The positions of all the nodes, we know where they are. 695 00:45:05,240 --> 00:45:10,960 Then there has to be a three by three matrix that will now 696 00:45:10,960 --> 00:45:13,510 connect to the coefficients. 697 00:45:13,510 --> 00:45:15,450 Why do we want the coefficients? 698 00:45:15,450 --> 00:45:18,630 Because those are what we do when we integrate. 699 00:45:18,630 --> 00:45:20,690 The coefficients are what we need, 700 00:45:20,690 --> 00:45:23,460 we need to integrate dU/dx, dU/dy, dU/dz. 701 00:45:23,460 --> 00:45:27,930 Sorry, dU/dx, dU/dy. 702 00:45:27,930 --> 00:45:36,870 Are you visualizing this overall solution capital U, yeah. 703 00:45:36,870 --> 00:45:39,230 So the overall solution capital U, 704 00:45:39,230 --> 00:45:41,820 you should visualize with a combination of all 705 00:45:41,820 --> 00:45:45,100 the little U's, is zero here and then 706 00:45:45,100 --> 00:45:48,700 it's going to go up in these triangles and bend around 707 00:45:48,700 --> 00:45:51,580 and, I don't know, maybe down again. 708 00:45:51,580 --> 00:45:53,690 Or maybe, no, maybe it keeps going up. 709 00:45:53,690 --> 00:45:57,530 This is probably the largest value, 710 00:45:57,530 --> 00:46:00,850 because it's the largest value in the correct solution. 711 00:46:00,850 --> 00:46:11,060 So is this is probably going to be the highest point of this, 712 00:46:11,060 --> 00:46:14,370 what's-- The Forbidden City, right? 713 00:46:14,370 --> 00:46:21,770 In China, in Beijing is like, or a single-- Do pagodas 714 00:46:21,770 --> 00:46:23,821 have flat--? 715 00:46:23,821 --> 00:46:24,320 No. 716 00:46:24,320 --> 00:46:29,360 We we will meet pagoda functions. 717 00:46:29,360 --> 00:46:34,430 But this would be just an ordinary western roof, I guess. 718 00:46:34,430 --> 00:46:35,830 Just flat pieces. 719 00:46:35,830 --> 00:46:36,570 Yeah. 720 00:46:36,570 --> 00:46:40,290 OK, see, you've got to see the whole thing 721 00:46:40,290 --> 00:46:42,610 and then you look at each piece. 722 00:46:42,610 --> 00:46:47,450 Each piece looks like that, and the integrals are doable. 723 00:46:47,450 --> 00:46:54,240 OK, so while I'm going here, I want to do quadratics. 724 00:46:54,240 --> 00:46:55,880 You'll get the idea right away. 725 00:46:55,880 --> 00:46:59,040 So, same triangle, now I'm going to have quadratics. 726 00:46:59,040 --> 00:47:01,810 So I'm now going to have, so this won't be the arrow, 727 00:47:01,810 --> 00:47:04,000 this arrow will now go this way. 728 00:47:04,000 --> 00:47:10,530 I'm going to have d x squared, exy, and f y squared. 729 00:47:10,530 --> 00:47:12,160 So now how many coefficients have 730 00:47:12,160 --> 00:47:15,580 I got to determine a quadratic? 731 00:47:15,580 --> 00:47:18,240 Six, right? a, b, c, d, e, f. 732 00:47:18,240 --> 00:47:20,680 How many nodes do I need? 733 00:47:20,680 --> 00:47:21,700 Six. 734 00:47:21,700 --> 00:47:22,650 Where are they? 735 00:47:22,650 --> 00:47:29,710 Well, the natural positions are those guys in the mid-points. 736 00:47:29,710 --> 00:47:33,310 So now, those are all nodes now. 737 00:47:33,310 --> 00:47:38,010 Some nodes are at vertices of triangles, 738 00:47:38,010 --> 00:47:39,790 some nodes are at midpoints. 739 00:47:39,790 --> 00:47:42,320 But remember, we've got other triangles 740 00:47:42,320 --> 00:47:45,180 hooking on here, many other triangles, 741 00:47:45,180 --> 00:47:48,170 all with their own six nodes. 742 00:47:48,170 --> 00:47:51,310 Well, not their own, because they share. 743 00:47:51,310 --> 00:47:53,730 That's a big point. 744 00:47:53,730 --> 00:47:59,970 So there's a grid of triangles, with nodes for quadratic. 745 00:47:59,970 --> 00:48:02,750 And we've got one, two, three, four, five, six, seven, eight, 746 00:48:02,750 --> 00:48:09,410 nine, ten, 11, 12, 13, 14, 15, 16 nodes, I think. 747 00:48:09,410 --> 00:48:13,370 And within each triangle, this is what we've got. 748 00:48:13,370 --> 00:48:17,930 So there's a six by six matrix for each triangle. 749 00:48:17,930 --> 00:48:20,440 A six by six matrix which will connect 750 00:48:20,440 --> 00:48:29,260 the values U_1, U_2, U_3, U_4, U_5, U_6 for this triangle. 751 00:48:29,260 --> 00:48:33,510 Connect those six heights with these six numbers. 752 00:48:33,510 --> 00:48:42,100 And what will the roof look like within that triangle? 753 00:48:42,100 --> 00:48:44,000 Well, sort of curved. 754 00:48:44,000 --> 00:48:45,200 A parabola, right? 755 00:48:45,200 --> 00:48:49,290 A parabola somehow in 2-D, it'll look like this, yeah. 756 00:48:49,290 --> 00:48:49,790 Yeah. 757 00:48:49,790 --> 00:48:52,280 And here's the key question. 758 00:48:52,280 --> 00:48:59,350 Will that roof, that curvy roof, fit the one over there? 759 00:48:59,350 --> 00:49:01,830 Because if it didn't fit, we're in trouble. 760 00:49:01,830 --> 00:49:03,890 This derivative would have a delta function, 761 00:49:03,890 --> 00:49:07,640 and we've got delta functions, and integrals squaring them 762 00:49:07,640 --> 00:49:09,320 would give infinite. 763 00:49:09,320 --> 00:49:10,930 So here's the question. 764 00:49:10,930 --> 00:49:16,830 Why does this roof, using these six points, fit onto the roof 765 00:49:16,830 --> 00:49:23,900 that uses U_7, U_8, U_9, and U_3, U_4 and U_5? 766 00:49:23,900 --> 00:49:26,230 Why do those two roofs fit together? 767 00:49:26,230 --> 00:49:30,990 This is the fun of piecewise polynomials? 768 00:49:30,990 --> 00:49:33,200 Of course, the slope will change. 769 00:49:33,200 --> 00:49:35,480 But the roof won't have a gap. 770 00:49:35,480 --> 00:49:37,050 Water won't go through it. 771 00:49:37,050 --> 00:49:38,560 Why's that? 772 00:49:38,560 --> 00:49:41,110 Do you see why? 773 00:49:41,110 --> 00:49:46,190 Because what do they share, what do those two curvy roofs share? 774 00:49:46,190 --> 00:49:48,060 They share a side. 775 00:49:48,060 --> 00:49:53,680 They share the same values along the side. 776 00:49:53,680 --> 00:49:56,010 And are those three values that are 777 00:49:56,010 --> 00:49:59,660 shared along the side sufficient to make 778 00:49:59,660 --> 00:50:03,040 it match all along the side? 779 00:50:03,040 --> 00:50:03,790 Yes. 780 00:50:03,790 --> 00:50:05,340 That's the important question. 781 00:50:05,340 --> 00:50:08,550 Finite elements lives or dies on that question. 782 00:50:08,550 --> 00:50:14,350 The answer is yes, because along that side, if I just 783 00:50:14,350 --> 00:50:18,130 focus on that side, where these three 784 00:50:18,130 --> 00:50:23,150 values are shared on both sides, by the triangle on both sides. 785 00:50:23,150 --> 00:50:28,250 Along that edge, what kind of a function have I got? 786 00:50:28,250 --> 00:50:31,110 It's second degree. 787 00:50:31,110 --> 00:50:34,660 This is whatever, when I restrict this to just run along 788 00:50:34,660 --> 00:50:37,030 a line, it's a parabola. 789 00:50:37,030 --> 00:50:40,060 And the parabola is determined by those three values. 790 00:50:40,060 --> 00:50:41,940 So having it right at three points 791 00:50:41,940 --> 00:50:44,170 means I have it right the whole way. 792 00:50:44,170 --> 00:50:44,670 Yeah. 793 00:50:44,670 --> 00:50:48,850 So there you see what quadratic elements would look like, 794 00:50:48,850 --> 00:50:52,500 and you could extend the code in the book 795 00:50:52,500 --> 00:50:57,320 and on the CSE site to work for quadratic elements. 796 00:50:57,320 --> 00:51:01,610 And you want to just guess what cubic elements could look like? 797 00:51:01,610 --> 00:51:03,380 I'm sorry, we've run five minutes over, 798 00:51:03,380 --> 00:51:06,340 but maybe finite elements is worth it. 799 00:51:06,340 --> 00:51:13,900 So if I had cubic elements, any idea how many? 800 00:51:13,900 --> 00:51:16,640 So I'm now going up to, I'm adding g x cubed, 801 00:51:16,640 --> 00:51:25,070 h, i, j, any idea how many coefficients I now have? 802 00:51:25,070 --> 00:51:28,630 Four new ones plus these six is ten. 803 00:51:28,630 --> 00:51:29,920 I need ten nodes. 804 00:51:29,920 --> 00:51:33,310 Where I am I going to put ten nodes in this triangle? 805 00:51:33,310 --> 00:51:36,430 I want to put them, I'd like to have some on the edges. 806 00:51:36,430 --> 00:51:39,930 Because the edges help me make triangles match each other. 807 00:51:39,930 --> 00:51:42,140 They'll just be like bowling balls. 808 00:51:42,140 --> 00:51:52,400 So here's six, oops, that wouldn't be believable. 809 00:51:52,400 --> 00:51:54,300 Is that right? 810 00:51:54,300 --> 00:51:55,790 Four, three, two, and one. 811 00:51:55,790 --> 00:51:56,450 Yeah. 812 00:51:56,450 --> 00:51:57,620 Yeah. 813 00:51:57,620 --> 00:51:58,120 OK. 814 00:51:58,120 --> 00:52:03,330 So, now I've got a bubble node inside 815 00:52:03,330 --> 00:52:10,730 and I've got four nodes of vertices and two points, 816 00:52:10,730 --> 00:52:14,420 at two 1/3 points, and that will then 817 00:52:14,420 --> 00:52:16,260 match the triangle next to it. 818 00:52:16,260 --> 00:52:19,920 Because four points determine a cubic. 819 00:52:19,920 --> 00:52:22,860 There you go, I hope you have fun, 820 00:52:22,860 --> 00:52:24,680 I hope you have a great holiday. 821 00:52:24,680 --> 00:52:27,140 I'll see you Wednesday for Fourier 822 00:52:27,140 --> 00:52:32,720 and always open for questions on the MATLAB.