60 likes | 79 Views
Problem with Variable Coefficients. BVP. Remark:. is a function. If k is a constant then this problem reduces to the one we solved before. Weak Formulation ( variational formulation). Multiply equation (1) by and then integrate over the domain. Green’s theorem gives.
E N D
Problem with Variable Coefficients BVP Remark: is a function If k is a constant then this problem reduces to the one we solved before. Weak Formulation ( variational formulation) Multiply equation (1) by and then integrate over the domain Green’s theorem gives where
Problem with Variable Coefficients For k = 1 : 16 Step1a: find all gradients Step1b: Find 9 integrals Step1c: Add these contributions to the primary stiffness matrix End the loop
Find the gradients with cyclic permutation of the index i,j k over 1,2,3 function [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 matrix Loop over all triangles 1 -16 for example K9 10 5 13
Problem with Variable Coefficients Find 3x3 matrix Loop over all triangles 1 -16. for example K9 10 5 13 1 Find gradient for each
Problem with Variable Coefficients 10 Find gradient for each Loop over all triangles 1 -16. for example K9 5 13 1 2 3 4 5 6 7 8 9 10 11 12 function 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 A end xc = mean(x); yc = mean(y); kc = k(xc,yc);