Changeset 18044


Ignore:
Timestamp:
05/22/14 09:36:44 (11 years ago)
Author:
Mathieu Morlighem
Message:

CHG: initialize as NaN only for arrays

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/damage.m

    r18043 r18044  
    99                isdamage            = 0;
    1010                D                   = NaN;
    11                 law                 = NaN;
     11                law                 = 0;
    1212                spcdamage           = NaN;
    13                 max_damage          = NaN;
     13                max_damage          = 0;
    1414       
    1515                %numerical
    16                 stabilization       = NaN;
    17                 maxiter             = NaN;
     16                stabilization       = 0;
     17                maxiter             = 0;
    1818                elementinterp       = '';
    19                 penalty_threshold   = NaN;
    20                 penalty_lock        = NaN;
    21                 penalty_factor      = NaN;
     19                penalty_threshold   = 0;
     20                penalty_lock        = 0;
     21                penalty_factor      = 0;
    2222               
    2323                %general parameters for evolution law:
    24                 stress_threshold    = NaN;
    25                 c1                  = NaN;
    26                 c2                  = NaN;
    27                 c3                  = NaN;
    28                 c4                  = NaN;
    29                 healing             = NaN;
    30                 equiv_stress              = NaN;
     24                stress_threshold    = 0;
     25                c1                  = 0;
     26                c2                  = 0;
     27                c3                  = 0;
     28                c4                  = 0;
     29                healing             = 0;
     30                equiv_stress              = 0;
    3131                requested_outputs   = {};
    3232        end
    3333        methods
    34         function createxml(obj,fid) % {{{
    35             fprintf(fid, '\n\n');
    36             fprintf(fid, '%s\n', '<!-- damage -->');
    37             fprintf(fid, '%s\n', '<!-- Note: this class depends on different input of law -->');
    38            
    39             %fprintf(fid,'%s%s%s%s\n%s\n%s\n%s\n',    '<parameter key ="law" type="logical"',           '" default="',                num2str(obj.law),'">',   '     <section name="damage" />','     <help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>');
    40             % drop-down
    41             fprintf(fid,'%s%s%s%s%s\n\t%s\n','<parameter key ="law" type="','alternative','" optional="','false','">','<section name="damage" />');
    42            
    43             % law = 'undamage'
    44             fprintf(fid,'\t%s%s%s%s%s\n\t\t%s\n','<option value="undamage" type="','string','" default="','true','">','<help> law = undamage </help>');
    45             % footer for option
    46             fprintf(fid,'\t%s\n%s\n','</option>');
    47            
    48             % law = 'pralong'
    49             fprintf(fid,'\t%s%s%s%s%s\n\t\t%s\n','<option value="pralong" type="','string','" default="','false','">','<help> law = pralong </help>');
    50                
    51             fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="stress_threshold" type="',class(obj.stress_threshold),'" default="',num2str(obj.stress_threshold),'">','<help> damage stress threshold [Pa] </help>','</parameter>');
    52             fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="c1" type="', class(obj.c1),'" default="',   num2str(obj.c1),'">',   '<help> damage parameter 1 </help>','</parameter>');
    53             fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="c2" type="',          class(obj.c2),'" default="',            num2str(obj.c2),'">','<help> damage parameter 2 </help>','</parameter>');
    54             fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="c3" type="',          class(obj.c3),'" default="',            num2str(obj.c3),'">','<help> damage parameter 3 [W/m^2] </help>','</parameter>');
    55             fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="c4" type="',            class(obj.c4),'" default="',              num2str(obj.c4),'">','<help> damage parameter 4 </help>','</parameter>');
    56             fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="healing" type="', class(obj.healing),'" default="',   num2str(obj.healing),'">','<help> damage healing parameter 1 </help>','</parameter>');
    57             fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="equiv_stress" type="',          class(obj.equiv_stress),'" default="',convert2str(obj.equiv_stress),'">','<help> 0: von Mises </help>','</parameter>');
    58             fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="requested_outputs" type="',          class(obj.requested_outputs),'" default="',convert2str(obj.requested_outputs),'">','<help> additional outputs requested </help>','</parameter>');
    59              
    60                
    61             % footer for option
    62             fprintf(fid,'\t%s\n%s\n','</option>');
    63                  
    64            
    65             % footer for drop-down
    66             fprintf(fid,'\t%s\n%s\n%s','<help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>');
    67            
    68            
     34                function createxml(obj,fid) % {{{
     35                        fprintf(fid, '\n\n');
     36                        fprintf(fid, '%s\n', '<!-- damage -->');
     37                        fprintf(fid, '%s\n', '<!-- Note: this class depends on different input of law -->');
     38
     39                        %fprintf(fid,'%s%s%s%s\n%s\n%s\n%s\n',    '<parameter key ="law" type="logical"',           '" default="',                num2str(obj.law),'">',   '     <section name="damage" />','     <help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>');
     40                        % drop-down
     41                        fprintf(fid,'%s%s%s%s%s\n\t%s\n','<parameter key ="law" type="','alternative','" optional="','false','">','<section name="damage" />');
     42
     43                        % law = 'undamage'
     44                        fprintf(fid,'\t%s%s%s%s%s\n\t\t%s\n','<option value="undamage" type="','string','" default="','true','">','<help> law = undamage </help>');
     45                        % footer for option
     46                        fprintf(fid,'\t%s\n%s\n','</option>');
     47
     48                        % law = 'pralong'
     49                        fprintf(fid,'\t%s%s%s%s%s\n\t\t%s\n','<option value="pralong" type="','string','" default="','false','">','<help> law = pralong </help>');
     50
     51                        fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',   '<parameter key ="stress_threshold" type="',class(obj.stress_threshold),'" default="',num2str(obj.stress_threshold),'">','<help> damage stress threshold [Pa] </help>','</parameter>');
     52                        fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',       '<parameter key ="c1" type="', class(obj.c1),'" default="',   num2str(obj.c1),'">',   '<help> damage parameter 1 </help>','</parameter>');
     53                        fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',       '<parameter key ="c2" type="',          class(obj.c2),'" default="',            num2str(obj.c2),'">','<help> damage parameter 2 </help>','</parameter>');
     54                        fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',       '<parameter key ="c3" type="',          class(obj.c3),'" default="',            num2str(obj.c3),'">','<help> damage parameter 3 [W/m^2] </help>','</parameter>');
     55                        fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',       '<parameter key ="c4" type="',            class(obj.c4),'" default="',              num2str(obj.c4),'">','<help> damage parameter 4 </help>','</parameter>');
     56                        fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',       '<parameter key ="healing" type="', class(obj.healing),'" default="',   num2str(obj.healing),'">','<help> damage healing parameter 1 </help>','</parameter>');
     57                        fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',       '<parameter key ="equiv_stress" type="',          class(obj.equiv_stress),'" default="',convert2str(obj.equiv_stress),'">','<help> 0: von Mises </help>','</parameter>');
     58                        fprintf(fid,'\t\t%s%s%s%s%s\n\t\t\t%s\n\t\t%s\n',       '<parameter key ="requested_outputs" type="',          class(obj.requested_outputs),'" default="',convert2str(obj.requested_outputs),'">','<help> additional outputs requested </help>','</parameter>');
     59
     60
     61                        % footer for option
     62                        fprintf(fid,'\t%s\n%s\n','</option>');
     63
     64
     65                        % footer for drop-down
     66                        fprintf(fid,'\t%s\n%s\n%s','<help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>');
     67
     68
    6969                        fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',    '<parameter key ="D" type="',              class(obj.D),'" default="',                  num2str(obj.D),'">',              '     <section name="damage" />','     <help> damage tensor (scalar) </help>','</parameter>');
    70             fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',    '<parameter key ="law" type="',            class(obj.law),'" default="',                num2str(obj.law),'">',   '     <section name="damage" />','     <help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>');
    71             fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="spcdamage" type="',      class(obj.spcdamage),'" default="',          num2str(obj.spcdamage),'">',            '     <section name="damage" />','     <help> damage constraints (NaN means no constraint) </help>','</parameter>');
    72             fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="max_damage" type="',     class(obj.max_damage),'" default="',         num2str(obj.max_damage),'">',            '     <section name="damage" />','     <help> maximum possible damage (0&amp;lt;=max_damage&amp;lt;1) </help>','</parameter>');
    73              
    74             % stabilization (0,1, or 2) drop-down
    75             fprintf(fid,'%s\n%s\n%s\n%s\n',    '<parameter key ="stabilization" type="alternative" optional="false">','     <section name="damage" />','     <help> 0: no, 1: artificial_diffusivity, 2: SUPG </help>');
    76             fprintf(fid, '%s\n', '       <option value="0" type="string" default="true"></option>');
    77             fprintf(fid, '%s\n', '       <option value="1" type="string" default="false"></option>');
    78             fprintf(fid, '%s\n', '       <option value="2" type="string" default="false"></option>');
    79             fprintf(fid, '%s\n','</parameter>');
    80            
    81             fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',    '<parameter key ="maxiter" type="',             class(obj.maxiter),'" default="',   num2str(obj.maxiter),'">',   '     <section name="damage" />','     <help> maximum number of non linear iterations </help>','</parameter>');
    82             fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="penalty_lock" type="',        class(obj.penalty_lock),'" default="',            num2str(obj.penalty_lock),'">',            '     <section name="damage" />','     <help> stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization) </help>','</parameter>');
    83             fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="penalty_threshold" type="',   class(obj.penalty_threshold),'" default="',            num2str(obj.penalty_threshold),'">',            '     <section name="damage" />','     <help> threshold to declare convergence of damage evolution solution (default is 0) </help>','</parameter>');
    84             fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="penalty_factor" type="',      class(obj.penalty_factor),'" default="',            num2str(obj.penalty_factor),'">',            '     <section name="damage" />','     <help> scaling exponent (default is 3) </help>','</parameter>');
    85  
    86         end % }}}
     70                        fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',    '<parameter key ="law" type="',            class(obj.law),'" default="',                num2str(obj.law),'">',   '     <section name="damage" />','     <help> damage law (string) from {"undamaged","pralong"} </help>','</parameter>');
     71                        fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="spcdamage" type="',      class(obj.spcdamage),'" default="',          num2str(obj.spcdamage),'">',            '     <section name="damage" />','     <help> damage constraints (NaN means no constraint) </help>','</parameter>');
     72                        fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="max_damage" type="',     class(obj.max_damage),'" default="',         num2str(obj.max_damage),'">',            '     <section name="damage" />','     <help> maximum possible damage (0&amp;lt;=max_damage&amp;lt;1) </help>','</parameter>');
     73
     74                        % stabilization (0,1, or 2) drop-down
     75                        fprintf(fid,'%s\n%s\n%s\n%s\n',    '<parameter key ="stabilization" type="alternative" optional="false">','     <section name="damage" />','     <help> 0: no, 1: artificial_diffusivity, 2: SUPG </help>');
     76                        fprintf(fid, '%s\n', '       <option value="0" type="string" default="true"></option>');
     77                        fprintf(fid, '%s\n', '       <option value="1" type="string" default="false"></option>');
     78                        fprintf(fid, '%s\n', '       <option value="2" type="string" default="false"></option>');
     79                        fprintf(fid, '%s\n','</parameter>');
     80
     81                        fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',    '<parameter key ="maxiter" type="',             class(obj.maxiter),'" default="',   num2str(obj.maxiter),'">',   '     <section name="damage" />','     <help> maximum number of non linear iterations </help>','</parameter>');
     82                        fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="penalty_lock" type="',        class(obj.penalty_lock),'" default="',            num2str(obj.penalty_lock),'">',            '     <section name="damage" />','     <help> stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization) </help>','</parameter>');
     83                        fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="penalty_threshold" type="',   class(obj.penalty_threshold),'" default="',            num2str(obj.penalty_threshold),'">',            '     <section name="damage" />','     <help> threshold to declare convergence of damage evolution solution (default is 0) </help>','</parameter>');
     84                        fprintf(fid,'%s%s%s%s%s\n%s\n%s\n%s\n',        '<parameter key ="penalty_factor" type="',      class(obj.penalty_factor),'" default="',            num2str(obj.penalty_factor),'">',            '     <section name="damage" />','     <help> scaling exponent (default is 3) </help>','</parameter>');
     85
     86                end % }}}
    8787       
    8888                function obj = damage(varargin) % {{{
     
    155155                                md = checkfield(md,'fieldname','damage.maxiter','>=0',0);
    156156                                md = checkfield(md,'fieldname','damage.elementinterp','values',{'P1','P2'});
    157                                 md = checkfield(md,'fieldname','damage.penalty_factor','>=0',0);
    158                                 md = checkfield(md,'fieldname','damage.penalty_lock','>=0',0);
    159                                 md = checkfield(md,'fieldname','damage.penalty_threshold','>=0',0);
     157                                md = checkfield(md,'fieldname','damage.penalty_factor','>=',0);
     158                                md = checkfield(md,'fieldname','damage.penalty_lock','>=',0);
     159                                md = checkfield(md,'fieldname','damage.penalty_threshold','>=',0);
    160160                        end
    161161
Note: See TracChangeset for help on using the changeset viewer.