void draw() { for (float i = 0; i < sx; i++) { for (float j = 0; j < sy; j++) { glBegin(GL_QUADS); glNormal3f(getx((i+0.5)/sx,(j+0.5)/sy), gety((i+0.5)/sx, (j+0.5)/sy), getz((i+0.5)/sx,(j+0.5)/sy)); glVertex3f(getx(i/sx, j/sy), gety(i/sx, j/sy), getz(i/sx, j/sy)); glVertex3f(getx((i+1)/sx, j/sy), gety((i+1)/sx, j/sy), getz((i+1)/sx, j/sy)); glVertex3f(getx((i+1)/sx, (j+1)/sy), gety((i+1)/sx, (j+1)/sy), getz((i+1)/sx, (j+1)/sy)); glVertex3f(getx(i/sx, (j+1)/sy), gety(i/sx, (j+1)/sy), getz(i/sx, (j+1)/sy)); glEnd(); } } }
double getchi2(double dof, double alpha) { double tol = 1.0E-3; double ac, lm, rm, eps, chi2, za, x; int i, itmax = 100; if (dof > 30.0) { /* approximate a value if degrees of freedom are > 30 based on eqn 1. Sachs, 1984 */ za = -getz(alpha); /* NB: Eq. requires change of sign for percentile */ x = 2.0 / 9.0 / dof; chi2 = pow((dof * (1.0 - x + za * sqrt(x))), 3.0); } else{ lm = 0.0; rm = 1000.0; if (alpha > 0.5) eps = (1.0 - alpha) * tol; else eps = alpha * tol; for (i = 1; i <= itmax; i++) { chi2 = 0.5 * (lm + rm); ac = 1.0 - gammp(0.5 * dof, 0.5 * chi2); if (fabs(ac - alpha) <= eps) return (chi2); if (ac > alpha){ lm = chi2; }else { rm = chi2; } } } return (chi2); }
double Plane::getzbound(Area* limit, vect2d pt, double rad, double height, bool clipsolid) { PROBEGIN(checkz_fast); PROBEGIN(checkz_slow); if (slope==0 && !clipsolid) { // Special case: slope is zero, so bound is z [+-] height. return cpt.z+(ceil?-height:height); } if (rad == 0) { return getz(pt)+(ceil?-height:height); } // Calculate the highest (or lowest) point where the cylinder // intersects with the plane. This is always <px, py> [+-] <ix, iy>*rad vect2d tpt = pt; if ((slope>0) == ceil) { tpt -= dir*rad; } else { tpt += dir*rad; } // If the limit area is not specified, or <tpx, tpy> is in the // area, simply return the value of the plane at that point [+-] height. if ((limit == NULL) || limit->pointin(tpt)) { PROEND(checkz_fast); double ret = getz(tpt); if (ceil) { ret -= height; } else { ret += height; } return ret; } // Ok, so the point is not in the area. So, we have to find some // other point to be the (max|min)imum. This point will either be // 1. a vertex of the area, or // 2. a point along one of the walls. // // We start out with the value at [+-]infinity, and then check all // possible points. We loop through the walls, checking the vertex // if the vertex is inside the circle, then check the points where // the circle intersects the wall. double cz = (ceil?INFINITY:-INFINITY); #define ckz(pt) { \ double tz=getz(pt) + (ceil?-height:height); \ if (ceil == (tz<cz)) cz = tz; \ } double rad2 = sqr(rad); FOREACHW(w, limit) { double a, ta; // Check the vertex. if (vlen2(w->v1-pt) < rad2) { ckz(w->v1); } // Transform the point to wall coordinate space. double doti = ~w->j*(pt-w->v1); double dotj = w->j*(pt-w->v1); // Circle does not intersect. if (fabs(doti)>rad+EPSILON) continue; // Check intersection points. a = sqrt(rad2-sqr(doti)); if (isnan(a)) a = 0; ta = dotj+a; if (ta >= 0 && ta <= w->len) { ckz(w->v1+w->j*ta); } ta = dotj-a; if (ta >= 0 && ta <= w->len) { ckz(w->v1+w->j*ta); } }
//================================================================================ const tensor& DM04_PF::Dm_Dkin2(const stresstensor &Stre, const straintensor &Stra, const MaterialParameter &MaterialParameter_in) const { const double oneOver3 = 1.0/3.0; const double rt23 = sqrt(2.0/3.0); tensor I2("I", 2, def_dim_2); double e0 = gete0(MaterialParameter_in); double e_r = gete_r(MaterialParameter_in); double lambda_c = getlambda_c(MaterialParameter_in); double xi = getxi(MaterialParameter_in); double Pat = getPat(MaterialParameter_in); //double m = getm(MaterialParameter_in); double M_cal = getM_cal(MaterialParameter_in); double cc = getcc(MaterialParameter_in); double A0 = getA0(MaterialParameter_in); double nd = getnd(MaterialParameter_in); stresstensor alpha = getalpha(MaterialParameter_in); stresstensor z = getz(MaterialParameter_in); stresstensor n; stresstensor alpha_d; stresstensor alpha_d_alpha; double g = 0.0; double ec = e_r; double stateParameter = 0.0; double expnd = 1.0; //double ad = 0.0; double D0 = 0.0; stresstensor s_bar; double norm_s = 0.0; double epsilon_v = 0.0; double e = e0; double J3D; double cos3theta = 0.0; double z_n = 0.0; double alpha_n = 0.0; double s_n = 0.0; double p = Stre.p_hydrostatic(); stresstensor s = Stre.deviator(); s_bar = s - (alpha *p); norm_s = sqrt( (s_bar("ij")*s_bar("ij")).trace() ); if (p > 0.0 && norm_s > 0.0) n = s_bar * (1.0/norm_s); J3D = n.Jinvariant3(); cos3theta = -3.0*sqrt(6.0) *J3D; if (cos3theta > 1.0) cos3theta = 1.0; if (cos3theta < -1.0) cos3theta = -1.0; g = getg(cc, cos3theta); if ( (p/Pat) >= 0.0 ) ec = getec(e_r, lambda_c, xi, Pat, p); epsilon_v = Stra.Iinvariant1(); e = e0 + (1.0 + e0) *epsilon_v; stateParameter = e - ec; expnd = exp(nd*stateParameter); alpha_n = (alpha("ij")*n("ij")).trace(); s_n = (s("ij")*n("ij")).trace(); // way 1 //ad = g*M_cal*expnd - m; //D0 = rt23 * ad - alpha_n; // way 2 D0 = rt23*g*M_cal*expnd - s_n /p; tensor dD_dz(2, def_dim_2, 0.0); // dD_dz: if (z_n > 0.0) dD_dz = n *A0; // dm_da: tensor tensor1 = I2("ij")*dD_dz("mn"); tensor1.null_indices(); PlasticFlow::PF_tensorR4 = tensor1 *(-D0*oneOver3); return PlasticFlow::PF_tensorR4; }
//================================================================================ const tensor& DM04_PF::Dm_Dkin(const stresstensor &Stre, const straintensor &Stra, const MaterialParameter &MaterialParameter_in) const { const double oneOver3 = 1.0/3.0; const double rt23 = sqrt(2.0/3.0); tensor I2("I", 2, def_dim_2); tensor I4 = I2("ij")*I2("kl"); tensor I4s = ( I4.transpose0110() + I4.transpose0111() ) *0.5; double e0 = gete0(MaterialParameter_in); double e_r = gete_r(MaterialParameter_in); double lambda_c = getlambda_c(MaterialParameter_in); double xi = getxi(MaterialParameter_in); double Pat = getPat(MaterialParameter_in); //double m = getm(MaterialParameter_in); double M_cal = getM_cal(MaterialParameter_in); double cc = getcc(MaterialParameter_in); double A0 = getA0(MaterialParameter_in); double nd = getnd(MaterialParameter_in); stresstensor alpha = getalpha(MaterialParameter_in); stresstensor z = getz(MaterialParameter_in); stresstensor n; stresstensor alpha_d; stresstensor alpha_d_alpha; double g = 0.0; double ec = e_r; double stateParameter = 0.0; double expnd = 1.0; //double ad = 0.0; double A_d = 0.0; double B = 1.0; double C = 0.0; double D0 = 0.0; stresstensor s_bar; double norm_s = 0.0; double epsilon_v = 0.0; double e = e0; double J3D; double cos3theta = 0.0; double z_n = 0.0; double alpha_n = 0.0; double s_n = 0.0; double p = Stre.p_hydrostatic(); stresstensor s = Stre.deviator(); s_bar = s - (alpha *p); norm_s = sqrt( (s_bar("ij")*s_bar("ij")).trace() ); if (p > 0.0 && norm_s > 0.0) n = s_bar * (1.0/norm_s); J3D = n.Jinvariant3(); cos3theta = -3.0*sqrt(6.0) *J3D; if (cos3theta > 1.0) cos3theta = 1.0; if (cos3theta < -1.0) cos3theta = -1.0; g = getg(cc, cos3theta); if ( (p/Pat) >= 0.0 ) ec = getec(e_r, lambda_c, xi, Pat, p); epsilon_v = Stra.Iinvariant1(); e = e0 + (1.0 + e0) *epsilon_v; stateParameter = e - ec; expnd = exp(nd*stateParameter); alpha_n = (alpha("ij")*n("ij")).trace(); s_n = (s("ij")*n("ij")).trace(); // way 1 //ad = g*M_cal*expnd - m; //D0 = rt23 * ad - alpha_n; // way 2 D0 = rt23*g*M_cal*expnd - s_n /p; z_n = (z("ij")*n("ij")).trace(); if (z_n < 0.0) z_n = 0.0; A_d = A0 * (1.0 + z_n); B = 1.0 + 1.5 *((1.0-cc)/cc) *g *cos3theta; C = 3.0 *sqrt(1.5) *((1.0-cc)/cc) *g; tensor n_n = n("ik")*n("kj"); n_n.null_indices(); tensor nt_nt = n("ij")*n("kl"); nt_nt.null_indices(); tensor alpha_I = alpha("ij")*I2("kl"); alpha_I.null_indices(); tensor n_I = n("ij")*I2("kl"); n_I.null_indices(); // dn_dalpha: tensor dn_da = nt_nt - I4s; dn_da = dn_da *(p/norm_s); // dcos3theta_dalpha: tensor dcos3theta_da = dn_da("ijmn")*n_n("ji"); dcos3theta_da.null_indices(); dcos3theta_da = dcos3theta_da *(-3.0*sqrt(6.0)); // dg_da: tensor dg_da = dcos3theta_da *(g*g*(1.0-cc)/(2.0*cc)); // dB_da: tensor dB_da = (dg_da*cos3theta + dcos3theta_da*g) *(1.5*(1.0-cc)/cc); // dC_ds: tensor dC_da = dg_da *(3.0*sqrt(1.5)*(1.0-cc)/cc); // dR_da: tensor tensor1 = n("ij")*dB_da("mn"); tensor1.null_indices(); tensor tensor2 = n_n - I2 *oneOver3; tensor tensor3 = tensor2("ij")*dC_da("mn"); tensor3.null_indices(); tensor tensor4 = n("kj")*dn_da("ikmn"); tensor4.null_indices(); tensor4.transpose1100(); tensor dR_da = dn_da *B + tensor1 + tensor4 *(2.0*C) + tensor3; // dad_da: tensor dad_da = dg_da *(M_cal*expnd); // dD_da: // way 1 //tensor tensor5 = alpha("pq")*dn_da("pqmn"); // tensor5.null_indices(); //tensor dD_da = (dad_da *rt23 - n - tensor5) *(-A_d); // way 2 tensor tensor5 = s("pq")*dn_da("pqmn"); tensor5.null_indices(); tensor dD_da = (dad_da *rt23 - tensor5 *(1.0/p)) *(-A_d); if (z_n > 0.0) { tensor tensor6 = z("pq")*dn_da("pqmn"); tensor6.null_indices(); dD_da += tensor6 *(-A0*D0); } // dm_da: tensor tensor7 = I2("ij")*dD_da("mn"); tensor7.null_indices(); PlasticFlow::PF_tensorR4 = dR_da + tensor7 *oneOver3; return PlasticFlow::PF_tensorR4; }
//================================================================================ const straintensor& DM04_PF::PlasticFlowTensor(const stresstensor& Stre, const straintensor& Stra, const MaterialParameter &MaterialParameter_in) const { const double oneOver3 = 1.0/3.0; const double rt23 = sqrt(2.0/3.0); tensor I2("I", 2, def_dim_2); double e0 = gete0(MaterialParameter_in); double e_r = gete_r(MaterialParameter_in); double lambda_c = getlambda_c(MaterialParameter_in); double xi = getxi(MaterialParameter_in); double Pat = getPat(MaterialParameter_in); //double m = getm(MaterialParameter_in); double M_cal = getM_cal(MaterialParameter_in); double cc = getcc(MaterialParameter_in); double A0 = getA0(MaterialParameter_in); double nd = getnd(MaterialParameter_in); stresstensor alpha = getalpha(MaterialParameter_in); stresstensor z = getz(MaterialParameter_in); stresstensor n; stresstensor alpha_d; stresstensor alpha_d_alpha; double g = 0.0; double ec = e_r; double stateParameter = 0.0; double expnd = 1.0; //double ad = 0.0; double A_d = 0.0; double B = 1.0; double C = 0.0; double D = 0.0; double D0 = 0.0; stresstensor s_bar; double norm_s = 0.0; double epsilon_v = 0.0; double e = e0; double J3D; double cos3theta = 0.0; double z_n = 0.0; double alpha_n = 0.0; double s_n = 0.0; double p = Stre.p_hydrostatic(); stresstensor s = Stre.deviator(); s_bar = s - (alpha *p); norm_s = sqrt( (s_bar("ij")*s_bar("ij")).trace() ); if (p > 0.0 && norm_s > 0.0) n = s_bar * (1.0/norm_s); J3D = n.Jinvariant3(); cos3theta = -3.0*sqrt(6.0) *J3D; if (p <= 0.0) cos3theta = 1.0; if (cos3theta > 1.0) cos3theta = 1.0; if (cos3theta < -1.0) cos3theta = -1.0; g = getg(cc, cos3theta); if ( (p/Pat) >= 0.0 ) ec = getec(e_r, lambda_c, xi, Pat, p); epsilon_v = Stra.Iinvariant1(); e = e0 + (1.0 + e0) *epsilon_v; stateParameter = e - ec; expnd = exp(nd*stateParameter); alpha_n = (alpha("ij")*n("ij")).trace(); s_n = (s("ij")*n("ij")).trace(); // way 1 //ad = g*M_cal*expnd - m; //D0 = rt23 *ad - alpha_n; // way 2, better use this when "p" is small D0 = rt23*g*M_cal*expnd - s_n /p; z_n = (z("ij")*n("ij")).trace(); if (z_n < 0.0) z_n = 0.0; A_d = A0 * (1.0 + z_n); D = D0 *(-A_d); B = 1.0 + 1.5 *((1.0-cc)/cc) *g *cos3theta; C = 3.0 *sqrt(1.5) *((1.0-cc)/cc) *g; stresstensor n_n = n("ik")*n("kj"); n_n.null_indices(); // note different 'positive-negative' since we assume extension (dilation) positive // which is different from the Ref. DM04_PF::DM04m = n *B + n_n *C + I2 *((D-C)*oneOver3); return DM04_PF::DM04m; }
void Matrix::addscale (float x,float y,float z) { getx ()->mul (x); gety ()->mul (y); getz ()->mul (z); }