source: issm/trunk/src/m/classes/damage.m@ 20500

Last change on this file since 20500 was 20500, checked in by Mathieu Morlighem, 9 years ago

merged trunk-jpl and trunk for revision 20497

File size: 6.9 KB
Line 
1%DAMAGEICE class definition
2%
3% Usage:
4% damage=damage();
5
6classdef damage
7 properties (SetAccess=public)
8 %damage
9 isdamage = 0;
10 D = NaN;
11 law = 0;
12 spcdamage = NaN;
13 max_damage = 0;
14
15 %numerical
16 stabilization = 0;
17 maxiter = 0;
18 elementinterp = '';
19
20 %general parameters for evolution law:
21 stress_threshold = 0;
22 kappa = 0;
23 c1 = 0;
24 c2 = 0;
25 c3 = 0;
26 c4 = 0;
27 healing = 0;
28 equiv_stress = 0;
29 requested_outputs = {};
30 end
31 methods
32 function self = damage(varargin) % {{{
33 switch nargin
34 case 0
35 self=setdefaultparameters(self);
36 case 1
37 inputstruct=varargin{1};
38 list1 = properties('damage');
39 list2 = fieldnames(inputstruct);
40 for i=1:length(list1)
41 fieldname = list1{i};
42 if ismember(fieldname,list2),
43 self.(fieldname) = inputstruct.(fieldname);
44 end
45 end
46 otherwise
47 error('constructor not supported');
48 end
49 end % }}}
50 function self = extrude(self,md) % {{{
51 self.D=project3d(md,'vector',self.D,'type','node');
52 self.spcdamage=project3d(md,'vector',self.spcdamage,'type','node');
53 end % }}}
54 function self = setdefaultparameters(self) % {{{
55
56 %damage parameters:
57 self.isdamage=0;
58 self.D=0;
59 self.law=0;
60
61 self.max_damage=1-1e-5; %if damage reaches 1, solve becomes singular, as viscosity becomes nil
62
63 %Type of stabilization used
64 self.stabilization=4;
65
66 %Maximum number of iterations
67 self.maxiter=100;
68
69 %finite element interpolation
70 self.elementinterp='P1';
71
72 %damage evolution parameters
73 self.stress_threshold=1.3e5;
74 self.kappa=2.8;
75 self.healing=0;
76 self.c1=0;
77 self.c2=0;
78 self.c3=0;
79 self.c4=0;
80 self.equiv_stress=0;
81
82 %output default:
83 self.requested_outputs={'default'};
84
85 end % }}}
86 function md = checkconsistency(self,md,solution,analyses) % {{{
87
88 md = checkfield(md,'fieldname','damage.isdamage','values',[1,0]);
89 if self.isdamage,
90 md = checkfield(md,'fieldname','damage.law','numel',[1],'values',[0,1,2]);
91 md = checkfield(md,'fieldname','damage.D','>=',0,'<=',self.max_damage,'size',[md.mesh.numberofvertices 1]);
92 md = checkfield(md,'fieldname','damage.spcdamage','Inf',1,'timeseries',1);
93 md = checkfield(md,'fieldname','damage.max_damage','<',1,'>=',0);
94 md = checkfield(md,'fieldname','damage.stabilization','numel',[1],'values',[0 1 2 4]);
95 md = checkfield(md,'fieldname','damage.maxiter','>=0',0);
96 md = checkfield(md,'fieldname','damage.elementinterp','values',{'P1','P2'});
97 md = checkfield(md,'fieldname','damage.stress_threshold','>=',0);
98 md = checkfield(md,'fieldname','damage.kappa','>',1);
99 md = checkfield(md,'fieldname','damage.healing','>=',0);
100 md = checkfield(md,'fieldname','damage.c1','>=',0);
101 md = checkfield(md,'fieldname','damage.c2','>=',0);
102 md = checkfield(md,'fieldname','damage.c3','>=',0);
103 md = checkfield(md,'fieldname','damage.c4','>=',0);
104 md = checkfield(md,'fieldname','damage.equiv_stress','numel',[1],'values',[0 1]);
105 md = checkfield(md,'fieldname','damage.requested_outputs','stringrow',1);
106 elseif (self.law~=0),
107 if (solution==DamageEvolutionSolutionEnum),
108 error('Invalid evolution law (md.damage.law) for a damage solution');
109 end
110 end
111 end % }}}
112 function list=defaultoutputs(self,md) % {{{
113
114 if strcmp(domaintype(md.mesh),'2Dhorizontal'),
115 list = {'DamageDbar'};
116 else
117 list = {'DamageD'};
118 end
119 end % }}}
120 function disp(self) % {{{
121 disp(sprintf(' Damage:\n'));
122
123 fielddisplay(self,'isdamage','is damage mechanics being used? {true,false}');
124 if self.isdamage,
125 fielddisplay(self,'law','damage law {''0: analytical'',''1: pralong''}');
126 fielddisplay(self,'D','damage tensor (scalar)');
127 fielddisplay(self,'spcdamage','damage constraints (NaN means no constraint)');
128 fielddisplay(self,'max_damage','maximum possible damage (0<=max_damage<1)');
129
130 fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: SUPG (not working), 4: flux corrected transport');
131 fielddisplay(self,'maxiter','maximum number of non linear iterations');
132 fielddisplay(self,'elementinterp','interpolation scheme for finite elements {''P1'',''P2''}');
133 fielddisplay(self,'stress_threshold','stress threshold for damage initiation [Pa]');
134 fielddisplay(self,'kappa','ductility parameter for stress softening and damage');
135 fielddisplay(self,'c1','damage parameter 1');
136 fielddisplay(self,'c2','damage parameter 2');
137 fielddisplay(self,'c3','damage parameter 3');
138 fielddisplay(self,'c4','damage parameter 4');
139 fielddisplay(self,'healing','damage healing parameter');
140 fielddisplay(self,'equiv_stress','0: von Mises, 1: max principal');
141 fielddisplay(self,'requested_outputs','additional outputs requested');
142 end
143
144 end % }}}
145 function marshall(self,md,fid) % {{{
146
147 WriteData(fid,'object',self,'fieldname','isdamage','format','Boolean');
148 if self.isdamage,
149 WriteData(fid,'object',self,'fieldname','law','format','Integer');
150 WriteData(fid,'object',self,'fieldname','D','format','DoubleMat','mattype',1);
151 WriteData(fid,'object',self,'fieldname','spcdamage','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1);
152 WriteData(fid,'object',self,'fieldname','max_damage','format','Double');
153
154 WriteData(fid,'object',self,'fieldname','stabilization','format','Integer');
155 WriteData(fid,'object',self,'fieldname','maxiter','format','Integer');
156 WriteData(fid,'enum',DamageElementinterpEnum(),'data',StringToEnum(self.elementinterp),'format','Integer');
157 WriteData(fid,'object',self,'fieldname','stress_threshold','format','Double');
158 WriteData(fid,'object',self,'fieldname','kappa','format','Double');
159 WriteData(fid,'object',self,'fieldname','c1','format','Double');
160 WriteData(fid,'object',self,'fieldname','c2','format','Double');
161 WriteData(fid,'object',self,'fieldname','c3','format','Double');
162 WriteData(fid,'object',self,'fieldname','c4','format','Double');
163 WriteData(fid,'object',self,'fieldname','healing','format','Double');
164 WriteData(fid,'object',self,'fieldname','equiv_stress','format','Integer');
165 end
166
167 %process requested outputs
168 outputs = self.requested_outputs;
169 pos = find(ismember(outputs,'default'));
170 if ~isempty(pos),
171 outputs(pos) = []; %remove 'default' from outputs
172 outputs = [outputs defaultoutputs(self,md)]; %add defaults
173 end
174 if self.isdamage,
175 WriteData(fid,'data',outputs,'enum',DamageEvolutionRequestedOutputsEnum,'format','StringArray');
176 end
177
178 end % }}}
179 function savemodeljs(self,fid,modelname) % {{{
180
181 writejsdouble(fid,[modelname '.damage.isdamage'],self.isdamage);
182 if self.isdamage,
183 error('savemodeljs error message: not implemented yet!');
184 end
185
186 end % }}}
187 end
188end
Note: See TracBrowser for help on using the repository browser.