示例#1
0
mObject spcsToJSON(void) {
    SP_ConstraintIter &theSPs = theDomain.getSPs();
    SP_Constraint *theSP;

    mObject sps;
    mArray sp_val;
    mValue tag, ntag, dir, ref_val;
    char tag_str[15];

    sps.clear();
    while ((theSP = theSPs()) != 0) {
        sp_val.clear();
        tag = theSP->getTag();
        ntag = theSP->getNodeTag();
        dir = theSP->getDOF_Number();
        ref_val = theSP->getValue();
        sp_val.push_back(ntag);
        sp_val.push_back(dir);
        sp_val.push_back(ref_val);

        sprintf(tag_str, "%d", tag.get_int());
        sps[tag_str] = sp_val;
    }
	
    return sps; 
}
void
UniformExcitation::setDomain(Domain *theDomain) 
{
  this->LoadPattern::setDomain(theDomain);

  // now we go through and set all the node velocities to be vel0 
  // for those nodes not fixed in the dirn!
  if (vel0 != 0.0) {

    SP_ConstraintIter &theSPs = theDomain->getSPs();
    SP_Constraint *theSP;
    ID constrainedNodes(0);
    int count = 0;
    while ((theSP=theSPs()) != 0) {
      if (theSP->getDOF_Number() == theDof) {
	constrainedNodes[count] = theSP->getNodeTag();
	count++;
      }
    }


    NodeIter &theNodes = theDomain->getNodes();
    Node *theNode;
    Vector newVel(1);
    int currentSize = 1;
    while ((theNode = theNodes()) != 0) {
      int tag = theNode->getTag();
      if (constrainedNodes.getLocation(tag) < 0) {
	int numDOF = theNode->getNumberDOF();
	if (numDOF != currentSize) 
	  newVel.resize(numDOF);
	
	newVel = theNode->getVel();
	newVel(theDof) = vel0;
	theNode->setTrialVel(newVel);
	theNode->commitState();
      }
    }
  }
}
示例#3
0
GSA_Recorder::GSA_Recorder(Domain &theDom, 
			   const char *fileName, 
			   const char *title1,
			   const char *title2,
			   const char *title3,
			   const char *jobno,
			   const char *initials,
			   const char *spec,
			   const char *currency,
			   const char *length,
			   const char *force,
			   const char *temp,
			   double dT)
: Recorder(RECORDER_TAGS_GSA_Recorder),
  theDomain(&theDom), ndm(3), ndf(6), counter(0), deltaT(dT), nextTimeStampToRecord(0.0)
{
  // open file 
  if (theFile.setFile(fileName, OVERWRITE) < 0) {
    opserr << "WARNING - GSA_Recorder::GSA_Recorder()";
    opserr << " - could not open file " << fileName << endln;
    exit(-1);
  } 

  // spit out header data
  if (title1 != 0)
    theFile << "TITLE\t" << title1;
  else
    theFile << "TITLE\t" << "No Title";


  if (title2 != 0)
    theFile << "\t" << title2;
  else
    theFile << "\t" << "BLANK";


  if (title3 != 0)
    theFile << "\t" << title3;
  else
    theFile << "\t" << "BLANK";  


  if (jobno != 0)
    theFile << "\t" << jobno;
  else
    theFile << "\t" << "0000";


  if (initials != 0)
    theFile<< "\t" << initials << endln;
  else
    theFile << "\t" << "ANOTHER\n";  


  if (spec != 0)
    theFile << "SPEC\t" << spec << endln;


  if (currency != 0)
    theFile << "CURRENCY\t" << currency << endln;


  if (length != 0)
    theFile << "UNIT_DATA\tLENGTH\t" << length << endln; 


  if (force != 0)
    theFile << "UNIT_DATA\tFORCE\t" << force << endln;


  if (temp != 0)
    theFile << "UNIT_DATA\tTEMP\t" << temp << endln;


  // spit out nodal data
  NodeIter &theNodes = theDomain->getNodes();
  Node *theNode;
  while ((theNode=theNodes()) != 0) {
    int nodeTag = theNode->getTag();
    theFile << "NODE\t" << nodeTag;
    const Vector &crds = theNode->getCrds();
    if (crds.Size() != ndm) {
      opserr << "WARNING - GSA_Recorder::GSA_Recorder() - node: " <<  nodeTag ;
      opserr << " has invalid number of coordinates, expecting: " << ndm << " got: " << crds.Size() << endln;
      exit(-1);
    }
    const Vector &disp = theNode->getTrialDisp();
    if (disp.Size() != ndf) {
      opserr << "WARNING - GSA_Recorder::GSA_Recorder() - node: " <<  nodeTag ;
      opserr << " has invalid number of dof, expecting: " << ndf << " got: " << disp.Size() << endln;
      exit(-1);
    }
    for (int i=0; i<ndm; i++)
      theFile << "\t" << crds(i);
    theFile << endln;
  }
  
  
  // open file and spit out the initial data
  SP_ConstraintIter &theSPs = theDomain->getSPs();
  SP_Constraint *theSP;
  ID theConstrainedNodes(0,6);
  ID theSpMatrix(0, 6*ndf);
  int numNodesWithSP = 0;
  while ((theSP=theSPs()) != 0) {
    int nodeTag =  theSP->getNodeTag();
    int location = theConstrainedNodes.getLocation(nodeTag);
    if (location < 0) {
      theConstrainedNodes[numNodesWithSP] = nodeTag;
      for (int i=0; i<ndf; i++)
	theSpMatrix[numNodesWithSP*ndf+i] = 0;	  
      location = numNodesWithSP++;
    }
    int id = theSP->getDOF_Number();
    theSpMatrix[location*ndf + id] = 1;
  }
  
  for (int j=0; j<numNodesWithSP; j++) {
    theFile << "SPC\t" <<  theConstrainedNodes[j] << "\t0";
    for (int i=0; i<ndf; i++)
      theFile << "\t" << theSpMatrix[j*ndf+i];
    theFile << endln;
  }
  
  ElementIter &theElements = theDomain->getElements();
  Element *theElement;
  while ((theElement=theElements()) != 0) {
    theElement->Print(theFile, -1);
  }

}