00001 #include <string.h>
00002
00003 #include "nonlocdamg.h"
00004 #include "global.h"
00005 #include "mechmat.h"
00006 #include "intpoints.h"
00007 #include "matrix.h"
00008 #include "vector.h"
00009 #include "vecttens.h"
00010
00011
00012
00013
00014
00015
00016
00017
00018 nonlocdamg::nonlocdamg(void)
00019 {
00020 r = 0;
00021 af = avrgf(0);
00022 }
00023
00024
00025
00026
00027
00028
00029
00030
00031 nonlocdamg::~nonlocdamg(void)
00032 {
00033 r = 0;
00034 af = avrgf(0);
00035 }
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 long nonlocdamg::read(XFILE *in)
00053 {
00054 if (xfscanf(in, "%k%le%k%m", "radius", &r, "aver_func", &avrgf_kwdset, &af) == 4)
00055 return 0;
00056
00057 print_err("cannot read parameters of nonlocal damage",__FILE__,__LINE__,__func__);
00058 return 1;
00059 }
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 void nonlocdamg::print(FILE *out)
00076 {
00077 fprintf(out, "%le %d\n", r, int(af));
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 long nonlocdamg::give_num_averq (long ipp, long im)
00095 {
00096 switch(Mm->ip[ipp].tm[im+1])
00097 {
00098 case scaldamage:{
00099 return(1);
00100 }
00101 case scaldamagecc:{
00102 return(2);
00103 }
00104 case ortodamage:{
00105 return(6);
00106 }
00107 case ortodamagerot:{
00108 return(6);
00109 }
00110 case anisodamage:{
00111 return(6);
00112 }
00113 case anisodamagerot:{
00114 return(6);
00115 }
00116 default:
00117 print_err("unknown damage material type is required", __FILE__, __LINE__, __func__);
00118 }
00119 return 0;
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 void nonlocdamg::give_aver_quantv(long ipp, long im, long ido, vector &qv)
00139 {
00140 switch(Mm->ip[ipp].tm[im+1])
00141 {
00142 case scaldamage:
00143 Mm->give_kappa(ipp, im+1, ido, qv);
00144 return;
00145 case scaldamagecc:
00146 Mm->give_kappa(ipp, im+1, ido, qv);
00147 return;
00148 case ortodamage:
00149 case ortodamagerot:
00150 case anisodamage:
00151 case anisodamagerot:
00152 {
00153 long nc = Mm->ip[ipp].ncompstr;
00154 long i;
00155 for (i=0; i<nc; i++)
00156 qv[i] = Mm->ip[ipp].strain[i];
00157 return;
00158 }
00159 default:
00160 print_err("unknown damage material type is required", __FILE__, __LINE__, __func__);
00161 }
00162 return;
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 void nonlocdamg::average (long ipp, long im, long ido)
00182 {
00183 double rr, alpha, sum = 0.0;
00184 double weight;
00185 long i, j;
00186
00187 long nad;
00188
00189 long aip;
00190
00191 long naq = Mm->give_num_averq(ipp, im);
00192
00193 vector aq(naq);
00194
00195 vector aux(naq);
00196
00197
00198 nad=Mt->nadjip[ipp];
00199
00200
00201 for (i = 0; i < nad; i++)
00202 {
00203
00204 aip=Mt->adjip[ipp][i];
00205
00206 rr=Mt->dist[ipp][i];
00207
00208 switch (af)
00209 {
00210 case parab:
00211 alpha = (rr >= r) ? 0 : (1-rr*rr/(r*r));
00212 break;
00213 case cubic:
00214 alpha = (rr >= r) ? 0 : (1-rr*rr/(r*r))*(1-rr*rr/(r*r));
00215 break;
00216 default:
00217 print_err("unknown type of the averaging function is required",__FILE__,__LINE__,__func__);
00218 break;
00219 }
00220 if (alpha < 1.0e-3)
00221 continue;
00222
00223 weight = alpha * Mm->ipv[aip];
00224 sum += weight;
00225 Mm->give_aver_quantv(aip, im, ido, aux);
00226 for (j=0; j<naq; j++)
00227 aq[j] += weight*aux[j];
00228
00229 }
00230 for(i=0; i<naq; i++)
00231 Mm->ip[ipp].nonloc[i] = aq[i] / sum;
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 double nonlocdamg::give_proczonelength(long ipp, long im, long ido)
00251 {
00252 return 2.0*r;
00253 }