Subversion Repositories OpenSees

Rev

Rev 1231 | Rev 1321 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1231 Rev 1271
Line 16... Line 16...
16
**   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
16
**   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
17
**   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
17
**   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
18
**                                                                    **
18
**                                                                    **
19
** ****************************************************************** */
19
** ****************************************************************** */
20
                                                                       
20
                                                                       
21
// $Revision: 1.14 $
-
 
22
// $Date: 2002-12-16 21:10:08 $
-
 
-
 
21
// $Revision: 1.15 $
-
 
22
// $Date: 2003-02-14 23:01:18 $
23
// $Source: /usr/local/cvs/OpenSees/SRC/element/truss/Truss.cpp,v $
23
// $Source: /usr/local/cvs/OpenSees/SRC/element/truss/Truss.cpp,v $
24
                                                                       
24
                                                                       
25
                                                                       
25
                                                                       
26
// File: ~/element/truss/Truss.C
26
// File: ~/element/truss/Truss.C
27
// 
27
// 
Line 40... Line 40...
40
#include <Node.h>
40
#include <Node.h>
41
#include <Channel.h>
41
#include <Channel.h>
42
#include <FEM_ObjectBroker.h>
42
#include <FEM_ObjectBroker.h>
43
#include <UniaxialMaterial.h>
43
#include <UniaxialMaterial.h>
44
#include <Renderer.h>
44
#include <Renderer.h>
45
-
 
46
#include <G3Globals.h>
-
 
47
45
48
#include <math.h>
46
#include <math.h>
49
#include <stdlib.h>
47
#include <stdlib.h>
50
#include <string.h>
48
#include <string.h>
51
49
Line 75... Line 73...
75
  theMatrix(0), theVector(0), t(0),
73
  theMatrix(0), theVector(0), t(0),
76
  L(0.0), A(a), M(rho)
74
  L(0.0), A(a), M(rho)
