.
This commit is contained in:
parent
52609c6099
commit
43bc7df338
4 changed files with 131 additions and 0 deletions
23
Sheet6/Ex6B.m
Normal file
23
Sheet6/Ex6B.m
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
clear; clc;
|
||||
lambda = @(x) (x < 1/sqrt(2)) + 10*(x >= 1/sqrt(2)); %diffusion coefficient
|
||||
f = @(x) 0; %homogeneous RHS
|
||||
x = linspace(0,1,6); %coarse initial mesh, doesn't include x_m
|
||||
nIter = 6;
|
||||
|
||||
for it = 1:nIter
|
||||
[K,F] = assemble_1D(x,lambda,f); %assemble
|
||||
K(1,:) = 0; K(1,1) = 1; F(1) = 0; % Dirichlet BC at x=0
|
||||
K(end,:) = 0; K(end,end) = 1; F(end) = 1; % Dirichlet BC at x=1
|
||||
u = K\F;
|
||||
|
||||
if it < nIter %h-adaptivity loop
|
||||
eta = flux_jump(x, u, lambda);
|
||||
x = h_adapt(x,eta,0.4);
|
||||
end
|
||||
end
|
||||
|
||||
figure
|
||||
plot(x,u,'-o','LineWidth',1.5)
|
||||
xlabel('x'), ylabel('u')
|
||||
title('Ex6B, h-adaptivity with coefficient jump')
|
||||
grid on
|
||||
Loading…
Add table
Add a link
Reference in a new issue