| 1 |
%GOMIN A minimal driver script for using the MCLite package |
| 2 |
% |
| 3 |
% Usage: gomin |
| 4 |
% |
| 5 |
% Author: Michael Holst |
| 6 |
% rcsid="$Id: gomin.m,v 1.1.1.1 2007/04/27 08:28:05 hrg Exp $" |
| 7 |
|
| 8 |
%%% initialize |
| 9 |
clf; |
| 10 |
|
| 11 |
%%% create the mesh |
| 12 |
[VERT,SIMP] = read(0); |
| 13 |
[N,eight] = size(VERT); |
| 14 |
[L,seventeen] = size(SIMP); |
| 15 |
|
| 16 |
%%% plot the mesh |
| 17 |
subplot(2,2,1); |
| 18 |
draw(VERT,SIMP); |
| 19 |
title('Finite element mesh'); |
| 20 |
|
| 21 |
%%% initialize the dirichlet function |
| 22 |
Ugg = u_d( VERT(1:N,1), VERT(1:N,2), VERT(1:N,6) ); |
| 23 |
[NN,n] = size(Ugg); |
| 24 |
diriMask = vdiri(VERT(1:N,6)); |
| 25 |
theMask = []; |
| 26 |
for i=1:n |
| 27 |
theMask = [ theMask , diriMask ]; |
| 28 |
end |
| 29 |
Ugg = Ugg .* theMask; |
| 30 |
Ug = reshape( Ugg, N*n, 1 ); |
| 31 |
|
| 32 |
%%% initialize the solution |
| 33 |
U = zeros(N*n,1); |
| 34 |
|
| 35 |
%%% assemble the discrete system |
| 36 |
parm = zeros(10,1); |
| 37 |
assKey = 2; |
| 38 |
[A,F]=assem(assKey, parm, U, Ug, VERT, SIMP); |
| 39 |
|
| 40 |
%%% build matrix copy with small entries dropped (for display only) |
| 41 |
tolZero = 1.0e-5; |
| 42 |
AA=A .* ( (A > tolZero) | (A < -tolZero) ); |
| 43 |
|
| 44 |
%%% graph the matrix |
| 45 |
NODES = []; |
| 46 |
for i=1:n |
| 47 |
NODES = [ NODES ; VERT(:,1:2) ]; |
| 48 |
end; |
| 49 |
subplot(2,2,3); |
| 50 |
gplot(AA,NODES,'r'); axis('equal'); axis('off'); |
| 51 |
title('Graph of stiffness matrix'); |
| 52 |
|
| 53 |
%%% show matrix structure |
| 54 |
[mm,nn] = size(A); |
| 55 |
subplot(2,2,4); |
| 56 |
spy(AA,'r'); |
| 57 |
title('Nonzero structure of stiffness matrix'); |
| 58 |
|
| 59 |
%%% solution of system |
| 60 |
U = A \ F; |
| 61 |
|
| 62 |
%%% plot the solution |
| 63 |
subplot(2,2,2); |
| 64 |
if (n==2) |
| 65 |
drawd(VERT,SIMP,U); |
| 66 |
else |
| 67 |
drawf(VERT,SIMP,U); |
| 68 |
end |
| 69 |
title('Finite element solution'); |
| 70 |
|