Ejemplo n.º 1
0
int
FiberSection2d::sendSelf(int commitTag, Channel &theChannel)
{
  int res = 0;

  // create an id to send objects tag and numFibers, 
  //     size 3 so no conflict with matData below if just 1 fiber
  static ID data(3);
  data(0) = this->getTag();
  data(1) = numFibers;
  int dbTag = this->getDbTag();
  res += theChannel.sendID(dbTag, commitTag, data);
  if (res < 0) {
    opserr <<  "FiberSection2d::sendSelf - failed to send ID data\n";
    return res;
  }    

  if (numFibers != 0) {
    
    // create an id containingg classTag and dbTag for each material & send it
    ID materialData(2*numFibers);
    for (int i=0; i<numFibers; i++) {
      UniaxialMaterial *theMat = theMaterials[i];
      materialData(2*i) = theMat->getClassTag();
      int matDbTag = theMat->getDbTag();
      if (matDbTag == 0) {
	matDbTag = theChannel.getDbTag();
	if (matDbTag != 0)
	  theMat->setDbTag(matDbTag);
      }
      materialData(2*i+1) = matDbTag;
    }    
    
    res += theChannel.sendID(dbTag, commitTag, materialData);
    if (res < 0) {
      opserr <<  "FiberSection2d::sendSelf - failed to send material data\n";
      return res;
    }    

    // send the fiber data, i.e. area and loc
    Vector fiberData(matData, 2*numFibers);
    res += theChannel.sendVector(dbTag, commitTag, fiberData);
    if (res < 0) {
      opserr <<  "FiberSection2d::sendSelf - failed to send material data\n";
      return res;
    }    

    // now invoke send(0 on all the materials
    for (int j=0; j<numFibers; j++)
      theMaterials[j]->sendSelf(commitTag, theChannel);

  }

  return res;
}
Ejemplo n.º 2
0
N4BiaxialTruss::N4BiaxialTruss(int tag, 
int dim,
int Nd1, int Nd2, 
int GNd1, int GNd2, 
UniaxialMaterial &theMat,
double a, double r, int damp)
:Element(tag,ELE_TAG_N4BiaxialTruss),     
theMaterial_1(0), theBetaMaterial_1(0), 
theMaterial_2(0), theBetaMaterial_2(0), 
connectedExternalNodes(4),
dimension(dim), numDOF(0), theLoad(0),
theMatrix(0), theVector(0), theVector2(0),
L(0.0), A(a), rho(r), doRayleighDamping(damp)
{
	// get a copy of the material and check we obtained a valid copy
	theMaterial_1 = theMat.getCopy();
	theMaterial_2 = theMat.getCopy();
	if ((theMaterial_1 == 0) || (theMaterial_2 == 0)) {
		opserr << "FATAL N4BiaxialTruss::N4BiaxialTruss - " << tag <<
		"failed to get a copy of material with tag " << theMat.getTag() << endln;
		exit(-1);
	} else if (theMat.getClassTag() == MAT_TAG_ConcretewBeta) {
	  theBetaMaterial_1 = (ConcretewBeta *) theMaterial_1;
	  theBetaMaterial_2 = (ConcretewBeta *) theMaterial_2;
	}
	
	// ensure the connectedExternalNode ID is of correct size & set values
	if (connectedExternalNodes.Size() != 4) {
		opserr << "FATAL N4BiaxialTruss::N4BiaxialTruss - " <<  tag << "failed to create an node ID array of size 4\n";
		exit(-1);
	}

	connectedExternalNodes(0) = Nd1;
	connectedExternalNodes(1) = Nd2;
	connectedExternalNodes(2) = GNd1;
	connectedExternalNodes(3) = GNd2;

	// set node pointers to NULL
	for (int i=0; i<4; i++)
	theNodes[i] = 0;

	cosX[0] = 0.0;
	cosX[1] = 0.0;
	cosX[2] = 0.0;
}