Hi, now we'll move on to looking at set-up system and then assemble system. And we'll probably finish up with the homework 3 template in 2D in this segment. All right, so lets look at the code. Here in setup system it looks very, very similar to problem one, or rather to homework two, which was our first coding assignment. Slight differences here, is that no location, again we have two indices. Again the first is your global node number, just as before. But again, the column number now is which component of the position vector you want. Do you want the x-component or the y-component, or in 3D, the z-component? Okay, we again call the define boundary conditions function. Resize our vectors and matrices, we define the quadrature rule. Again, you'll need to decide what quadrature rule you need. Is two enough, do you need three? Or more, or less? Not a lot to do here in setup system, not much different from before. But now we'll move into assemble system Okay we have the same setup before k=0, f=0, same constants, data types. We set up our element loop the same way. Again we update the local DOF indices vector with element. So that we can again relate our local degree of freedom numbering, or local node numbering with the global node number. But, now we have introduced these other objects. We have a full matrix called Jacobian, and then a double detJ, which will hold the determinant of the Jacobian. The Jacobian you can see is of dimension dim by dim, or in this case a two by two matrix. It's the Jacobian for the mapping between the real domain and the bi-unit domain. Remember, in the 1D case we actually did have this Jacobian, but it was just a 1 by 1 matrix. Essentially was H, E over two. All right, so that's how that showed up there. In this case we have to create the matrix itself. Now in the general case, elements aren't always going to be the same. And they aren't always going to be square. Or have nice right angle corners like they are in this problem. And so, I've kept the Jacobian general for that case. However in our case, as you're checking your code you may notice that the Jacobian is actually the same at every quadrature point in every element. And that it's actually a diagonal matrix. That's because of the uniformity of our mesh. Okay, but in general with an unstructured mesh, you wouldn't have the Jacobian being the same at each quadrature point. And it wouldn't necessarily be a diagonal matrix. So on this first part, I have the same structure for defining Flocal. Again, we don't have Neumann boundary conditions. Or at least, we don't have non-zero Neumann boundary conditions. And we don't have any forcing function. So Flocal is actually zero for this problem. However I've left this structure there in case you wanted to include a forcing function. So it's there for you if you'd like. Again, all the structures there you would still have to define what the eighth component of Flocal was. Just as you did in the 1D problem. All right. Now for Klocal, I also created a full matrix called in the Jacobian, which will store the inverse of the Jacobian. I'll go into that a little bit more on the board in a second. I've also created this full matrix Kappa, which will be our connectivity tensor. In the assignment, it's already defined for you that it's a diagonal matrix with the value of 385. Okay so now let's look at K local itself. And actually before we get into that. Again Klocal used Jacobean, uses the determent of the Jacobian. Which actually comes into play with the quadrature, numerical quadrature. And So that's where it will come into play. So let me look at the Jacobian for a second. Look at it in 2D, but it easily expands to 3D. Okay. So here's the Jacobian, it's in 2D. It's just the partial of x 1 with respect to dPsi 1. Partial of x 1 with respect to dPsi 2. Here of course x 1 is x, x 2 is y, if you're thinking of it that way. Partial of x 2 with respect to x dPsi 1, partial of x 2, with respect to dPsi 2. Another way to put a more generally. We could say that the Jacobian of [i][j] is equal to the partial of x, sub i with respect to dPsi sub j. And, of course, that easily transfers over to the 3D problem. Okay, now where do we actually need this? Well of course, we need the determinant of the Jacobian to do our numerical quadrature. Again we saw the HE over 2 and we did quadrature in 1D. The HE over 2 was the determinative of the Jacobian. So that will show up again, and we'll see that in a second. Now the other place it will show up is when we're doing our basis function gradients. Remember when we define the function basis gradient. It was the derivative with respect to dPsi, okay. Now for Klocal, let me just look at Klocal [A][B]. Something to point out, first is we have this negative sign. I include the negative sign in the Klocal. So that when we're solving the actual system we can still do, D is equal to K inverse, F, okay? So, I include that, minus sign here. We have this integral over dPsi domain. In this case it's a double integral, so I'll just include that here. We have our basis function A. Now it's the derivative, I'm going to write it out here. The derivative with respect to X, I. Times kappa, I, J. And then a partial of B with respect with X,J Determinant of j. Sorry, the determinant of the j isn't necessarily with the numerical quadrature. It's with the change of domain. The change of indices from our real domain to our bi-unit domain, just to clarify that. dPsi 1, dPsi 2. And I think this notation we used in the lecture. When you have this repeated index there's an implied summation over I and J. Over I and J. And it's going from using our C++ notation would be 0 up to dim-1, okay? So in this case, I will do a summation with I equals 0,1. And a summation with J equals 0, 1. All right, but now this term here, or rather both of these terms. These are the gradients with respect to the real domain, but we only have the gradients with respect to the bi-unit domain. So if we look at this first term, of course it applies to the second as well. Partial of NA with respect to dPsi i Is equal to, using the chain rule, partial of NA with respect to dPsi 1 times the partial of dPsi 1. With respect to xi plus- Partial of Na with respect to dPsi 2. Times the partial of dPsi 2 with respect to, again, xi. So you can see that these are very close to what we have up here. Of course the little I and the big I is just an index. Except that these terms come from the inverse. So, this term here would be the Jacobian Inverse. And it would be component [2][I] for example. Okay? So that's why in the code over here, after I've created, after we found the Jacobian I. And you can see that we've done that using an interpolation here of the node locations of x, times the basis_gradients. Once we've defined the Jacobian, we come out. Notice this is all within our quadrature loop here. Okay, we are at, since it's 2-D, we're looping over the quadrule in two directions. And at each quadrature point, we evaluate the Jacobian, then take the determinant. This Jacobian.determinant, that's a function related to the DL2 full matrix class. So we can do that. And also associated with it, there's this function dot invert, so we can get our inverse Jacobean. Okay? Now this term here I could actually write as a summation as well. Let me write that on the next slide, just so we have a little more room. So the partial of A, N A with respect to X I. Actually be, the product N A with respect to dPsi. I'll do a little i. Times the partial of dPsi little i with respecting XI. And again, there is an implied summation here. It's the same as summing over I equals zero up to less than ten. Okay. Writing that summation in again wasn't necessary, because there is the repeated index here. There's an implied simation over the index i. Alright, so now if we look back at our code here, I've set up several different for loops. We have the for loops over A and B. Which of course correspond to the components of Klocal. We have a for loop over capital I and capital J. Which of course are these capital I's and capital J's. And then, a for loop over the little i and little j's. Which are the i's and j's that we saw in this notation here. But now again, you will have to decide what is integral going to be, so you'll set that up. Using, of course, the quadrature rules. Including the quadrature weights. And, of course, we're using the inverse Jacobian and the determinant of the Jacobian. Because of the bi-unit domain. Okay? You will still need to do the assemble system portion of this function. But it will be exactly the same as assembling the system in the previous homework template. We apply Dirichlet boundary conditions the exact same way DLT will do it. Solve is exactly the same as is output results. Again, the biggest portion that you'll have to be working on in this template, is again with an assemble system. And the basis functions themselves, as well as defining your boundary conditions. Okay, so that wraps it up for the 2 D template. In the next segment we will quickly go over the coding template for the 3 D problem on homework 3.