/////////////////////////////////////////////////////////////////////// // Class : CObject // Method : makeBound // Description : /// \brief Make sure we do not have empty bounding box // Return Value : // Comments : void CObject::makeBound(float *bmin,float *bmax) const { vector D; float maxD; float maxDisp = attributes->maxDisplacement; subvv(D,bmax,bmin); maxD = D[0]; maxD = max(D[1],maxD); maxD = max(D[2],maxD); maxD *= attributes->bexpand; // Add the displacement amount of the surface if (attributes->maxDisplacementSpace != NULL) { const float *from,*to; ECoordinateSystem sys; if (CRenderer::findCoordinateSystem(attributes->maxDisplacementSpace,from,to,sys)) { maxDisp = attributes->maxDisplacement * getDisp(from,attributes->maxDisplacement); } free(attributes->maxDisplacementSpace); attributes->maxDisplacementSpace = NULL; } maxD += maxDisp; // Expand the bound accordingly subvf(bmin,maxD); addvf(bmax,maxD); }
void printInstruction(const INSTRUCTION * const i) { DISASSEMBLY d; FlushDecoded(&d); d.Address = (DWORD)(i->data); DWORD ilen = 0; Decode(&d, (char *)(i->data), &ilen); printf("[%2d] ", i->index); printDisassembly(d); printf("size:\t\t%d\n", i->totalSize); if (i->regReads) { printf("reads:\t\t"); for (BYTE reg = 0; reg < 8; reg++) { if (GET_READS(i, reg)) printf ("%s ", REG[2][reg]); } printf("\n"); } if (i->regWrites) { printf("writes:\t\t"); for (BYTE reg = 0; reg < 8; reg++) { if (GET_WRITES(i, reg)) printf ("%s ", REG[2][reg]); } printf("\n"); } if (i->freeRegs) { printf("free:\t\t"); for (BYTE reg = 0; reg < 8; reg++) { if (IS_FREE_REG(i,reg)) printf ("%s ", REG[2][reg]); } printf("\n"); } if (i->flags) printf("flags:\t\t0x%08X\n", i->flags); printf("offsets:\tOPCODE:%d, MODRM:%d, SIB:%d, DISP:%d:0x%08X, IMM:%d:0x%08X\n", OFFSET_TO_OPCODE(i), OFFSET_TO_MODRM(i), OFFSET_TO_SIB(i), OFFSET_TO_DISP(i), getDisp(i), OFFSET_TO_IMM(i), getImm(i)); if (i->jmp) printf("jumps to:\t%d\n", i->jmp->index); if (i->directVA) printf("refers to:\t0x%08X\n", *((DWORD *)(i->data + i->directVA))); }
// compute C8 sensitivities at all gauss points void CHak3DCont_8::shpSens(int numDual, int numCase, double **disp_prim, double **disp_dual, double *wgt_fact, double *wgt_case, double *gSens, int pNum, double *Nf, double alpha) { int i,j,p,l,d,ind; double const_fact, ftemp; Coord3D np[8], gp; double B[144]; // Strain displacement matrix double Ba[54]; // Strain displacement matrix for internal dof double ud[24]; // Primary element displacement array double dd[24]; // Dual element displacement array double stn[6]; // strain tensor double strs[6]; // stress tensor double sens; // variable to keep running total of a sensitivity value double /*ux[8], uy[8],*/ uz[8]; double /*px[8], py[8],*/ pz[8]; double sw_fact; // get element nodal coords getNcrd(np); // compute material property matrix double *Em = Mat->getD(); // for each gauss point for(p=0;p<8;p++) { gp.x = gauss2 * c8_pos[p].x; gp.y = gauss2 * c8_pos[p].y; gp.z = gauss2 * c8_pos[p].z; // non-dim gauss point coords // compute isoparametric B matrix (6 x 24) & Ba (6 x 9) C8_isoBMat(gp, np, B); // NB: gp should be in non-dim coordinates (i.e center = 0,0,0) C8M_isoBMat(gp, np, Ba); // for each load case for(l=0;l<numCase;l++) { // compute the constant sensitivty factor for the element const_fact = wgt_fact[l] * Mat->getDens(); // DO NOT multiply by the volume ratio // get the primary element displacements getDisp(ud, disp_prim[l]); for(i=0;i<8;i++) { j=i*3; //ux[i] = ud[j]; //uy[i] = ud[j+1]; uz[i] = ud[j+2]; } // compute self weight factor fg * u ftemp = Mat->getDens() * Nf[l] * -9.81 * alpha; // mass times acceleration (in +ve z direction) sw_fact = ftemp * C8_interpolate(gp,uz); //( C8_interpolate(gp,ux) + C8_interpolate(gp,uy) + C8_interpolate(gp,uz) );; // compute stress tensor Ee(u) = strs // multiply: strain = B x u cblas_dgemv(CblasRowMajor, CblasNoTrans, 6, 24, 1.0, B, 24, ud, 1, 0.0, stn, 1); // Finally multiply: stress = material matrix x strain cblas_dgemv(CblasRowMajor, CblasNoTrans, 6, 6, 1.0, Em, 6, stn, 1, 0.0, strs, 1); // for each dual response p for(d=0;d<numDual;d++) { // add the 3 componnents (multipled by the load case weight) // Ee(u)e(p) - fg(u+p) - const_fact // get the dual element displacements getDisp(dd, disp_dual[index2(l,d,numDual)]); // compute dual strain tensor e(p) = stn // multiply: strain = B x u cblas_dgemv(CblasRowMajor, CblasNoTrans, 6, 24, 1.0, B, 24, dd, 1, 0.0, stn, 1); // compute stress(u) x strain(p) sens = 0.0; // reset to zero for(i=0;i<6;i++) { sens += strs[i]*stn[i]; } sens *= alpha ; // need to multiply by the volume ratio (account for modified modulus) // interpolate, then multiply // need to extract u, v, w disp and forces in seperate vectors for(i=0;i<8;i++) { j=i*3; //px[i] = dd[j]; //py[i] = dd[j+1]; pz[i] = dd[j+2]; } // now interpolate and add to sens sens -= sw_fact; sens -= ftemp * C8_interpolate(gp,pz); //( C8_interpolate(gp,px) + C8_interpolate(gp,py) + C8_interpolate(gp,pz) ); sens -= const_fact; sens *= wgt_case[l]; // multiply by load case weight // add to overall sensitivity ind=pNum+p; gSens[index2(ind,d,numDual)] += sens; // add value for this load case } } } }
// compute C8 sensitivities at all gauss points, for eigenvalue problems void CHak3DCont_8::shpSens_Eig(int numDual, int numEig, double **disp_prim, double **disp_dual, double *eig, double *wgt_case, double *gSens, int pNum, double alpha) { int i,j,p,l,d,ind; double ftemp; Coord3D np[8], gp; double B[144]; // Strain displacement matrix double ud[24]; // Primary element displacement array double dd[24]; // Dual element displacement array double stn[6]; // strain tensor double strs[6]; // stress tensor double sens; // variable to keep running total of a sensitivity value double ux[8], uy[8], uz[8]; double px[8], py[8], pz[8]; double ug[3]; // get element nodal coords getNcrd(np); // get material property matrix double *Em = Mat->getD(); double rho = Mat->getDens(); // for each gauss point for(p=0;p<8;p++) { gp.x = gauss2 * c8_pos[p].x; gp.y = gauss2 * c8_pos[p].y; gp.z = gauss2 * c8_pos[p].z; // non-dim gauss point coords // compute isoparametric B matrix (6 x 24) & Ba (6 x 9) C8_isoBMat(gp, np, B); // NB: gp should be in non-dim coordinates (i.e center = 0,0,0) // for each eigenvalue for(l=0;l<numEig;l++) { // get the primary element displacements getDisp(ud, disp_prim[l]); for(i=0;i<8;i++) { j=i*3; ux[i] = ud[j]; uy[i] = ud[j+1]; uz[i] = ud[j+2]; } ug[0] = C8_interpolate(gp,ux); // x disp at Gauss point ug[1] = C8_interpolate(gp,uy); // x disp at Gauss point ug[2] = C8_interpolate(gp,uz); // x disp at Gauss point // compute stress tensor Ee(u) = strs // multiply: strain = B x u cblas_dgemv(CblasRowMajor, CblasNoTrans, 6, 24, 1.0, B, 24, ud, 1, 0.0, stn, 1); // Finally multiply: stress = material matrix x strain cblas_dgemv(CblasRowMajor, CblasNoTrans, 6, 6, 1.0, Em, 6, stn, 1, 0.0, strs, 1); // for each dual response p for(d=0;d<numDual;d++) { // add the 3 componnents (multipled by the load case weight) // Ee(u)e(p) - fg(u+p) - const_fact // get the dual element displacements getDisp(dd, disp_dual[index2(l,d,numDual)]); // compute dual strain tensor e(p) = stn // multiply: strain = B x u cblas_dgemv(CblasRowMajor, CblasNoTrans, 6, 24, 1.0, B, 24, dd, 1, 0.0, stn, 1); // compute stress(u) x strain(p) sens = 0.0; // reset to zero for(i=0;i<6;i++) { sens += strs[i]*stn[i]; } sens *= alpha ; // need to multiply by the volume ratio (account for modified modulus) // interpolate, then multiply // need to extract u, v, w disp and forces in seperate vectors for(i=0;i<8;i++) { j=i*3; px[i] = dd[j]; py[i] = dd[j+1]; pz[i] = dd[j+2]; } // now interpolate and add to sens ftemp = ug[0]*C8_interpolate(gp,px) + ug[1]*C8_interpolate(gp,py) + ug[2]*C8_interpolate(gp,pz); sens -= eig[l]*ftemp*rho*alpha; // add to overall sensitivity ind=pNum+p; gSens[index2(ind,d,numDual)] += sens*wgt_case[l]; // add value for this load case } } } }