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.
154 lines
3.4 KiB
154 lines
3.4 KiB
function mp= Build_Lshape()
|
|
% Bulid mp obj (contains models and all arguments)
|
|
%% init
|
|
pace=1;
|
|
Pst=[0 0 0];
|
|
Ped=[3 15 15];
|
|
Ped=FCM_dV.round_Ped(Pst,Ped,pace);
|
|
maxdeep=5;
|
|
order=3;
|
|
viewxy=[150 30];
|
|
|
|
Shape.accessThreshold(pace/maxdeep/2/2/2);%
|
|
Oa=[0 0 0];
|
|
Ra=[0 0 0];
|
|
|
|
rvec=(Ped-Pst)/pace
|
|
num_cells=rvec(1)*rvec(2)*rvec(3);
|
|
fprintf("num_cells: %.0f\n",num_cells);% show num of cells
|
|
|
|
|
|
%% add SS lib & python path
|
|
additon_path=pwd;
|
|
|
|
if count(py.sys.path,additon_path) == 0
|
|
insert(py.sys.path,int32(0),additon_path);
|
|
end
|
|
|
|
%% assemble c0
|
|
%----------------------------------------2D sketch
|
|
|
|
rect_top=Rect([0 0 0],[3 3 0]);
|
|
cube_top=Sketch([0 0 0],Ra,15,rect_top);
|
|
c_top=CSG();c_top.init(cube_top);
|
|
|
|
rect_down=Rect([0 0 0],[3 15 0]);
|
|
cube_down=Sketch([0 0 0],Ra,3,rect_down);
|
|
c_down=CSG();c_down.init(cube_down);
|
|
|
|
|
|
rc_line=Line([3 3 0],[0 3 0]);
|
|
rc_skt=Sketch([0 0 3],Ra,12,rc_line);
|
|
rc_obj=RoundCorner(6,rc_skt,rc_line,false,false);
|
|
rc=CSG();rc.init(rc_obj,'rc');
|
|
|
|
|
|
c=c_top+c_down+rc;
|
|
|
|
|
|
|
|
|
|
V0=1;
|
|
% time and calculate Volume
|
|
tic
|
|
fcmv=FCM_V(Pst,Ped,pace,maxdeep,order,@c.calSDF,@(X) ones(size(X,1),1));% |||1 dV
|
|
V0=fcmv.calIntegral_V();
|
|
Vstd=243+(9-9/4*pi)*3;
|
|
Verr=(V0-Vstd)/Vstd
|
|
% fcmv=FCM_V(Pst,Ped,pace,maxdeep,order,@c.calSDF,@(X) ones(24,24,size(X,1)));% |||1 dV
|
|
% K0=sum(fcmv.cal_Ke(),3);
|
|
% K0(1)
|
|
|
|
tmp_c=CSG('Sphere',[1.5,1.5,1.5],1.5);
|
|
fcmv=FCM_V(Pst,Ped,pace,maxdeep,order,@tmp_c.calSDF,@(X) ones(size(X,1),1));% |||1 dV
|
|
calV=fcmv.calIntegral_V();
|
|
stdV=4/3*pi*1.5^3;
|
|
err=abs(calV-stdV)/stdV
|
|
% S0=fcmdv.calIntegral_S(Dir)
|
|
% Sstd=4*pi*5*5;
|
|
% abs(S0-Sstd)/Sstd
|
|
%
|
|
% fcmdv=FCM_V(Pst,Ped,pace,maxdeep,order,@tmp_c.calSDF,@(X) ones(size(X,1),1));% |||1 dV
|
|
% Vstd=4/3*pi*5^3;
|
|
% V00=fcmdv.calIntegral_V()
|
|
% abs(Vstd-V00)/Vstd
|
|
fprintf('V0: %f ,Time: %f\n',V0,toc);
|
|
|
|
%% build Dirichlet/Neumann boundary
|
|
%-----------------------------------------Dir
|
|
eepsD=1.5e-2;
|
|
eepsN=1e-3;
|
|
|
|
|
|
Dirich_csg=CSG('Cube','corner',[0 0 15],Ra,[3 3 eps]);
|
|
Dirich_csg.judge_func=@(X) abs(X(:,3)-15)<eepsD;
|
|
|
|
%------------------------------------------Neu
|
|
Neuman_csg=CSG('Cube','corner',[0 15 0],Ra,[3 eps 3]);
|
|
Neuman_csg.judge_func=@(X) abs(X(:,2)-15)<eepsN;
|
|
Neuman_csg.fdv=@cal_NeuF;
|
|
|
|
% fcmdv=FCM_dV(Pst,Ped,pace,maxdeep,order,@c.calSDF,@(X) ones(size(X,1),1));% |||1 dV
|
|
% S0=fcmdv.calIntegral_S(Dirich_csg)
|
|
% Sstd=9;
|
|
% relaS=(S0-Sstd)/Sstd
|
|
%
|
|
% S1=fcmdv.calIntegral_S(Neuman_csg)
|
|
% S1std=9;
|
|
% relaS1=(S1-S1std)/S1std
|
|
|
|
%% show model
|
|
clf;
|
|
% c=c+(CSG("NULL")*Dirich_csg);
|
|
c.set_display_args(Pst,Ped,pace/6,'viewxy',viewxy);
|
|
c.saveAs('c');
|
|
c.display_csg();
|
|
axis on
|
|
|
|
% fcmv=FCM_V(Pst,Ped,pace,maxdeep,order,@c.calSDF,@(X) ones(size(X,1),1));% |||1 dV
|
|
% V0=fcmv.calIntegral_V(true);
|
|
|
|
|
|
%% init mp(save handle)
|
|
mp=ModelPlus(Pst,Ped,pace,order,maxdeep);
|
|
mp.c=c;
|
|
mp.Dirich_csg=Dirich_csg;
|
|
mp.Neuman_csg=Neuman_csg;
|
|
mp.V0=V0;
|
|
mp.viewxy=viewxy;
|
|
mp.E=2e11*1e-3;
|
|
mp.u=0.3;
|
|
|
|
|
|
tmphandle=TmpHandle();
|
|
tmphandle.rcH=rc_obj;
|
|
mp.tmphandle=tmphandle;
|
|
|
|
mp.strongDBC=1;
|
|
mp.strongNBC=1;
|
|
mp.Neu_st=[0 15 0];
|
|
mp.Neu_ed=[3 15 3];
|
|
if 1 && order<=3
|
|
saveKeH=SaveKe(mp,@compute_B_in_local,mp.pace,mp.order,mp);
|
|
mp.saveKe=saveKeH;
|
|
end
|
|
|
|
%% set args here
|
|
mp.fixedNeu=1;
|
|
mp.iscontrast=1;
|
|
mp.isrecord=1;
|
|
|
|
%% init fmt
|
|
tic
|
|
fmt=FeatureMappingTable(c,Pst,Ped,pace);
|
|
fmt.reflash_table();
|
|
tini=toc;
|
|
mp.recorder.time_maintain_fmt(end+1)=tini;
|
|
mp.fmt=fmt;
|
|
|
|
|
|
end
|
|
|
|
function ret=cal_NeuF(X)
|
|
ret=zeros(size(X,1),3)+[0 0 -900]/9*1e3;
|
|
end
|
|
|