source: issm/branches/trunk-jpl-damage/src/m/model/MatlabProcessPatch.m@ 12168

Last change on this file since 12168 was 12168, checked in by cborstad, 13 years ago

merged trunk-jpl into branch through revision 12167

File size: 1.6 KB
Line 
1function structure=MatlabProcessPatch(structure);
2%PROCESSPATCH - create a structure from a patch
3%
4% Usage:
5% Result=ProcessPatch(Result);
6
7%return if there is no fiel Patch
8if (~isfield(structure,'Patch')),
9 return;
10end
11
12%loop over steps
13for i=1:length(structure),
14
15 %Get Patch for current step
16 Patch=structure(i).Patch;
17 numvertices=structure(i).PatchVertices;
18
19 %check that Patch is not empty
20 if length(Patch)==0 continue; end
21
22 %Get number of fields;
23 fields=unique(Patch(:,1));
24 steps=unique(Patch(:,2));
25
26 %parse steps
27 for j=1:length(steps),
28
29 posstep=find(Patch(:,2)==steps(j));
30
31 %Take all the lines of the Patch for this timestep
32 temporarypatch=Patch(posstep,:);
33 time=temporarypatch(1,3);
34 step=temporarypatch(1,2);
35
36 %parse fields
37 for i=1:length(fields),
38
39 %get name
40 fieldname=EnumToString(fields(i));
41
42 %get line positions
43 pos=find(temporarypatch(:,1)==fields(i));
44
45 %Fill Result structure
46 structure(step).steps=step;
47 structure(step).time=time;
48 structure(step).(fieldname).element=temporarypatch(pos,4);
49 structure(step).(fieldname).interpolation=temporarypatch(pos,5);
50 structure(step).(fieldname).index=temporarypatch(pos,6:5+numvertices);
51 if structure(step).(fieldname).interpolation==P1Enum,
52 structure(step).(fieldname).value=temporarypatch(pos,6+numvertices:end);
53 end
54 if structure(step).(fieldname).interpolation==P0Enum,
55 structure(step).(fieldname).value=temporarypatch(pos,6+numvertices);
56 end
57
58 end
59 end
60end
61
62%remove fields
63structure=rmfield(structure,'Patch');
64structure=rmfield(structure,'PatchVertices');
65structure=rmfield(structure,'PatchNodes');
Note: See TracBrowser for help on using the repository browser.