Subversion Repositories OpenSees

Rev

Rev 4269 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4269 Rev 4355
Line 167... Line 167...
167
             double a, double r, int damp)
167
             double a, double r, int damp)
168
 :Element(tag,ELE_TAG_Truss),    
168
 :Element(tag,ELE_TAG_Truss),    
169
  theMaterial(0), connectedExternalNodes(2),
169
  theMaterial(0), connectedExternalNodes(2),
170
  dimension(dim), numDOF(0), theLoad(0),
170
  dimension(dim), numDOF(0), theLoad(0),
171
  theMatrix(0), theVector(0),
171
  theMatrix(0), theVector(0),
172
  L(0.0), A(a), rho(r), doRayleighDamping(damp)
-
 
-
 
172
  L(0.0), A(a), rho(r), doRayleighDamping(damp), initialDisp(0)
173
{
173
{
174
    // get a copy of the material and check we obtained a valid copy
174
    // get a copy of the material and check we obtained a valid copy
175
    theMaterial = theMat.getCopy();
175
    theMaterial = theMat.getCopy();
176
    if (theMaterial == 0) {
176
    if (theMaterial == 0) {
177
      opserr << "FATAL Truss::Truss - " << tag <<
177
      opserr << "FATAL Truss::Truss - " << tag <<
Line 208... Line 208...
208
Truss::Truss()
208
Truss::Truss()
209
:Element(0,ELE_TAG_Truss),    
209
:Element(0,ELE_TAG_Truss),    
210
 theMaterial(0),connectedExternalNodes(2),
210
 theMaterial(0),connectedExternalNodes(2),
211
 dimension(0), numDOF(0), theLoad(0),
211
 dimension(0), numDOF(0), theLoad(0),
212
 theMatrix(0), theVector(0),
212
 theMatrix(0), theVector(0),
213
 L(0.0), A(0.0), rho(0.0)
-
 
-
 
213
 L(0.0), A(0.0), rho(0.0), initialDisp(0)
214
{
214
{
215
    // ensure the connectedExternalNode ID is of correct size 
215
    // ensure the connectedExternalNode ID is of correct size 
216
  if (connectedExternalNodes.Size() != 2) {
216
  if (connectedExternalNodes.Size() != 2) {
217
      opserr << "FATAL Truss::Truss - failed to create an ID of size 2\n";
217
      opserr << "FATAL Truss::Truss - failed to create an ID of size 2\n";
218
      exit(-1);
218
      exit(-1);
Line 242... Line 242...
242
        delete theMaterial;
242
        delete theMaterial;
243
    if (theLoad != 0)
243
    if (theLoad != 0)
244
        delete theLoad;
244
        delete theLoad;
245
    if (theLoadSens != 0)
245
    if (theLoadSens != 0)
246
        delete theLoadSens;
246
        delete theLoadSens;
-
 
247
    if (initialDisp != 0)
-
 
248
      delete [] initialDisp;
247
}
249
}
248
250
249
251
250
int
252
int
251
Truss::getNumExternalNodes(void) const
253
Truss::getNumExternalNodes(void) const
Line 384... Line 386...
384
   
386
   
385
    // now determine the length, cosines and fill in the transformation
387
    // now determine the length, cosines and fill in the transformation
386
    // NOTE t = -t(every one else uses for residual calc)
388
    // NOTE t = -t(every one else uses for residual calc)
387
    const Vector &end1Crd = theNodes[0]->getCrds();
389
    const Vector &end1Crd = theNodes[0]->getCrds();
388
    const Vector &end2Crd = theNodes[1]->getCrds();    
390
    const Vector &end2Crd = theNodes[1]->getCrds();    
-
 
391
    const Vector &end1Disp = theNodes[0]->getDisp();
-
 
392
    const Vector &end2Disp = theNodes[1]->getDisp();
389
393
390
    if (dimension == 1) {
394
    if (dimension == 1) {
391
      double dx = end2Crd(0)-end1Crd(0);       
-
 
-
 
395
      double dx = end2Crd(0)-end1Crd(0);
392
396
-
 
397
      if (initialDisp == 0) {
-
 
398
        double iDisp = end2Disp(0)-end1Disp(0);
-
 
399
-
 
400
        if (iDisp != 0) {
-
 
401
          initialDisp = new double[1];
-
 
402
          initialDisp[0] = iDisp;
-
 
403
          dx += iDisp;
-
 
404
        }
-
 
405
      }
393
      L = sqrt(dx*dx);
406
      L = sqrt(dx*dx);
394
     
407
     
395
      if (L == 0.0) {
408
      if (L == 0.0) {
396
        opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
409
        opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
397
        return;
410
        return;
398
      }
411
      }
399
-
 
-
 
412
     
400
      cosX[0] = 1.0;
413
      cosX[0] = 1.0;
401
    }
414
    }
402
    else if (dimension == 2) {
415
    else if (dimension == 2) {
403
        double dx = end2Crd(0)-end1Crd(0);
-
 
404
        double dy = end2Crd(1)-end1Crd(1);     
-
 
-
 
416
      double dx = end2Crd(0)-end1Crd(0);
-
 
417
      double dy = end2Crd(1)-end1Crd(1);       
405
   
418
   
406
        L = sqrt(dx*dx + dy*dy);
-
 
407
   
-
 
408
        if (L == 0.0) {
-
 
409
          opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
-
 
410
          return;
-
 
-
 
419
      if (initialDisp == 0) {
-
 
420
        double iDispX = end2Disp(0)-end1Disp(0);
-
 
421
        double iDispY = end2Disp(1)-end1Disp(1);
-
 
422
        if (iDispX != 0 || iDispY != 0) {
-
 
423
          initialDisp = new double[2];
-
 
424
          initialDisp[0] = iDispX;
-
 
425
          initialDisp[1] = iDispY;
-
 
426
          dx += iDispX;
-
 
427
          dy += iDispY;
411
        }
428
        }
-
 
429
      }
-
 
430
     
-
 
431
      L = sqrt(dx*dx + dy*dy);
-
 
432
     
-
 
433
      if (L == 0.0) {
-
 
434
        opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
-
 
435
        return;
-
 
436
      }
412
       
437
       
413
        cosX[0] = dx/L;
-
 
414
        cosX[1] = dy/L;
-
 
-
 
438
      cosX[0] = dx/L;
-
 
439
      cosX[1] = dy/L;
415
    }
440
    }
416
    else {
441
    else {
417
        double dx = end2Crd(0)-end1Crd(0);
-
 
418
        double dy = end2Crd(1)-end1Crd(1);     
-
 
419
        double dz = end2Crd(2)-end1Crd(2);             
-
 
420
   
-
 
421
        L = sqrt(dx*dx + dy*dy + dz*dz);
-
 
422
   
-
 
423
        if (L == 0.0) {
-
 
424
          opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
-
 
425
          return;
-
 
-
 
442
-
 
443
      double dx = end2Crd(0)-end1Crd(0);
-
 
444
      double dy = end2Crd(1)-end1Crd(1);       
-
 
445
      double dz = end2Crd(2)-end1Crd(2);               
-
 
446
-
 
447
      if (initialDisp == 0) {
-
 
448
        double iDispX = end2Disp(0)-end1Disp(0);
-
 
449
        double iDispY = end2Disp(1)-end1Disp(1);      
-
 
450
        double iDispZ = end2Disp(2)-end1Disp(2);      
-
 
451
        if (iDispX != 0 || iDispY != 0 || iDispZ != 0) {
-
 
452
          initialDisp = new double[3];
-
 
453
          initialDisp[0] = iDispX;
-
 
454
          initialDisp[1] = iDispY;
-
 
455
          initialDisp[2] = iDispZ;
-
 
456
          dx += iDispX;
-
 
457
          dy += iDispY;
-
 
458
          dz += iDispZ;
426
        }
459
        }
-
 
460
      }
-
 
461
     
-
 
462
      L = sqrt(dx*dx + dy*dy + dz*dz);
-
 
463
     
-
 
464
      if (L == 0.0) {
-
 
465
        opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
-
 
466
        return;
-
 
467
      }
427
       
468
       
428
        cosX[0] = dx/L;
469
        cosX[0] = dx/L;
429
        cosX[1] = dy/L;
470
        cosX[1] = dy/L;
430
        cosX[2] = dz/L;
471
        cosX[2] = dz/L;
431
    }
472
    }
Line 792... Line 833...
792
  int dataTag = this->getDbTag();
833
  int dataTag = this->getDbTag();
793
834
794
  // truss packs it's data into a Vector and sends this to theChannel
835
  // truss packs it's data into a Vector and sends this to theChannel
795
  // along with it's dbTag and the commitTag passed in the arguments
836
  // along with it's dbTag and the commitTag passed in the arguments
796
837
797
  static Vector data(8);
-
 
-
 
838
  static Vector data(11);
798
  data(0) = this->getTag();
839
  data(0) = this->getTag();
799
  data(1) = dimension;
840
  data(1) = dimension;
800
  data(2) = numDOF;
841
  data(2) = numDOF;
801
  data(3) = A;
842
  data(3) = A;
-
 
843
  data(4) = theMaterial->getClassTag();
802
  data(6) = rho;
844
  data(6) = rho;
-
 
845
803
  if (doRayleighDamping == 0)
846
  if (doRayleighDamping == 0)
804
    data(7) = 0;
847
    data(7) = 0;
805
  else
848
  else
806
    data(7) = 1;
849
    data(7) = 1;
807
850
808
  data(4) = theMaterial->getClassTag();
-
 
-
 
851
809
  int matDbTag = theMaterial->getDbTag();
852
  int matDbTag = theMaterial->getDbTag();
-
 
853
-
 
854
  if (initialDisp != 0) {
-
 
855
    for (int i=0; i<dimension; i++) {
-
 
856
      data[8+i] = initialDisp[i];
-
 
857
    }
-
 
858
  }
810
859
811
  // NOTE: we do have to ensure that the material has a database
860
  // NOTE: we do have to ensure that the material has a database
812
  // tag if we are sending to a database channel.
861
  // tag if we are sending to a database channel.
813
  if (matDbTag == 0) {
862
  if (matDbTag == 0) {
814
    matDbTag = theChannel.getDbTag();
863
    matDbTag = theChannel.getDbTag();
Line 848... Line 897...
848
  int dataTag = this->getDbTag();
897
  int dataTag = this->getDbTag();
849
898
850
  // truss creates a Vector, receives the Vector and then sets the 
899
  // truss creates a Vector, receives the Vector and then sets the 
851
  // internal data with the data in the Vector
900
  // internal data with the data in the Vector
852
901
853
  static Vector data(8);
-
 
-
 
902
  static Vector data(11);
854
  res = theChannel.recvVector(dataTag, commitTag, data);
903
  res = theChannel.recvVector(dataTag, commitTag, data);
855
  if (res < 0) {
904
  if (res < 0) {
856
    opserr <<"WARNING Truss::recvSelf() - failed to receive Vector\n";
905
    opserr <<"WARNING Truss::recvSelf() - failed to receive Vector\n";
857
    return -1;
906
    return -1;
858
  }          
907
  }          
Line 864... Line 913...
864
  rho = data(6);
913
  rho = data(6);
865
  if (data(7) == 0)
914
  if (data(7) == 0)
866
    doRayleighDamping = 0;
915
    doRayleighDamping = 0;
867
  else
916
  else
868
    doRayleighDamping = 1;
917
    doRayleighDamping = 1;
-
 
918
-
 
919
-
 
920
  initialDisp = new double[dimension];
-
 
921
  for (int i=0; i<dimension; i++)
-
 
922
    initialDisp[i] = 0.0;
-
 
923
-
 
924
  int initial = 0;
-
 
925
  for (int i=0; i<dimension; i++) {
-
 
926
    if (data(8+i) != 0.0) {
-
 
927
      initial = 1;
-
 
928
    }
-
 
929
  }
-
 
930
 
-
 
931
  if (initial != 0) {
-
 
932
    for (int i=0; i<dimension; i++) {
-
 
933
      initialDisp[i] = data(8+i);
-
 
934
    }    
-
 
935
  }
869
 
936
 
870
  // truss now receives the tags of it's two external nodes
937
  // truss now receives the tags of it's two external nodes
871
  res = theChannel.recvID(dataTag, commitTag, connectedExternalNodes);
938
  res = theChannel.recvID(dataTag, commitTag, connectedExternalNodes);
872
  if (res < 0) {
939
  if (res < 0) {
873
    opserr <<"WARNING Truss::recvSelf() - " << this->getTag() << " failed to receive ID\n";
940
    opserr <<"WARNING Truss::recvSelf() - " << this->getTag() << " failed to receive ID\n";
Line 982... Line 1049...
982
        s << " type: Truss  iNode: " << connectedExternalNodes(0);
1049
        s << " type: Truss  iNode: " << connectedExternalNodes(0);
983
        s << " jNode: " << connectedExternalNodes(1);
1050
        s << " jNode: " << connectedExternalNodes(1);
984
        s << " Area: " << A << " Mass/Length: " << rho;
1051
        s << " Area: " << A << " Mass/Length: " << rho;
985
       
1052
       
986
        s << " \n\t strain: " << strain;
1053
        s << " \n\t strain: " << strain;
-
 
1054
        if (initialDisp != 0) {
-
 
1055
          s << " initialDisplacements: ";
-
 
1056
          for (int i = 0; i < dimension; i++)
-
 
1057
            s << initialDisp[i] << " ";
-
 
1058
        }
-
 
1059
987
        s << " axial load: " <<  force;
1060
        s << " axial load: " <<  force;
-
 
1061
988
        if (L != 0.0) {
1062
        if (L != 0.0) {
989
          int numDOF2 = numDOF/2;
1063
          int numDOF2 = numDOF/2;
990
          double temp;
1064
          double temp;
991
          for (int i = 0; i < dimension; i++) {
1065
          for (int i = 0; i < dimension; i++) {
992
            temp = cosX[i]*force;
1066
            temp = cosX[i]*force;
Line 1012... Line 1086...
1012
    // determine the strain
1086
    // determine the strain
1013
    const Vector &disp1 = theNodes[0]->getTrialDisp();
1087
    const Vector &disp1 = theNodes[0]->getTrialDisp();
1014
    const Vector &disp2 = theNodes[1]->getTrialDisp(); 
1088
    const Vector &disp2 = theNodes[1]->getTrialDisp(); 
1015
1089
1016
    double dLength = 0.0;
1090
    double dLength = 0.0;
1017
    for (int i = 0; i < dimension; i++)
-
 
1018
      dLength += (disp2(i)-disp1(i))*cosX[i];
-
 
-
 
1091
    if (initialDisp == 0)
-
 
1092
      for (int i = 0; i < dimension; i++)
-
 
1093
        dLength += (disp2(i)-disp1(i))*cosX[i];
-
 
1094
    else
-
 
1095
      for (int i = 0; i < dimension; i++)
-
 
1096
        dLength += (disp2(i)-disp1(i)-initialDisp[i])*cosX[i];
1019
 
1097
 
1020
    // this method should never be called with L == 0
1098
    // this method should never be called with L == 0
1021
    return dLength/L;
1099
    return dLength/L;
1022
}
1100
}
1023
1101
Line 1029... Line 1107...
1029
    // determine the strain
1107
    // determine the strain
1030
    const Vector &vel1 = theNodes[0]->getTrialVel();
1108
    const Vector &vel1 = theNodes[0]->getTrialVel();
1031
    const Vector &vel2 = theNodes[1]->getTrialVel();   
1109
    const Vector &vel2 = theNodes[1]->getTrialVel();   
1032
1110
1033
    double dLength = 0.0;
1111
    double dLength = 0.0;
1034
    for (int i = 0; i < dimension; i++){
-
 
1035
        dLength += (vel2(i)-vel1(i))*cosX[i];
-
 
1036
    }
-
 
-
 
1112
    for (int i = 0; i < dimension; i++)
-
 
1113
      dLength += (vel2(i)-vel1(i))*cosX[i];
1037
1114
1038
    // this method should never be called with L == 0
1115
    // this method should never be called with L == 0
1039
    return dLength/L;
1116
    return dLength/L;
1040
}
1117
}
1041
1118