int
PFEMElement2DBubble::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **displayModes, int numModes)
{

    // first set the quantity to be displayed at the nodes;
    // if displayMode is 1 through 3 we will plot material stresses otherwise 0.0

    /*
  static Vector values(numgp);

    for (int j=0; j<numgp; j++) values(j) = 0.0;

    if (displayMode < numgp && displayMode > 0) {
		for (int i=0; i<numgp; i++) {
			const Vector &stress = theMaterial[i]->getStress();
	        values(i) = stress(displayMode-1);
	    }
    }
    */

  static Vector values(3);

    // now  determine the end points of the Tri31 based on
    // the display factor (a measure of the distorted image)
    // store this information in 3 3d vectors v1 through v3
    const Vector &end1Crd = nodes[0]->getCrds();
    const Vector &end2Crd = nodes[2]->getCrds();	
    const Vector &end3Crd = nodes[4]->getCrds();	

    const int numnodes = 3;
    static Matrix coords(numnodes,3);

    if (displayMode >= 0) {  

        const Vector &end1Disp = nodes[0]->getDisp();
        const Vector &end2Disp = nodes[2]->getDisp();
        const Vector &end3Disp = nodes[4]->getDisp();

        for (int i = 0; i < 2; i++) {
            coords(0,i) = end1Crd(i) + end1Disp(i)*fact;
            coords(1,i) = end2Crd(i) + end2Disp(i)*fact;    
            coords(2,i) = end3Crd(i) + end3Disp(i)*fact;    
        }
    } else {
        int mode = displayMode * -1;
        const Matrix &eigen1 = nodes[0]->getEigenvectors();
        const Matrix &eigen2 = nodes[2]->getEigenvectors();
        const Matrix &eigen3 = nodes[4]->getEigenvectors();
        if (eigen1.noCols() >= mode) {
            for (int i = 0; i < 2; i++) {
                coords(0,i) = end1Crd(i) + eigen1(i,mode-1)*fact;
                coords(1,i) = end2Crd(i) + eigen2(i,mode-1)*fact;
                coords(2,i) = end3Crd(i) + eigen3(i,mode-1)*fact;
            }    
        } else {
            for (int i = 0; i < 2; i++) {
                coords(0,i) = end1Crd(i);
                coords(1,i) = end2Crd(i);
                coords(2,i) = end3Crd(i);
            }    
        }
    }
    
    int error = 0;

    // finally we draw the element using drawPolygon
    error += theViewer.drawPolygon (coords, values);

    return error;
}
int
FourNodeQuadWithSensitivity::displaySelf(Renderer &theViewer, int displayMode, float fact)
{

    // first set the quantity to be displayed at the nodes;
    // if displayMode is 1 through 3 we will plot material stresses otherwise 0.0

    static Vector values(4);

    for (int j=0; j<4; j++)
	   values(j) = 0.0;

    if (displayMode < 4 && displayMode > 0) {
	for (int i=0; i<4; i++) {
	  const Vector &stress = theMaterial[i]->getStress();
	  values(i) = stress(displayMode-1);
	}
    }

    // now  determine the end points of the quad based on
    // the display factor (a measure of the distorted image)
    // store this information in 4 3d vectors v1 through v4
    const Vector &end1Crd = theNodes[0]->getCrds();
    const Vector &end2Crd = theNodes[1]->getCrds();	
    const Vector &end3Crd = theNodes[2]->getCrds();	
    const Vector &end4Crd = theNodes[3]->getCrds();	

    static Matrix coords(4,3);

    if (displayMode >= 0) {    
      
      const Vector &end1Disp = theNodes[0]->getDisp();
      const Vector &end2Disp = theNodes[1]->getDisp();
      const Vector &end3Disp = theNodes[2]->getDisp();
      const Vector &end4Disp = theNodes[3]->getDisp();

      for (int i = 0; i < 2; i++) {
	coords(0,i) = end1Crd(i) + end1Disp(i)*fact;
	coords(1,i) = end2Crd(i) + end2Disp(i)*fact;    
	coords(2,i) = end3Crd(i) + end3Disp(i)*fact;    
	coords(3,i) = end4Crd(i) + end4Disp(i)*fact;    
      }
    } else {
      int mode = displayMode * -1;
      const Matrix &eigen1 = theNodes[0]->getEigenvectors();
      const Matrix &eigen2 = theNodes[1]->getEigenvectors();
      const Matrix &eigen3 = theNodes[2]->getEigenvectors();
      const Matrix &eigen4 = theNodes[3]->getEigenvectors();
      if (eigen1.noCols() >= mode) {
	for (int i = 0; i < 2; i++) {
	  coords(0,i) = end1Crd(i) + eigen1(i,mode-1)*fact;
	  coords(1,i) = end2Crd(i) + eigen2(i,mode-1)*fact;
	  coords(2,i) = end3Crd(i) + eigen3(i,mode-1)*fact;
	  coords(3,i) = end4Crd(i) + eigen4(i,mode-1)*fact;
	}    
      } else {
	for (int i = 0; i < 2; i++) {
	  coords(0,i) = end1Crd(i);
	  coords(1,i) = end2Crd(i);
	  coords(2,i) = end3Crd(i);
	  coords(3,i) = end4Crd(i);
	}    
      }
    }
    
    int error = 0;

    // finally we draw the element using drawPolygon
    error += theViewer.drawPolygon (coords, values);

    return error;
}
Exemple #3
0
// method: setDomain()
//    to set a link to the enclosing Domain and to set the node pointers.
//    also determines the number of dof associated
//    with the truss element, we set matrix and vector pointers,
//    allocate space for t matrix, determine the length
//    and set the transformation matrix.
void
TrussSection::setDomain(Domain *theDomain)
{
    // check Domain is not null - invoked when object removed from a domain
    if (theDomain == 0) {
	theNodes[0] = 0;
	theNodes[1] = 0;
	L = 0;
	return;
    }

    // first set the node pointers
    int Nd1 = connectedExternalNodes(0);
    int Nd2 = connectedExternalNodes(1);
    theNodes[0] = theDomain->getNode(Nd1);
    theNodes[1] = theDomain->getNode(Nd2);	

    // if nodes not in domain, warning message & set default numDOF as 2
    if ((theNodes[0] == 0) || (theNodes[1] == 0)){
      if (theNodes[0] == 0)
        opserr << "TrussSection::setDomain() - Nd1: " << Nd1 << " does not exist in Domain\n";
      else
        opserr << "TrussSection::setDomain() - Nd1: " << Nd2 << " does not exist in Domain\n";

      opserr << " for truss with id " << this->getTag() << endln;

      // fill this in so don't segment fault later
      numDOF = 2;    
      theMatrix = &trussM2;
      theVector = &trussV2;	

      return;
    }

    // now determine the number of dof and the dimesnion    
    int dofNd1 = theNodes[0]->getNumberDOF();
    int dofNd2 = theNodes[1]->getNumberDOF();	

    if (dofNd1 != dofNd2) {
      opserr << "WARNING TrussSection::setDomain(): nodes " << Nd1 << " and " <<
	Nd2 << "have differing dof at ends for truss " << this->getTag() << endln;	

      // fill this in so don't segment fault later
      numDOF = 2;    
      theMatrix = &trussM2;
      theVector = &trussV2;	
	
      return;
    }	

    // call the base class method
    this->DomainComponent::setDomain(theDomain);

    // now set the number of dof for element and set matrix and vector pointers
    if (dimension == 1 && dofNd1 == 1) {
	numDOF = 2;    
	theMatrix = &trussM2;
	theVector = &trussV2;
    }
    else if (dimension == 2 && dofNd1 == 2) {
	numDOF = 4;
	theMatrix = &trussM4;
	theVector = &trussV4;	
    }
    else if (dimension == 2 && dofNd1 == 3) {
	numDOF = 6;	
	theMatrix = &trussM6;
	theVector = &trussV6;		
    }
    else if (dimension == 3 && dofNd1 == 3) {
	numDOF = 6;	
	theMatrix = &trussM6;
	theVector = &trussV6;			
    }
    else if (dimension == 3 && dofNd1 == 6) {
	numDOF = 12;	    
	theMatrix = &trussM12;
	theVector = &trussV12;			
    }
    else {
      opserr << "WARNING TrussSection::setDomain cannot handle " << dimension << 
	" dofs at nodes in " << dofNd1 << " d problem\n"; 

      numDOF = 2;    
      theMatrix = &trussM2;
      theVector = &trussV2;	
      return;
    }

    // now determine the length, cosines and fill in the transformation
    // NOTE t = -t(every one else uses for residual calc)
    const Vector &end1Crd = theNodes[0]->getCrds();
    const Vector &end2Crd = theNodes[1]->getCrds();	
    const Vector &end1Disp = theNodes[0]->getDisp();
    const Vector &end2Disp = theNodes[1]->getDisp();

    if (dimension == 1) {
      double dx = end2Crd(0)-end1Crd(0);	
      if (initialDisp == 0) {
	double iDisp = end2Disp(0)-end1Disp(0);
	
	if (iDisp != 0) {
	  initialDisp = new double[1];
	  initialDisp[0] = iDisp;
	  dx += iDisp;
	}
      }
      
      L = sqrt(dx*dx);
      
      if (L == 0.0) {
	opserr << "WARNING TrussSection::setDomain() - truss " << this->getTag() << " has zero length\n";
	return;
      }	

	cosX[0] = 1.0;

    } else if (dimension == 2) {
      double dx = end2Crd(0)-end1Crd(0);
      double dy = end2Crd(1)-end1Crd(1);	

      if (initialDisp == 0) {
	double iDispX = end2Disp(0)-end1Disp(0);
	double iDispY = end2Disp(1)-end1Disp(1);
	if (iDispX != 0 || iDispY != 0) {
	  initialDisp = new double[2];
	  initialDisp[0] = iDispX;
	  initialDisp[1] = iDispY;
	  dx += iDispX;
	  dy += iDispY;
	}
      }
    
      L = sqrt(dx*dx + dy*dy);
      
      if (L == 0.0) {
	opserr << "WARNING TrussSection::setDomain() - truss " << this->getTag() << " has zero length\n";
	return;
      }
	
      cosX[0] = dx/L;
      cosX[1] = dy/L;

    } else {
      double dx = end2Crd(0)-end1Crd(0);
      double dy = end2Crd(1)-end1Crd(1);	
      double dz = end2Crd(2)-end1Crd(2);		
      
      if (initialDisp == 0) {
	double iDispX = end2Disp(0)-end1Disp(0);
	double iDispY = end2Disp(1)-end1Disp(1);      
	double iDispZ = end2Disp(2)-end1Disp(2);      
	if (iDispX != 0 || iDispY != 0 || iDispZ != 0) {
	  initialDisp = new double[3];
	  initialDisp[0] = iDispX;
	  initialDisp[1] = iDispY;
	  initialDisp[2] = iDispZ;
	  dx += iDispX;
	  dy += iDispY;
	  dz += iDispZ;
	}
      }

      L = sqrt(dx*dx + dy*dy + dz*dz);
      
      if (L == 0.0) {
	opserr << "WARNING TrussSection::setDomain() - truss " << this->getTag() << " has zero length\n";
	return;
      }
	
	cosX[0] = dx/L;
	cosX[1] = dy/L;
	cosX[2] = dz/L;	
    }

    // create the load vector
    if (theLoad == 0)
      theLoad = new Vector(numDOF);
    else if (theLoad->Size() != numDOF) {
      delete theLoad;
      theLoad = new Vector(numDOF);
    }

    if (theLoad == 0) {
      opserr << "TrussSection::setDomain - truss " << this->getTag() << 
	"out of memory creating vector of size" << numDOF << endln;
      exit(-1);
      return;
    }          
    
    this->update();
}   	 
Exemple #4
0
int
TrussSection::displaySelf(Renderer &theViewer, int displayMode, float fact)
{
    // ensure setDomain() worked
    if (L == 0.0)
       return 0;

    // first determine the two end points of the truss based on
    // the display factor (a measure of the distorted image)
    // store this information in 2 3d vectors v1 and v2
    const Vector &end1Crd = theNodes[0]->getCrds();
    const Vector &end2Crd = theNodes[1]->getCrds();	

    static Vector v1(3);
    static Vector v2(3);

    if (displayMode == 1 || displayMode == 2) {
      const Vector &end1Disp = theNodes[0]->getDisp();
      const Vector &end2Disp = theNodes[1]->getDisp();    

      for (int i=0; i<dimension; i++) {
	v1(i) = end1Crd(i)+end1Disp(i)*fact;
	v2(i) = end2Crd(i)+end2Disp(i)*fact;    
      }
      
      // compute the strain and axial force in the member
      double strain, force;
      if (L == 0.0) {
	strain = 0.0;
	force = 0.0;
      } else {
	strain = this->computeCurrentStrain();
    force = 0.0;
	
	int order = theSection->getOrder();
	const ID &code = theSection->getType();
	
	Vector e (order);
	
	int i;
	for (i = 0; i < order; i++) {
	  if (code(i) == SECTION_RESPONSE_P)
	    e(i) = strain;
	}
	
	theSection->setTrialSectionDeformation(e);
	
	const Vector &s = theSection->getStressResultant();
	for (i = 0; i < order; i++) {
	  if (code(i) == SECTION_RESPONSE_P)
	    force += s(i);
	}
      }
      
      if (displayMode == 2) // use the strain as the drawing measure
	return theViewer.drawLine(v1, v2, (float)strain, (float)strain);	
      else { // otherwise use the axial force as measure
	return theViewer.drawLine(v1,v2, (float)force, (float)force);
      }
    } else if (displayMode < 0) {
      int mode = displayMode  *  -1;
      const Matrix &eigen1 = theNodes[0]->getEigenvectors();
      const Matrix &eigen2 = theNodes[1]->getEigenvectors();
      if (eigen1.noCols() >= mode) {
	for (int i = 0; i < dimension; i++) {
	  v1(i) = end1Crd(i) + eigen1(i,mode-1)*fact;
	  v2(i) = end2Crd(i) + eigen2(i,mode-1)*fact;    
	}    
      } else {
	for (int i = 0; i < dimension; i++) {
	  v1(i) = end1Crd(i);
	  v2(i) = end2Crd(i);
	}    
      }
    }
    return 0;
}
Exemple #5
0
int
NineNodeMixedQuad::displaySelf(Renderer &theViewer, int displayMode, float fact)
{
    // first determine the end points of the quad based on
    // the display factor (a measure of the distorted image)
    // store this information in 4 3d vectors v1 through v4
    const Vector &end1Crd = nodePointers[0]->getCrds();
    const Vector &end2Crd = nodePointers[4]->getCrds();	
    const Vector &end3Crd = nodePointers[1]->getCrds();	
    const Vector &end4Crd = nodePointers[5]->getCrds();	
    const Vector &end5Crd = nodePointers[2]->getCrds();
    const Vector &end6Crd = nodePointers[6]->getCrds();	
    const Vector &end7Crd = nodePointers[3]->getCrds();	
    const Vector &end8Crd = nodePointers[7]->getCrds();	

    const Vector &end1Disp = nodePointers[0]->getDisp();
    const Vector &end2Disp = nodePointers[4]->getDisp();
    const Vector &end3Disp = nodePointers[1]->getDisp();
    const Vector &end4Disp = nodePointers[5]->getDisp();
    const Vector &end5Disp = nodePointers[2]->getDisp();
    const Vector &end6Disp = nodePointers[6]->getDisp();
    const Vector &end7Disp = nodePointers[3]->getDisp();
    const Vector &end8Disp = nodePointers[7]->getDisp();


    static Matrix coords(8,3) ;
    static Vector values(8) ;
    static Vector P(8) ;

    coords.Zero( ) ;

    values(0) = 1 ;
    values(1) = 1 ;
    values(2) = 1 ;
    values(3) = 1 ;
    values(4) = 1 ;
    values(5) = 1 ;
    values(6) = 1 ;
    values(7) = 1 ;


    if (displayMode < 3 && displayMode > 0)
      P = this->getResistingForce();

    for (int i = 0; i < 2; i++) {
      coords(0,i) = end1Crd(i) + end1Disp(i)*fact;
      coords(1,i) = end2Crd(i) + end2Disp(i)*fact;    
      coords(2,i) = end3Crd(i) + end3Disp(i)*fact;    
      coords(3,i) = end4Crd(i) + end4Disp(i)*fact;    
      coords(4,i) = end5Crd(i) + end5Disp(i)*fact;
      coords(5,i) = end6Crd(i) + end6Disp(i)*fact;    
      coords(6,i) = end7Crd(i) + end7Disp(i)*fact;    
      coords(7,i) = end8Crd(i) + end8Disp(i)*fact;    
      /*      if (displayMode < 3 && displayMode > 0)
	values(i) = P(displayMode*2+i);
      else
      values(i) = 1;  */
    }

    //opserr << coords;
    int error = 0;

    error += theViewer.drawPolygon (coords, values);

    return error;
}
Exemple #6
0
int
ShellMITC9::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **modes, int numMode)
{
  // first determine the end points of the quad based on
  // the display factor (a measure of the distorted image)
  // store this information in 4 3d vectors v1 through v4
  const Vector &end1Crd = nodePointers[0]->getCrds();
  const Vector &end2Crd = nodePointers[1]->getCrds();	
  const Vector &end3Crd = nodePointers[2]->getCrds();	
  const Vector &end4Crd = nodePointers[3]->getCrds();
  static Matrix coords(4,3);
  static Vector values(4);
  static Vector P(54) ;

  for (int j=0; j<9; j++)
    values(j) = 0.0;

  if (displayMode >= 0) {
    const Vector &end1Disp = nodePointers[0]->getDisp();
    const Vector &end2Disp = nodePointers[1]->getDisp();
    const Vector &end3Disp = nodePointers[2]->getDisp();
    const Vector &end4Disp = nodePointers[3]->getDisp();

    if (displayMode < 8 && displayMode > 0) {
      for (int i=0; i<4; i++) {
        const Vector &stress = materialPointers[i]->getStressResultant();
        values(i) = stress(displayMode-1);
	  }
    }

    for (int i = 0; i < 3; i++) {
	  coords(0,i) = end1Crd(i) + end1Disp(i)*fact;
	  coords(1,i) = end2Crd(i) + end2Disp(i)*fact;    
	  coords(2,i) = end3Crd(i) + end3Disp(i)*fact;    
	  coords(3,i) = end4Crd(i) + end4Disp(i)*fact;
    }
  } else {
    int mode = displayMode * -1;
    const Matrix &eigen1 = nodePointers[0]->getEigenvectors();
    const Matrix &eigen2 = nodePointers[1]->getEigenvectors();
    const Matrix &eigen3 = nodePointers[2]->getEigenvectors();
    const Matrix &eigen4 = nodePointers[3]->getEigenvectors();
	if (eigen1.noCols() >= mode) {
	  for (int i = 0; i < 3; i++) {
	    coords(0,i) = end1Crd(i) + eigen1(i,mode-1)*fact;
	    coords(1,i) = end2Crd(i) + eigen2(i,mode-1)*fact;
	    coords(2,i) = end3Crd(i) + eigen3(i,mode-1)*fact;
	    coords(3,i) = end4Crd(i) + eigen4(i,mode-1)*fact;
	  }    
	} else {
	  for (int i = 0; i < 3; i++) {
	    coords(0,i) = end1Crd(i);
	    coords(1,i) = end2Crd(i);
	    coords(2,i) = end3Crd(i);
	    coords(3,i) = end4Crd(i);
	  }    
	}
  }
  int error = 0;
  error += theViewer.drawPolygon (coords, values);
  return error;
}
int
ConstantPressureVolumeQuad::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **mode, int numModes)
{
    // first determine the end points of the quad based on
    // the display factor (a measure of the distorted image)
    // store this information in 4 3d vectors v1 through v4
    const Vector &end1Crd = nodePointers[0]->getCrds();
    const Vector &end2Crd = nodePointers[1]->getCrds();	
    const Vector &end3Crd = nodePointers[2]->getCrds();	
    const Vector &end4Crd = nodePointers[3]->getCrds();	

    static Matrix coords(4,3) ;
    static Vector values(4) ;

    coords.Zero( ) ;

    values(0) = 1 ;
    values(1) = 1 ;
    values(2) = 1 ;
    values(3) = 1 ;


    if (displayMode >= 0) {    
      
      const Vector &end1Disp = nodePointers[0]->getDisp();
      const Vector &end2Disp = nodePointers[1]->getDisp();
      const Vector &end3Disp = nodePointers[2]->getDisp();
      const Vector &end4Disp = nodePointers[3]->getDisp();

      for (int i = 0; i < 2; i++) {
	coords(0,i) = end1Crd(i) + end1Disp(i)*fact;
	coords(1,i) = end2Crd(i) + end2Disp(i)*fact;    
	coords(2,i) = end3Crd(i) + end3Disp(i)*fact;    
	coords(3,i) = end4Crd(i) + end4Disp(i)*fact;    
      }
    } else {
      int mode = displayMode  *  -1;
      const Matrix &eigen1 = nodePointers[0]->getEigenvectors();
      const Matrix &eigen2 = nodePointers[1]->getEigenvectors();
      const Matrix &eigen3 = nodePointers[2]->getEigenvectors();
      const Matrix &eigen4 = nodePointers[3]->getEigenvectors();
      if (eigen1.noCols() >= mode) {
	for (int i = 0; i < 2; i++) {
	  coords(0,i) = end1Crd(i) + eigen1(i,mode-1)*fact;
	  coords(1,i) = end2Crd(i) + eigen2(i,mode-1)*fact;
	  coords(2,i) = end3Crd(i) + eigen3(i,mode-1)*fact;
	  coords(3,i) = end4Crd(i) + eigen4(i,mode-1)*fact;
	}    
      } else {
	for (int i = 0; i < 2; i++) {
	  coords(0,i) = end1Crd(i);
	  coords(1,i) = end2Crd(i);
	  coords(2,i) = end3Crd(i);
	  coords(3,i) = end4Crd(i);
	}    
      }
    }

    //opserr << coords;
    int error = 0;

    error += theViewer.drawPolygon (coords, values);

    return error;
}
Exemple #8
0
int
BbarBrick::displaySelf(Renderer &theViewer, int displayMode, float fact)
{

    const Vector &end1Crd = nodePointers[0]->getCrds();
    const Vector &end2Crd = nodePointers[1]->getCrds();
    const Vector &end3Crd = nodePointers[2]->getCrds();
    const Vector &end4Crd = nodePointers[3]->getCrds();

    const Vector &end5Crd = nodePointers[4]->getCrds();
    const Vector &end6Crd = nodePointers[5]->getCrds();
    const Vector &end7Crd = nodePointers[6]->getCrds();
    const Vector &end8Crd = nodePointers[7]->getCrds();

    static Matrix coords(4,3);
    static Vector values(4);
    static Vector P(24) ;

    values(0) = 1 ;
    values(1) = 1 ;
    values(2) = 1 ;
    values(3) = 1 ;

    int error = 0;
    int i;

    if (displayMode >= 0) {
      const Vector &end1Disp = nodePointers[0]->getDisp();
      const Vector &end2Disp = nodePointers[1]->getDisp();
      const Vector &end3Disp = nodePointers[2]->getDisp();
      const Vector &end4Disp = nodePointers[3]->getDisp();

      const Vector &end5Disp = nodePointers[4]->getDisp();
      const Vector &end6Disp = nodePointers[5]->getDisp();
      const Vector &end7Disp = nodePointers[6]->getDisp();
      const Vector &end8Disp = nodePointers[7]->getDisp();

      if (displayMode < 3 && displayMode > 0)
	P = this->getResistingForce();

      for (i = 0; i < 3; i++) {
	coords(0,i) = end1Crd(i) + end1Disp(i)*fact;
	coords(1,i) = end2Crd(i) + end2Disp(i)*fact;
	coords(2,i) = end3Crd(i) + end3Disp(i)*fact;
	coords(3,i) = end4Crd(i) + end4Disp(i)*fact;
      }
      error += theViewer.drawPolygon (coords, values);

      for (i = 0; i < 3; i++) {
	coords(0,i) = end5Crd(i) + end5Disp(i)*fact;
	coords(1,i) = end6Crd(i) + end6Disp(i)*fact;
	coords(2,i) = end7Crd(i) + end7Disp(i)*fact;
	coords(3,i) = end8Crd(i) + end8Disp(i)*fact;
      }
      error += theViewer.drawPolygon (coords, values);

      for (i = 0; i < 3; i++) {
	coords(0,i) = end1Crd(i) + end1Disp(i)*fact;
	coords(1,i) = end4Crd(i) + end4Disp(i)*fact;
	coords(2,i) = end8Crd(i) + end8Disp(i)*fact;
	coords(3,i) = end5Crd(i) + end5Disp(i)*fact;
      }
      error += theViewer.drawPolygon (coords, values);

      for (i = 0; i < 3; i++) {
	coords(0,i) = end2Crd(i) + end2Disp(i)*fact;
	coords(1,i) = end3Crd(i) + end3Disp(i)*fact;
	coords(2,i) = end7Crd(i) + end7Disp(i)*fact;
	coords(3,i) = end6Crd(i) + end6Disp(i)*fact;
      }
      error += theViewer.drawPolygon (coords, values);


      for (i = 0; i < 3; i++) {
	coords(0,i) = end1Crd(i) + end1Disp(i)*fact;
	coords(1,i) = end2Crd(i) + end2Disp(i)*fact;
	coords(2,i) = end6Crd(i) + end6Disp(i)*fact;
	coords(3,i) = end5Crd(i) + end5Disp(i)*fact;
      }
      error += theViewer.drawPolygon (coords, values);

      for (i = 0; i < 3; i++) {
	coords(0,i) = end4Crd(i) + end4Disp(i)*fact;
	coords(1,i) = end3Crd(i) + end3Disp(i)*fact;
	coords(2,i) = end7Crd(i) + end7Disp(i)*fact;
	coords(3,i) = end8Crd(i) + end8Disp(i)*fact;
      }
      error += theViewer.drawPolygon (coords, values);

    } else {
      int mode = displayMode  *  -1;

      const Matrix &eigen1 = nodePointers[0]->getEigenvectors();
      const Matrix &eigen2 = nodePointers[1]->getEigenvectors();
      const Matrix &eigen3 = nodePointers[2]->getEigenvectors();
      const Matrix &eigen4 = nodePointers[3]->getEigenvectors();
      const Matrix &eigen5 = nodePointers[4]->getEigenvectors();
      const Matrix &eigen6 = nodePointers[5]->getEigenvectors();
      const Matrix &eigen7 = nodePointers[6]->getEigenvectors();
      const Matrix &eigen8 = nodePointers[7]->getEigenvectors();

      if (eigen1.noCols() >= mode) {

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end1Crd(i) + eigen1(i,mode-1)*fact;
	  coords(1,i) = end2Crd(i) + eigen2(i,mode-1)*fact;
	  coords(2,i) = end3Crd(i) + eigen3(i,mode-1)*fact;
	  coords(3,i) = end4Crd(i) + eigen4(i,mode-1)*fact;
	}

	error += theViewer.drawPolygon (coords, values);

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end5Crd(i) + eigen5(i,mode-1)*fact;
	  coords(1,i) = end6Crd(i) + eigen6(i,mode-1)*fact;
	  coords(2,i) = end7Crd(i) + eigen7(i,mode-1)*fact;
	  coords(3,i) = end8Crd(i) + eigen8(i,mode-1)*fact;
	}

	error += theViewer.drawPolygon (coords, values);

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end1Crd(i) + eigen1(i,mode-1)*fact;
	  coords(1,i) = end4Crd(i) + eigen4(i,mode-1)*fact;
	  coords(2,i) = end8Crd(i) + eigen8(i,mode-1)*fact;
	  coords(3,i) = end5Crd(i) + eigen5(i,mode-1)*fact;
	}

	error += theViewer.drawPolygon (coords, values);

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end2Crd(i) + eigen2(i,mode-1)*fact;
	  coords(1,i) = end3Crd(i) + eigen3(i,mode-1)*fact;
	  coords(2,i) = end7Crd(i) + eigen7(i,mode-1)*fact;
	  coords(3,i) = end6Crd(i) + eigen6(i,mode-1)*fact;
	}

	error += theViewer.drawPolygon (coords, values);


	for (i = 0; i < 3; i++) {
	  coords(0,i) = end1Crd(i) + eigen1(i,mode-1)*fact;
	  coords(1,i) = end2Crd(i) + eigen2(i,mode-1)*fact;
	  coords(2,i) = end6Crd(i) + eigen6(i,mode-1)*fact;
	  coords(3,i) = end5Crd(i) + eigen5(i,mode-1)*fact;
	}

	error += theViewer.drawPolygon (coords, values);

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end4Crd(i) + eigen4(i,mode-1)*fact;
	  coords(1,i) = end3Crd(i) + eigen3(i,mode-1)*fact;
	  coords(2,i) = end7Crd(i) + eigen7(i,mode-1)*fact;
	  coords(3,i) = end8Crd(i) + eigen8(i,mode-1)*fact;
	}

	error += theViewer.drawPolygon (coords, values);
      } else {
	values.Zero();
	for (i = 0; i < 3; i++) {
	  coords(0,i) = end1Crd(i);
	  coords(1,i) = end2Crd(i);
	  coords(2,i) = end3Crd(i);
	  coords(3,i) = end4Crd(i);
	}

	error += theViewer.drawPolygon (coords, values);

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end5Crd(i);
	  coords(1,i) = end6Crd(i);
	  coords(2,i) = end7Crd(i);
	  coords(3,i) = end8Crd(i);
	}

	error += theViewer.drawPolygon (coords, values);

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end1Crd(i);
	  coords(1,i) = end4Crd(i);
	  coords(2,i) = end8Crd(i);
	  coords(3,i) = end5Crd(i);
	}

	error += theViewer.drawPolygon (coords, values);

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end2Crd(i);
	  coords(1,i) = end3Crd(i);
	  coords(2,i) = end7Crd(i);
	  coords(3,i) = end6Crd(i);
	}

	error += theViewer.drawPolygon (coords, values);


	for (i = 0; i < 3; i++) {
	  coords(0,i) = end1Crd(i);
	  coords(1,i) = end2Crd(i);
	  coords(2,i) = end6Crd(i);
	  coords(3,i) = end5Crd(i);
	}

	error += theViewer.drawPolygon (coords, values);

	for (i = 0; i < 3; i++) {
	  coords(0,i) = end4Crd(i);
	  coords(1,i) = end3Crd(i);
	  coords(2,i) = end7Crd(i);
	  coords(3,i) = end8Crd(i);
	}

	error += theViewer.drawPolygon (coords, values);
      }
    }

    return error;
}
Exemple #9
0
int
N4BiaxialTruss::displaySelf(Renderer &theViewer, int displayMode, float fact)
{
	// ensure setDomain() worked
	if (L == 0.0)
	return 0;

	// first determine the two end points of the N4BiaxialTruss based on
	// the display factor (a measure of the distorted image)
	// store this information in 2 3d vectors v1 and v2
	const Vector &end1Crd = theNodes[0]->getCrds();
	const Vector &end2Crd = theNodes[1]->getCrds();	
	const Vector &end3Crd = theNodes[3]->getCrds();	
	const Vector &end4Crd = theNodes[4]->getCrds();	

	static Vector v1(3);
	static Vector v2(3);
	static Vector v3(3);
	static Vector v4(3);
	
	int retVal = 0;

	if (displayMode == 1 || displayMode == 2) {
		const Vector &end1Disp = theNodes[0]->getDisp();
		const Vector &end2Disp = theNodes[1]->getDisp();    
		const Vector &end3Disp = theNodes[3]->getDisp();   
		const Vector &end4Disp = theNodes[4]->getDisp();   

		for (int i=0; i<dimension; i++) {
			v1(i) = end1Crd(i)+end1Disp(i)*fact;
			v2(i) = end2Crd(i)+end2Disp(i)*fact;    
			v3(i) = end3Crd(i)+end3Disp(i)*fact;    
			v4(i) = end4Crd(i)+end4Disp(i)*fact;    
		}
		
		// compute the strain and axial force in the member
		double force1, force2;
		if (L == 0.0) {
			strain_1 = 0.0;
			strain_2 = 0.0;
			force1 = 0.0;
			force2 = 0.0;
		} else {
			this->computeCurrentStrainBiaxial();
			theMaterial_1->setTrialStrain(strain_1);
			theMaterial_2->setTrialStrain(strain_2);
			force1 = A*theMaterial_1->getStress();    
			force2 = A*theMaterial_2->getStress();    
		}
		
		if (displayMode == 2) {// use the strain as the drawing measure
			retVal += theViewer.drawLine(v1, v2, (float)strain_1, (float)strain_1);	
			retVal += theViewer.drawLine(v3, v4, (float)strain_2, (float)strain_2);	
		} else { // otherwise use the axial force as measure
			retVal += theViewer.drawLine(v1, v2, (float)force1, (float)force1);	
			retVal += theViewer.drawLine(v3, v4, (float)force2, (float)force2);	
		}
		return retVal;
	} else if (displayMode < 0) {
		int mode = displayMode  *  -1;
		const Matrix &eigen1 = theNodes[0]->getEigenvectors();
		const Matrix &eigen2 = theNodes[1]->getEigenvectors();
		const Matrix &eigen3 = theNodes[3]->getEigenvectors();
		const Matrix &eigen4 = theNodes[4]->getEigenvectors();
		if (eigen1.noCols() >= mode) {
			for (int i = 0; i < dimension; i++) {
				v1(i) = end1Crd(i) + eigen1(i,mode-1)*fact;
				v2(i) = end2Crd(i) + eigen2(i,mode-1)*fact;    
				v3(i) = end3Crd(i) + eigen3(i,mode-1)*fact;    
				v4(i) = end4Crd(i) + eigen4(i,mode-1)*fact;    
			}    
		} else {
			for (int i = 0; i < dimension; i++) {
				v1(i) = end1Crd(i);
				v2(i) = end2Crd(i);
				v3(i) = end3Crd(i);
				v4(i) = end4Crd(i);
			}    
		}
		retVal += theViewer.drawLine(v1, v2, 1.0, 1.0);	
		retVal += theViewer.drawLine(v3, v4, 1.0, 1.0);	
		return retVal;
	}
	return 0;
}