跳转至

DropOnNet

user_createSurfaceNet.m
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 Le

valleyData=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);

return
lpsData=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);
user_DropOnNet.m
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%using functions to build objects, modify and import objects
clear;
%-----------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 parameters
columnObj=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 object
B.name='DropOnNet';
B.ballR=ballR;%element radius
B.sampleW=netWidth;%width, length, height
B.sampleL=netHeight;%when L is zero, it is a 2-dimensional model
B.sampleH=1;
B.isSample=0;%an empty box without sample elements
B.setType('botPlaten');%add a top platen to compact model
B.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 file
matTxt(1)=matTxt(1)/1;
Mats{1,1}=material('rubber',matTxt,B.ballR);
Mats{1,1}.Id=1;
d.Mats=Mats;%assign new material
d.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.name num2str(B.ballR) '-' num2str(B.distriRate) 'loopNum'];
save([fName '0.mat']);%return;
for i=1:totalCircle
    d.balance('Standard',0.1);
    d.show(showType);
    pause(0.05);

    d.clearData(1);%clear data in d.mo
    save([fName num2str(i) '.mat']);
    d.calculateData();
end
%f.run('fun/makeGIF.m',fName,0,totalCircle,'mV');
Was this page helpful?