You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
553 B
17 lines
553 B
3 years ago
|
%--------------------------
|
||
|
% @Author: Jingqiao Hu
|
||
|
% @Date: 2021-10-06 14:46:55
|
||
|
% @LastEditTime: 2021-10-06 14:46:55
|
||
|
%--------------------------
|
||
|
%Heaviside function
|
||
|
function H=Heaviside(phi,globalx,globaly,epsilon)
|
||
|
alpha=1e-3; % parameter alpha in the Heaviside function
|
||
|
|
||
|
num_all=[1:(globalx+1)*(globaly+1)]';
|
||
|
num1=find(phi>epsilon);
|
||
|
H(num1)=1;
|
||
|
num2=find(phi<-epsilon);
|
||
|
H(num2)=alpha;
|
||
|
num3=setdiff(num_all,[num1;num2]);
|
||
|
H(num3)=3*(1-alpha)/4*(phi(num3)/epsilon-phi(num3).^3/(3*(epsilon)^3))+ (1+alpha)/2;
|
||
|
end
|