void XC::Twenty_Node_Brick::formInertiaTerms( int tangFlag ) const { static double xsj ; // determinant jacaobian matrix int i, j, k, m; double Nrho; //zero mass mass.Zero( ) ; //compute basis vectors and local nodal coordinates computeBasis( ) ; //gauss loop to compute and save shape functions for( i = 0; i < nintu; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 0); //volume element to also be saved dvolu[i] = wu[i] * xsj ; } // end for i // Compute consistent mass matrix for(i = 0; i < nenu; i++) { for(j = 0; j < nenu; j++) { for(m = 0; m < nintu; m++) { Nrho = dvolu[m]*mixtureRho(m)*shgu[3][i][m]*shgu[3][j][m]; for( k = 0; k < 3; k++) { mass(i*3+k,j*3+k) += Nrho; } } } } }
// compute stiffness matrix const XC::Matrix& XC::Twenty_Node_Brick::getStiff(int flag) const { if(flag != 0 && flag != 1) { std::cerr << "FATAL XC::Twenty_Node_Brick::getStiff() - illegal use\n"; exit(-1); } if(flag == 0 && Ki != 0) return *Ki; int i, j ; static double xsj ; // determinant jacaobian matrix double volume = 0.; //------------------------------------------------------- int j3, j3m1, j3m2; static XC::Matrix B(6,nenu*3); static XC::Matrix BTDB(nenu*3,nenu*3); static XC::Matrix D(6, 6); B.Zero(); BTDB.Zero(); stiff.Zero(); // FILE *fp; // fp = fopen("stiff.dat","w"); //compute basis vectors and local nodal coordinates computeBasis( ) ; for( i = 0; i < nintu; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 0); //volume element to also be saved dvolu[i] = wu[i] * xsj ; volume += dvolu[i]; } // end for i //printf("volume = %f\n", volume); // for( i = 0; i < nintu; i++ ) { // for(int j = 0; j < nenu; j++ ) { // printf("%5d %5d %15.6e %15.6e %15.6e %15.6e\n", i,j, // shgu[0][j][i], shgu[1][j][i], shgu[2][j][i], shgu[3][j][i]); // } // } // exit(-1); // Loop over the integration points for(i = 0; i < nintu; i++) { // Get the material tangent if( flag == 0 ) D = physicalProperties[i]->getInitialTangent(); else D = physicalProperties[i]->getTangent(); //const Matrix &D = physicalProperties[i]->getTangent(); for(j=0; j<nenu; j++) { j3 = 3*j+2; j3m1 = j3 - 1; j3m2 = j3 - 2; B(0,j3m2) = shgu[0][j][i]; B(0,j3m1) = 0.; B(0,j3 ) = 0.; B(1,j3m2) = 0.; B(1,j3m1) = shgu[1][j][i]; B(1,j3 ) = 0.; B(2,j3m2) = 0.; B(2,j3m1) = 0.; B(2,j3 ) = shgu[2][j][i]; B(3,j3m2) = shgu[1][j][i]; B(3,j3m1) = shgu[0][j][i]; B(3,j3 ) = 0.; B(4,j3m2) = 0.; B(4,j3m1) = shgu[2][j][i]; B(4,j3 ) = shgu[1][j][i]; B(5,j3m2) = shgu[2][j][i]; B(5,j3m1) = 0.; B(5,j3 ) = shgu[0][j][i]; } // Perform numerical integration //K = K + (B^ D * B) * intWt(i) * detJ; BTDB.addMatrixTripleProduct(1.0, B, D, dvolu[i]); } for( i = 0; i < 60; i++) for( j = 0; j < 60; j++) stiff(i,j) = BTDB(i,j); if( flag == 1) { return stiff; } Ki = new Matrix(stiff); if(Ki == 0) { std::cerr << "FATAL XC::Twenty_Node_Brick::getStiff() -"; std::cerr << "ran out of memory\n"; exit(-1); } return *Ki; }
//get residual const XC::Vector &XC::Twenty_Node_Brick::getResistingForce(void) const { int i, j, k, k1; double xsj; static XC::Matrix B(6, 3); double volume = 0.; // printf("calling getResistingForce()\n"); resid.Zero(); //compute basis vectors and local nodal coordinates computeBasis( ) ; //gauss loop to compute and save shape functions for( i = 0; i < nintu; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 0); //volume element to also be saved dvolu[i] = wu[i] * xsj ; volume += dvolu[i]; } // end for i //printf("volume = %f\n", volume); // Loop over the integration points for(i = 0; i < nintu; i++) { // Get material stress response const XC::Vector &sigma = physicalProperties[i]->getStress(); // Perform numerical integration on internal force //P = P + (B^ sigma) * intWt(i)*intWt(j) * detJ; //P.addMatrixTransposeVector(1.0, B, sigma, intWt(i)*intWt(j)*detJ); for(j = 0; j < nenu; j++) { B(0,0) = shgu[0][j][i]; B(0,1) = 0.; B(0,2) = 0.; B(1,0) = 0.; B(1,1) = shgu[1][j][i]; B(1,2) = 0.; B(2,0) = 0.; B(2,1) = 0.; B(2,2) = shgu[2][j][i]; B(3,0) = shgu[1][j][i]; B(3,1) = shgu[0][j][i]; B(3,2) = 0.; B(4,0) = 0.; B(4,1) = shgu[2][j][i]; B(4,2) = shgu[1][j][i]; B(5,0) = shgu[2][j][i]; B(5,1) = 0.; B(5,2) = shgu[0][j][i]; for(k = 0; k < 3; k++) { for(k1 = 0; k1 < 6; k1++) resid(j*3+k) += dvolu[i]*(B(k1,k)*sigma(k1)); } // Subtract equiv. body forces from the nodes //P = P - (N^ b) * intWt(i)*intWt(j) * detJ; //P.addMatrixTransposeVector(1.0, N, b, -intWt(i)*intWt(j)*detJ); double r = mixtureRho(i); resid(j*3) -= dvolu[i]*(shgu[3][j][i]*r*bf[0]); resid(j*3+1) -= dvolu[i]*(shgu[3][j][i]*r*bf[1]); resid(j*3+2) -= dvolu[i]*(shgu[3][j][i]*r*bf[2]); } } // Subtract other external nodal loads ... P_res = P_int - P_ext // std::cerr<<"resid before:"<<resid<<std::endl; if(!load.isEmpty()) resid-= load; // std::cerr<<"resid "<<resid<<std::endl; if(isDead()) resid*=dead_srf; return resid ; }
int XC::Twenty_Node_Brick::update() { int i, j; static double u[3][20]; static double xsj; static XC::Matrix B(6, 3); double volume = 0.; for(i = 0; i < nenu; i++) { const XC::Vector &disp = theNodes[i]->getTrialDisp(); u[0][i] = disp(0); u[1][i] = disp(1); u[2][i] = disp(2); } static XC::Vector eps(6); int ret = 0; //compute basis vectors and local nodal coordinates computeBasis( ) ; for( i = 0; i < nintu; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 0); //volume element to also be saved dvolu[i] = wu[i] * xsj ; volume += dvolu[i]; } // end for i //printf("volume = %f\n", volume); // Loop over the integration points for(i = 0; i < nintu; i++) { // Interpolate strains //eps = B*u; //eps.addMatrixVector(0.0, B, u, 1.0); eps.Zero(); for( j = 0; j < nenu; j++) { B(0,0) = shgu[0][j][i]; B(0,1) = 0.; B(0,2) = 0.; B(1,0) = 0.; B(1,1) = shgu[1][j][i]; B(1,2) = 0.; B(2,0) = 0.; B(2,1) = 0.; B(2,2) = shgu[2][j][i]; B(3,0) = shgu[1][j][i]; B(3,1) = shgu[0][j][i]; B(3,2) = 0.; B(4,0) = 0.; B(4,1) = shgu[2][j][i]; B(4,2) = shgu[1][j][i]; B(5,0) = shgu[2][j][i]; B(5,1) = 0.; B(5,2) = shgu[0][j][i]; //BJ = computeB( j, shp ) ; //nodal displacements const XC::Vector &ul = theNodes[j]->getTrialDisp( ) ; Vector ul3(3); ul3(0) = ul(0); ul3(1) = ul(1); ul3(2) = ul(2); //compute the strain //strain += (BJ*ul) ; eps.addMatrixVector(1.0,B,ul3,1.0 ) ; /* for( k = 0; k < 6; k++) { for( k1 = 0; k1 < 3; k1++) { eps[k] += BJ(k, k1)*u[k1][j]; } } */ } // Set the material strain ret += physicalProperties[i]->setTrialStrain(eps); } return ret; }
const Matrix& TwentyEightNodeBrickUP::getStiff( int flag ) { if (flag != 0 && flag != 1) { opserr << "FATAL TwentyEightNodeBrickUP::getStiff() - illegal use\n"; exit(-1); } if (flag == 0 && Ki != 0) return *Ki; int i, j ; static double xsj ; // determinant jacaobian matrix double volume = 0.; //------------------------------------------------------- int j3, j3m1, j3m2, ik, ib, jk, jb; static Matrix B(6,nenu*3); static Matrix BTDB(nenu*3,nenu*3); static Matrix D(6, 6); B.Zero(); BTDB.Zero(); stiff.Zero(); //compute basis vectors and local nodal coordinates computeBasis( ) ; for( i = 0; i < nintu; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 0); //volume element to also be saved dvolu[i] = wu[i] * xsj ; volume += dvolu[i]; } // end for i //printf("volume = %f\n", volume); // for( i = 0; i < nintu; i++ ) { // for(int j = 0; j < nenu; j++ ) { // printf("%5d %5d %15.6e %15.6e %15.6e %15.6e\n", i,j, // shgu[0][j][i], shgu[1][j][i], shgu[2][j][i], shgu[3][j][i]); // } // } // exit(-1); // Loop over the integration points for (i = 0; i < nintu; i++) { // Get the material tangent if( flag == 0 ) D = materialPointers[i]->getInitialTangent(); else D = materialPointers[i]->getTangent(); //const Matrix &D = materialPointers[i]->getTangent(); for (j=0; j<nenu; j++) { j3 = 3*j+2; j3m1 = j3 - 1; j3m2 = j3 - 2; B(0,j3m2) = shgu[0][j][i]; B(0,j3m1) = 0.; B(0,j3 ) = 0.; B(1,j3m2) = 0.; B(1,j3m1) = shgu[1][j][i]; B(1,j3 ) = 0.; B(2,j3m2) = 0.; B(2,j3m1) = 0.; B(2,j3 ) = shgu[2][j][i]; B(3,j3m2) = shgu[1][j][i]; B(3,j3m1) = shgu[0][j][i]; B(3,j3 ) = 0.; B(4,j3m2) = 0.; B(4,j3m1) = shgu[2][j][i]; B(4,j3 ) = shgu[1][j][i]; B(5,j3m2) = shgu[2][j][i]; B(5,j3m1) = 0.; B(5,j3 ) = shgu[0][j][i]; } // Perform numerical integration //K = K + (B^ D * B) * intWt(i) * detJ; BTDB.addMatrixTripleProduct(1.0, B, D, dvolu[i]); } for (i = 0; i < nenu; i++) { if (i<nenp) ik = i*4; else ik = nenp*4 + (i-nenp)*3; ib = i*3; for (j = 0; j < nenu; j++) { if (j<nenp) jk = j*4; else jk = nenp*4 + (j-nenp)*3; jb = j*3; for( int i1 = 0; i1 < 3; i1++) for(int j1 = 0; j1 < 3; j1++) { stiff(ik+i1, jk+j1) = BTDB(ib+i1,jb+j1); } } } if( flag == 1) { return stiff; } Ki = new Matrix(stiff); if (Ki == 0) { opserr << "FATAL TwentyEightNodeBrickUP::getStiff() -"; opserr << "ran out of memory\n"; exit(-1); } return *Ki; }
void TwentyEightNodeBrickUP::formInertiaTerms( int tangFlag ) { static double xsj ; // determinant jacaobian matrix int i, j, k, ik, m, jk; double Nrho; //zero mass mass.Zero( ) ; //compute basis vectors and local nodal coordinates computeBasis( ) ; //gauss loop to compute and save shape functions for( i = 0; i < nintu; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 0); //volume element to also be saved dvolu[i] = wu[i] * xsj ; } // end for i for( i = 0; i < nintp; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 1); //volume element to also be saved dvolp[i] = wp[i] * xsj ; } // end for i // Compute consistent mass matrix for (i = 0; i < nenu; i++) { if (i<nenp) ik = i*4; else ik = nenp*4 + (i-nenp)*3; for (j = 0; j < nenu; j++) { if (j<nenp) jk = j*4; else jk = nenp*4 + (j-nenp)*3; for (m = 0; m < nintu; m++) { Nrho = dvolu[m]*mixtureRho(m)*shgu[3][i][m]*shgu[3][j][m]; for( k = 0; k < 3; k++) { mass(ik+k,jk+k) += Nrho; } } } } // Compute compressibility matrix double oneOverKc = 1./kc; for (i = 0; i < nenp; i++) { ik = i*4+3; for (j = 0; j < nenp; j++) { jk = j*4+3; for (m = 0; m < nintp; m++) { mass(ik,jk) += -dvolp[m]*oneOverKc*shgp[3][i][m]*shgp[3][j][m]; } } } }
const Vector& TwentyEightNodeBrickUP::getResistingForce( ) { int i, j, jk, k, k1; double xsj; static Matrix B(6, 3); double volume = 0.; // printf("calling getResistingForce()\n"); resid.Zero(); //compute basis vectors and local nodal coordinates computeBasis( ) ; //gauss loop to compute and save shape functions for( i = 0; i < nintu; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 0); //volume element to also be saved dvolu[i] = wu[i] * xsj ; volume += dvolu[i]; } // end for i //printf("volume = %f\n", volume); volume = 0.; for( i = 0; i < nintp; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 1); //volume element to also be saved dvolp[i] = wp[i] * xsj ; volume += dvolp[i]; } // end for i //printf("volume = %f\n", volume); // Loop over the integration points for (i = 0; i < nintu; i++) { // Get material stress response const Vector &sigma = materialPointers[i]->getStress(); // Perform numerical integration on internal force //P = P + (B^ sigma) * intWt(i)*intWt(j) * detJ; //P.addMatrixTransposeVector(1.0, B, sigma, intWt(i)*intWt(j)*detJ); for (j = 0; j < nenu; j++) { if (j<nenp) jk = j*4; else jk = nenp*4 + (j-nenp)*3; B(0,0) = shgu[0][j][i]; B(0,1) = 0.; B(0,2) = 0.; B(1,0) = 0.; B(1,1) = shgu[1][j][i]; B(1,2) = 0.; B(2,0) = 0.; B(2,1) = 0.; B(2,2) = shgu[2][j][i]; B(3,0) = shgu[1][j][i]; B(3,1) = shgu[0][j][i]; B(3,2) = 0.; B(4,0) = 0.; B(4,1) = shgu[2][j][i]; B(4,2) = shgu[1][j][i]; B(5,0) = shgu[2][j][i]; B(5,1) = 0.; B(5,2) = shgu[0][j][i]; for(k = 0; k < 3; k++) { for(k1 = 0; k1 < 6; k1++) resid(jk+k) += dvolu[i]*(B(k1,k)*sigma(k1)); } // Subtract equiv. body forces from the nodes //P = P - (N^ b) * intWt(i)*intWt(j) * detJ; //P.addMatrixTransposeVector(1.0, N, b, -intWt(i)*intWt(j)*detJ); double r = mixtureRho(i); if (applyLoad == 0) { resid(jk) -= dvolu[i]*(shgu[3][j][i]*r*b[0]); resid(jk+1) -= dvolu[i]*(shgu[3][j][i]*r*b[1]); resid(jk+2) -= dvolu[i]*(shgu[3][j][i]*r*b[2]); } else { resid(jk) -= dvolu[i]*(shgu[3][j][i]*r*appliedB[0]); resid(jk+1) -= dvolu[i]*(shgu[3][j][i]*r*appliedB[1]); resid(jk+2) -= dvolu[i]*(shgu[3][j][i]*r*appliedB[2]); } } } // Subtract fluid body force for (j = 0; j < nenp; j++) { jk = j*4+3; for (i = 0; i < nintp; i++) { if (applyLoad == 0) { resid(jk) += dvolp[i]*rho*(perm[0]*b[0]*shgp[0][j][i] + perm[1]*b[1]*shgp[1][j][i] + perm[2]*b[2]*shgp[2][j][i]); } else { resid(jk) += dvolp[i]*rho*(perm[0]*appliedB[0]*shgp[0][j][i] + perm[1]*appliedB[1]*shgp[1][j][i] + perm[2]*appliedB[2]*shgp[2][j][i]); } } } // Subtract other external nodal loads ... P_res = P_int - P_ext // opserr<<"resid before:"<<resid<<endln; if (load != 0) resid -= *load; // opserr<<"resid "<<resid<<endln; return resid ; }
void TwentyEightNodeBrickUP::formDampingTerms( int tangFlag ) { static double xsj ; // determinant jacaobian matrix int i, j, k, m, ik, jk; double volume = 0.; //zero damp damp.Zero( ) ; if (betaK != 0.0) damp.addMatrix(1.0, this->getTangentStiff(), betaK); if (betaK0 != 0.0) damp.addMatrix(1.0, this->getInitialStiff(), betaK0); if (betaKc != 0.0) damp.addMatrix(1.0, *Kc, betaKc); if (alphaM != 0.0) { this->getMass(); for( i = 0; i < nenu; i++ ) { if( i < nenp) ik = i*4; else ik = nenp*4 + (i - nenp) * 3; for( j = 0; j < nenu; j++) { if( j < nenp) jk = j * 4; else jk = nenp * 4 + (j-nenp) * 3; for( k = 0; k < 3; k++) damp(ik + k, jk + k) += mass(ik + k, jk + k) * alphaM; } } } //compute basis vectors and local nodal coordinates computeBasis( ) ; //gauss loop to compute and save shape functions for( i = 0; i < nintp; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 1); //volume element to also be saved dvolp[i] = wp[i] * xsj ; volume += dvolp[i]; } // end for i //printf("volume = %f\n", volume); volume = 0.; for( i = 0; i < nintp; i++ ) { // compute Jacobian and global shape functions Jacobian3d(i, xsj, 2); //volume element to also be saved dvolq[i] = wp[i] * xsj ; volume += dvolq[i]; } // end for i //printf("volume = %f\n", volume); // Compute coupling matrix for( i = 0; i < nenu; i++ ) { if( i < nenp) ik = i * 4; else ik = nenp * 4 + (i-nenp)*3; for( j = 0; j < nenp; j++) { jk = j * 4 + 3; for( m = 0; m < nintp; m++) { for( k = 0; k < 3; k++) { damp(ik+k,jk) += -dvolq[m]*shgq[k][i][m]*shgp[3][j][m]; } } for( k = 0; k < 3; k++ ) { damp(jk, ik+k) = damp(ik+k, jk); } } } // Compute permeability matrix for( i = 0; i < nenp; i++ ) { ik = i*4 + 3; for( j = 0; j < nenp; j++ ) { jk = j * 4 + 3; for( m = 0; m < nintp; m++ ) { damp(ik,jk) += - dvolp[m]*(perm[0]*shgp[0][i][m]*shgp[0][j][m] + perm[1]*shgp[1][i][m]*shgp[1][j][m]+ perm[2]*shgp[2][i][m]*shgp[2][j][m]); } } } }