Skip to content
Snippets Groups Projects
Commit 57215b5f authored by Lars Hubatsch's avatar Lars Hubatsch
Browse files

WIP: create_mesh.

Outside is not so important, as long as >100 points. Inside close to r=0 also not sensitive, but getting closer (> 75% * R) to boundary needs better mesh. Presumably due to high initial gradient.
parent 32cdd0c8
No related branches found
No related tags found
No related merge requests found
......@@ -3,19 +3,20 @@ function create_mesh(T)
% Mesh density larger for steeper gradients.
% Start with left side of mesh, at r=0/x=0, with a given step size
x = [0, 0.01/T.precision/10];%/10
while x<-2*T.a
% x = [0, 0.01/T.precision/10];%/10
x = linspace(0, 0.75, 40);
x = [x, x(end)+0.01/T.precision/10];%/10
while x(end)<-2*T.a
x_temp = x(end)-x(end-1);
phi_nm1 = T.phi_tot(x(end), T.a, T.b, T.e, T.u0);
phi_n = T.phi_tot(x(end)+x_temp, T.a, T.b, T.e, T.u0);
if x(end) <= -T.a
while phi_nm1-phi_n > 0.0002/T.precision
while phi_nm1-phi_n > 0.002/T.precision
x_temp = x_temp/2;
phi_n = T.phi_tot(x(end)+x_temp, T.a, T.b, T.e, T.u0);
end
elseif x(end) > -T.a
while (phi_nm1-phi_n < 0.0001/T.precision) && ...
while (phi_nm1-phi_n < 0.001/T.precision) && ...
(x_temp < 0.01/T.precision)
x_temp = 2*x_temp;
phi_n = T.phi_tot(x(end)+x_temp, T.a, T.b, T.e, T.u0);
......@@ -23,8 +24,8 @@ while x<-2*T.a
end
x = [x, x(end)+x_temp];
end
x_middle = linspace(-2*T.a+x(end)-x(end-1), -10*T.a, 600*T.precision);
x_right = linspace(-10*T.a+0.1, T.system_size, 600*T.precision);
x_middle = linspace(-2*T.a+x(end)-x(end-1), -10*T.a, 100*T.precision);
x_right = linspace(-10*T.a+0.1, T.system_size, 100*T.precision);
T.x = [x, x_middle, x_right];
T.x = T.x(1:find(T.x-T.system_size>=0, 1)-1);
end
......
......@@ -26,7 +26,7 @@ if strcmp(mode, 'mov')
elseif strcmp(mode, 'plot')
figure(20);
hold on;
xlim([-6, 10]); ylim([0, inf]);
xlim([-inf, 3]); ylim([0, inf]);
ax = gca;
ax.FontSize = 26;
xlabel('x [\mum]'); ylabel('volume fraction');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment