Пример #1
0
int
Truss2::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **modes, int numMode)
{
	// 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();
			theMaterial->setTrialStrain(strain);
			force = A*theMaterial->getStress();    
		}

		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 theViewer.drawLine(v1, v2, 1.0, 1.0);	
	}
	return 0;
}
Пример #2
0
int Adapter::displaySelf(Renderer &theViewer,
    int displayMode, float fact)
{
    int rValue = 0, i, j;
    
    if (numExternalNodes > 1)  {
        if (displayMode >= 0)  {
            for (i=0; i<numExternalNodes-1; i++)  {
                const Vector &end1Crd = theNodes[i]->getCrds();
                const Vector &end2Crd = theNodes[i+1]->getCrds();
                
                const Vector &end1Disp = theNodes[i]->getDisp();
                const Vector &end2Disp = theNodes[i+1]->getDisp();
                
                int end1NumCrds = end1Crd.Size();
                int end2NumCrds = end2Crd.Size();
                
                static Vector v1(3), v2(3);
                
                for (j=0; j<end1NumCrds; j++)
                    v1(j) = end1Crd(j) + end1Disp(j)*fact;
                for (j=0; j<end2NumCrds; j++)
                    v2(j) = end2Crd(j) + end2Disp(j)*fact;
                
                rValue += theViewer.drawLine(v1, v2, 1.0, 1.0);
            }
        } else  {
            int mode = displayMode * -1;
            for (i=0; i<numExternalNodes-1; i++)  {
                const Vector &end1Crd = theNodes[i]->getCrds();
                const Vector &end2Crd = theNodes[i+1]->getCrds();
                
                const Matrix &eigen1 = theNodes[i]->getEigenvectors();
                const Matrix &eigen2 = theNodes[i+1]->getEigenvectors();
                
                int end1NumCrds = end1Crd.Size();
                int end2NumCrds = end2Crd.Size();
                
                static Vector v1(3), v2(3);
                
                if (eigen1.noCols() >= mode)  {
                    for (j=0; j<end1NumCrds; j++)
                        v1(j) = end1Crd(j) + eigen1(j,mode-1)*fact;
                    for (j=0; j<end2NumCrds; j++)
                        v2(j) = end2Crd(j) + eigen2(j,mode-1)*fact;
                } else  {
                    for (j=0; j<end1NumCrds; j++)
                        v1(j) = end1Crd(j);
                    for (j=0; j<end2NumCrds; j++)
                        v2(j) = end2Crd(j);
                }
                
                rValue += theViewer.drawLine(v1, v2, 1.0, 1.0);
            }
        }
    }
    
    return rValue;
}
Пример #3
0
int
PFEMElement2D::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **displayModes, int numModes) 
{

  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;
}
Пример #4
0
int
CoupledZeroLength::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **modes, int numMode)
{
    // ensure setDomain() worked
    if (theNodes[0] == 0 || theNodes[1] == 0 )
       return 0;

    // first determine the two end points of the CoupledZeroLength 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 &end1Disp = theNodes[0]->getDisp();
    const Vector &end2Disp = theNodes[1]->getDisp();    

    if (displayMode == 1 || displayMode == 2) {
	Vector v1(3);
	Vector v2(3);
	for (int i=0; i<dimension; i++) {
	    v1(i) = end1Crd(i)+end1Disp(i)*fact;
	    v2(i) = end2Crd(i)+end2Disp(i)*fact;    
	}
	
	// don't display strain or force
	double strain = 0.0;
	double force  = 0.0;
    
	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);
	}
    }
    return 0;
}
Пример #5
0
int
ZeroLengthSection::displaySelf(Renderer &theViewer, int displayMode, float fact)
{
    // ensure setDomain() worked
    if (theNodes[0] == 0 || theNodes[1] == 0)
		return 0;

    // first determine the two end points of the ZeroLengthSection 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 &end1Disp = theNodes[0]->getDisp();
    const Vector &end2Disp = theNodes[1]->getDisp();    

    if (displayMode == 1 || displayMode == 2) {
		static Vector v1(3);
		static Vector v2(3);
		for (int i = 0; i < dimension; i++) {
			v1(i) = end1Crd(i)+end1Disp(i)*fact;
			v2(i) = end2Crd(i)+end2Disp(i)*fact;    
		}
		
		return theViewer.drawLine(v1, v2, 0.0, 0.0);
    }

    return 0;
}
Пример #6
0
int SingleFPSimple2d::displaySelf(Renderer &theViewer,
    int displayMode, float fact)
{
    int errCode = 0;

    // first determine the end points of the element based on
    // the display factor (a measure of the distorted image)
    const Vector &end1Crd = theNodes[0]->getCrds();
    const Vector &end2Crd = theNodes[1]->getCrds();
    Vector xp = end2Crd - end1Crd;
    
    static Vector v1(3);
    static Vector v2(3);
    static Vector v3(3);

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

        for (int i=0; i<2; i++)  {
            v1(i) = end1Crd(i) + end1Disp(i)*fact;
            v3(i) = end2Crd(i) + end2Disp(i)*fact;
        }
        v2(0) = end1Crd(0) + (end2Disp(0) + xp(1)*end2Disp(2))*fact;
        v2(1) = end1Crd(1) + (end2Disp(1) - xp(0)*end2Disp(2))*fact;
    } else  {
        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<2; i++)  {
                v1(i) = end1Crd(i) + eigen1(i,mode-1)*fact;
                v3(i) = end2Crd(i) + eigen2(i,mode-1)*fact;
            }
            v2(0) = end1Crd(0) + (eigen2(0,mode-1) + xp(1)*eigen2(2,mode-1))*fact;
            v2(1) = end1Crd(1) + (eigen2(1,mode-1) - xp(0)*eigen2(2,mode-1))*fact;
        } else  {
            for (int i=0; i<2; i++)  {
                v1(i) = end1Crd(i);
                v2(i) = end1Crd(i);
                v3(i) = end2Crd(i);
            }
        }
    }

    errCode += theViewer.drawLine (v1, v2, 1.0, 1.0);
    errCode += theViewer.drawLine (v2, v3, 1.0, 1.0);

    return errCode;
}
int ElastomericBearingBoucWen2d::displaySelf(Renderer &theViewer,
    int displayMode, float fact)
{
    // first determine the end points of the element based on
    // the display factor (a measure of the distorted image)
    const Vector &end1Crd = theNodes[0]->getCrds();
    const Vector &end2Crd = theNodes[1]->getCrds();
    
    static Vector v1(3);
    static Vector v2(3);
    
    if (displayMode >= 0)  {
        const Vector &end1Disp = theNodes[0]->getDisp();
        const Vector &end2Disp = theNodes[1]->getDisp();
        
        for (int i=0; i<2; i++)  {
            v1(i) = end1Crd(i) + end1Disp(i)*fact;
            v2(i) = end2Crd(i) + end2Disp(i)*fact;
        }
    } else  {
        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<2; 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<2; i++)  {
                v1(i) = end1Crd(i);
                v2(i) = end2Crd(i);
            }
        }
    }
    
    return theViewer.drawLine (v1, v2, 1.0, 1.0);
}
Пример #8
0
int
FourNodeQuadUP::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **argv, 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(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 = nd1Ptr->getCrds();
    const Vector &end2Crd = nd2Ptr->getCrds();
    const Vector &end3Crd = nd3Ptr->getCrds();
    const Vector &end4Crd = nd4Ptr->getCrds();

    const Vector &end1Disp = nd1Ptr->getDisp();
    const Vector &end2Disp = nd2Ptr->getDisp();
    const Vector &end3Disp = nd3Ptr->getDisp();
    const Vector &end4Disp = nd4Ptr->getDisp();

    static Matrix coords(4,3);

    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;
    }

    int error = 0;

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

    return error;
}
Пример #9
0
int EETrussCorot::displaySelf(Renderer &theViewer,
    int displayMode, float fact)
{
    // first determine the end points of the element based on
    // the display factor (a measure of the distorted image)
    const Vector &end1Crd = theNodes[0]->getCrds();
    const Vector &end2Crd = theNodes[1]->getCrds();
    
    const Vector &end1Disp = theNodes[0]->getDisp();
    const Vector &end2Disp = theNodes[1]->getDisp();
    
    static Vector v1(3);
    static Vector v2(3);
    
    for (int i=0; i<numDIM; i++)  {
        v1(i) = end1Crd(i) + end1Disp(i)*fact;
        v2(i) = end2Crd(i) + end2Disp(i)*fact;
    }
    
    return theViewer.drawLine (v1, v2, 1.0, 1.0);
}
Пример #10
0
int
beam2d02::displaySelf(Renderer &theViewer, int displayMode, float fact)
{
    // 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();	
    const Vector &end1Disp = theNodes[0]->getDisp();
    const Vector &end2Disp = theNodes[1]->getDisp();    

    if (displayMode == 1 || displayMode == 2) {
	Vector v1(3);
	Vector v2(3);
	for (int i=0; i<2; i++) {
	    v1(i) = end1Crd(i)+end1Disp(i)*fact;
	    v2(i) = end2Crd(i)+end2Disp(i)*fact;    
	}
	
	return theViewer.drawLine(v1, v2, 1.0,1.0);	
    } else 
	return 0;
}
Пример #11
0
int
CorotTruss::displaySelf(Renderer &theViewer, int displayMode, float fact)
{
	// ensure setDomain() worked
	if (Ln == 0.0)
		return 0;

	// first determine the two end points of the CorotTruss 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 &end1Disp = theNodes[0]->getDisp();
	const Vector &end2Disp = theNodes[1]->getDisp();    

	static Vector v1(3);
	static Vector v2(3);
	for (int i = 0; i < numDIM; i++) {
		v1(i) = end1Crd(i)+end1Disp(i)*fact;
		v2(i) = end2Crd(i)+end2Disp(i)*fact;    
	}

	return theViewer.drawLine(v1, v2, 1.0, 1.0);
}
Пример #12
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;
}
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;
}
Пример #14
0
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
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;
}
Пример #16
0
// method: setDomain()
//    to set a link to the enclosing XC::Domain and to set the node pointers.
//    also determines the number of dof associated
//    with the XC::CorotTruss element, we set matrix and vector pointers,
//    allocate space for t matrix, determine the length
//    and set the transformation matrix.
void XC::CorotTruss::setDomain(Domain *theDomain)
  {
    // check Domain is not null - invoked when object removed from a domain
    CorotTrussBase::setDomain(theDomain);
    if(!theDomain)
      {
        Lo= 0.0;
        Ln= 0.0;
        return;
      }

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

    // if differing dof at the ends - print a warning message
    if(dofNd1 != dofNd2)
      {
        std::cerr << getClassName() << "::" << __FUNCTION__
		  << "WARNING; nodes " << theNodes[0]->getTag()
		  << " and " << theNodes[1]->getTag()
		  << "have differing dof at ends for CorotTruss element: "
		  << this->getTag() << std::endl;
        // fill this in so don't segment fault later
        numDOF = 6;
        return;
      }

    setup_matrix_vector_ptrs(dofNd1);

    // 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();

    // Determine global offsets
    double cosX[3];
    cosX[0] = 0.0;  cosX[1] = 0.0;  cosX[2] = 0.0;
    int i;
    for(i = 0; i < getNumDIM(); i++)
      { cosX[i] += end2Crd(i)-end1Crd(i); }

    // Set undeformed and initial length
    Lo= cosX[0]*cosX[0] + cosX[1]*cosX[1] + cosX[2]*cosX[2];
    Lo= sqrt(Lo);
    Ln= Lo;
    CableMaterial *ptrCableMaterial= dynamic_cast<CableMaterial *>(theMaterial);
    if(ptrCableMaterial)
      ptrCableMaterial->setLength(Ln);
   

    // Initial offsets
    d21[0] = Lo;
    d21[1] = 0.0;
    d21[2] = 0.0;

    // Set global orientation
    cosX[0] /= Lo;
    cosX[1] /= Lo;
    cosX[2] /= Lo;

    R(0,0) = cosX[0];
    R(0,1) = cosX[1];
    R(0,2) = cosX[2];

    // Element lies outside the YZ plane
    if(fabs(cosX[0]) > 0.0)
      {
        R(1,0) = -cosX[1];
        R(1,1) =  cosX[0];
        R(1,2) =  0.0;

        R(2,0) = -cosX[0]*cosX[2];
        R(2,1) = -cosX[1]*cosX[2];
        R(2,2) =  cosX[0]*cosX[0] + cosX[1]*cosX[1];
      } // Element is in the YZ plane
    else
      {
        R(1,0) =  0.0;
        R(1,1) = -cosX[2];
        R(1,2) =  cosX[1];

        R(2,0) =  1.0;
        R(2,1) =  0.0;
        R(2,2) =  0.0;
      }

    // Orthonormalize last two rows of R
    double norm;
    for(i = 1; i < 3; i++)
      {
        norm = sqrt(R(i,0)*R(i,0) + R(i,1)*R(i,1) + R(i,2)*R(i,2));
        R(i,0) /= norm;
        R(i,1) /= norm;
        R(i,2) /= norm;
      }
  }
Пример #17
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;
}
Пример #18
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();
}   	 
Пример #19
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
PY_Macro2D::setDomain(Domain *theDomain)
{
  // check Domain is not null - invoked when object removed from a domain
  if (theDomain == 0) {
    theNodes[0] = 0;
    theNodes[1] = 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 can't find both - send a warning message
  if ((theNodes[0] == 0) || (theNodes[1] == 0)) {
    if (theNodes[0] == 0)
      opserr <<"PY_Macro2D::setDomain() - truss" << this->getTag() << " node " << Nd1 <<
	"does not exist in the model\n";
    else
      opserr <<"PY_Macro2D::setDomain() - truss" << this->getTag() << " node " << Nd2 <<
	"does not exist in the model\n";

    return;
  }

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

  if (dofNd1 != 2) {		//!!!!!!!!!!!!!
    opserr <<"WARNING PY_Macro2D::setDomain(): node 1: " << Nd1 << " needs 3 dof\n ";
    return;
  }

  if (dofNd2 != 2) {
    opserr <<"WARNING PY_Macro2D::setDomain(): node 2: " << Nd2 << " needs 2 dof\n ";
    return;
  }

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

   // now determine the length & transformation matrix
    const Vector &end1Crd = theNodes[0]->getCrds();
    const Vector &end2Crd = theNodes[1]->getCrds();

    double dx = end2Crd(0)-end1Crd(0);
    double dy = end2Crd(1)-end1Crd(1);

    double L = sqrt(dx*dx + dy*dy);

    if (L == 0.0) {
      opserr << "WARNING PY_Macro2D::setDomain() - PY_Macro2D " << this->getTag() <<
	" has zero length\n";
      return;  // don't go any further - otherwise divide by 0 error
    }

    double cs = dx/L;
    double sn = dy/L;

    trans(0,0) = -cs;
    trans(0,1) = -sn;
    trans(0,2) = cs;
    trans(0,3) = sn;
}
Пример #20
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 N4BiaxialTruss element, we set matrix and vector pointers,
//    allocate space for t matrix, determine the length
//    and set the transformation matrix.
void
N4BiaxialTruss::setDomain(Domain *theDomain)
{
	// check Domain is not null - invoked when object removed from a domain
	if (theDomain == 0) {
		theNodes[0] = 0;
		theNodes[1] = 0;
		theNodes[2] = 0;
		theNodes[3] = 0;
		L = 0;
		return;
	}

	// first set the node pointers
	int Nd1 = connectedExternalNodes(0);
	int Nd2 = connectedExternalNodes(1);
	int GNd1 = connectedExternalNodes(2);
	int GNd2 = connectedExternalNodes(3);
	theNodes[0] = theDomain->getNode(Nd1);
	theNodes[1] = theDomain->getNode(Nd2);	
	theNodes[2] = theDomain->getNode(GNd1);	
	theNodes[3] = theDomain->getNode(GNd2);	
	
	// if can't find the nodes - send a warning message
	if ((theNodes[0] == 0)) {
		opserr <<"N4BiaxialTruss::setDomain() - N4BiaxialTruss" << this->getTag() << " node " << Nd1 <<
		"does not exist in the model\n";
		
		// fill this in so don't segment fault later
		numDOF = 2;    
		theMatrix = &trussM2;
		theVector = &trussV2;	
		theVector2 = &trussV2;	
		return;
	} else if ((theNodes[1] == 0)) {
		opserr <<"N4BiaxialTruss::setDomain() - N4BiaxialTruss" << this->getTag() << " node " << Nd2 <<
		"does not exist in the model\n";
		
		// fill this in so don't segment fault later
		numDOF = 2;    
		theMatrix = &trussM2;
		theVector = &trussV2;	
		theVector2 = &trussV2;	
		return;
	} else if ((theNodes[2] == 0)) {
		opserr <<"N4BiaxialTruss::setDomain() - N4BiaxialTruss" << this->getTag() << " node " << GNd1 <<
		"does not exist in the model\n";
		
		// fill this in so don't segment fault later
		numDOF = 2;    
		theMatrix = &trussM2;
		theVector = &trussV2;	
		theVector2 = &trussV2;	
		return;
	} else if ((theNodes[3] == 0)) {
		opserr <<"N4BiaxialTruss::setDomain() - N4BiaxialTruss" << this->getTag() << " node " << GNd2 <<
		"does not exist in the model\n";
		
		// fill this in so don't segment fault later
		numDOF = 2;    
		theMatrix = &trussM2;
		theVector = &trussV2;	
		theVector2 = &trussV2;	
		return;
	}

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

	// if differing dof at the ends - print a warning message
	if (dofNd1 != dofNd2 || dofNd2 != dofNd3 || dofNd3 != dofNd4 || dofNd4 != dofNd1) {
		opserr <<"WARNING N4BiaxialTruss::setDomain(): nodes have differing dof at ends for N4BiaxialTruss " << this->getTag() << endln;

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

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

	// now set the number of dof for element and set matrix and vector pointer
	if (dimension == 2 && dofNd1 == 2) {
		numDOF = 8;
		theMatrix = &trussM8;
		theVector = &trussV8;	
		theVector2 = &trussV4;	
	}
	else if (dimension == 2 && dofNd1 == 3) {
		numDOF = 12;	
		theMatrix = &trussM12;
		theVector = &trussV12;		
		theVector2 = &trussV6;
	}
	else if (dimension == 3 && dofNd1 == 3) {
		numDOF = 12;	
		theMatrix = &trussM12;
		theVector = &trussV12;			
		theVector2 = &trussV6;
	}
	else if (dimension == 3 && dofNd1 == 6) {
		numDOF = 24;	    
		theMatrix = &trussM24;
		theVector = &trussV24;			
		theVector2 = &trussV12;	
	}
	else {
		opserr <<"WARNING N4BiaxialTruss::setDomain cannot handle " << dimension << " dofs at nodes in " << 
		dofNd1  << " problem\n";

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

	if (theLoad == 0)
	theLoad = new Vector(numDOF);
	else if (theLoad->Size() != numDOF) {
		delete theLoad;
		theLoad = new Vector(numDOF);
	}

	if (theLoad == 0) {
		opserr << "N4BiaxialTruss::setDomain - N4BiaxialTruss " << this->getTag() << 
		"out of memory creating vector of size" << numDOF << endln;
		exit(-1);
		return;
	}          
	
	// now determine the length, directions, and fill in transformation matrix
	const Vector &end1Crd = theNodes[0]->getCrds();
	const Vector &end2Crd = theNodes[1]->getCrds();	
	const Vector &GN1Crd = theNodes[2]->getCrds();
	const Vector &GN2Crd = theNodes[3]->getCrds();	
	
	if (dimension == 2) {
		double dx = end2Crd(0) - end1Crd(0);
		double dy = end2Crd(1) - end1Crd(1);
		
		double dx2 = GN2Crd(0) - GN1Crd(0);
		double dy2 = GN2Crd(1) - GN1Crd(1);
		L = sqrt(dx*dx + dy*dy);
		L2 = sqrt(dx2*dx2 + dy2*dy2);
		
		if (L == 0.0 || L2 == 0.0) {
			opserr <<"WARNING N4BiaxialTruss::setDomain() - N4BiaxialTruss " << this->getTag() << " has zero length\n";
			return;
		} else if (fabs(L - L2) > 1.e-6) {
			opserr <<"WARNING N4BiaxialTruss::setDomain() - N4BiaxialTruss " << this->getTag() << " is not a rectangular element, error in diagonal length comparison\n";
			return;
		}
		cosX[0] = dx/L;
		cosX[1] = dy/L;
		cosX[2] = 0;
		cosX2[0] = dx2/L2;
		cosX2[1] = dy2/L2;
		cosX2[2] = 0;
		
		// forming local coordinates
		vectorX[0] = GN1Crd(0)-end1Crd(0);
		vectorX[1] = GN1Crd(1)-end1Crd(1);
		vectorX[2] = 0;
		
		vectorY[0] = GN2Crd(0)-end1Crd(0);
		vectorY[1] = GN2Crd(1)-end1Crd(1);
		vectorY[2] = 0;
	
		lengthX = sqrt(vectorX[0]*vectorX[0] + vectorX[1]*vectorX[1]);
		lengthY = sqrt(vectorY[0]*vectorY[0] + vectorY[1]*vectorY[1]);
		
		if (lengthX == 0.0 || lengthY == 0.0) {
			opserr <<"WARNING N4BiaxialTruss::setDomain() - N4BiaxialTruss " << this->getTag() << " is not rectangular, error in forming local coordinates\n";
			return;
		} 
		
		// normalizing direction vectors
		vectorX[0] = vectorX[0]/lengthX;
		vectorX[1] = vectorX[1]/lengthX;
		
		vectorY[0] = vectorY[0]/lengthY;
		vectorY[1] = vectorY[1]/lengthY;
		
		double perpCheck = vectorX[0]*vectorY[0] + vectorX[1]*vectorY[1];
		if (fabs(perpCheck) > 1.e-6) {
			opserr <<"WARNING N4BiaxialTruss::setDomain() - N4BiaxialTruss " << this->getTag() << " is not a rectangular element\n";
			opserr << "perpCheck returns " << perpCheck << "\n";
			return;
		}
	}
	else {
		double dx = end2Crd(0) - end1Crd(0);
		double dy = end2Crd(1) - end1Crd(1);
		double dz = end2Crd(2) - end1Crd(2);
		
		double dx2 = GN2Crd(0) - GN1Crd(0);
		double dy2 = GN2Crd(1) - GN1Crd(1);
		double dz2 = GN2Crd(2) - GN1Crd(2);
		L = sqrt(dx*dx + dy*dy + dz*dz);
		L2 = sqrt(dx2*dx2 + dy2*dy2 + dz2*dz2);
		
		if (L == 0.0 || L2 == 0.0) {
			opserr <<"WARNING N4BiaxialTruss::setDomain() - N4BiaxialTruss " << this->getTag() << " has zero length\n";
			return;
		} else if (fabs(L - L2) > 1.e-6) {
			opserr <<"WARNING N4BiaxialTruss::setDomain() - N4BiaxialTruss " << this->getTag() << " is not a rectangular element, error in diagonal length comparison\n";
			return;
		}
		
		cosX[0] = dx/L;
		cosX[1] = dy/L;
		cosX[2] = dz/L;
		cosX2[0] = dx2/L2;
		cosX2[1] = dy2/L2;
		cosX2[2] = dz2/L2;
		
		// forming local coordinates
		vectorX[0] = GN1Crd(0)-end1Crd(0);
		vectorX[1] = GN1Crd(1)-end1Crd(1);
		vectorX[2] = GN1Crd(2)-end1Crd(2);
		
		vectorY[0] = GN2Crd(0)-end1Crd(0);
		vectorY[1] = GN2Crd(1)-end1Crd(1);
		vectorY[2] = GN2Crd(2)-end1Crd(2);

		lengthX = sqrt(vectorX[0]*vectorX[0] + vectorX[1]*vectorX[1] + vectorX[2]*vectorX[2]);
		lengthY = sqrt(vectorY[0]*vectorY[0] + vectorY[1]*vectorY[1] + vectorY[2]*vectorY[2]);
		
		if (lengthX == 0.0 || lengthY == 0.0) {
			opserr <<"WARNING N4BiaxialTruss::setDomain() - N4BiaxialTruss " << this->getTag() << " is not rectangular, error in forming local coordinates\n";
			return;
		} 
				
		// normalizing direction vectors
		vectorX[0] = vectorX[0]/lengthX;
		vectorX[1] = vectorX[1]/lengthX;
		vectorX[2] = vectorX[2]/lengthX;
		
		vectorY[0] = vectorY[0]/lengthY;
		vectorY[1] = vectorY[1]/lengthY;
		vectorY[2] = vectorY[2]/lengthY;
		
		// checking the rectangularity of the elements
		double dx0 = GN2Crd(0)-end2Crd(0);
		double dx1 = GN2Crd(1)-end2Crd(1);
		dx2 = GN2Crd(2)-end2Crd(2);
		
		double dy0 = GN1Crd(0)-end2Crd(0);
		double dy1 = GN1Crd(1)-end2Crd(1);
		dy2 = GN1Crd(2)-end2Crd(2);
		
		double Lx2 = sqrt(dx0*dx0 + dx1*dx1 +dx2*dx2);
		double Ly2 = sqrt(dy0*dy0 + dy1*dy1 +dy2*dy2);
		
		double perpCheck = vectorX[0]*vectorY[0] + vectorX[1]*vectorY[1] + vectorX[2]*vectorY[2];
		if (fabs(perpCheck) > 1.e-6 || fabs(Lx2 - lengthX) > 1.e-6 || fabs(Ly2 - lengthY) > 1.e-6) {
			opserr <<"WARNING N4BiaxialTruss::setDomain() - N4BiaxialTruss " << this->getTag() << " is not a rectangular element\n";
			return;
		}
	}
	
	// fill in computation variables:
	oneOverL = 1.0/L;
	LxoverL = lengthX/L;
	LyoverL = lengthY/L;
	oneOver2Lx = 1.0/(2.0*lengthX);
	oneOver2Ly = 1.0/(2.0*lengthY);
}
Пример #21
0
// to set a link to the enclosing Domain and to set the node pointers.
void EETrussCorot::setDomain(Domain *theDomain)
{
    // check Domain is not null - invoked when object removed from a domain
    if (!theDomain)  {
        theNodes[0] = 0;
        theNodes[1] = 0;
        L  = 0.0;
        Ln = 0.0;
        return;
    }
    
    // set default values for error conditions
    numDOF = 2;
    theMatrix = &EETrussCorotM2;
    theVector = &EETrussCorotV2;
    
    // first set the node pointers
    int Nd1 = connectedExternalNodes(0);
    int Nd2 = connectedExternalNodes(1);
    theNodes[0] = theDomain->getNode(Nd1);
    theNodes[1] = theDomain->getNode(Nd2);
    
    // if can't find both - send a warning message
    if (!theNodes[0] || !theNodes[1])  {
        if (!theNodes[0])  {
            opserr << "EETrussCorot::setDomain() - Nd1: "
                << Nd1 << "does not exist in the model for ";
        } else  {
            opserr << "EETrussCorot::setDomain() - Nd2: "
                << Nd2 << "does not exist in the model for ";
        }
        opserr << "EETrussCorot ele: " << this->getTag() << endln;
        
        return;
    }
    
    // now determine the number of dof and the dimension
    int dofNd1 = theNodes[0]->getNumberDOF();
    int dofNd2 = theNodes[1]->getNumberDOF();
    
    // if differing dof at the ends - print a warning message
    if (dofNd1 != dofNd2)  {
        opserr <<"EETrussCorot::setDomain(): nodes " << Nd1 << " and " << Nd2
            << "have differing dof at ends for element: " << this->getTag() << endln;
        
        return;
    }
    
    // call the base class method
    this->DomainComponent::setDomain(theDomain);
    
    // now set the number of dof for element and set matrix and vector pointer
    if (numDIM == 1 && dofNd1 == 1)  {
        numDOF = 2;
        theMatrix = &EETrussCorotM2;
        theVector = &EETrussCorotV2;
    }
    else if (numDIM == 2 && dofNd1 == 2)  {
        numDOF = 4;
        theMatrix = &EETrussCorotM4;
        theVector = &EETrussCorotV4;
    }
    else if (numDIM == 2 && dofNd1 == 3)  {
        numDOF = 6;
        theMatrix = &EETrussCorotM6;
        theVector = &EETrussCorotV6;
    }
    else if (numDIM == 3 && dofNd1 == 3)  {
        numDOF = 6;
        theMatrix = &EETrussCorotM6;
        theVector = &EETrussCorotV6;
    }
    else if (numDIM == 3 && dofNd1 == 6)  {
        numDOF = 12;
        theMatrix = &EETrussCorotM12;
        theVector = &EETrussCorotV12;
    }
    else  {
        opserr <<"EETrussCorot::setDomain() - can not handle "
            << numDIM << " dofs at nodes in " << dofNd1  << " d problem\n";
        
        return;
    }
    
    // set the initial stiffness matrix size
    theInitStiff.resize(numDOF,numDOF);
    
    if (!theLoad)
        theLoad = new Vector(numDOF);
    else if (theLoad->Size() != numDOF)  {
        delete theLoad;
        theLoad = new Vector(numDOF);
    }
    
    if (!theLoad)  {
        opserr << "EETrussCorot::setDomain() - element: " << this->getTag()
            << " out of memory creating vector of size: " << numDOF << endln;
        
        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();
    
    // initalize the cosines
    double cosX[3];
    cosX[0] = cosX[1] = cosX[2] = 0.0;
    for (int i=0; i<numDIM; i++)
        cosX[i] = end2Crd(i)-end1Crd(i);
    
    // get initial length
    L = sqrt(cosX[0]*cosX[0] + cosX[1]*cosX[1] + cosX[2]*cosX[2]);
    if (L == 0.0)  {
        opserr <<"EETrussCorot::setDomain() - element: "
            << this->getTag() << " has zero length\n";
        return;
    }
    Ln = L;
    
    // set global orientations
    cosX[0] /= L;
    cosX[1] /= L;
    cosX[2] /= L;
    
    // initialize rotation matrix
    R(0,0) = cosX[0];
    R(0,1) = cosX[1];
    R(0,2) = cosX[2];
    if (fabs(cosX[0]) > 0.0)  {  // element outside the YZ plane
        R(1,0) = -cosX[1];
        R(1,1) =  cosX[0];
        R(1,2) =  0.0;
        
        R(2,0) = -cosX[0]*cosX[2];
        R(2,1) = -cosX[1]*cosX[2];
        R(2,2) =  cosX[0]*cosX[0] + cosX[1]*cosX[1];
    }
    else  {  // element in the YZ plane
        R(1,0) =  0.0;
        R(1,1) = -cosX[2];
        R(1,2) =  cosX[1];
        
        R(2,0) =  1.0;
        R(2,1) =  0.0;
        R(2,2) =  0.0;
    }
    
    // orthonormalize last two rows of R
    double norm;
    for (int i=1; i<3; i++)  {
        norm = sqrt(R(i,0)*R(i,0) + R(i,1)*R(i,1) + R(i,2)*R(i,2));
        R(i,0) /= norm;
        R(i,1) /= norm;
        R(i,2) /= norm;
    }
    
    // set initial offsets
    d21[0] = L; d21[1] = d21[2] = 0.0;
    v21[0] = v21[1] = v21[2] = 0.0;
    a21[0] = a21[1] = a21[2] = 0.0;
}
Пример #22
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;
}
Пример #23
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;
}
Пример #24
0
void
beam2d02::setDomain(Domain *theDomain)
{
    // first set the node pointers
    int Nd1 = connectedExternalNodes(0);
    int Nd2 = connectedExternalNodes(1);
    theNodes[0] = theDomain->getNode(Nd1);
    theNodes[1] = theDomain->getNode(Nd2);	
    if (theNodes[0] == 0) {
	opserr << "WARNING beam2d02::setDomain(): Nd1: ";
	opserr << Nd1 << "does not exist in model for beam \n" << *this;
	return;
    }
    if (theNodes[1] == 0) {
	opserr << "WARNING beam2d02::setDomain(): Nd2: ";
	opserr << Nd2 << "does not exist in model for beam\n" << *this;
	return;
    }	
    
    // now verify the number of dof at node ends
    int dofNd1 = theNodes[0]->getNumberDOF();
    int dofNd2 = theNodes[1]->getNumberDOF();	
    if (dofNd1 != 3 && dofNd2 != 3) {
	opserr << "WARNING beam2d02::setDomain(): node " << Nd1;
	opserr << " and/or node " << Nd2 << " have/has incorrect number ";
	opserr << "of dof's at end for beam\n " << *this;
	return;
    }	

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

    // determine length and direction cosines
    double dx,dy;
    const Vector &end1Crd = theNodes[0]->getCrds();
    const Vector &end2Crd = theNodes[1]->getCrds();	
    
    dx = end2Crd(0)-end1Crd(0);
    dy = end2Crd(1)-end1Crd(1);	
    
    L = sqrt(dx*dx + dy*dy);
    if (L == 0.0) {
	opserr << "WARNING beam2d02::setDomain(): beam " << this->getTag();
	opserr << " has zero length for beam\n" << *this;
	return;  
    }

    Kd(0,0) = E*A/L;
    Kd(0,1) = 0.0;
    Kd(0,2) = 0.0;    

    Kd(1,0) = 0.0;        
    Kd(1,1) = 4.0*E*I/L;
    Kd(1,2) = 2.0*E*I/L;

    Kd(2,0) = 0.0;    
    Kd(2,1) = 2.0*E*I/L;
    Kd(2,2) = 4.0*E*I/L;

    cs = dx/L;
    sn = dy/L;
    
    // set the mass variable equal to 1/2 tha mass of the beam = 0.5 * rho*A*L
    M = 0.5*M*A*L;    
}
Пример #25
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
	Truss2::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;

		theOtherNodes[0] = 0;
		theOtherNodes[1] = 0;
		otherLength = 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);	

	// and the other node pointers (will be reordered later)
	int oNd1 = connectedExternalOtherNodes(0);
	int oNd2 = connectedExternalOtherNodes(1);
	theOtherNodes[0] = theDomain->getNode(oNd1);
	theOtherNodes[1] = theDomain->getNode(oNd2);	

	// if can't find both - send a warning message
	if ((theNodes[0] == 0) || (theNodes[1] == 0) || theOtherNodes[0] == 0 || theOtherNodes[1] == 0) {
		if (theNodes[0] == 0)
			opserr <<"Truss2::setDomain() - truss" << this->getTag() << " node " << Nd1 <<
			" does not exist in the model\n";
		else if (theNodes[1] == 0)
			opserr <<"Truss2::setDomain() - truss" << this->getTag() << " node " << Nd2 <<
			" does not exist in the model\n";
		else if (theOtherNodes[0] == 0)
			opserr <<"Truss2::setDomain() - truss" << this->getTag() << " node " << oNd1 <<
			" does not exist in the model\n";
		else 
			opserr <<"Truss2::setDomain() - truss" << this->getTag() << " node " << oNd2 <<
			" does not exist in the model\n";

		// 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 differing dof at the ends - print a warning message
	if (dofNd1 != dofNd2) {
		opserr <<"WARNING Truss2::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 pointer
	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 Truss2::setDomain cannot handle " << dimension << " dofs at nodes in " << 
				dofNd1  << " problem\n";

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

		if (theLoad == 0)
			theLoad = new Vector(numDOF);
		else if (theLoad->Size() != numDOF) {
			delete theLoad;
			theLoad = new Vector(numDOF);
		}

		if (theLoad == 0) {
			opserr << "Truss2::setDomain - truss " << this->getTag() << 
				"out of memory creating vector of size" << numDOF << endln;
			exit(-1);
			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();	

		if (dimension == 1) {
			double dx = end2Crd(0)-end1Crd(0);	

			L = sqrt(dx*dx);

			if (L == 0.0) {
				opserr <<"WARNING Truss2::setDomain() - truss " << this->getTag() << " has zero length\n";
				return;
			}

			cosX[0] = 1.0;

			const Vector &end1Crd2 = theOtherNodes[0]->getCrds();
			const Vector &end2Crd2 = theOtherNodes[1]->getCrds();	
			dx = end2Crd2(0)-end1Crd2(0);
			otherLength = sqrt(dx*dx);
			otherCosX[0] = 0;

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

			L = sqrt(dx*dx + dy*dy);

			if (L == 0.0) {
				opserr <<"WARNING Truss2::setDomain() - truss " << this->getTag() << " has zero length\n";
				return;
			}

			cosX[0] = dx/L;
			cosX[1] = dy/L;

			const Vector &end1Crd2 = theOtherNodes[0]->getCrds();
			const Vector &end2Crd2 = theOtherNodes[1]->getCrds();	
			double dx2 = end2Crd2(0)-end1Crd2(0);
			double dy2 = end2Crd2(1)-end1Crd2(1);	

			otherLength = sqrt(dx2*dx2 + dy2*dy2);

			if (otherLength == 0.0) {
				opserr <<"WARNING Truss2::setDomain() - truss " << this->getTag() << " has auxiliary nodes that are the same point\n";
				otherCosX[0] = 0;
				otherCosX[1] = 0;
				return;
			} 

			otherCosX[0] = dx2/otherLength;
			otherCosX[1] = dy2/otherLength;

			// project on normal of truss direction.
			theta = acos((dx*dx2+dy*dy2)/(L*otherLength)); // cos*theta = a*b/(|a|*|b|)
			if (theta == 0.0) {
				opserr << "WARNING Truss2::setDomain() - truss2 " << this->getTag() << " has theta = 0, disabling biaxial effects\n";
			}
		}

		else {
			double dx = end2Crd(0)-end1Crd(0);
			double dy = end2Crd(1)-end1Crd(1);	
			double dz = end2Crd(2)-end1Crd(2);		

			L = sqrt(dx*dx + dy*dy + dz*dz);

			if (L == 0.0) {
				opserr <<"WARNING Truss2::setDomain() - truss " << this->getTag() << " has zero length\n";
				return;
			}

			cosX[0] = dx/L;
			cosX[1] = dy/L;
			cosX[2] = dz/L;

			const Vector &end1Crd2 = theOtherNodes[0]->getCrds();
			const Vector &end2Crd2 = theOtherNodes[1]->getCrds();	
			double dx2 = end2Crd2(0)-end1Crd2(0);
			double dy2 = end2Crd2(1)-end1Crd2(1);	
			double dz2 = end2Crd2(2)-end1Crd2(2);	

			otherLength = sqrt(dx2*dx2 + dy2*dy2 + dz2*dz2);

			if (otherLength == 0.0) {
				opserr <<"WARNING Truss2::setDomain() - truss " << this->getTag() << " has auxiliary nodes that are the same point\n";
				otherCosX[0] = 0;
				otherCosX[1] = 0;
				otherCosX[2] = 0;
				return;
			} 

			otherCosX[0] = dx2/otherLength;
			otherCosX[1] = dy2/otherLength;
			otherCosX[2] = dz2/otherLength;

			// project on normal of truss direction.
			theta = acos((dx*dx2+dy*dy2+dz*dz2)/(L*otherLength)); // cos*theta = a*b/(|a|*|b|)
			if (theta == 0.0) {
				opserr << "WARNING Truss2::setDomain() - truss2 " << this->getTag() << " has theta = 0, disabling biaxial effects\n";
			}
		}
}   	 
Пример #26
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 CorotTruss element, we set matrix and vector pointers,
//    allocate space for t matrix, determine the length
//    and set the transformation matrix.
void
CorotTruss::setDomain(Domain *theDomain)
{
  // check Domain is not null - invoked when object removed from a domain
  if (theDomain == 0) {
    theNodes[0] = 0;
    theNodes[1] = 0;
    Lo = 0.0;
    Ln = 0.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 can't find both - send a warning message
  if ((theNodes[0] == 0) || (theNodes[1] == 0)) {
    opserr << "CorotTruss::setDomain() - CorotTruss " << this->getTag() << " node " <<
      Nd1 << "does not exist in the model \n";
    
    // fill this in so don't segment fault later
    numDOF = 6;    
    
    return;
  }
  
  // now determine the number of dof and the dimesnion    
  int dofNd1 = theNodes[0]->getNumberDOF();
  int dofNd2 = theNodes[1]->getNumberDOF();	
  
  // if differing dof at the ends - print a warning message
  if (dofNd1 != dofNd2) {
    opserr << "WARNING CorotTruss::setDomain(): nodes " << Nd1 <<
      " and " << Nd2 << "have differing dof at ends for CorotTruss " << this->getTag() << endln;
    
    // fill this in so don't segment fault later
    numDOF = 6;    
    
    return;
  }	
  
  if (numDIM == 1 && dofNd1 == 1) {
    numDOF = 2;
    theMatrix = &M2;
    theVector = &V2;
  }
  else if (numDIM == 2 && dofNd1 == 2) {
    numDOF = 4;
    theMatrix = &M4;
    theVector = &V4;
  }
  else if (numDIM == 2 && dofNd1 == 3) {
    numDOF = 6;
    theMatrix = &M6;
    theVector = &V6;
  }
  else if (numDIM == 3 && dofNd1 == 3) {
    numDOF = 6;
    theMatrix = &M6;
    theVector = &V6;
  }
  else if (numDIM == 3 && dofNd1 == 6) {
    numDOF = 12;
    theMatrix = &M12;
    theVector = &V12;
  }
  else {
    opserr << " CorotTruss::setDomain -- nodal DOF " << dofNd1 << " not compatible with element\n";
    
    // fill this in so don't segment fault later
    numDOF = 6;    
    
    return;
  }

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

	// 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();

	// Determine global offsets
    double cosX[3];
    cosX[0] = 0.0;  cosX[1] = 0.0;  cosX[2] = 0.0;
    int i;
    for (i = 0; i < numDIM; i++) {
        cosX[i] += end2Crd(i)-end1Crd(i);
    }

	// Set undeformed and initial length
	Lo = cosX[0]*cosX[0] + cosX[1]*cosX[1] + cosX[2]*cosX[2];
	Lo = sqrt(Lo);
	Ln = Lo;

    // Initial offsets
   	d21[0] = Lo;
	d21[1] = 0.0;
	d21[2] = 0.0;

	// Set global orientation
	cosX[0] /= Lo;
	cosX[1] /= Lo;
	cosX[2] /= Lo;

	R(0,0) = cosX[0];
	R(0,1) = cosX[1];
	R(0,2) = cosX[2];

	// Element lies outside the YZ plane
	if (fabs(cosX[0]) > 0.0) {
		R(1,0) = -cosX[1];
		R(1,1) =  cosX[0];
		R(1,2) =  0.0;

		R(2,0) = -cosX[0]*cosX[2];
		R(2,1) = -cosX[1]*cosX[2];
		R(2,2) =  cosX[0]*cosX[0] + cosX[1]*cosX[1];
	}
	// Element is in the YZ plane
	else {
		R(1,0) =  0.0;
		R(1,1) = -cosX[2];
		R(1,2) =  cosX[1];

		R(2,0) =  1.0;
		R(2,1) =  0.0;
		R(2,2) =  0.0;
	}

	// Orthonormalize last two rows of R
	double norm;
	for (i = 1; i < 3; i++) {
		norm = sqrt(R(i,0)*R(i,0) + R(i,1)*R(i,1) + R(i,2)*R(i,2));
		R(i,0) /= norm;
		R(i,1) /= norm;
		R(i,2) /= norm;
	}
}
Пример #27
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;
}