# Variational Formulation

date post

01-Jan-2016Category

## Documents

view

51download

0

Embed Size (px)

description

### Transcript of Variational Formulation

Variational FormulationPDEWithBCWeak FormDiscrete FormLinear System

Variational FormulationWeak FormPDEWithBCwhere

BVPWeak Formulation ( variational formulation)whereMultiply equation (1) by and then integrate over the domain Greens theorem givesVariational Formulation

TriangulationWe have We have

Weak Formulation ( variational formulation)Infinite dimensional spaceFinite dim subspaceSpace of all cont. pcw-linear

Discrete Form Linear Systemapproximate uThis is a linear system of 5 equations in 5 unknowns In expanded formIn Matrix form

The approximate Solution In Matrix formOnce this linear system is solved we obtain an approximation to the solution Remark: Remark: We are going to focus our attention in the efficient construction of this stiffness matrix

Sparsity In Matrix formThis matrix is sparse (many zeros) few non-zero entriesRemark: another example

312 triangles and 177nodesSparsity of the matrix# of nonzero =1153Use spy(A) to see sparsitySparsity

Local basis function and global basis functionGlobal basis function12135If we restrict the function to the triangle K12 it becomes one of the local basis functions for K12 Matrix tK12 has 3 local basis functions

12345678910111213141516131011121011121355513967841239678131011510111213967812341011121213101112

Assembly of the Stiffness MatrixIn Matrix formThis matrix is sparse (many zeros) few non-zero entriesRemark: These few nonzero entries are computed by looping over all trianglesRemark: nonzero entry is a sum of integrals of local basis functions over a triangleRemark:

12345678910111213141516131011121011121355513967841239678131011510111213967812341011121213101112

Assembly of the Stiffness MatrixStep1 primary stiffnes matrixStep2 impose boundary conditionLoop over all triangles 1 -16. in each triangle, we calculate 3x3 matrix which involves calculating 9 integrals of all possible combination of local basis functions.After we assemble the primary stiffness matrix in step1, we enforce the boundary condition by forcing the corresponding coefficient to be zero.

Step1 primary stiffnes matrixfind all gradients Step1a: For k = 1 : 16Find 9 integralsStep1b: Add these contributions to the primary stiffness matrixStep1c: End the loop

with cyclic permutation of the index i,j k over 1,2,3Find the gradients

Find the gradientsfunction [area,b,c] = Gradients(x,y)area=polyarea(x,y);b=[y(2)-y(3); y(3)-y(1); y(1)-y(2)]/2/area;c=[x(3)-x(2); x(1)-x(3); x(2)-x(1)]/2/area;

Step1 primary stiffnes matrixLoop over all triangles 1 -1610135for example K9

12345678910111213141516131011121011121355513967841239678131011510111213967812341011121213101112

Step1 primary stiffnes matrixLoop over all triangles 1 -16. for example K910135local basis functionsFind gradient for eachFind 3x3 matrixWe want to compute:

Step1 primary stiffnes matrixLoop over all triangles 1 -16. for example K910135local basis functionsFind gradient for eachFind 3x3 matrixWe want to compute:

Step1 primary stiffnes matrixLoop over all triangles 1 -16. for example K910135local basis functionsFind gradient for eachFind 3x3 matrixWe want to compute:

Step1 primary stiffnes matrixlocal basis functionsFind gradient for eachFind 3x3 matrixWe want to compute:Local to global

Step1 primary stiffnes matrixlocal basis functionsFind gradient for eachFind 3x3 matrixWe want to compute:Local to global

Step1 primary stiffnes matrixLocal to global 1 2 31 1 -1/2 -1/2 2 -1/2 1/2 0 3 -1/2 0 1/2 5 10 115 1 -1/2 -1/2 10 -1/2 1/2 0 11 -1/2 0 1/2 Triangle K10

K =1

1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1

K =2

1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1

K = 3

1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1

K =4

1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1 K =13

1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1

K =14

1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1

K =15

1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1

K =16

1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1

1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 4 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 -1 -1 0 -1 0 0 -1 -1 0 0 -1 0 -1 0 0 0 0 -1 -1 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 -1 -1 -1 0 0 0 -1 -1 0 0 2 0 0 0 -1 -1 0 0 2 0 0 0 -1 -1 0 0 2 -1 0 0 -1 0 0 -1 4 0 0 0-1 0 0 0 4 0 0-1 -1 0 0 0 4 0 0 -1 -1 0 0 0 4Step1 primary stiffnes matrixfunction A = StiffMat2D(p,t)np = size(p,2);nt = size(t,2);A = sparse(np,np);for K = 1:nt loc2glb = t(1:3,K); % local-to-global map x = p(1,loc2glb); % node x-coordinates y = p(2,loc2glb); % node y- [area,b,c] = Gradients(x,y); AK = (b*b'+c*c')*area; % element stiff mat A(loc2glb,loc2glb) = A(loc2glb,loc2glb)+ AK; % add element stiffnesses to Aend

12345678910111213141516131011121011121355513967841239678131011510111213967812341011121213101112

Assemble the Load vector LIn Matrix form

12345678910111213141516131011121011121355513967841239678131011510111213967812341011121213101112

Assembly of the Load VectorStep1 primary Load vectorStep2 impose boundary conditionLoop over all triangles 1 -16. in each triangle, we calculate 3x1 matrix which involves calculating 3 integralsAfter we assemble the primary load vector and stiffness matrix in step1, we enforce the boundary condition by forcing the corresponding coefficient to be zero.

The load vector b is assembled using the same technique as the primary stiffness matrix A, that is, by summing element load vectors BK over the mesh.

On each element K we get a local 31 element load vector BK with entries

BKi = Kf i dx; i = 1;2;3

Using node quadrature, we compute these integrals we end up with

BKi 1/3f (Ni)|K|; i = 1;2;3

We summarize the computation of the load vector with the following Matlab code.

function b = LoadVec2D(p,t,f)np = size(p,2);nt = size(t,2);b = zeros(n,1);for K = 1:ntloc2glb = t(1:3,K);x = p(1,loc2glb);y = p(2,loc2glb);area = polyarea(x,y);bK = [f(x(1),y(1));f(x(2),y(2));f(x(3),y(3))]/3*area; % element load vectorb(loc2glb) = b(loc2glb) ...+ bK; % add element loads to bend

***