77
{
75
{
78
    // get a copy of the material and check we obtained a valid copy
76
    // get a copy of the material and check we obtained a valid copy
79
    theMaterial = theMat.getCopy();
77
    theMaterial = theMat.getCopy();
80
    if (theMaterial == 0)
-
 
81
      g3ErrorHandler->fatal("FATAL Truss::Truss - %d %s %d\n", tag,
-
 
82
                            "failed to get a copy of material with tag ",
-
 
83
                            theMat.getTag());
-
 
84
-
 
-
 
78
    if (theMaterial == 0) {
-
 
79
      opserr << "FATAL Truss::Truss - " << tag <<
-
 
80
        "failed to get a copy of material with tag " << theMat.getTag() << endln;
-
 
81
      exit(-1);
-
 
82
    }
-
 
83
   
85
    // ensure the connectedExternalNode ID is of correct size & set values
84
    // ensure the connectedExternalNode ID is of correct size & set values
86
    if (connectedExternalNodes.Size() != 2)
-
 
87
      g3ErrorHandler->fatal("FATAL Truss::Truss - %d %s\n", tag,
-
 
88
                            "failed to create an ID of size 2");
-
 
-
 
85
    if (connectedExternalNodes.Size() != 2) {
-
 
86
      opserr << "FATAL Truss::Truss - " <<  tag << "failed to create an ID of size 2\n";
-
 
87
      exit(-1);
-
 
88
    }
-
 
89
89
    connectedExternalNodes(0) = Nd1;
90
    connectedExternalNodes(0) = Nd1;
90
    connectedExternalNodes(1) = Nd2;        
91
    connectedExternalNodes(1) = Nd2;        
91
92
92
    // set node pointers to NULL
93
    // set node pointers to NULL
93
    for (int i=0; i<2; i++)
94
    for (int i=0; i<2; i++)
Line 107... Line 108...
107
 dimension(0), numDOF(0),
108
 dimension(0), numDOF(0),
108
 theMatrix(0), theVector(0), t(0),
109
 theMatrix(0), theVector(0), t(0),
109
  L(0.0), A(0.0), M(0.0)
110
  L(0.0), A(0.0), M(0.0)
110
{
111
{
111
    // ensure the connectedExternalNode ID is of correct size 
112
    // ensure the connectedExternalNode ID is of correct size 
112
    if (connectedExternalNodes.Size() != 2)
-
 
113
      g3ErrorHandler->fatal("FATAL Truss::Truss - %s\n",
-
 
114
                            "failed to create an ID of size 2");
-
 
-
 
113
  if (connectedExternalNodes.Size() != 2) {
-
 
114
      opserr << "FATAL Truss::Truss - failed to create an ID of size 2\n";
-
 
115
      exit(-1);
-
 
116
  }
115
117
116
    for (int i=0; i<2; i++)
-
 
117
      theNodes[i] = 0;
-
 
-
 
118
  for (int i=0; i<2; i++)
-
 
119
    theNodes[i] = 0;
118
120
119
// AddingSensitivity:BEGIN /////////////////////////////////////
121
// AddingSensitivity:BEGIN /////////////////////////////////////
120
        gradientIdentifier = 0;
122
        gradientIdentifier = 0;
121
// AddingSensitivity:END //////////////////////////////////////
123
// AddingSensitivity:END //////////////////////////////////////
122
}
124
}
Line 186... Line 188...
186
    theNodes[1] = theDomain->getNode(Nd2);     
188
    theNodes[1] = theDomain->getNode(Nd2);     
187
   
189
   
188
    // if can't find both - send a warning message
190
    // if can't find both - send a warning message
189
    if ((theNodes[0] == 0) || (theNodes[1] == 0)) {
191
    if ((theNodes[0] == 0) || (theNodes[1] == 0)) {
190
      if (theNodes[0] == 0)
192
      if (theNodes[0] == 0)
191
        g3ErrorHandler->warning("Truss::setDomain() - truss %d node %d %s\n",
-
 
192
                                this->getTag(), Nd1,
-
 
193
                                "does not exist in the model");
-
 
-
 
193
        opserr <<"Truss::setDomain() - truss" << this->getTag() << " node " << Nd1 <<
-
 
194
          "does not exist in the model\n";
194
      else
195
      else
195
        g3ErrorHandler->warning("Truss::setDomain() - truss %d node %d %s\n",
-
 
196
                                this->getTag(), Nd2,
-
 
197
                                "does not exist in the model");
-
 
-
 
196
        opserr <<"Truss::setDomain() - truss" << this->getTag() << " node " << Nd2 <<
-
 
197
          "does not exist in the model\n";
198
198
199
      // fill this in so don't segment fault later
199
      // fill this in so don't segment fault later
200
      numDOF = 2;    
200
      numDOF = 2;    
201
      theMatrix = &trussM2;
201
      theMatrix = &trussM2;
202
      theVector = &trussV2;    
202
      theVector = &trussV2;    
Line 208... Line 208...
208
    int dofNd1 = theNodes[0]->getNumberDOF();
208
    int dofNd1 = theNodes[0]->getNumberDOF();
209
    int dofNd2 = theNodes[1]->getNumberDOF();  
209
    int dofNd2 = theNodes[1]->getNumberDOF();  
210
210
211
    // if differing dof at the ends - print a warning message
211
    // if differing dof at the ends - print a warning message
212
    if (dofNd1 != dofNd2) {
212
    if (dofNd1 != dofNd2) {
213
      g3ErrorHandler->warning("WARNING Truss::setDomain(): nodes %d and %d %s %d\n",Nd1, Nd2,
-
 
214
                              "have differing dof at ends for truss",this->getTag());
-
 
-
 
213
      opserr <<"WARNING Truss::setDomain(): nodes " << Nd1 << " and " << Nd2 <<
-
 
214
        "have differing dof at ends for truss " << this->getTag() << endln;
215
215
216
      // fill this in so don't segment fault later
216
      // fill this in so don't segment fault later
217
      numDOF = 2;    
217
      numDOF = 2;    
218
      theMatrix = &trussM2;
218
      theMatrix = &trussM2;
219
      theVector = &trussV2;    
219
      theVector = &trussV2;    
Line 249... Line 249...
249
        numDOF = 12;       
249
        numDOF = 12;       
250
        theMatrix = &trussM12;
250
        theMatrix = &trussM12;
251
        theVector = &trussV12;                 
251
        theVector = &trussV12;                 
252
    }
252
    }
253
    else {
253
    else {
254
      g3ErrorHandler->warning("WARNING Truss::setDomain cannot handle %d dofs at nodes in %d d problem\n",
-
 
255
                              dimension,dofNd1);
-
 
-
 
254
      opserr <<"WARNING Truss::setDomain cannot handle " << dimension << " dofs at nodes in " <<
-
 
255
        dofNd1  << " problem\n";
256
256
257
      numDOF = 2;    
257
      numDOF = 2;    
258
      theMatrix = &trussM2;
258
      theMatrix = &trussM2;
259
      theVector = &trussV2;    
259
      theVector = &trussV2;    
260
      return;
260
      return;
Line 263... Line 263...
263
    // create a transformation matrix for the element
263
    // create a transformation matrix for the element
264
    t = new Matrix(1,numDOF);
264
    t = new Matrix(1,numDOF);
265
    theLoad = new Vector(numDOF);
265
    theLoad = new Vector(numDOF);
266
   
266
   
267
    if (t == 0 || (t->noCols() != numDOF)) {
267
    if (t == 0 || (t->noCols() != numDOF)) {
268
      g3ErrorHandler->fatal("Truss::setDomain - truss %d %s %d\n",
-
 
269
                            this->getTag(),
-
 
270
                            "out of memory creating T matrix of size 1 x",
-
 
271
                            numDOF);   
-
 
272
     
-
 
-
 
268
      opserr << "Truss::setDomain - truss " << this->getTag() <<
-
 
269
        "out of memory creating T matrix of size 1 x" << numDOF << endln;
-
 
270
      exit(-1);
273
      return;
271
      return;
274
    }      
272
    }      
275
   
273
   
276
    if (theLoad == 0) {
274
    if (theLoad == 0) {
277
        g3ErrorHandler->fatal("Truss::setDomain - truss %d %s %d\n",
-
 
278
                              this->getTag(),
-
 
279
                              "out of memory creating vector of size",
-
 
280
                              numDOF); 
-
 
-
 
275
      opserr << "Truss::setDomain - truss " << this->getTag() <<
-
 
276
        "out of memory creating vector of size" << numDOF << endln;
-
 
277
      exit(-1);
281
      return;
278
      return;
282
    }          
279
    }          
283
   
280
   
284
    // now determine the length, cosines and fill in the transformation
281
    // now determine the length, cosines and fill in the transformation
285
    // NOTE t = -t(every one else uses for residual calc)
282
    // NOTE t = -t(every one else uses for residual calc)
Line 292... Line 289...
292
        trans(0,1) = 1;
289
        trans(0,1) = 1;
293
290
294
        double dx = end2Crd(0)-end1Crd(0);     
291
        double dx = end2Crd(0)-end1Crd(0);     
295
        L = sqrt(dx*dx);
292
        L = sqrt(dx*dx);
296
       
293
       
-
 
294
297
        if (L == 0.0) {
295
        if (L == 0.0) {
298
          g3ErrorHandler->warning("WARNING Truss::setDomain() - truss %d has zero length\n",
-
 
299
                                  this->getTag());
-
 
-
 
296
          opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
300
          return;
297
          return;
301
        }      
298
        }      
302
299
303
    } else if (dimension == 2) {
300
    } else if (dimension == 2) {
304
        double dx = end2Crd(0)-end1Crd(0);
301
        double dx = end2Crd(0)-end1Crd(0);
305
        double dy = end2Crd(1)-end1Crd(1);     
302
        double dy = end2Crd(1)-end1Crd(1);     
306
   
303
   
307
        L = sqrt(dx*dx + dy*dy);
304
        L = sqrt(dx*dx + dy*dy);
308
   
305
   
309
        if (L == 0.0) {
306
        if (L == 0.0) {
310
          g3ErrorHandler->warning("WARNING Truss::setDomain() - truss %d has zero length\n",
-
 
311
                                  this->getTag());
-
 
-
 
307
          opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
312
          return;
308
          return;
313
        }
309
        }
314
       
310
       
315
        double cs = dx/L;
311
        double cs = dx/L;
316
        double sn = dy/L;
312
        double sn = dy/L;
Line 336... Line 332...
336
        double dz = end2Crd(2)-end1Crd(2);             
332
        double dz = end2Crd(2)-end1Crd(2);             
337
   
333
   
338
        L = sqrt(dx*dx + dy*dy + dz*dz);
334
        L = sqrt(dx*dx + dy*dy + dz*dz);
339
   
335
   
340
        if (L == 0.0) {
336
        if (L == 0.0) {
341
          g3ErrorHandler->warning("WARNING Truss::setDomain() - truss %d has zero length\n",
-
 
342
                                  this->getTag());
-
 
-
 
337
          opserr <<"WARNING Truss::setDomain() - truss " << this->getTag() << " has zero length\n";
343
          return;
338
          return;
344
        }
339
        }
345
       
340
       
346
        double cx = dx/L;
341
        double cx = dx/L;
347
        double cy = dy/L;
342
        double cy = dy/L;
Line 380... Line 375...
380
Truss::commitState()
375
Truss::commitState()
381
{
376
{
382
  int retVal = 0;
377
  int retVal = 0;
383
  // call element commitState to do any base class stuff
378
  // call element commitState to do any base class stuff
384
  if ((retVal = this->Element::commitState()) != 0) {
379
  if ((retVal = this->Element::commitState()) != 0) {
385
    cerr << "Truss::commitState () - failed in base class";
-
 
-
 
380
    opserr << "Truss::commitState () - failed in base class";
386
  }    
381
  }    
387
  retVal = theMaterial->commitState();
382
  retVal = theMaterial->commitState();
388
  return retVal;
383
  return retVal;
389
}
384
}
390
385
Line 531... Line 526...
531
526
532
int
527
int
533
Truss::addLoad(ElementalLoad *theLoad, double loadFactor)
528
Truss::addLoad(ElementalLoad *theLoad, double loadFactor)
534
529
535
{  
530
{  
536
  g3ErrorHandler->warning("Truss::addLoad - load type unknown for truss with tag: %d\n",
-
 
537
                          this->getTag());
-
 
-
 
531
  opserr <<"Truss::addLoad - load type unknown for truss with tag: " << this->getTag() << endln;
538
 
532
 
539
  return -1;
533
  return -1;
540
}
534
}
541
535
542
int
536
int
Line 552... Line 546...
552
546
553
  int nodalDOF = numDOF/2;
547
  int nodalDOF = numDOF/2;
554
   
548
   
555
#ifdef _G3DEBUG    
549
#ifdef _G3DEBUG    
556
  if (nodalDOF != Raccel1.Size() || nodalDOF != Raccel2.Size()) {
550
  if (nodalDOF != Raccel1.Size() || nodalDOF != Raccel2.Size()) {
557
    g3ErrorHandler->warning("Truss::addInertiaLoadToUnbalance %s\n",
-
 
558
                            "matrix and vector sizes are incompatable");
-
 
-
 
551
    opserr <<"Truss::addInertiaLoadToUnbalance " <<
-
 
552
      "matrix and vector sizes are incompatable\n";
559
    return -1;
553
    return -1;
560
  }
554
  }
561
#endif
555
#endif
562
   
556
   
563
    // want to add ( - fact * M R * accel ) to unbalance
557
    // want to add ( - fact * M R * accel ) to unbalance
Line 656... Line 650...
656
  }
650
  }
657
  data(5) = matDbTag;
651
  data(5) = matDbTag;
658
652
659
  res = theChannel.sendVector(dataTag, commitTag, data);
653
  res = theChannel.sendVector(dataTag, commitTag, data);
660
  if (res < 0) {
654
  if (res < 0) {
661
    g3ErrorHandler->warning("WARNING Truss::sendSelf() - %d failed to send Vector\n",this->getTag());
-
 
-
 
655
    opserr <<"WARNING Truss::sendSelf() - " << this->getTag() << " failed to send Vector\n";
662
    return -1;
656
    return -1;
663
  }          
657
  }          
664
658
665
  // truss then sends the tags of it's two end nodes
659
  // truss then sends the tags of it's two end nodes
666
660
667
  res = theChannel.sendID(dataTag, commitTag, connectedExternalNodes);
661
  res = theChannel.sendID(dataTag, commitTag, connectedExternalNodes);
668
  if (res < 0) {
662
  if (res < 0) {
669
    g3ErrorHandler->warning("WARNING Truss::sendSelf() - %d failed to send Vector\n",this->getTag());
-
 
-
 
663
    opserr <<"WARNING Truss::sendSelf() - " << this->getTag() << " failed to send Vector\n";
670
    return -2;
664
    return -2;
671
  }
665
  }
672
666
673
  // finally truss asks it's material object to send itself
667
  // finally truss asks it's material object to send itself
674
  res = theMaterial->sendSelf(commitTag, theChannel);
668
  res = theMaterial->sendSelf(commitTag, theChannel);
675
  if (res < 0) {
669
  if (res < 0) {
676
    g3ErrorHandler->warning("WARNING Truss::sendSelf() - %d failed to send its Material\n",this->getTag());
-
 
-
 
670
    opserr <<"WARNING Truss::sendSelf() - " << this->getTag() << " failed to send its Material\n";
677
    return -3;
671
    return -3;
678
  }
672
  }
679
673
680
  return 0;
674
  return 0;
681
}
675
}
Line 691... Line 685...
691
  // internal data with the data in the Vector
685
  // internal data with the data in the Vector
692
686
693
  static Vector data(7);
687
  static Vector data(7);
694
  res = theChannel.recvVector(dataTag, commitTag, data);
688
  res = theChannel.recvVector(dataTag, commitTag, data);
695
  if (res < 0) {
689
  if (res < 0) {
696
    g3ErrorHandler->warning("WARNING Truss::recvSelf() - failed to receive Vector\n");
-
 
-
 
690
    opserr <<"WARNING Truss::recvSelf() - failed to receive Vector\n";
697
    return -1;
691
    return -1;
698
  }          
692
  }          
699
693
700
  this->setTag((int)data(0));
694
  this->setTag((int)data(0));
701
  dimension = data(1);
695
  dimension = data(1);
Line 704... Line 698...
704
  M = data(6);
698
  M = data(6);
705
 
699
 
706
  // truss now receives the tags of it's two external nodes
700
  // truss now receives the tags of it's two external nodes
707
  res = theChannel.recvID(dataTag, commitTag, connectedExternalNodes);
701
  res = theChannel.recvID(dataTag, commitTag, connectedExternalNodes);
708
  if (res < 0) {
702
  if (res < 0) {
709
    g3ErrorHandler->warning("WARNING Truss::recvSelf() - %d failed to receive ID\n", this->getTag());
-
 
-
 
703
    opserr <<"WARNING Truss::recvSelf() - " << this->getTag() << " failed to receive ID\n";
710
    return -2;
704
    return -2;
711
  }
705
  }
712
706
713
  // finally truss creates a material object of the correct type,
707
  // finally truss creates a material object of the correct type,
714
  // sets its database tag and asks this new object to recveive itself.
708
  // sets its database tag and asks this new object to recveive itself.
Line 724... Line 718...
724
      delete theMaterial;
718
      delete theMaterial;
725
719
726
    // create a new material object
720
    // create a new material object
727
    theMaterial = theBroker.getNewUniaxialMaterial(matClass);
721
    theMaterial = theBroker.getNewUniaxialMaterial(matClass);
728
    if (theMaterial == 0) {
722
    if (theMaterial == 0) {
729
      g3ErrorHandler->warning("WARNING Truss::recvSelf() - %d failed to get a blank Material of type %d\n",
-
 
730
                              this->getTag(), matClass);
-
 
-
 
723
      opserr <<"WARNING Truss::recvSelf() - " << this->getTag()
-
 
724
        << " failed to get a blank Material of type " << matClass << endln;
731
      return -3;
725
      return -3;
732
    }
726
    }
733
  }
727
  }
