跳转至

MicroParticle

user_L2MicroParticle1.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
%build the geometrical model
clear;
fs.randSeed(2);%build random model
B=obj_Box;%build a box object
B.name='BoxMicroParticle';
B.GPUstatus='auto';
B.ballR=2e-5;
B.isClump=0;
B.distriRate=0.2;
B.sampleW=5e-3;
B.sampleL=0;
B.sampleH=5e-3;
%B.BexpandRate=4;
%B.PexpandRate=4;
B.type='topPlaten';
%B.type='TriaxialCompression';
B.setType();
B.buildInitialModel();%B.show();

B.setUIoutput();

d=B.d;%d.breakGroup('sample');d.breakGroup('lefPlaten');

d.mo.setGPU('auto');

%--------------end initial model------------
B.gravitySediment();
B.compactSample(1);%input is compaction time
%------------return and save result--------------
d.status.dispEnergy();%display the energy of the model

d.clearData(1);%clear dependent data
d.recordCalHour('BoxMicroParticle1Finish');
save(['TempModel/' B.name '1.mat'],'B','d');
save(['TempModel/' B.name '1R' num2str(B.ballR) '-distri' num2str(B.distriRate)  'aNum' num2str(d.aNum) '.mat']);
d.calculateData();
d.show('aR');
user_L2MicroParticle2.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
%---------------1. load data
clear
load('TempModel/BoxMicroParticle1.mat');
B.setUIoutput();%set output of message
d=B.d;
d.calculateData();
d.mo.setGPU('off');
d.getModel();%get xyz from d.mo

%---------------2. get the gray rank matrix
fileName='slope\micro particle.PNG';%the file to 
source=imread(fileName);%read image
source=double(source);%change to double data
imH=size(source,1);imW=size(source,2);%the height and width of the image
RGB=(source(:,:,1)*256+source(:,:,2))*256+source(:,:,3);%changed to RGB values
RGB=flipud(RGB);%flip data along vertical direction
[uColor,iA,iC]=unique(RGB);%find unique color
Gray=mean(source,3);%get gray level
Gray=flipud(Gray);%flip data along vertical direction
uGray=Gray(iA);%unique gray level
[v,grayI]=sort(uGray);%sort the groupId according to gray level
GrayRank=reshape(grayI(iC),size(Gray));%gray rank matrix

%---------------3. get the groupId of clump by image
sampleId=d.GROUP.sample;%the sample group will be used
sampleX=d.mo.aX(sampleId);
sampleZ=d.mo.aZ(sampleId);
sampleR=d.mo.aR(sampleId);

x1=min(sampleX-sampleR);%get the four limits of the model
x2=max(sampleX+sampleR);
z1=min(sampleZ-sampleR);
z2=max(sampleZ+sampleR);
sFilter=false(d.mNum,1);
sFilter(d.GROUP.sample)=true;%filter of elements

dX=(x2-x1)/imW;
dZ=(z2-z1)/imH;
imageXI=ceil((sampleX-x1)/dX);%get the location of element in image
imageZI=ceil((sampleZ-z1)/dZ);

startId=min([d.GROUP.groupId;-10])-1;%clump starts from -11 or lowest groupId-1
GrayGId=-GrayRank+1+startId;%change gray rank to groupId
imageIndex=(imageXI-1)*imH+imageZI;%element index in image
imageGId=GrayGId(imageIndex);%element groupId in image

%---------------4. set the clump by groupId
d.GROUP.groupId(sFilter)=imageGId;%assing groupId to the group
d.setClump();%set clump for groupId<=-11
delFilter=d.GROUP.groupId==startId;%groupId of pores is startId
d.delElement(find(delFilter));%delete pores

figure
subplot(1,2,1);
imshow(fileName);
subplot(1,2,2);
d.showData('groupId');
colorbar off;

%---------------5. save the data
d.mo.setGPU('off');
d.clearData(1);
d.recordCalHour('BoxModel2Finish');
save(['TempModel/' B.name '2.mat'],'B','d');
save(['TempModel/' B.name '2R' num2str(B.ballR) '-distri' num2str(B.distriRate)  'aNum' num2str(d.aNum) '.mat']);
d.calculateData();