1 00:00:00,030 --> 00:00:02,400 The following content is provided under a Creative 2 00:00:02,400 --> 00:00:03,780 Commons license. 3 00:00:03,780 --> 00:00:06,020 Your support will help MIT OpenCourseWare 4 00:00:06,020 --> 00:00:10,100 continue to offer high quality educational resources for free. 5 00:00:10,100 --> 00:00:12,670 To make a donation or to view additional materials 6 00:00:12,670 --> 00:00:16,405 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:16,405 --> 00:00:17,030 at OCW.MIT.edu. 8 00:00:25,629 --> 00:00:26,670 KAREN WILLCOX: All right. 9 00:00:26,670 --> 00:00:27,890 So let's see. 10 00:00:27,890 --> 00:00:30,345 I have the graded projects here which maybe you guys 11 00:00:30,345 --> 00:00:31,220 can grab after class. 12 00:00:35,306 --> 00:00:38,600 Or you can grab them now if you want but it can take a while. 13 00:00:38,600 --> 00:00:41,520 Vikram, maybe you want to give the projects back. 14 00:00:41,520 --> 00:00:43,851 Just quietly ask people what their names are. 15 00:00:47,090 --> 00:00:47,590 OK. 16 00:00:47,590 --> 00:00:52,220 So today, we're going to talk about finite elements. 17 00:00:52,220 --> 00:00:54,530 You guys have read a little bit in the reading. 18 00:00:54,530 --> 00:00:57,347 I'm going to talk about a couple things first, just 19 00:00:57,347 --> 00:00:59,180 go through a couple of the very basic ideas. 20 00:00:59,180 --> 00:01:01,013 And then we're going to do it interactively. 21 00:01:01,013 --> 00:01:03,370 You're going to actually implement the one 1D 22 00:01:03,370 --> 00:01:04,819 finite element codes. 23 00:01:04,819 --> 00:01:08,570 We'll do it piece by piece together. 24 00:01:08,570 --> 00:01:14,810 So let me just put the topics up over here. 25 00:01:20,310 --> 00:01:24,940 So again we're going to talk about 1D finite elements. 26 00:01:24,940 --> 00:01:27,937 We're going to start off just with basically 27 00:01:27,937 --> 00:01:29,145 thinking about the key ideas. 28 00:01:32,970 --> 00:01:40,890 We'll just look at a very brief history of finite elements. 29 00:01:40,890 --> 00:01:46,160 We'll think about what 1D linear elements look like. 30 00:01:50,840 --> 00:01:52,300 We'll talk about the nodal bases. 31 00:01:58,740 --> 00:02:04,230 And then we will spend most of the session doing 32 00:02:04,230 --> 00:02:08,133 the derivation and implementation for the 1D 33 00:02:08,133 --> 00:02:08,924 diffusion equation. 34 00:02:18,430 --> 00:02:21,120 Same derivation and implementation 35 00:02:21,120 --> 00:02:24,120 for 1D diffusion. 36 00:02:24,120 --> 00:02:24,620 OK. 37 00:02:24,620 --> 00:02:27,070 So by the end of today, you'll more or less 38 00:02:27,070 --> 00:02:30,620 have a basic shell of a code that 39 00:02:30,620 --> 00:02:34,070 implements at least the meaty part of the finite element. 40 00:02:34,070 --> 00:02:35,970 I'm not quite sure how far we'll get today. 41 00:02:35,970 --> 00:02:37,490 Then on Monday, I am unfortunately 42 00:02:37,490 --> 00:02:38,200 not going to be here. 43 00:02:38,200 --> 00:02:39,740 But Vikram is going to run the class session. 44 00:02:39,740 --> 00:02:41,920 And you guys will continue working with that code. 45 00:02:41,920 --> 00:02:44,880 Probably Monday you'll implement the boundary condition 46 00:02:44,880 --> 00:02:48,410 and implement some quadrature schemes in it. 47 00:02:48,410 --> 00:02:50,250 And so then, by the end of class on Monday, 48 00:02:50,250 --> 00:02:52,120 you should have a working 1D finite element 49 00:02:52,120 --> 00:02:53,990 code which will then hopefully be 50 00:02:53,990 --> 00:02:57,710 of help to do the 2D that you have to do for the project. 51 00:02:57,710 --> 00:02:59,510 And on Wednesday of next week, Vikram 52 00:02:59,510 --> 00:03:03,444 will talk a little bit about 2D finite elements. 53 00:03:03,444 --> 00:03:07,370 So let's just start off with key ideas. 54 00:03:07,370 --> 00:03:09,360 I'm just going to write over there for a bit 55 00:03:09,360 --> 00:03:13,392 because I want to put something up on the screen in a second. 56 00:03:13,392 --> 00:03:23,350 So remember on Monday, we talked about the method 57 00:03:23,350 --> 00:03:24,640 of weighted residuals. 58 00:03:24,640 --> 00:03:26,710 And again, just to sort of go over 59 00:03:26,710 --> 00:03:29,480 what the steps were in the method of weighted residuals. 60 00:03:29,480 --> 00:03:33,110 Kind of the fundamental idea is take the solution 61 00:03:33,110 --> 00:03:35,331 and to approximate it in a basis. 62 00:03:35,331 --> 00:03:35,830 Right? 63 00:03:35,830 --> 00:03:38,890 Remember we took the intradimensional PDE 64 00:03:38,890 --> 00:03:40,530 and we discretized it. 65 00:03:40,530 --> 00:03:42,077 And this is already different to what 66 00:03:42,077 --> 00:03:43,910 we do in finite difference or finite volume. 67 00:03:43,910 --> 00:03:46,160 We discretized it by saying let's assume 68 00:03:46,160 --> 00:03:49,230 that a solution t of x lives in this finite dimensional space 69 00:03:49,230 --> 00:03:54,810 described as a weighted sum of basis functions. 70 00:03:54,810 --> 00:03:56,390 Then we said how do we figure out 71 00:03:56,390 --> 00:03:59,376 the coefficient of the basis function? 72 00:03:59,376 --> 00:04:00,920 And we went through the derivation 73 00:04:00,920 --> 00:04:05,270 of choosing weighting functions to be the same functions 74 00:04:05,270 --> 00:04:07,880 that we used in the basis to approximate the solution. 75 00:04:07,880 --> 00:04:08,755 What was that called? 76 00:04:12,664 --> 00:04:14,580 What's it called when you choose the weighting 77 00:04:14,580 --> 00:04:16,621 functions to be the same functions that you think 78 00:04:16,621 --> 00:04:17,730 [INAUDIBLE]? 79 00:04:17,730 --> 00:04:18,350 Galerkin. 80 00:04:18,350 --> 00:04:18,850 Yeah. 81 00:04:18,850 --> 00:04:21,645 It's the Galerkin method. 82 00:04:21,645 --> 00:04:24,170 When we define the residual, multiplying by the weighting 83 00:04:24,170 --> 00:04:25,827 function using Galerkin. 84 00:04:25,827 --> 00:04:28,160 Integrating over the domain, setting that equal to zero. 85 00:04:28,160 --> 00:04:29,368 That's the weighted residual. 86 00:04:29,368 --> 00:04:32,310 Those gave us the equations we solve 87 00:04:32,310 --> 00:04:33,960 to find the approximation. 88 00:04:33,960 --> 00:04:36,470 So we're more or less going to do the same thing now 89 00:04:36,470 --> 00:04:37,454 with finite elements. 90 00:04:37,454 --> 00:04:38,870 So what you are going to see today 91 00:04:38,870 --> 00:04:41,351 is that a finite element as we're going to view it 92 00:04:41,351 --> 00:04:43,225 is based on the method of weighted residuals. 93 00:04:53,820 --> 00:04:56,190 But what is different is the first step. 94 00:04:56,190 --> 00:05:01,417 Before we start with the approximation of the solution, 95 00:05:01,417 --> 00:05:03,000 the very first thing we're going to do 96 00:05:03,000 --> 00:05:07,330 is to discretize the domain into small cells. 97 00:05:07,330 --> 00:05:07,830 OK? 98 00:05:07,830 --> 00:05:09,470 So we're going to divide up our domain-- 99 00:05:09,470 --> 00:05:11,990 rather than thinking about the approximation of the solution 100 00:05:11,990 --> 00:05:13,850 globally over the whole domain, we're 101 00:05:13,850 --> 00:05:19,970 going to discretize our domain into small cells, elements. 102 00:05:19,970 --> 00:05:22,202 That's the element of the finite element method. 103 00:05:22,202 --> 00:05:24,285 They've been called-- I think you guys called them 104 00:05:24,285 --> 00:05:26,201 cells when you talked about finite difference. 105 00:05:26,201 --> 00:05:27,090 Is that right? 106 00:05:27,090 --> 00:05:28,970 Nodes and cells? 107 00:05:28,970 --> 00:05:30,790 And for finite elements, the cells 108 00:05:30,790 --> 00:05:33,310 are referred to as elements. 109 00:05:33,310 --> 00:05:36,607 Then once we've discretized the domain into small cells, 110 00:05:36,607 --> 00:05:38,440 then we're just going to go and basically do 111 00:05:38,440 --> 00:05:40,315 what we did with negative weighted residuals. 112 00:05:40,315 --> 00:05:43,420 So now we're going to think about approximating 113 00:05:43,420 --> 00:05:45,165 the solution in each element. 114 00:05:50,980 --> 00:05:52,830 So in each element, we're going to say 115 00:05:52,830 --> 00:05:55,740 let's assume that the solution can 116 00:05:55,740 --> 00:05:59,280 be approximated as a linear combination of basis functions. 117 00:05:59,280 --> 00:06:01,550 And we're going to use polynomials 118 00:06:01,550 --> 00:06:03,217 just like we did on Monday. 119 00:06:03,217 --> 00:06:04,800 But now the polynomials are just going 120 00:06:04,800 --> 00:06:07,677 to be defined over the little element, the little piece 121 00:06:07,677 --> 00:06:08,260 of the domain. 122 00:06:08,260 --> 00:06:09,220 Not the whole domain. 123 00:06:12,500 --> 00:06:13,000 E.g. 124 00:06:13,000 --> 00:06:16,900 Here with polynomial functions. 125 00:06:16,900 --> 00:06:18,850 Again, just like we did on Monday but now 126 00:06:18,850 --> 00:06:23,109 to serve a small element polynomial function. 127 00:06:23,109 --> 00:06:25,150 And then again, it's going to be the same as what 128 00:06:25,150 --> 00:06:26,090 we did on Monday. 129 00:06:26,090 --> 00:06:28,350 Once we've done the approximation, 130 00:06:28,350 --> 00:06:32,260 we're going to evaluate weighted residuals for each element. 131 00:06:38,330 --> 00:06:43,300 We're going to use the Galerkin method to do that, 132 00:06:43,300 --> 00:06:45,990 to define the weighted residual. 133 00:06:45,990 --> 00:06:50,280 That's going to give us a system of equations. 134 00:06:50,280 --> 00:06:56,011 And we're going to solve to determine the weighting 135 00:06:56,011 --> 00:06:56,510 coefficient. 136 00:07:06,880 --> 00:07:08,340 Weighting coefficients. 137 00:07:08,340 --> 00:07:11,180 So basically exactly what we did on Monday, 138 00:07:11,180 --> 00:07:13,570 except that first step which is discretize 139 00:07:13,570 --> 00:07:15,405 the domain to small cells. 140 00:07:15,405 --> 00:07:16,780 And then what you're going to see 141 00:07:16,780 --> 00:07:20,780 is that idea of breaking the domain up into small cells, 142 00:07:20,780 --> 00:07:22,490 we're going to make a very special choice 143 00:07:22,490 --> 00:07:23,970 for the polynomial basis functions. 144 00:07:23,970 --> 00:07:25,744 It's going to be really neat because when 145 00:07:25,744 --> 00:07:28,160 we do the weighted residuals and we do all the integrals-- 146 00:07:28,160 --> 00:07:29,090 like we mentioned a little bit, I think, 147 00:07:29,090 --> 00:07:30,920 in response to one of [INAUDIBLE] questions-- 148 00:07:30,920 --> 00:07:32,961 a whole bunch of integrals are going to fall out. 149 00:07:32,961 --> 00:07:34,500 And it'll turn out that everything 150 00:07:34,500 --> 00:07:39,520 has got a very special and really efficient and kind 151 00:07:39,520 --> 00:07:41,480 of neat structure to it. 152 00:07:41,480 --> 00:07:43,105 AUDIENCE: Did you pick the same basis 153 00:07:43,105 --> 00:07:46,343 functions for the entire problem or for each individual cell? 154 00:07:46,343 --> 00:07:47,176 KAREN WILLCOX: Yeah. 155 00:07:47,176 --> 00:07:49,240 So the question is do you pick the same basic functions 156 00:07:49,240 --> 00:07:51,406 for the entire problem, or for each individual cell? 157 00:07:51,406 --> 00:07:53,396 You're going to see it in just a second. 158 00:07:53,396 --> 00:07:54,770 There are a lot of different ways 159 00:07:54,770 --> 00:07:56,090 to choose the basic function. 160 00:07:56,090 --> 00:07:58,642 Today we're going to talk about a special choice that's 161 00:07:58,642 --> 00:08:00,340 referred to as the nodal basis. 162 00:08:00,340 --> 00:08:02,280 And you'll see exactly what they are. 163 00:08:05,680 --> 00:08:07,530 Before I start, are there any kind 164 00:08:07,530 --> 00:08:11,410 of residual questions from method of weighted residuals? 165 00:08:11,410 --> 00:08:12,435 Residual questions. 166 00:08:12,435 --> 00:08:13,810 Are there any things about method 167 00:08:13,810 --> 00:08:19,212 of weighted residuals that is mysterious or uncomfortable? 168 00:08:19,212 --> 00:08:20,670 It's pretty straightforward, right? 169 00:08:28,110 --> 00:08:32,700 So just before we start, I want to give you a little bit 170 00:08:32,700 --> 00:08:40,590 of a-- I hate this WebEx thing. 171 00:08:40,590 --> 00:08:43,480 Because when you try to grab things, 172 00:08:43,480 --> 00:08:49,430 it goes down-- little bit of a historical perspective. 173 00:08:49,430 --> 00:08:52,840 And actually I went to Wikipedia as you do, 174 00:08:52,840 --> 00:08:56,240 which actually doesn't have a bad-- this is the Wikipedia 175 00:08:56,240 --> 00:09:00,796 entry for finite element method, which actually surprised me. 176 00:09:00,796 --> 00:09:02,170 Look how many sections there are. 177 00:09:02,170 --> 00:09:04,522 Vikram, have you contributing to Wikipedia? 178 00:09:04,522 --> 00:09:05,935 AUDIENCE: No. 179 00:09:05,935 --> 00:09:07,348 [LAUGHTER] 180 00:09:07,348 --> 00:09:10,180 KAREN WILLCOX: Aha. 181 00:09:10,180 --> 00:09:12,345 There's actually quite a lot here. 182 00:09:12,345 --> 00:09:13,220 I didn't read it all. 183 00:09:13,220 --> 00:09:15,515 So I can't verify how good it is. 184 00:09:15,515 --> 00:09:17,390 Although Wikipedia appears to be pretty good, 185 00:09:17,390 --> 00:09:20,994 there's enough of a community of people. 186 00:09:20,994 --> 00:09:22,870 So I was going to show you guys the history 187 00:09:22,870 --> 00:09:26,530 about technical discussion, general principles 188 00:09:26,530 --> 00:09:28,614 of weak formulation, discretization. 189 00:09:28,614 --> 00:09:30,280 Then you can see all the different kinds 190 00:09:30,280 --> 00:09:35,040 of finite element methods that exist. 191 00:09:35,040 --> 00:09:37,190 So that should give you a sense of just how big 192 00:09:37,190 --> 00:09:38,670 of a field of study this is. 193 00:09:38,670 --> 00:09:40,930 We're going to be just a little tiny bit of it. 194 00:09:40,930 --> 00:09:43,360 [INAUDIBLE] for finite difference method application. 195 00:09:43,360 --> 00:09:47,910 I just wanted to mention a little bit just 196 00:09:47,910 --> 00:09:49,400 about the history. 197 00:09:49,400 --> 00:09:51,310 So like it says here, it's difficult to quote 198 00:09:51,310 --> 00:09:54,840 the date of the invention of the finite element method. 199 00:09:54,840 --> 00:09:58,650 More or less, its origins are actually 200 00:09:58,650 --> 00:10:02,290 from structures in both civil and aerospace aeronautical 201 00:10:02,290 --> 00:10:02,790 engineering. 202 00:10:02,790 --> 00:10:06,490 So it has roots in aeronautical engineering. 203 00:10:06,490 --> 00:10:13,000 And there were three kind of groups where if you trace back, 204 00:10:13,000 --> 00:10:16,280 that's where things seem to have really originated. 205 00:10:16,280 --> 00:10:20,320 Courant is often the person whose is cited as being, 206 00:10:20,320 --> 00:10:22,344 I guess, the father of a lot of theories 207 00:10:22,344 --> 00:10:23,510 that led to finite elements. 208 00:10:23,510 --> 00:10:28,980 So he was at NYU and then established an Applied Math 209 00:10:28,980 --> 00:10:31,470 institute, the Courant Institute which still exists today. 210 00:10:31,470 --> 00:10:33,469 It is one of the best Applied Math computational 211 00:10:33,469 --> 00:10:35,760 places in the world. 212 00:10:35,760 --> 00:10:41,130 And as you can see here, I think this is a German mathematician. 213 00:10:41,130 --> 00:10:45,720 And also things were going on in China at the same time. 214 00:10:45,720 --> 00:10:47,790 So there's a little bit here. 215 00:10:47,790 --> 00:10:50,009 You can see there Rayleigh, Ritz, and Galerkin. 216 00:10:50,009 --> 00:10:51,550 Those are all names of mathematicians 217 00:10:51,550 --> 00:10:55,120 that you guys have seen in various methods, things 218 00:10:55,120 --> 00:10:56,880 that came up. 219 00:10:56,880 --> 00:10:59,020 Really the way the finite element method 220 00:10:59,020 --> 00:11:01,120 started to really sort of become like 221 00:11:01,120 --> 00:11:04,200 a computational powerhouse, I think, 222 00:11:04,200 --> 00:11:05,980 was here in the 60s and 70s. 223 00:11:05,980 --> 00:11:08,964 So Agyris at the University of Stuttgart. 224 00:11:08,964 --> 00:11:10,380 I think this is pronounced Clough. 225 00:11:10,380 --> 00:11:12,130 Is that right, Vikram? 226 00:11:12,130 --> 00:11:13,000 Yeah. 227 00:11:13,000 --> 00:11:15,650 Clough at UC Berkeley. 228 00:11:15,650 --> 00:11:17,786 And Zienkiewicz at University of Swansea. 229 00:11:17,786 --> 00:11:19,160 And in fact University of Swansea 230 00:11:19,160 --> 00:11:21,880 is where Professor [INAUDIBLE] did his PhD. 231 00:11:21,880 --> 00:11:24,309 And he was working with some of the later people 232 00:11:24,309 --> 00:11:26,392 there that were at the forefront of finite element 233 00:11:26,392 --> 00:11:30,400 methods and their development. 234 00:11:30,400 --> 00:11:32,240 So it's actually a really kind of neat story 235 00:11:32,240 --> 00:11:34,100 because it really comes from applied math. 236 00:11:34,100 --> 00:11:36,430 And you're not going to see a whole lot of it in class. 237 00:11:36,430 --> 00:11:40,270 But there's a lot of incredible analysis 238 00:11:40,270 --> 00:11:44,870 and theoretical results that go with finite element methods, 239 00:11:44,870 --> 00:11:46,760 a lot of guarantees that can be made. 240 00:11:46,760 --> 00:11:50,000 So there's really a hardcore math component. 241 00:11:50,000 --> 00:11:54,240 But then it has gone on to be of such practical use. 242 00:11:54,240 --> 00:11:56,220 So it started off in structural problems 243 00:11:56,220 --> 00:11:59,680 but now is applied to fluid problems, acoustics, 244 00:11:59,680 --> 00:12:01,785 all kinds of things. 245 00:12:01,785 --> 00:12:04,410 You can see here NASA sponsored the original vision of NASTRAN. 246 00:12:04,410 --> 00:12:06,550 I actually didn't know that until I read this. 247 00:12:06,550 --> 00:12:07,925 So now there's a lot of software, 248 00:12:07,925 --> 00:12:10,420 things like NASTRAN ADINA is Professor Bathe 249 00:12:10,420 --> 00:12:13,350 from mechanical engineering package. 250 00:12:13,350 --> 00:12:15,170 Professor Strang in the math department 251 00:12:15,170 --> 00:12:17,640 also plays a really important role 252 00:12:17,640 --> 00:12:21,436 in some of the rigorous results early on. 253 00:12:21,436 --> 00:12:26,620 So there's also a lot of connections to MIT. 254 00:12:26,620 --> 00:12:33,050 So we're going to see only just a little piece 255 00:12:33,050 --> 00:12:36,854 of the finite element method. 256 00:12:36,854 --> 00:12:39,394 But it is certainly, I think, one 257 00:12:39,394 --> 00:12:41,810 of the really great examples of where applied methods made 258 00:12:41,810 --> 00:12:46,440 enormous impact on real problems and particularly on engineering 259 00:12:46,440 --> 00:12:47,427 and engineering design. 260 00:12:50,050 --> 00:12:54,260 So let's get into talking about how it works. 261 00:12:54,260 --> 00:12:56,797 We're going to talk about 1D linear elements. 262 00:12:56,797 --> 00:12:58,380 I'm just going to go over a few things 263 00:12:58,380 --> 00:13:01,310 that you guys read about just to make sure 264 00:13:01,310 --> 00:13:04,640 that the notation is clear and that the ideas are clear. 265 00:13:04,640 --> 00:13:07,470 And then we're going to start together 266 00:13:07,470 --> 00:13:11,751 deriving and implementing the methods for the 1D diffusion 267 00:13:11,751 --> 00:13:12,250 equation. 268 00:13:19,330 --> 00:13:22,980 So we're at number three. 269 00:13:22,980 --> 00:13:24,480 1D linear elements. 270 00:13:29,830 --> 00:13:30,330 OK. 271 00:13:30,330 --> 00:13:34,790 So I'm just going to draw a picture. 272 00:13:34,790 --> 00:13:39,100 And again this is the picture that was in the online reading. 273 00:13:39,100 --> 00:13:40,536 Board is not very clean. 274 00:13:46,961 --> 00:13:47,460 All right. 275 00:13:47,460 --> 00:13:49,796 So we're thinking in 1D. 276 00:13:49,796 --> 00:13:55,790 So draw this line that's going to go in both directions. 277 00:13:55,790 --> 00:13:58,100 So this is the x direction. 278 00:13:58,100 --> 00:14:01,380 And I'm going to have nodes just like I 279 00:14:01,380 --> 00:14:03,915 had in finite difference. 280 00:14:03,915 --> 00:14:04,790 So I draw some nodes. 281 00:14:08,260 --> 00:14:13,936 This guy here is going to be node i. 282 00:14:13,936 --> 00:14:16,942 And this guy here is going to be node i plus one. 283 00:14:16,942 --> 00:14:21,130 So node i is located in at position xi. 284 00:14:21,130 --> 00:14:25,470 Node i plus one is located at position xi plus one. 285 00:14:25,470 --> 00:14:28,820 i minus one to the left and so on. 286 00:14:28,820 --> 00:14:33,284 And then in between xi and xi plus one is element i. 287 00:14:33,284 --> 00:14:33,784 OK? 288 00:14:33,784 --> 00:14:37,410 So when we talk about element i, we're 289 00:14:37,410 --> 00:14:39,840 talking about the region of the domain that lies 290 00:14:39,840 --> 00:14:43,510 between xi and xi plus one. 291 00:14:43,510 --> 00:14:45,060 And--