double Quad4FiberOverlay::computeCurrentStrain() { // determine the current strain given trial displacements at nodes u.Zero(); const Vector &disp1 = theNodes[0]->getTrialDisp(); const Vector &disp2 = theNodes[1]->getTrialDisp(); const Vector &disp3 = theNodes[2]->getTrialDisp(); const Vector &disp4 = theNodes[3]->getTrialDisp(); u[0] = disp1(0); u[1] = disp1(1); u[2] = disp2(0); u[3] = disp2(1); u[4] = disp3(0); u[5] = disp3(1); u[6] = disp4(0); u[7] = disp4(1); // Loop over the integration points strain = 0; for(int ip = 0; ip < 2; ip++) { //This llop calculates twice the strain, since it is adding the strain at two GP... this->getEltBb(pts[ip][0],pts[ip][1]); for (int i = 0; i < SL_NUM_DOF; i++) { strain += Bb(i)*u(i); } } strain = strain/2.0; //Since it was calculated twice. this function should be redeveloped return strain; }
int FourNodeQuad3d::update() { const Vector &disp1 = theNodes[0]->getTrialDisp(); const Vector &disp2 = theNodes[1]->getTrialDisp(); const Vector &disp3 = theNodes[2]->getTrialDisp(); const Vector &disp4 = theNodes[3]->getTrialDisp(); static double u[2][4]; u[0][0] = disp1(dirn[0]); u[1][0] = disp1(dirn[1]); u[0][1] = disp2(dirn[0]); u[1][1] = disp2(dirn[1]); u[0][2] = disp3(dirn[0]); u[1][2] = disp3(dirn[1]); u[0][3] = disp4(dirn[0]); u[1][3] = disp4(dirn[1]); static Vector eps(3); int ret = 0; // Loop over the integration points for (int i = 0; i < 4; i++) { // Determine Jacobian for this integration point this->shapeFunction(pts[i][0], pts[i][1]); // Interpolate strains //eps = B*u; //eps.addMatrixVector(0.0, B, u, 1.0); eps.Zero(); for (int beta = 0; beta < 4; beta++) { eps(0) += shp[0][beta]*u[0][beta]; eps(1) += shp[1][beta]*u[1][beta]; eps(2) += shp[0][beta]*u[1][beta] + shp[1][beta]*u[0][beta]; } // Set the material strain ret += theMaterial[i]->setTrialStrain(eps); } return ret; }
//! @brief Update the values of the state variables. int XC::FourNodeQuad::update(void) { const Vector &disp1 = theNodes[0]->getTrialDisp(); const Vector &disp2 = theNodes[1]->getTrialDisp(); const Vector &disp3 = theNodes[2]->getTrialDisp(); const Vector &disp4 = theNodes[3]->getTrialDisp(); static double u[2][4]; u[0][0] = disp1(0); u[1][0] = disp1(1); u[0][1] = disp2(0); u[1][1] = disp2(1); u[0][2] = disp3(0); u[1][2] = disp3(1); u[0][3] = disp4(0); u[1][3] = disp4(1); static XC::Vector eps(3); int ret = 0; // Loop over the integration points for(size_t i= 0;i<physicalProperties.size();i++) { //Determine Jacobian for this integration point const GaussPoint &gp= getGaussModel().getGaussPoints()[i]; this->shapeFunction(gp); // Interpolate strains //eps = B*u; //eps.addMatrixVector(0.0, B, u, 1.0); eps.Zero(); for(int beta= 0;beta<4;beta++) { eps(0)+= shp[0][beta]*u[0][beta]; eps(1)+= shp[1][beta]*u[1][beta]; eps(2)+= shp[0][beta]*u[1][beta] + shp[1][beta]*u[0][beta]; } // Set the material strain ret += physicalProperties[i]->setTrialStrain(eps); } return ret; }
void BeamColumnJoint3d::getGlobalDispls(Vector &dg) { // local variables that will be used in this method int converge = 0; int linesearch = 0; int totalCount = 0; int dtConverge = 0; int incCount = 0; int count = 0; int maxTotalCount = 1000; int maxCount = 20; double loadStep = 0.0; double dLoadStep = 1.0; double stepSize; Vector uExtOld(24); uExtOld.Zero(); Vector uExt(12); uExt.Zero(); Vector duExt(12); duExt.Zero(); Vector uIntOld(4); uIntOld.Zero(); Vector uInt(4); uInt.Zero(); Vector duInt(4); duInt.Zero(); Vector duIntTemp(4); duIntTemp.Zero(); Vector intEq(4); intEq.Zero(); Vector intEqLast(4); intEqLast.Zero(); Vector Uepr(24); Uepr.Zero(); Vector UeprInt(4); UeprInt.Zero(); Vector Ut(24); Ut.Zero(); Vector duExtTemp(24); duExtTemp.Zero(); Vector disp1 = nodePtr[0]->getTrialDisp(); Vector disp2 = nodePtr[1]->getTrialDisp(); Vector disp3 = nodePtr[2]->getTrialDisp(); Vector disp4 = nodePtr[3]->getTrialDisp(); for (int i = 0; i < 6; i++) { Ut(i) = disp1(i); Ut(i+6) = disp2(i); Ut(i+12) = disp3(i); Ut(i+18) = disp4(i); } Uepr = Uecommit; UeprInt = UeIntcommit; uExtOld = Uepr; duExtTemp = Ut - Uepr; duExt.addMatrixVector(0.0,Transf,duExtTemp,1.0); uExt.addMatrixVector(0.0,Transf,uExtOld,1.0); uIntOld = UeprInt; uInt = uIntOld; double tol = 1e-12; double tolIntEq = tol; double toluInt = (tol>tol*uInt.Norm())? tol:tol*uInt.Norm(); double tolIntEqdU = tol; double ctolIntEqdU = tol; double ctolIntEq = tol; double normDuInt = toluInt; double normIntEq = tolIntEq; double normIntEqdU = tolIntEqdU; Vector u(16); u.Zero(); double engrLast = 0.0; double engr = 0.0; Vector fSpring(13); fSpring.Zero(); Vector kSpring(13); kSpring.Zero(); Matrix dintEq_du(4,4); dintEq_du.Zero(); Matrix df_dDef(13,13); df_dDef.Zero(); Matrix tempintEq_du (4,13); tempintEq_du.Zero(); while ((loadStep < 1.0) && (totalCount < maxTotalCount)) { count = 0; converge = 0; dtConverge = 0; while ((!converge) && (count < maxCount)) { if (dLoadStep <= 1e-3) { dLoadStep = dLoadStep; } totalCount ++; count ++; for (int ic = 0; ic < 12; ic++ ) { u(ic) = uExt(ic) + duExt(ic); } u(12) = uInt(0); u(13) = uInt(1); u(14) = uInt(2); u(15) = uInt(3); getMatResponse(u,fSpring,kSpring); // performs internal equilibrium intEq(0) = -fSpring(2)-fSpring(3)+fSpring(9)-fSpring(12)/elemHeight; intEq(1) = fSpring(1)-fSpring(5)-fSpring(7)+fSpring(12)/elemWidth; intEq(2) = -fSpring(4)-fSpring(8)+fSpring(10)+fSpring(12)/elemHeight; intEq(3) = fSpring(0)-fSpring(6)-fSpring(11)-fSpring(12)/elemWidth; matDiag(kSpring, df_dDef); //////////////////////// dintEq_du = dg_df*df_dDef*dDef_du tempintEq_du.addMatrixProduct(0.0,dg_df,df_dDef,1.0); dintEq_du.addMatrixProduct(0.0,tempintEq_du,dDef_du,1.0); normIntEq = intEq.Norm(); normIntEqdU = 0.0; for (int jc = 0; jc<4 ; jc++) { normIntEqdU += intEq(jc)*duInt(jc); } normIntEqdU = fabs(normIntEqdU); if (totalCount == 1) { tolIntEq = (tol>tol*normIntEq) ? tol:tol*normIntEq; tolIntEqdU = tol; } else if (totalCount == 2) { tolIntEqdU = (tol>tol*normIntEqdU) ? tol:tol*normIntEqdU; } ctolIntEqdU = (tolIntEqdU*dLoadStep > tol) ? tolIntEqdU*dLoadStep:tol; ctolIntEq = (tolIntEq*dLoadStep > tol) ? tolIntEq*dLoadStep:tol; // check for convergence starts if ((normIntEq < tol) || ((normIntEqdU < tol) && (count >1)) || (normDuInt < toluInt) || (dLoadStep < 1e-3)) { if ((normIntEq > ctolIntEq) || (normIntEqdU > tolIntEqdU) || (normDuInt > toluInt)) { dtConverge = 1; } else { dtConverge = 0; } converge = 1; loadStep = loadStep + dLoadStep; if (fabs(1.0 - loadStep) < tol) { loadStep = 1.0; } } else { ////////////// duInt = -dintEq_du/intEq dintEq_du.Solve(intEq,duInt); duInt *= -1; normDuInt = duInt.Norm(); if (!linesearch) { uInt = uInt + duInt; } else { engrLast = 0.0; engr = 0.0; for (int jd = 0; jd<4 ; jd++) { engrLast += duInt(jd)*intEqLast(jd); engr += duInt(jd)*intEq(jd); } if (fabs(engr) > tol*engrLast) { duIntTemp = duInt; duIntTemp *= -1; // lineSearch algorithm requirement stepSize = getStepSize(engrLast,engr,uExt,duExt,uInt,duIntTemp,tol); if (fabs(stepSize) > 0.001) { uInt = uInt + stepSize*duInt; } else { uInt = uInt + duInt; } } else { uInt = uInt + duInt; } intEqLast = intEq; } } } if (!converge && loadStep < 1.0) { incCount = 0; maxCount = 25; if (!linesearch) { linesearch = 1; uInt = uIntOld; duInt.Zero(); } else { opserr << "WARNING : BeamColumnJoint::getGlobalDispls() - convergence problem in state determination" << endln; uInt = uIntOld; duInt.Zero(); duExt = duExt*0.1; dLoadStep = dLoadStep*0.1; } } else if (loadStep < 1.0) { maxCount = 10; incCount ++; normDuInt = toluInt; if ((incCount < maxCount) || dtConverge) { uExt = uExt + duExt; if (loadStep + dLoadStep > 1.0) { duExt = duExt*(1.0 - loadStep)/dLoadStep; dLoadStep = 1.0 - loadStep; incCount = 9; } } else { incCount = 0; uExt = uExt + duExt; dLoadStep = dLoadStep*10; if (loadStep + dLoadStep > 1.0) { uExt = uExt + duExt*(1.0 - loadStep)/dLoadStep; dLoadStep = 1.0 - loadStep; incCount = 9; } } } } // determination of stiffness matrix and the residual force vector for the element formR(fSpring); formK(kSpring); for (int ig = 0; ig < 25; ig++ ) { if (ig<24) { dg(ig) = Ut(ig); } } dg(24) = uInt(0); dg(25) = uInt(1); dg(26) = uInt(2); dg(27) = uInt(3); }
int FourNodeQuadUP::update() { const Vector &disp1 = nd1Ptr->getTrialDisp(); const Vector &disp2 = nd2Ptr->getTrialDisp(); const Vector &disp3 = nd3Ptr->getTrialDisp(); const Vector &disp4 = nd4Ptr->getTrialDisp(); static double u[2][4]; if (end1InitDisp == 0) { u[0][0] = disp1(0); u[1][0] = disp1(1); } else { u[0][0] = disp1(0) - end1InitDisp[0]; u[1][0] = disp1(1) - end1InitDisp[1]; } if (end2InitDisp == 0) { u[0][1] = disp2(0); u[1][1] = disp2(1); } else { u[0][1] = disp2(0) - end2InitDisp[0]; u[1][1] = disp2(1) - end2InitDisp[1]; } if (end3InitDisp == 0) { u[0][2] = disp3(0); u[1][2] = disp3(1); } else { u[0][2] = disp3(0) - end3InitDisp[0]; u[1][2] = disp3(1) - end3InitDisp[1]; } if (end3InitDisp == 0) { u[0][3] = disp4(0); u[1][3] = disp4(1); } else { u[0][3] = disp4(0) - end4InitDisp[0]; u[1][3] = disp4(1) - end4InitDisp[1];; } static Vector eps(3); int ret = 0; // Determine Jacobian for this integration point this->shapeFunction(); // Loop over the integration points for (int i = 0; i < 4; i++) { // Interpolate strains //eps = B*u; //eps.addMatrixVector(0.0, B, u, 1.0); eps.Zero(); for (int beta = 0; beta < 4; beta++) { eps(0) += shp[0][beta][i]*u[0][beta]; eps(1) += shp[1][beta][i]*u[1][beta]; eps(2) += shp[0][beta][i]*u[1][beta] + shp[1][beta][i]*u[0][beta]; } // Set the material strain ret += theMaterial[i]->setTrialStrain(eps); } return ret; }
void FourNodeQuadUP::setDomain(Domain *theDomain) { // Check Domain is not null - invoked when object removed from a domain if (theDomain == 0) { nd1Ptr = 0; nd2Ptr = 0; nd3Ptr = 0; nd4Ptr = 0; return; } int Nd1 = connectedExternalNodes(0); int Nd2 = connectedExternalNodes(1); int Nd3 = connectedExternalNodes(2); int Nd4 = connectedExternalNodes(3); nd1Ptr = theDomain->getNode(Nd1); nd2Ptr = theDomain->getNode(Nd2); nd3Ptr = theDomain->getNode(Nd3); nd4Ptr = theDomain->getNode(Nd4); if (nd1Ptr == 0 || nd2Ptr == 0 || nd3Ptr == 0 || nd4Ptr == 0) { //opserr << "FATAL ERROR FourNodeQuadUP (tag: %d), node not found in domain", // this->getTag()); return; } int dofNd1 = nd1Ptr->getNumberDOF(); int dofNd2 = nd2Ptr->getNumberDOF(); int dofNd3 = nd3Ptr->getNumberDOF(); int dofNd4 = nd4Ptr->getNumberDOF(); if (dofNd1 != 3 || dofNd2 != 3 || dofNd3 != 3 || dofNd4 != 3) { //opserr << "FATAL ERROR FourNodeQuadUP (tag: %d), has differing number of DOFs at its nodes", // this->getTag()); return; } this->DomainComponent::setDomain(theDomain); // Compute consistent nodal loads due to pressure this->setPressureLoadAtNodes(); const Vector &disp1 = nd1Ptr->getDisp(); if (disp1.Norm() != 0.0) { end1InitDisp = new double[2]; for (int i=0; i<2; i++) { end1InitDisp[0] = disp1(i); } } const Vector &disp2 = nd2Ptr->getDisp(); if (disp2.Norm() != 0.0) { end2InitDisp = new double[2]; for (int i=0; i<2; i++) { end2InitDisp[0] = disp2(i); } } const Vector &disp3 = nd3Ptr->getDisp(); if (disp3.Norm() != 0.0) { end3InitDisp = new double[2]; for (int i=0; i<2; i++) { end3InitDisp[0] = disp3(i); } } const Vector &disp4 = nd4Ptr->getDisp(); if (disp4.Norm() != 0.0) { end4InitDisp = new double[2]; for (int i=0; i<2; i++) { end4InitDisp[0] = disp4(i); } } }