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)