// Compute section tangent stiffness, ks, from material tangent, Dt, // by integrating over section area // eps = [eps_11, eps_12 ]' // e = [eps_a, kappa_z, gamma_y ]' // ks = int_A a'*Dt*a dA // a = [1 -y 0 // 0 0 1 ] const Matrix& TimoshenkoSection2d::getSectionTangent(void) { for (int i=0; i<9; i++) kData[i] = 0.0; double y, z, w; double y2, z2, yz; double d00, d01; double d10, d11; double tmp; //double five6 = 5./6.; //double root56 = sqrt(five6); for (int i = 0; i < numFibers; i++) { y = matData[i*3] - yBar; z = matData[i*3+1] - zBar; w = matData[i*3+2]; y2 = y*y; z2 = z*z; yz = y*z; const Matrix &Dt = theMaterials[i]->getTangent(); d00 = Dt(0,0)*w; d01 = Dt(0,1)*w; d10 = Dt(1,0)*w; d11 = Dt(1,1)*w; kData[0] += d00; //0,0 P kData[4] += y2*d00; //1,1 M kData[8] += d11; //2,2 five6* V tmp = -y*d00; kData[1] += tmp; // 0,1 kData[3] += tmp; // 1,0 // Hit tangent terms with root56 //d01 *= root56; d10 *= root56; kData[2] += d01; //0,2 kData[6] += d10; //2,0 kData[5] -= y*d01; //1,2 kData[7] -= y*d10; //2,1 } return *ks; }
void Foam::SuppressionCollision<CloudType>::collide(const scalar dt) { const kinematicCloud& sc = this->owner().mesh().template lookupObject<kinematicCloud>(suppressionCloud_); volScalarField vDotSweep(sc.vDotSweep()); dimensionedScalar Dt("dt", dimTime, dt); volScalarField P(type() + ":p", 1.0 - exp(-vDotSweep*Dt)); forAllIter(typename CloudType, this->owner(), iter) { typename CloudType::parcelType& p = iter(); label cellI = p.cell(); scalar xx = this->owner().rndGen().template sample01<scalar>(); if (xx < P[cellI]) { p.canCombust() = -1; p.typeId() = max(p.typeId(), suppressedParcelType_); } } }
Type objective_function<Type>::operator() () { DATA_VECTOR(times); DATA_VECTOR(obs); PARAMETER(log_R0); PARAMETER(m); PARAMETER(log_theta); PARAMETER(log_sigma); Type theta=exp(log_theta); Type sigma=exp(log_sigma); Type R0=exp(log_R0); int n1=times.size(); int n2=2;//mean and variance vector<Type> Dt(n1-1); vector<Type> Ex(n1-1); vector<Type> Vx(n1-1); Type nll=0; m=0; Dt=diff(times); Ex=theta*(Type(1)-exp(-R0*Dt)) + obs.segment(0, n1-1)*exp(-R0*Dt); Vx=Type(0.5)*sigma*sigma*(Type(1)-exp(Type(-2)*R0*Dt))/R0; for(int i=0; i<n1-1; i++) { nll-= dnorm(obs[i+1], Ex[i], sqrt(Vx[i]), true); } return nll; }
void Remove(edge *e) { point *u = Oi(e), *v = Dt(e); if (u->in == e) u->in = e->on; if (v->in == e) v->in = e->dn; if (Oi(e->on) == u) e->on->op = e->op; else e->on->dp = e->op; if (Oi(e->op) == u) e->op->on = e->on; else e->op->dn = e->on; if (Oi(e->dn) == v) e->dn->op = e->dp; else e->dn->dp = e->dp; if (Oi(e->dp) == v) e->dp->on = e->dn; else e->dp->dn = e->dn; elist[nfree++] = e; }
int main(){ int N = 3; CGAL::Timer cost; std::vector<Point_d> points; Point_d point1(1,3,5); Point_d point2(4,8,10); Point_d point3(2,7,9); Point_d point(1,2,3); points.push_back(point1); points.push_back(point2); points.push_back(point3); K Kernel D Dt(d,Kernel,Kernel); // CGAL_assertion(Dt.empty()); // insert the points in the triangulation cost.reset();cost.start(); std::cout << " Delaunay triangulation of "<<N<<" points in dim "<<d<< std::flush; std::vector<Point_d>::iterator it; for(it = points.begin(); it!= points.end(); ++it){ Dt.insert(*it); } std::list<Simplex_handle> NL = Dt.all_simplices(D::NEAREST); std::cout << " done in "<<cost.time()<<" seconds." << std::endl; CGAL_assertion(Dt.is_valid() ); CGAL_assertion(!Dt.empty()); Vertex_handle v = Dt.nearest_neighbor(point); Simplex_handle s = Dt.simplex(v); std::vector<Point_d> Simplex_vertices; for(int j=0; j<=d; ++j){ Vertex_handle vertex = Dt.vertex_of_simplex(s,j); Simplex_vertices.push_back(Dt.associated_point(vertex)); } std::vector<K::FT> coords; K::Barycentric_coordinates_d BaryCoords; BaryCoords(Simplex_vertices.begin(), Simplex_vertices.end(),point,std::inserter(coords, coords.begin())); std::cout << coords[0] << std::endl; return 0; }
double TimoshenkoSection2d::getGAy(void) { double G, GAy = 0.; double y, z, A; for (int i = 0; i < numFibers; i++) { //y =matData[i*3] - yBar; //z =matData[i*3+1] - zBar; A =matData[i*3+2]; const Matrix &Dt = theMaterials[i]->getTangent(); G = Dt(1,1); GAy += G * A; } return GAy; }
double TimoshenkoSection2d::getEIz(void) { double G, E, K, EIz = 0.; double y, z, A; for (int i = 0; i < numFibers; i++) { y = matData[i*3] - yBar; z = matData[i*3+1] - zBar; A = matData[i*3+2]; const Matrix &Dt = theMaterials[i]->getTangent(); //G = Dt(1,1); K= Dt(0,0) - 4./3.*G; E = Dt(0,0); //9.*K*G/(3.*K+G); EIz += E * A * pow(y,2.); } return EIz; }
void Divide(int s, int t, edge **L, edge **R) { edge *a, *b, *c, *ll, *lr, *rl, *rr, *tangent; int n = t - s + 1; if (n == 2) *L = *R = Make_edge(Q[s], Q[t]); else if (n == 3) { a = Make_edge(Q[s], Q[s + 1]), b = Make_edge(Q[s + 1], Q[t]); Splice(a, b, Q[s + 1]); double v = C3(Q[s], Q[s + 1], Q[t]); if (v > eps) c = Join(a, Q[s], b, Q[t], 0), *L = a, *R = b; else if (v < -eps) c = Join(a, Q[s], b, Q[t], 1), *L = c, *R = c; else *L = a, *R = b; } else if (n > 3) { int split = (s + t) / 2; Divide(s, split, &ll, &lr); Divide(split + 1, t, &rl, &rr); Merge(lr, Q[split], rl, Q[split + 1], &tangent); if (Oi(tangent) == Q[s]) ll = tangent; if (Dt(tangent) == Q[t]) rr = tangent; *L = ll; *R = rr; } }
void extr(jvec &ext_EP,jvec &ext_ED,jvec &ext_Q2,jvec &ext_fP,jvec &ext_fM,jvec &ext_f0,jvec &ext_fT,int il_sea,int il,int ic) { ////////////////////////////////////////// R0 ////////////////////////////////////// jvec R0_corr; jack R0(njack); //load standing jvec ll0_st=load_3pts("V0",il,il,0,RE,ODD,1); jvec lc0_st=load_3pts("V0",ic,il,0,RE,ODD,1); jvec cc0_st=load_3pts("V0",ic,ic,0,RE,ODD,1); //build R0 R0_corr=lc0_st*lc0_st.simmetric()/(cc0_st*ll0_st); //fit and plot R0=constant_fit(R0_corr,TH-tmax,tmax,combine("plots/R0_il_%d_ic_%d.xmg",il,ic).c_str()); //////////////////////////////////////////// R2 //////////////////////////////////// jvec R2_corr[nth]; jvec RT_corr[nth]; jvec R2(nth,njack); jvec RT(nth,njack); ofstream out_R2(combine("plots/R2_il_%d_ic_%d.xmg",il,ic).c_str()); ofstream out_RT(combine("plots/RT_il_%d_ic_%d.xmg",il,ic).c_str()); jvec lcK_th[nth],lc0_th[nth],lcT_th[nth]; for(int ith=0;ith<nth;ith++) { //load corrs lcK_th[ith]=load_3pts("VK",ic,il,ith,IM,EVN,-1)/(6*th_P[ith]); lc0_th[ith]=load_3pts("V0",ic,il,ith,RE,ODD,1); lcT_th[ith]=load_3pts("VTK",ic,il,ith,IM,ODD,1)/(6*th_P[ith]); //build ratios R2_corr[ith]=lcK_th[ith]/lc0_th[ith]; RT_corr[ith]=lcT_th[ith]/lcK_th[ith]; //fit R2[ith]=constant_fit(R2_corr[ith],tmin,tmax); RT[ith]=constant_fit(RT_corr[ith],tmin,tmax); //plot out_R2<<write_constant_fit_plot(R2_corr[ith],R2[ith],tmin,tmax); out_RT<<write_constant_fit_plot(RT_corr[ith],RT[ith],tmin,tmax); } ////////////////////////////////////////// R1 ////////////////////////////////////// jvec R1_corr[nth]; jvec R1(nth,njack); ofstream out_P(combine("plots/out_P_il_%d_ic_%d.xmg",il,ic).c_str()); out_P<<"@type xydy"<<endl; ofstream out_D(combine("plots/out_D_il_%d_ic_%d.xmg",il,ic).c_str()); out_D<<"@type xydy"<<endl; ofstream out_R1(combine("plots/out_R1_il_%d_ic_%d.xmg",il,ic).c_str()); out_R1<<"@type xydy"<<endl; //load Pi and D jvec P_corr[nth],D_corr[nth]; jvec ED(nth,njack),EP(nth,njack); for(int ith=0;ith<nth;ith++) { //load moving pion P_corr[ith]=load_2pts("2pts_P5P5.dat",il_sea,il,ith); out_P<<"@type xydy"<<endl; EP[ith]=constant_fit(effective_mass(P_corr[ith]),tmin_P,TH,combine("plots/P_eff_mass_il_%d_ic_%d_ith_%d.xmg", il,ic,ith).c_str()); out_P<<write_constant_fit_plot(effective_mass(P_corr[ith]),EP[ith],tmin_P,TH); out_P<<"&"<<endl; //recompute EP and ED from standing one if(ith) { ED[ith]=latt_en(ED[0],th_P[ith]); EP[ith]=latt_en(EP[0],th_P[ith]); } //load moving D D_corr[ith]=load_2pts("2pts_P5P5.dat",il,ic,ith); out_D<<"@type xydy"<<endl; ED[ith]=constant_fit(effective_mass(D_corr[ith]),tmin_D,TH,combine("plots/D_eff_mass_il_%d_ic_%d_ith_%d.xmg", il,ic,ith).c_str()); out_D<<write_constant_fit_plot(effective_mass(D_corr[ith]),ED[ith],tmin_D,TH); out_D<<"&"<<endl; //build the ratio R1_corr[ith]=lc0_th[ith]/lc0_th[0]; for(int t=0;t<TH;t++) { int E_fit_reco_flag=1; jack Dt(njack),Pt(njack); if(E_fit_reco_flag==0) { Dt=D_corr[0][t]/D_corr[ith][t]; Pt=P_corr[0][TH-t]/P_corr[ith][TH-t]; } else { jack ED_th=latt_en(ED[0],th_P[ith]),EP_th=latt_en(EP[0],th_P[ith]); Dt=exp(-(ED[0]-ED_th)*t)*ED_th/ED[0]; Pt=exp(-(EP[0]-EP_th)*(TH-t))*EP_th/EP[0]; } R1_corr[ith][t]*=Dt*Pt; } //fit R1[ith]=constant_fit(R1_corr[ith],tmin,tmax); //plot out_R1<<write_constant_fit_plot(R1_corr[ith],R1[ith],tmin,tmax); } //////////////////////////////////////// solve the ratios ////////////////////////////// //compute f0[q2max] jvec f0_r(nth,njack),fP_r(nth,njack),fT_r(nth,njack); f0_r[0]=sqrt(R0*4*ED[0]*EP[0])/(ED[0]+EP[0]); cout<<"f0_r[q2max]: "<<f0_r[0]<<endl; //compute QK and Q2 double mom[nth]; jvec PK(nth,njack),QK(nth,njack); jvec P0(nth,njack),Q0(nth,njack),Q2(nth,njack),P2(nth,njack); jvec P0_r(nth,njack),Q0_r(nth,njack),Q2_r(nth,njack),P2_r(nth,njack); for(int ith=0;ith<nth;ith++) { P0[ith]=ED[ith]+EP[ith]; //P=initial+final Q0[ith]=ED[ith]-EP[ith]; //Q=initial-final P0_r[ith]=latt_en(ED[0],th_P[ith])+latt_en(EP[0],th_P[ith]); Q0_r[ith]=latt_en(ED[0],th_P[ith])-latt_en(EP[0],th_P[ith]); //we are describing the process D->Pi mom[ith]=momentum(th_P[ith]); double P_D=-mom[ith]; double P_Pi=mom[ith]; PK[ith]=P_D+P_Pi; QK[ith]=P_D-P_Pi; P2[ith]=sqr(P0[ith])-3*sqr(PK[ith]); Q2[ith]=sqr(Q0[ith])-3*sqr(QK[ith]); //reconstruct Q2 P2_r[ith]=sqr(P0_r[ith])-3*sqr(PK[ith]); Q2_r[ith]=sqr(Q0_r[ith])-3*sqr(QK[ith]); } //checking Pion dispertion relation ofstream out_disp_P(combine("plots/Pion_disp_rel_il_%d_ic_%d.xmg",il,ic).c_str()); out_disp_P<<"@type xydy"<<endl; for(int ith=0;ith<nth;ith++) out_disp_P<<3*sqr(mom[ith])<<" "<<sqr(EP[ith])<<endl; out_disp_P<<"&"<<endl; for(int ith=0;ith<nth;ith++) out_disp_P<<3*sqr(mom[ith])<<" "<<sqr(cont_en(EP[0],th_P[ith]))<<endl; out_disp_P<<"&"<<endl; for(int ith=0;ith<nth;ith++) out_disp_P<<3*sqr(mom[ith])<<" "<<sqr(latt_en(EP[0],th_P[ith]))<<endl; out_disp_P<<"&"<<endl; //checking D dispertion relation ofstream out_disp_D(combine("plots/D_disp_rel_il_%d_ic_%d.xmg",il,ic).c_str()); out_disp_D<<"@type xydy"<<endl; for(int ith=0;ith<nth;ith++) out_disp_D<<3*sqr(mom[ith])<<" "<<sqr(ED[ith])<<endl; out_disp_D<<"&"<<endl; for(int ith=0;ith<nth;ith++) out_disp_D<<3*sqr(mom[ith])<<" "<<sqr(cont_en(ED[0],th_P[ith]))<<endl; out_disp_D<<"&"<<endl; for(int ith=0;ith<nth;ith++) out_disp_D<<3*sqr(mom[ith])<<" "<<sqr(latt_en(ED[0],th_P[ith]))<<endl; out_disp_D<<"&"<<endl; //compute xi jvec xi(nth,njack); for(int ith=1;ith<nth;ith++) { int E_fit_reco_flag=0; //it makes no diff jack P0_th=E_fit_reco_flag?P0_r[ith]:P0[ith]; jack Q0_th=E_fit_reco_flag?Q0_r[ith]:Q0[ith]; xi[ith]=R2[ith]*P0_th; xi[ith]/=QK[ith]-R2[ith]*Q0_th; } //compute fP ofstream out_fP_r(combine("plots/fP_r_il_%d_ic_%d.xmg",il,ic).c_str()); out_fP_r<<"@type xydy"<<endl; for(int ith=1;ith<nth;ith++) { int E_fit_reco_flag=1; //it makes no diff jack P0_th=E_fit_reco_flag?P0_r[ith]:P0[ith]; jack Q0_th=E_fit_reco_flag?Q0_r[ith]:Q0[ith]; jack c=P0_th/(ED[0]+EP[0])*(1+xi[ith]*Q0_th/P0_th); fP_r[ith]=R1[ith]/c*f0_r[0]; out_fP_r<<Q2[ith].med()<<" "<<fP_r[ith]<<endl; } //compute f0 and fT ofstream out_f0_r(combine("plots/f0_r_il_%d_ic_%d.xmg",il,ic).c_str()); ofstream out_fT_r(combine("plots/fT_r_il_%d_ic_%d.xmg",il,ic).c_str());; out_f0_r<<"@type xydy"<<endl; out_f0_r<<Q2[0].med()<<" "<<f0_r[0]<<endl; out_fT_r<<"@type xydy"<<endl; for(int ith=1;ith<nth;ith++) { //it seems better here to solve using reconstructed energies int E_fit_reco_flag=0; jack EP_th=E_fit_reco_flag?latt_en(EP[0],th_P[ith]):EP[ith]; jack ED_th=E_fit_reco_flag?latt_en(ED[0],th_P[ith]):ED[ith]; jack Q2_th=E_fit_reco_flag?Q2_r[ith]:Q2[ith]; jack fM_r=xi[ith]*fP_r[ith]; //checked f0_r[ith]=fP_r[ith]+fM_r[ith]*Q2_th/(sqr(ED_th)-sqr(EP_th)); out_f0_r<<Q2[ith].med()<<" "<<f0_r[ith]<<endl; fT_r[ith]=fM_r[ith]*RT[ith]*Zt_med[ibeta]/Zv_med[ibeta]*(EP[0]+ED[0])/(ED[ith]+EP[ith]); //ADD out_fT_r<<Q2[ith].med()<<" "<<fT_r[ith]<<endl; } //////////////////////////////////////// analytic method ///////////////////////////// jvec fP_a(nth,njack),fM_a(nth,njack),f0_a(nth,njack),fT_a(nth,njack); jvec fP_n(nth,njack),fM_n(nth,njack),f0_n(nth,njack),fT_n(nth,njack); //determine M and Z for pion and D jvec ZP(nth,njack),ZD(nth,njack); for(int ith=0;ith<nth;ith++) { jack E,Z2; two_pts_fit(E,Z2,P_corr[ith],tmin_P,TH); ZP[ith]=sqrt(Z2); two_pts_fit(E,Z2,D_corr[ith],tmin_D,TH); ZD[ith]=sqrt(Z2); } //compute V jvec VK_a(nth,njack),V0_a(nth,njack),TK_a(nth,njack); jvec VK_n(nth,njack),V0_n(nth,njack),TK_n(nth,njack); for(int ith=0;ith<nth;ith++) { ofstream out_V0(combine("plots/V0_il_%d_ic_%d_ith_%d_analytic_numeric.xmg",il,ic,ith).c_str()); out_V0<<"@type xydy"<<endl; ofstream out_VK(combine("plots/VK_il_%d_ic_%d_ith_%d_analytic_numeric.xmg",il,ic,ith).c_str()); out_VK<<"@type xydy"<<endl; ofstream out_TK(combine("plots/TK_il_%d_ic_%d_ith_%d_analytic_numeric.xmg",il,ic,ith).c_str()); out_TK<<"@type xydy"<<endl; ofstream out_dt(combine("plots/dt_il_%d_ic_%d_ith_%d.xmg",il,ic,ith).c_str()); out_dt<<"@type xydy"<<endl; //computing time dependance jvec dt_a(TH+1,njack),dt_n(TH+1,njack); { //it seems better here to use fitted energies int E_fit_reco_flag=1; jack EP_th=E_fit_reco_flag?latt_en(EP[0],th_P[ith]):EP[ith]; jack ED_th=E_fit_reco_flag?latt_en(ED[0],th_P[ith]):ED[ith]; for(int t=0;t<=TH;t++) { dt_a[t]=exp(-(ED_th*t+EP_th*(TH-t)))*ZP[0]*ZD[0]/(4*EP_th*ED_th); dt_n[t]=D_corr[ith][t]*P_corr[ith][TH-t]/(ZD[0]*ZP[0]); } } //remove time dependance using analytic or numeric expression jvec VK_corr_a=Zv_med[ibeta]*lcK_th[ith]/dt_a,V0_corr_a=Zv_med[ibeta]*lc0_th[ith]/dt_a; jvec VK_corr_n=Zv_med[ibeta]*lcK_th[ith]/dt_n,V0_corr_n=Zv_med[ibeta]*lc0_th[ith]/dt_n; jvec TK_corr_n=Zt_med[ibeta]*lcT_th[ith]/dt_n,TK_corr_a=Zt_med[ibeta]*lcT_th[ith]/dt_a; //fit V0 V0_a[ith]=constant_fit(V0_corr_a,tmin,tmax); V0_n[ith]=constant_fit(V0_corr_n,tmin,tmax); out_V0<<write_constant_fit_plot(V0_corr_a,V0_a[ith],tmin,tmax)<<"&"<<endl; out_V0<<write_constant_fit_plot(V0_corr_n,V0_n[ith],tmin,tmax)<<"&"<<endl; //fit VK VK_a[ith]=constant_fit(VK_corr_a,tmin,tmax); VK_n[ith]=constant_fit(VK_corr_n,tmin,tmax); out_VK<<write_constant_fit_plot(VK_corr_a,VK_a[ith],tmin,tmax)<<"&"<<endl; out_VK<<write_constant_fit_plot(VK_corr_n,VK_n[ith],tmin,tmax)<<"&"<<endl; //fit TK TK_a[ith]=constant_fit(TK_corr_a,tmin,tmax); TK_n[ith]=constant_fit(TK_corr_n,tmin,tmax); out_TK<<write_constant_fit_plot(TK_corr_a,TK_a[ith],tmin,tmax)<<"&"<<endl; out_TK<<write_constant_fit_plot(TK_corr_n,TK_n[ith],tmin,tmax)<<"&"<<endl; } //compute f0(q2max) f0_a[0]=V0_a[0]/(ED[0]+EP[0]); f0_n[0]=V0_n[0]/(ED[0]+EP[0]); cout<<"f0_a["<<Q2[0].med()<<"]: "<<f0_a[0]<<endl; cout<<"f0_n["<<Q2[0].med()<<"]: "<<f0_n[0]<<endl; //solve for fP and f0 for(int ith=1;ith<nth;ith++) { jack delta=P0[ith]*QK[ith]-Q0[ith]*PK[ith]; //solve using analytic fit jack deltaP_a=V0_a[ith]*QK[ith]-Q0[ith]*VK_a[ith]; jack deltaM_a=P0[ith]*VK_a[ith]-V0_a[ith]*PK[ith]; fP_a[ith]=deltaP_a/delta; fM_a[ith]=deltaM_a/delta; //solve using numeric fit jack deltaP_n=V0_n[ith]*QK[ith]-Q0[ith]*VK_n[ith]; jack deltaM_n=P0[ith]*VK_n[ith]-V0_n[ith]*PK[ith]; fP_n[ith]=deltaP_n/delta; fM_n[ith]=deltaM_n/delta; //compute f0 f0_a[ith]=fP_a[ith]+fM_a[ith]*Q2[ith]/(ED[0]*ED[0]-EP[0]*EP[0]); f0_n[ith]=fP_n[ith]+fM_n[ith]*Q2[ith]/(ED[0]*ED[0]-EP[0]*EP[0]); //solve fT fT_a[ith]=-TK_a[ith]*(EP[0]+ED[0])/(2*(ED[ith]+EP[ith]))/mom[ith]; fT_n[ith]=-TK_n[ith]*(EP[0]+ED[0])/(2*(ED[ith]+EP[ith]))/mom[ith]; } //write analytic and umeric plot of fP and f0 ofstream out_fP_a("plots/fP_a.xmg"),out_fP_n("plots/fP_n.xmg"); ofstream out_fM_a("plots/fM_a.xmg"),out_fM_n("plots/fM_n.xmg"); ofstream out_f0_a("plots/f0_a.xmg"),out_f0_n("plots/f0_n.xmg"); ofstream out_fT_a("plots/fT_a.xmg"),out_fT_n("plots/fT_n.xmg"); out_fP_a<<"@type xydy"<<endl; out_fP_n<<"@type xydy"<<endl; out_f0_a<<"@type xydy"<<endl; out_f0_n<<"@type xydy"<<endl; out_fM_a<<"@type xydy"<<endl; out_fM_n<<"@type xydy"<<endl; out_fT_a<<"@type xydy"<<endl; out_fT_n<<"@type xydy"<<endl; out_f0_a<<Q2[0].med()<<" "<<f0_a[0]<<endl; out_f0_n<<Q2[0].med()<<" "<<f0_n[0]<<endl; for(int ith=1;ith<nth;ith++) { out_fP_a<<Q2[ith].med()<<" "<<fP_a[ith]<<endl; out_fP_n<<Q2[ith].med()<<" "<<fP_n[ith]<<endl; out_fM_a<<Q2[ith].med()<<" "<<fM_a[ith]<<endl; out_fM_n<<Q2[ith].med()<<" "<<fM_n[ith]<<endl; out_f0_a<<Q2[ith].med()<<" "<<f0_a[ith]<<endl; out_f0_n<<Q2[ith].med()<<" "<<f0_n[ith]<<endl; out_fT_a<<Q2[ith].med()<<" "<<fT_a[ith]<<endl; out_fT_n<<Q2[ith].med()<<" "<<fT_n[ith]<<endl; } ext_EP=EP; ext_ED=ED; ext_Q2=Q2; ext_fP=fP_a; ext_fM=fM_a; ext_f0=f0_a; ext_fT=fT_a; }
// Compute section tangent stiffness, ks, from material tangent, Dt, // by integrating over section area // ks = int_A a'*Dt*a dA // a = [1 -y z 0 0 0 // 0 0 0 sqrt(5/6) 0 -z // 0 0 0 0 sqrt(5/6) y] const Matrix& WSection2d::getSectionTangent(void) { ks.Zero(); double y, z, w; double y2, z2, yz; double d00, d01, d02; double d10, d11, d12; double d20, d21, d22; double tmp; double five6 = shapeFactor; double root56 = sqrt(shapeFactor); int numFibers = nfdw + 2*nftf; for (int i = 0; i < numFibers; i++) { y = yFibers[i]; z = 0.0; w = AFibers[i]; y2 = y*y; z2 = z*z; yz = y*z; const Matrix &Dt = theFibers[i]->getTangent(); d00 = Dt(0,0)*w; d01 = Dt(0,1)*w; d02 = Dt(0,2)*w; d10 = Dt(1,0)*w; d11 = Dt(1,1)*w; d12 = Dt(1,2)*w; d20 = Dt(2,0)*w; d21 = Dt(2,1)*w; d22 = Dt(2,2)*w; // Bending terms ks(0,0) += d00; ks(1,1) += y2*d00; ks(2,2) += z2*d00; tmp = -y*d00; ks(0,1) += tmp; ks(1,0) += tmp; tmp = z*d00; ks(0,2) += tmp; ks(2,0) += tmp; tmp = -yz*d00; ks(1,2) += tmp; ks(2,1) += tmp; // Shear terms ks(3,3) += five6*d11; ks(3,4) += five6*d12; ks(4,3) += five6*d21; ks(4,4) += five6*d22; // Torsion term ks(5,5) += z2*d11 - yz*(d12+d21) + y2*d22; // Bending-torsion coupling terms tmp = -z*d01 + y*d02; ks(0,5) += tmp; ks(1,5) -= y*tmp; ks(2,5) += z*tmp; tmp = -z*d10 + y*d20; ks(5,0) += tmp; ks(5,1) -= y*tmp; ks(5,2) += z*tmp; // Hit tangent terms with root56 d01 *= root56; d02 *= root56; d10 *= root56; d11 *= root56; d12 *= root56; d20 *= root56; d21 *= root56; d22 *= root56; // Bending-shear coupling terms ks(0,3) += d01; ks(0,4) += d02; ks(1,3) -= y*d01; ks(1,4) -= y*d02; ks(2,3) += z*d01; ks(2,4) += z*d02; ks(3,0) += d10; ks(4,0) += d20; ks(3,1) -= y*d10; ks(4,1) -= y*d20; ks(3,2) += z*d10; ks(4,2) += z*d20; // Torsion-shear coupling terms y2 = y*d22; z2 = -z*d11; ks(5,3) += z2 + y*d21; ks(5,4) += -z*d12 + y2; ks(3,5) += z2 + y*d12; ks(4,5) += -z*d21 + y2; } // Non-zero value since this is 2d section (so ks can be inverted) ks(2,2) = 1.0; return ks; }
void CExWRegularGridBP::msg(float* s1, float* s2, float* s3, float* s4, float* dst, int offset, float w, float trunc) { float val; ////added by dy //float * dst_old = new float[VALUES]; //for (int i=0;i<VALUES;i++) //{ // dst_old[i] = dst[i]; //} ////added by dy end // offset: dstOffset - srcOffset // aggregate and find min float minimum = INF; for(int value = 0; value <VALUES; value++){ dst[value] = INF; } for (int value = 0; value < VALUES; value++) { //message y->x: h(y) + |x-y+offset| //h(y), y = value, dstOffset + x = srcOffset + y float hVal = s1[value] + s2[value] + s3[value] + s4[value]; //Calculating minimum should be here! Corrected by Xiangli Kong. if (hVal < minimum) minimum = hVal; int xVal = min(VALUES-1, max(0,value - offset)); hVal += abs(xVal - (value-offset)); dst[xVal] = min(dst[xVal],hVal); //if (hVal < minimum) // minimum = hVal; } // dt Dt(dst,w); // truncate minimum += w * trunc; for (int value = 0; value < VALUES; value++) if (minimum < dst[value]) dst[value] = minimum; // normalize val = 0; for (int value = 0; value < VALUES; value++) val += dst[value]; val /= VALUES; for (int value = 0; value < VALUES; value++) dst[value] -= val; //added by dy //static FILE * fout=fopen("dst.txt","w+"); //for (int value = 0; value < VALUES; value++) // dst[value] = (dst[value]+ dst_old[value])*0.25; //if (dst[5]>0) // fprintf(fout,"%f\n ",dst[5]); ////fclose(fout); //delete [] dst_old;dst_old = NULL; ///*for (int value = 0; value < VALUES; value++) // dst_old[value] = dst[value];*/ ////added by dy end }