mObject nodesDispToJSON(void) { NodeIter &theNodes = theDomain.getNodes(); Node *theNode; const Vector *nodalResponse; int size; int i; mObject disp_field, result; mArray nodal_disps; mValue tag, disp; char tag_str[15]; // TODO: The field 'time' shouldn't be here, but old SketchIT depends on it, for compatibilty. mValue ctime = theDomain.getCurrentTime(); result["time"] = ctime; disp_field.clear(); while ((theNode = theNodes()) != 0) { nodalResponse = theNode->getResponse(Disp); size = nodalResponse->Size(); nodal_disps.clear(); for (i = 0; i < size; i++) { disp = (*nodalResponse)(i); nodal_disps.push_back(disp); } tag = theNode->getTag(); sprintf(tag_str, "%d", tag.get_int()); disp_field[tag_str] = nodal_disps; } result["disp"] = disp_field; return result; };
const Vector& Adapter::getResistingForce() { // get current time Domain *theDomain = this->getDomain(); double t = theDomain->getCurrentTime(); // update response if time has advanced if (t > tPast) { // receive data theChannel->recvVector(0, 0, *recvData, 0); // check if force request was received if (rData[0] == RemoteTest_getForce) { // send daq displacements and forces theChannel->sendVector(0, 0, *sendData, 0); // receive new trial response theChannel->recvVector(0, 0, *recvData, 0); } if (rData[0] != RemoteTest_setTrialResponse) { if (rData[0] == RemoteTest_DIE) { opserr << "\nThe Simulation has successfully completed.\n"; } else { opserr << "Adapter::getResistingForce() - " << "wrong action received: expecting 3 but got " << rData[0] << endln; } exit(-1); } // save current time tPast = t; } // get resisting force in basic system q = k*db + q0 = k*(db - db0) q.addMatrixVector(0.0, kb, (db - *ctrlDisp), 1.0); //q = kb*(db - *ctrlDisp); // assign daq values for feedback *daqDisp = db; *daqForce = -1.0*q; // zero the residual theVector.Zero(); // determine resisting forces in global system theVector.Assemble(q, basicDOF); return theVector; }
int EETruss::update() { int rValue = 0; // get current time Domain *theDomain = this->getDomain(); (*t)(0) = theDomain->getCurrentTime(); // determine dsp, vel and acc in basic system const Vector &disp1 = theNodes[0]->getTrialDisp(); const Vector &disp2 = theNodes[1]->getTrialDisp(); const Vector &vel1 = theNodes[0]->getTrialVel(); const Vector &vel2 = theNodes[1]->getTrialVel(); const Vector &accel1 = theNodes[0]->getTrialAccel(); const Vector &accel2 = theNodes[1]->getTrialAccel(); const Vector &dispIncr1 = theNodes[0]->getIncrDeltaDisp(); const Vector &dispIncr2 = theNodes[1]->getIncrDeltaDisp(); (*db)(0) = (*vb)(0) = (*ab)(0) = 0.0; double dbDelta = 0.0; for (int i=0; i<numDIM; i++) { (*db)(0) += (disp2(i)-disp1(i))*cosX[i]; (*vb)(0) += (vel2(i)-vel1(i))*cosX[i]; (*ab)(0) += (accel2(i)-accel1(i))*cosX[i]; dbDelta += (dispIncr2(i)-dispIncr1(i))*cosX[i]; } // do not check time for right now because of transformation constraint // handler calling update at beginning of new step when applying load // if (fabs(dbDelta) > DBL_EPSILON || (*t)(0) > tLast) { if (fabs(dbDelta) > DBL_EPSILON) { // set the trial response at the site if (theSite != 0) { theSite->setTrialResponse(db, vb, ab, (Vector*)0, t); } else { sData[0] = OF_RemoteTest_setTrialResponse; rValue += theChannel->sendVector(0, 0, *sendData, 0); } } // save the last time tLast = (*t)(0); return rValue; }
int GenericClient::update() { int rValue = 0; if (theChannel == 0) { if (this->setupConnection() != 0) { opserr << "GenericClient::update() - " << "failed to setup connection\n"; return -1; } } // get current time Domain *theDomain = this->getDomain(); (*t)(0) = theDomain->getCurrentTime(); // assemble response vectors int ndim = 0, i; db->Zero(); vb->Zero(); ab->Zero(); for (i=0; i<numExternalNodes; i++) { Vector disp = theNodes[i]->getTrialDisp(); Vector vel = theNodes[i]->getTrialVel(); Vector accel = theNodes[i]->getTrialAccel(); db->Assemble(disp(theDOF[i]), ndim); vb->Assemble(vel(theDOF[i]), ndim); ab->Assemble(accel(theDOF[i]), ndim); ndim += theDOF[i].Size(); } // set trial response at remote element sData[0] = RemoteTest_setTrialResponse; rValue += theChannel->sendVector(0, 0, *sendData, 0); return rValue; }
int EETrussCorot::update() { int rValue = 0; // get current time Domain *theDomain = this->getDomain(); (*t)(0) = theDomain->getCurrentTime(); // determine dsp, vel and acc in basic system const Vector &disp1 = theNodes[0]->getTrialDisp(); const Vector &disp2 = theNodes[1]->getTrialDisp(); const Vector &vel1 = theNodes[0]->getTrialVel(); const Vector &vel2 = theNodes[1]->getTrialVel(); const Vector &accel1 = theNodes[0]->getTrialAccel(); const Vector &accel2 = theNodes[1]->getTrialAccel(); const Vector &dispIncr1 = theNodes[0]->getIncrDeltaDisp(); const Vector &dispIncr2 = theNodes[1]->getIncrDeltaDisp(); // initial offsets double d21Last[3]; d21[0] = L; d21[1] = d21[2] = 0.0; v21[0] = v21[1] = v21[2] = 0.0; a21[0] = a21[1] = a21[2] = 0.0; d21Last[0] = L; d21Last[1] = d21Last[2] = 0.0; // update offsets in basic system for (int i=0; i<numDIM; i++) { double deltaDisp = disp2(i) - disp1(i); d21[0] += deltaDisp*R(0,i); d21[1] += deltaDisp*R(1,i); d21[2] += deltaDisp*R(2,i); double deltaVel = vel2(i) - vel1(i); v21[0] += deltaVel*R(0,i); v21[1] += deltaVel*R(1,i); v21[2] += deltaVel*R(2,i); double deltaAccel = accel2(i) - accel1(i); a21[0] += deltaAccel*R(0,i); a21[1] += deltaAccel*R(1,i); a21[2] += deltaAccel*R(2,i); double deltaDispLast = (disp2(i)-dispIncr2(i)) - (disp1(i)-dispIncr1(i)); d21Last[0] += deltaDispLast*R(0,i); d21Last[1] += deltaDispLast*R(1,i); d21Last[2] += deltaDispLast*R(2,i); } // compute new length and deformation Ln = sqrt(d21[0]*d21[0] + d21[1]*d21[1] + d21[2]*d21[2]); double c1 = d21[0]*v21[0] + d21[1]*v21[1] + d21[2]*v21[2]; double c2 = v21[0]*v21[0] + v21[1]*v21[1] + v21[2]*v21[2] + d21[0]*a21[0] + d21[1]*a21[1] + d21[2]*a21[2]; (*db)(0) = Ln - L; (*vb)(0) = c1/Ln; (*ab)(0) = c2/Ln - (c1*c1)/(Ln*Ln*Ln); double LnLast = sqrt(d21Last[0]*d21Last[0] + d21Last[1]*d21Last[1] + d21Last[2]*d21Last[2]); double dbDelta = (Ln - L) - (LnLast - L); // do not check time for right now because of transformation constraint // handler calling update at beginning of new step when applying load // if (fabs(dbDelta) > DBL_EPSILON || (*t)(0) > tLast) { if (fabs(dbDelta) > DBL_EPSILON) { // set the trial response at the site if (theSite != 0) { theSite->setTrialResponse(db, vb, ab, (Vector*)0, t); } else { sData[0] = OF_RemoteTest_setTrialResponse; rValue += theChannel->sendVector(0, 0, *sendData, 0); } } // save the last time tLast = (*t)(0); return rValue; }
const Vector& ActuatorCorot::getResistingForce() { // get current time Domain *theDomain = this->getDomain(); double t = theDomain->getCurrentTime(); // update response if time has advanced if (t > tPast) { // receive data theChannel->recvVector(0, 0, *recvData, 0); // check if force request was received if (rData[0] == RemoteTest_getForce) { // send daq displacements and forces theChannel->sendVector(0, 0, *sendData, 0); // receive new trial response theChannel->recvVector(0, 0, *recvData, 0); } if (rData[0] != RemoteTest_setTrialResponse) { if (rData[0] == RemoteTest_DIE) { opserr << "\nThe Simulation has successfully completed.\n"; } else { opserr << "ActuatorCorot::getResistingForce() - " << "wrong action received: expecting 3 but got " << rData[0] << endln; } exit(-1); } // save current time tPast = t; } // get resisting force in basic system q = k*db + q0 = k*(db - db0) q(0) = EA/L*(db(0) - (*ctrlDisp)(0)); // assign daq values for feedback (*daqDisp)(0) = db(0); (*daqForce)(0) = -q(0); // local resisting force static Vector ql(3); ql(0) = d21[0]/Ln*q(0); ql(1) = d21[1]/Ln*q(0); ql(2) = d21[2]/Ln*q(0); static Vector qg(3); qg.addMatrixTransposeVector(0.0, R, ql, 1.0); // zero the residual theVector->Zero(); // copy forces into appropriate places int numDOF2 = numDOF/2; for (int i=0; i<numDIM; i++) { (*theVector)(i) = -qg(i); (*theVector)(i+numDOF2) = qg(i); } // subtract external load (*theVector) -= *theLoad; return *theVector; }
int EEBeamColumn2d::update() { int rValue = 0; // get current time Domain *theDomain = this->getDomain(); (*t)(0) = theDomain->getCurrentTime(); // update the coordinate transformation theCoordTransf->update(); // determine dsp, vel and acc in basic system A const Vector &dbA = theCoordTransf->getBasicTrialDisp(); const Vector &vbA = theCoordTransf->getBasicTrialVel(); const Vector &abA = theCoordTransf->getBasicTrialAccel(); const Vector &dbDeltaA = theCoordTransf->getBasicIncrDeltaDisp(); /* transform displacements from basic sys A to basic sys B (linear) Vector dbDelta(3); (*db)[0] = dbA(0); (*db)[1] = -L*dbA(1); (*db)[2] = -dbA(1)+dbA(2); (*vb)[0] = vbA(0); (*vb)[1] = -L*vbA(1); (*vb)[2] = -vbA(1)+vbA(2); (*ab)[0] = abA(0); (*ab)[1] = -L*abA(1); (*ab)[2] = -abA(1)+abA(2); dbDelta(0) = dbDeltaA(0); dbDelta(1) = -L*dbDeltaA(1); dbDelta(2) = -dbDeltaA(1)+dbDeltaA(2);*/ // transform displacements from basic sys A to basic sys B (nonlinear) Vector dbDelta(3); (*db)[0] = (L+dbA(0))*cos(dbA(1))-L; (*db)[1] = -(L+dbA(0))*sin(dbA(1)); (*db)[2] = -dbA(1)+dbA(2); (*vb)[0] = vbA(0)*cos(dbA(1))-(L+dbA(0))*sin(dbA(1))*vbA(1); (*vb)[1] = -vbA(0)*sin(dbA(1))-(L+dbA(0))*cos(dbA(1))*vbA(1); (*vb)[2] = -vbA(1)+vbA(2); (*ab)[0] = abA(0)*cos(dbA(1))-2*vbA(0)*sin(dbA(1))*vbA(1)-(L+dbA(0))*cos(dbA(1))*pow(vbA(1),2)-(L+dbA(0))*sin(dbA(1))*abA(1); (*ab)[1] = -abA(0)*sin(dbA(1))-2*vbA(0)*cos(dbA(1))*vbA(1)+(L+dbA(0))*sin(dbA(1))*pow(vbA(1),2)-(L+dbA(0))*cos(dbA(1))*abA(1); (*ab)[2] = -abA(1)+abA(2); dbDelta(0) = (L+dbDeltaA(0))*cos(dbDeltaA(1))-L; dbDelta(1) = -(L+dbDeltaA(0))*sin(dbDeltaA(1)); dbDelta(2) = -dbDeltaA(1)+dbDeltaA(2); // do not check time for right now because of transformation constraint // handler calling update at beginning of new step when applying load // if (dbDelta.pNorm(0) > DBL_EPSILON || (*t)(0) > tLast) { if (dbDelta.pNorm(0) > DBL_EPSILON) { // set the trial response at the site if (theSite != 0) { theSite->setTrialResponse(db, vb, ab, (Vector*)0, t); } else { sData[0] = OF_RemoteTest_setTrialResponse; rValue += theChannel->sendVector(0, 0, *sendData, 0); } } // save the last time tLast = (*t)(0); return rValue; }
int EEBearing3d::update() { int rValue = 0; // get current time Domain *theDomain = this->getDomain(); (*t)(0) = theDomain->getCurrentTime(); // get global trial response int ndim = 0, i; Vector dg(12), vg(12), ag(12), dgDelta(12); for (i=0; i<2; i++) { Vector disp = theNodes[i]->getTrialDisp(); Vector vel = theNodes[i]->getTrialVel(); Vector accel = theNodes[i]->getTrialAccel(); Vector dispIncr = theNodes[i]->getIncrDeltaDisp(); dg.Assemble(disp, ndim); vg.Assemble(vel, ndim); ag.Assemble(accel, ndim); dgDelta.Assemble(dispIncr, ndim); ndim += 6; } // transform response from the global to the local system Vector vl(12), al(12), dlDelta(12); dl.addMatrixVector(0.0, Tgl, dg, 1.0); vl.addMatrixVector(0.0, Tgl, vg, 1.0); al.addMatrixVector(0.0, Tgl, ag, 1.0); dlDelta.addMatrixVector(0.0, Tgl, dgDelta, 1.0); // transform response from the local to the basic system Vector dbDelta(6); db->addMatrixVector(0.0, Tlb, dl, 1.0); vb->addMatrixVector(0.0, Tlb, vl, 1.0); ab->addMatrixVector(0.0, Tlb, al, 1.0); dbDelta.addMatrixVector(0.0, Tlb, dlDelta, 1.0); // 1) set axial deformations in basic x-direction theMaterials[0]->setTrialStrain((*db)(0), (*vb)(0)); if (pFrcCtrl == 1) (*qb)(0) = theMaterials[0]->getStress(); // 2) set shear deformations in basic y- and z-direction // do not check time for right now because of transformation constraint // handler calling update at beginning of new step when applying load // if (dbDelta.pNorm(0) > DBL_EPSILON || (*t)(0) > tLast) { if (dbDelta.pNorm(0) > DBL_EPSILON) { // set the trial response at the site if (theSite != 0) { theSite->setTrialResponse(db, vb, ab, qb, t); } else { sData[0] = OF_RemoteTest_setTrialResponse; rValue += theChannel->sendVector(0, 0, *sendData, 0); } } // 3) set rotations about basic x-direction theMaterials[1]->setTrialStrain((*db)(3), (*vb)(3)); // 4) set rotations about basic y-direction theMaterials[2]->setTrialStrain((*db)(4), (*vb)(4)); // 5) set rotations about basic z-direction theMaterials[3]->setTrialStrain((*db)(5), (*vb)(5)); // save the last time tLast = (*t)(0); return rValue; }
int PFEMIntegrator::formSensitivityRHS(int passedGradNumber) { sensitivityFlag = 1; // Set a couple of data members gradNumber = passedGradNumber; // Get pointer to the SOE LinearSOE *theSOE = this->getLinearSOE(); // Get the analysis model AnalysisModel *theModel = this->getAnalysisModel(); // Randomness in external load (including randomness in time series) // Get domain Domain *theDomain = theModel->getDomainPtr(); // Loop through nodes to zero the unbalaced load Node *nodePtr; NodeIter &theNodeIter = theDomain->getNodes(); while ((nodePtr = theNodeIter()) != 0) nodePtr->zeroUnbalancedLoad(); // Loop through load patterns to add external load sensitivity LoadPattern *loadPatternPtr; LoadPatternIter &thePatterns = theDomain->getLoadPatterns(); double time; while((loadPatternPtr = thePatterns()) != 0) { time = theDomain->getCurrentTime(); loadPatternPtr->applyLoadSensitivity(time); } // Randomness in element/material contributions // Loop through FE elements FE_Element *elePtr; FE_EleIter &theEles = theModel->getFEs(); while((elePtr = theEles()) != 0) { theSOE->addB( elePtr->getResidual(this), elePtr->getID() ); } // Loop through DOF groups (IT IS IMPORTANT THAT THIS IS DONE LAST!) DOF_Group *dofPtr; DOF_GrpIter &theDOFs = theModel->getDOFs(); while((dofPtr = theDOFs()) != 0) { theSOE->addB( dofPtr->getUnbalance(this), dofPtr->getID() ); } // Reset the sensitivity flag sensitivityFlag = 0; return 0; }