734
728
735
  theMaterial->setDbTag(matDb); // note: we set the dbTag before we receive the material
729
  theMaterial->setDbTag(matDb); // note: we set the dbTag before we receive the material
736
  res = theMaterial->recvSelf(commitTag, theChannel, theBroker);
730
  res = theMaterial->recvSelf(commitTag, theChannel, theBroker);
737
  if (res < 0) {
731
  if (res < 0) {
738
    g3ErrorHandler->warning("WARNING Truss::recvSelf() - %d failed to receive its Material\n", this->getTag());
-
 
-
 
732
    opserr <<"WARNING Truss::recvSelf() - "<< this->getTag() << "failed to receive its Material\n";
739
    return -3;    
733
    return -3;    
740
  }
734
  }
741
735
742
  return 0;
736
  return 0;
743
}
737
}
Line 786... Line 780...
786
    return 0;
780
    return 0;
787
}
781
}
788
782
789
783
790
void
784
void
791
Truss::Print(ostream &s, int flag)
-
 
-
 
785
Truss::Print(OPS_Stream &s, int flag)
792
{
786
{
793
    // compute the strain and axial force in the member
787
    // compute the strain and axial force in the member
794
    double strain, force;
788
    double strain, force;
795
    strain = theMaterial->getStrain();
789
    strain = theMaterial->getStrain();
796
    force = A * theMaterial->getStress();
790
    force = A * theMaterial->getStress();
Line 808... Line 802...
808
            (*theVector)(i) = (*t)(0,i)*force;
802
            (*theVector)(i) = (*t)(0,i)*force;
809
          s << " \n\t unbalanced load: " << *theVector;
803
          s << " \n\t unbalanced load: " << *theVector;
810
        }
804
        }
811
805
812
        s << " \t Material: " << *theMaterial;
806
        s << " \t Material: " << *theMaterial;
813
        s << endl;
-
 
-
 
807
        s << endln;
814
    } else if (flag == 1) {
808
    } else if (flag == 1) {
815
        s << this->getTag() << "  " << strain << "  ";
809
        s << this->getTag() << "  " << strain << "  ";
816
        s << force << endl;
-
 
-
 
810
        s << force << endln;
817
    }
811
    }
818
}
812
}
819
813
820
double
814
double
821
Truss::computeCurrentStrain(void) const
815
Truss::computeCurrentStrain(void) const