clear;%The function signature of mfs.create3Dsurface is: obj=mfs.create3Dsurface(x,y,z,ballR,Rrate,varargin),%while the meanings of the input parameters are:%x,y,z: digital elelvation model (DEM) scattered data.%ballR: the uniform radius of elements.%Rrate: the ratio of the distance between two elements to their diameter. use 0.5~0.8, when it is 0.7, no gap between elements%varargin: 1 parameter, the uniform width of the margins to be clipped;% 2 parameters, the widths of the margins to be clipped, left and right, top and bottom, respectively;% 4 parameters, the widths of the margins to be clipped, left, right, top, bottom, respectively.%Tiancheng LevalleyData=load('slope/valley.txt');valleyX=valleyData(:,1);valleyY=valleyData(:,2);valleyZ=valleyData(:,3);[valleyX,valleyY]=mfs.rotateIJ(valleyX,valleyY,29);ballR=500;Rrate=0.6;valleyObj=mfs.createSurfaceNet(valleyX,valleyY,7*valleyZ,ballR,Rrate,6000,8000,10000,12000);%4 additional input parameters.ballR=500;Rrate=3;valleyObj2=mfs.createSurfaceNet(valleyX,valleyY,7*valleyZ,ballR,Rrate,6000,8000,10000,12000);%4 additional input parameters.valleyObj.Value=valleyObj.Z;valleyObj2.Value=valleyObj2.Z;%Display the 4 objects created with the function createSurfaceNet.figure(1);subplot(1,2,1);fs.showObj(valleyObj);subplot(1,2,2);fs.showObj(valleyObj2);returnlpsData=load('slope/lps1.txt');lpsX=lpsData(:,1);lpsY=lpsData(:,2);lpsZ=lpsData(:,3);[lpsX,lpsY]=mfs.rotateIJ(lpsX,lpsY,-60);ballR=7;Rrate=0.7;lpsObj.Value=lpsObj.Z;lpsObj=mfs.createSurfaceNet(lpsX,lpsY,lpsZ,ballR,Rrate,50,100);%2 additional input parameters.fs.showObj(lpsObj);
%using functions to build objects, modify and import objectsclear;%-----------step0: make object (struct data)------------ballR=0.02;hobObj=f.run('fun/makeHob.m',0.2,0.1,1,ballR,0.8);%see the function file about the input parameterscolumnObj=f.run('fun/makeColumn.m',0.1,0.28,ballR,0.8);netWidth=2;netHeight=2;cellW=0.1;cellH=0.1;netObj=mfs.denseModel(0.8,@mfs.makeNet,netWidth,netHeight,cellW,cellH,ballR);hobObj2=mfs.move(hobObj,netWidth/2+0.2,netHeight/2,0.8);columnObj2=mfs.move(columnObj,netWidth/2-0.2,netHeight/2,0.8);netObj2=mfs.rotate(netObj,'YZ',-90);netObj2=mfs.move(netObj2,0,0,0.2);allObj=mfs.combineObj(hobObj2,columnObj2,netObj2);%combine the objects%fs.showObj(allObj);%return;%-----------step1: build model------------B=obj_Box;%declare a box objectB.name='DropOnNet';B.ballR=ballR;%element radiusB.sampleW=netWidth;%width, length, heightB.sampleL=netHeight;%when L is zero, it is a 2-dimensional modelB.sampleH=1;B.isSample=0;%an empty box without sample elementsB.setType('botPlaten');%add a top platen to compact modelB.boundaryStatus=[0,0,0,0,1,0];B.buildInitialModel();d=B.d;d.mo.setGPU('off');[netId,hobId,columnId]=d.addElement(1,{netObj2,hobObj2,columnObj2});d.addGroup('net',netId);d.addGroup('hob',hobId);d.addGroup('column',columnId);d.setClump(netId);d.setClump(hobId);d.setClump(columnId);d.delElement('botPlaten');d.GROUP.groupProtect=[];d.delElement('botB');netX=d.mo.aX(d.GROUP.net);netY=d.mo.aY(d.GROUP.net);fixId=(netX==min(netX))|(netX==max(netX))|(netY==min(netY))|(netY==max(netY));fixId=find(fixId);d.addFixId('X',fixId);d.addFixId('Y',fixId);d.addFixId('Z',fixId);d.setGroupId();d.show('FixXId');d.show('groupId');%-----------step2: assign material------------matTxt=load('Mats\rubber.txt');%load material filematTxt(1)=matTxt(1)/1;Mats{1,1}=material('rubber',matTxt,B.ballR);Mats{1,1}.Id=1;d.Mats=Mats;%assign new materiald.groupMat2Model({'sample'},1);%apply the new material%-----------step3: numerical simulation------------d.mo.mVis(:)=0;d.mo.isShear=0;showType='mV';figureNumber=d.show(showType);d.figureNumber=figureNumber;d.mo.setGPU('auto');d.mo.dT=d.mo.dT*4;totalCircle=50;d.tic(totalCircle);fName=['data/step/'B.namenum2str(B.ballR)'-'num2str(B.distriRate)'loopNum'];save([fName'0.mat']);%return;fori=1:totalCircled.balance('Standard',0.1);d.show(showType);pause(0.05);d.clearData(1);%clear data in d.mosave([fNamenum2str(i)'.mat']);d.calculateData();end%f.run('fun/makeGIF.m',fName,0,totalCircle,'mV');