function [] = FESolveSimp() % MATLAB based 1-D XFEM Solver % J. Grogan (2012) clear all % Define Geometry len=10.; % Define Section Properties rho=1.; % Generate Mesh numElem=10; charlen=len/numElem; ndCoords=linspace(0,len,numElem+1); numNodes=size(ndCoords,2); indx=1:numElem; elemNodes(:,1)=indx; elemNodes(:,2)=indx+1; % dofs per node ndof=1; % Initial temperatures Tnew=zeros(numNodes,1); Bound=zeros(numNodes,1); Tnew(1)=1.; Bound(1)=1.; % Define Time Step dtime=0.01; tsteps=10; time=0.; % Loop through time steps for ts=1:tsteps K=zeros(numNodes,numNodes); M=zeros(numNodes,numNodes); % Loop Through Elements for e=1:numElem Ke=zeros(2*ndof); Me=zeros(2*ndof); crdn1=ndCoords(elemNodes(e,1)); crdn2=ndCoords(elemNodes(e,2)); elen=abs(crdn2-crdn1); ajacob=elen/2.; gpx(1)=-1/sqrt(3.); gpx(2)=1/sqrt(3.); w(1)=1.; w(2)=1.; % Loop Through Int Points for i=1:2; c=gpx(i); phi(1)=(1.-c)/2.; phi(2)=(1.+c)/2.; cond=1.; spec=1.; phic(1)=-0.5; phic(2)=0.5; phix(1)=phic(1)/ajacob; phix(2)=phic(2)/ajacob; we=ajacob*w(i); Ke=Ke+we*cond*phix'*phix; Me=Me+(we*rho*spec*phi'*phi)/dtime; end % Assemble Global Matrices gnum=elemNodes(e,1); for i=1:2; for j=1:2; K(gnum+j-1,gnum+i-1)=K(gnum+j-1,gnum+i-1)+Ke(j,i); M(gnum+j-1,gnum+i-1)=M(gnum+j-1,gnum+i-1)+Me(j,i); end end end %Remove NON-ENHANCED DOFs(Reduce Matrices) iindex=0.; A=K+M; Sub=A*Bound; RHS=M*Tnew-Sub; % Apply Boundary Conditions for i=1:numNodes; if Bound(i)==0.; iindex=iindex+1; RHSR(iindex)=RHS(i); jindex=0; for j=1:numNodes; if Bound(j)==0.; jindex=jindex+1; AR(iindex,jindex)=A(i,j); end end end end %Solve Tnewr=(AR^-1)*RHSR'; % Restore Matrices iindex=0; for i=1:numNodes; if Bound(i)==0.; iindex=iindex+1; Tnew(i)=Tnewr(iindex); end end Tnew end