Can I use a variant of existing code for the finite difference method of analysis on non-quadratic shapes?

Is it possible to alter an existing MATLAB file using Finite Difference Method to provide numerical analysis on a square plate so that the boundary conditions are applied in a different shape, specifically one where a corner is removed.
Apologies for the length of the script, it is taken from "An Introduction to Scientific Computing: Twelve Computational Projects Solved with MATLAB", and provided numerical analysis of a square plate (nx X ny) when strained. I've been tasked with finding an appropriate way of performing similar analysis on non quadratic shapes.
nx=18;ny=18;
long=1.e-03;large=1.e-03;
hx=long/(nx+1);hy=large/(ny+1);
h2x=hx*hx;h2y=hy*hy;
h4x=h2x*h2x;h4y=h2y*h2y;h4xy=h2x*h2y;
x=[0.:hx:long];y=[0.:hy:large];
n=nx*ny;
fprintf('\n ');
fprintf('\n Points in x direction %d',nx);
fprintf('\n Points in y direction %d',ny);
fprintf('\n Total number of points %d',n);
fprintf('\n ');
T=100.; % in Newton/m
E=1.3e+11; % in Newton/m2
e=1.e-06; % 1 up to 10 microns
nu=0.25; % no dimension
c1=T;c2=(E*e*e*e)/(12.*(1.0-nu*nu));
% Laplacian operator matrix
Ah5=ELAS_lap_matrix(hx,hy,nx,ny);
% Bi-Laplacian operator matrix
Ah13=ELAS_bilap_matrix(hx,hy,nx,ny);
% Test problem matrix
Ah=c2*Ah13+c1*Ah5;
% Cholesky factorization - Matlab
Lh=chol(Ah');
% Display of matrix structure
fs=18;
figure(10);colormap('gray');
spy(Ah);title('Matrix Ah ','FontSize',fs);
figure(11);colormap('gray');
spy(Lh');title('Matrix Lh ','FontSize',fs);
% sampling of the right-hand side
rhs0=zeros(nx*ny,1);
for ix=1:nx
for iy=1:ny
xx=x(ix+1);
yy=y(iy+1);
uu=0.;
rhs0((iy-1)*nx+ix)=ELAS_pressure(xx,yy,uu);
end
end
% boundary conditions
uh=zeros(nx+2,ny+2);
% uh is null on the boundary ==> no correction of rhs (cf ELAS_plate_ex.m)
% 2) Solution of the linear problem
%
vh=Lh'\rhs0;
wh=Lh\vh;
for ix=1:nx
for iy=1:ny
uh(ix+1,iy+1)=wh((iy-1)*nx+ix);
end
end
%
% 3) Display of results
%
% capacitor thickness
h=5.e-06; % 5 microns
figure(11);
colormap('gray');surf(x,y,h-uh');
fs=18;
title('Solution for the plate problem','FontSize',fs);
%
% 4) Solution of the nonlinear problem
%
eps0=1.0e-03;
var=1.0;
% initialisation
uuh=uh; % uh = solution of linear problem
rhs=zeros(nx*ny,1);
k=0;
while ( var > eps0 )
k=k+1;
uuha=uuh;
for ix=1:nx
for iy=1:ny
xx=x(ix+1);
yy=y(iy+1);
uu=uuh(ix+1,iy+1);
rhs((iy-1)*nx+ix)=ELAS_pressure(xx,yy,uu);
end
end
vh=Lh'\rhs;
wh=Lh\vh;
for ix=1:nx
for iy=1:ny
uuh(ix+1,iy+1)=wh((iy-1)*nx+ix);
end
end
% variation
e1=norm(uuh,2);
e2=norm(uuh-uuha,2);
var=e2/e1;
fprintf('\n Iteration %d',k);
fprintf('\n Variation %12.8f',var);
end
% computing time measure
time=cputime-t;
fprintf('\n Computing time %20.15f',time);
%
% 5) Display of results
%
figure(12);
colormap('gray');surf(x,y,h-uuh');
fs=18;
title('Solution for the microphone problem','FontSize',fs);
Any help or insight would be greatly appreciated.
Many thanks,
C Boyce

Answers (1)

Can't you transform the equations such that you solve your problem on the rectangle [0:R]x[0:2*Pi] instead ?
The mapping (r,phi)->(r*cos(phi),r*sin(phi)) maps the rectangle onto the circle ...
Best wishes
Torsten.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 27 Mar 2015

Answered:

on 27 Mar 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!