Beispiel #1
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
DispBeamColumn2d::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **displayModes, int numModes)
{
  static Vector v1(3);
  static Vector v2(3);

  if (displayMode >= 0) {

    theNodes[0]->getDisplayCrds(v1, fact);
    theNodes[1]->getDisplayCrds(v2, fact);

  } else {

    theNodes[0]->getDisplayCrds(v1, 0.);
    theNodes[1]->getDisplayCrds(v2, 0.);

    // add eigenvector values
    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) += eigen1(i,mode-1)*fact;
	v2(i) += eigen2(i,mode-1)*fact;    
      }    
    }
  }
	
  return theViewer.drawLine (v1, v2, 1.0, 1.0, this->getTag());
}
Beispiel #3
0
int
ElasticBeam3d::displaySelf(Renderer &theViewer, int displayMode, float fact, const char **modes, int numMode)
{
    static Vector v1(3);
    static Vector v2(3);

    theNodes[0]->getDisplayCrds(v1, fact);
    theNodes[1]->getDisplayCrds(v2, fact);
    float d1 = 0.0;
    float d2 = 0.0;
    int res = 0;
  
    if (displayMode > 0) {

      res += theViewer.drawLine(v1, v2, d1, d1, this->getTag(), 0);

    } else if (displayMode < 0) {

      theNodes[0]->getDisplayCrds(v1, 0.);
      theNodes[1]->getDisplayCrds(v2, 0.);

      // add eigenvector values
      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 < 3; i++) {
	  v1(i) += eigen1(i,mode-1)*fact;
	  v2(i) += eigen2(i,mode-1)*fact;    
	}    
      }
      return theViewer.drawLine (v1, v2, 0.0, 0.0, this->getTag(), 0);
    }

    if (numMode > 0) {
      // calculate q for potential need below
      this->getResistingForce();
    }

  for (int i=0; i<numMode; i++) {

    const char *theMode = modes[i];
    if (strcmp(theMode, "axialForce") == 0) {
      d1 = q(0); 
      d2 = q(0);;

      res +=theViewer.drawLine(v1, v2, d1, d1, this->getTag(), i);
      
    } else if (strcmp(theMode, "endMoments") == 0) {
      d1 = q(1);
      d2 = q(2);
      static Vector delta(3); delta = v2-v1; delta/=10;
      res += theViewer.drawPoint(v1+delta, d1, this->getTag(), i);
      res += theViewer.drawPoint(v2-delta, d2, this->getTag(), i);
      
    }
  }    

  return res;
}
Beispiel #4
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;
}
Beispiel #5
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;
}
Beispiel #6
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;
}
Beispiel #7
0
int
Quad4FiberOverlay::displaySelf(Renderer &theViewer, int displayMode, float fact)
{
	int dimension = 2;
    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) = Qfi(i)+end1Disp(i)*fact;
	    v2(i) = Qfj(i)+end2Disp(i)*fact;    
	}
	
	// compute the strain and axial force in the member
	double strain, force;
	if (Lf == 0.0) {
	    strain = 0.0;
	    force = 0.0;
	} else {
	    strain = this->computeCurrentStrain();
	    theMaterial->setTrialStrain(strain);
	    force = Af*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) = Qfi(i) + eigen1(i,mode-1)*fact;
	  v2(i) = Qfj(i) + eigen2(i,mode-1)*fact;    
	}    
      } else {
	for (int i = 0; i < dimension; i++) {
	  v1(i) = Qfi(i);
	  v2(i) = Qfj(i);
	}    
      }
      return theViewer.drawLine(v1, v2, 1.0, 1.0);	
    }
    return 0;
}
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);
}
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;
}
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;
}
Beispiel #11
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;
}
Beispiel #12
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;
}
Beispiel #14
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;
}
Beispiel #15
0
int bbfile(pMesh mesh) {
  FILE      *in;
  pSolution  ps;
  double     a,b,c,lambda[3],eigv[3][3],m[6],vp[2][2];
  float      dummy;
  int        j,k,l,dim,np,nfield,nf,i1,i2,i3,i4,err,iord;
  char      *ptr,data[128],tmp[128];
  ubyte      bigbb;

  /* default */
  strcpy(tmp,mesh->name);
  ptr = (char *)strstr(tmp,".mesh");
  if ( ptr ) *ptr = '\0';

  sprintf(data,"%s.bb",tmp);
  in = fopen(data,"r");
  bigbb = 0;
  if ( !in ) {
    sprintf(data,"%s.pbb",tmp);
    in = fopen(data,"r");
  }  
  if ( !in ) {
    bigbb = 1;
    sprintf(data,"%s.BB",tmp);
    in = fopen(data,"r");  
    if ( !in ) { /* hack FH pour le mac */
      sprintf(data,"%s.gbb",tmp);
      in = fopen(data,"r");
    }
    
  }
  if ( !in )    
    return(0);
  
  /* if ( !quiet )  fprintf(stdout,"  Reading %s\n",data); */
  i1=i2=i3=i4=-1;
  /* read file format */
  err=0;
  fscanf(in,"%d",&dim);
  if(EatSpace(in)) err++;
  fscanf(in,"%d",&i1);
  if(EatSpace(in)) err++;
  fscanf(in,"%d",&i2);
  if(EatSpace(in)) err++;
  fscanf(in,"%d",&i3);
  bigbb=  (EatSpace(in)==0); /* not nl after the 4 integer => BB */

  if ( !quiet )
    if(bigbb)  fprintf(stdout,"  Reading BB file %s\n",data);
    else  fprintf(stdout,"  Reading bb file %s\n",data);

  if ( dim < 2 || dim > 3 || err ) {
    fprintf(stderr,"  %%%% Wrong file (dim=%d) (err=%d). Ignored\n",dim,err);
    return(0);
  }
  /* read number of field(s) */
  nf = 0;

  if ( bigbb ) {
    /* get only 1st field */
    /* fscanf(in,"%d",&nfield);*/
    nfield=i1;
    /*fscanf(in,"%d",&mesh->nfield);*/
    mesh->nfield = i2;
    if (nfield>1) 
      {
	nf += i3;
	for (k=1; k<nfield-1; k++) {
	  fscanf(in,"%d",&np);
	  nf += np;
	}
	fscanf(in,"%d",&np);
      }
    else 
      np = i3;
    /* read file type */
    fscanf(in,"%d",&mesh->typage);
    printf(" np= %d, type= %d\n",np,mesh->typage);
  }
  else {
   /* fscanf(in,"%d",&mesh->nfield);
      fscanf(in,"%d",&np);*/
    /* read file type */
    /* fscanf(in,"%d",&mesh->typage);*/
    mesh->nfield=i1;
    np=i2;
    mesh->typage=i3;
  }  
  

  if ( mesh->typage == 2 ) {
    if ( np < mesh->np ) {
      fprintf(stderr,"  %%%% Wrong solution number (%d , %d). Ignored\n",np,mesh->np);
      fclose(in);
      return(0);
    }
    mesh->nbb = mesh->np;
  }
  else if ( mesh->typage == 1 ) {
    if ( np < mesh->ne ) {
      fprintf(stderr,"  %%%% Wrong solution number (%d , %d). Ignored\n",np,mesh->ne);
      fclose(in);
      return(0);
    }
    mesh->nbb = mesh->ne;
  }
  else {
    fprintf(stderr,"  %%%% Wrong typage (%d). Ignored\n",mesh->typage);
    fclose(in);
    return(0);
  }

  /* read solutions */
  mesh->bbmin  =  1.e10;
  mesh->bbmax  = -1.e10;

  /* allocate memory */
  if ( !zaldy2(mesh) ) {
    mesh->nbb = 0;
    fclose(in);
    return(0);
  }

  /* scalar field */
  if ( mesh->nfield == 1 ) {
    if ( ddebug )  printf("   scalar (isotropic) field\n");
    for (k=1; k<=mesh->nbb; k++) {
      ps = &mesh->sol[k];
      ps->bb = 0.0;
      if ( fscanf(in,"%s",data) != 1 )  continue;
      if ( ptr = strpbrk(data,"dD") ) *ptr = 'E';
      sscanf(data,"%f",&ps->bb);
      if ( ps->bb < mesh->bbmin )  mesh->bbmin = ps->bb;
      if ( ps->bb > mesh->bbmax )  mesh->bbmax = ps->bb;
      for (j=1; j<=nf; j++)  fscanf(in,"%f",&dummy);
    }
  }

  /* vector field */
  else if ( mesh->nfield == mesh->dim ) {
    if ( ddebug )  fprintf(stdout,"   vector field \n");
    for (k=1; k<=mesh->nbb; k++) {
      ps = &mesh->sol[k];
      ps->bb = 0.0;
      for (l=0; l<mesh->dim; l++) {
        if ( fscanf(in,"%s",data) != 1 )  continue;
        if ( ptr = strpbrk(data,"dD") ) *ptr = 'E';
        sscanf(data,"%f",&ps->m[l]);
        ps->bb += ps->m[l]*ps->m[l];
      }
      ps->bb = sqrt(ps->bb);
      if ( ps->bb < mesh->bbmin )  mesh->bbmin = ps->bb;
      if ( ps->bb > mesh->bbmax )
        mesh->bbmax = ps->bb;
      for (j=1; j<nf; j++)  fscanf(in,"%f",&dummy);
    }
    fclose(in);
    return(0);
  }
  else if ( dim == 2 && mesh->nfield == 3 ) {
    if ( ddebug )  fprintf(stdout,"   2D metric field\n");
    for (k=1; k<=mesh->np; k++) {
      ps = &mesh->sol[k];
      fscanf(in,"%lf %lf %lf",&a,&b,&c);
      ps->m[0] = a;
      ps->m[1] = b;
      ps->m[2] = c;
      m[0] = a;
      m[1] = b;
      m[2] = c;
      eigen2(m,lambda,vp);
      ps->bb = MEDIT_MIN(lambda[0],lambda[1]);
      if ( ps->bb < mesh->bbmin )  mesh->bbmin = ps->bb;
      if ( ps->bb > mesh->bbmax )  mesh->bbmax = ps->bb;
      for (j=1; j<nf; j++)  fscanf(in,"%f",&dummy);
    }
  }
  else if ( dim == 3 && mesh->nfield == 6 ) {
    if ( ddebug )  fprintf(stdout,"   3D metric field\n");
    for (k=1; k<=mesh->np; k++) {
      ps = &mesh->sol[k];
      ps->bb = 0.0f;
      for (l=0; l<6; l++) {
        if ( fscanf(in,"%s",data) != 1 )  continue;
        if ( ptr = strpbrk(data,"dD") ) *ptr = 'E';
        sscanf(data,"%f",&dummy);
        m[l] = dummy;
      }
      ps->m[0] = m[0];
      ps->m[1] = m[1];
      ps->m[2] = m[3];
      ps->m[3] = m[2];
      ps->m[4] = m[4];
      ps->m[5] = m[5];

      m[2] = ps->m[2];
      m[3] = ps->m[3];
      iord = eigenv(1,m,lambda,eigv);
      if ( iord ) {
        ps->bb = lambda[0];
        ps->bb = MEDIT_MAX(ps->bb,lambda[1]);
        ps->bb = MEDIT_MAX(ps->bb,lambda[2]);
        if ( ps->bb < mesh->bbmin )  mesh->bbmin = ps->bb;
        if ( ps->bb > mesh->bbmax )  mesh->bbmax = ps->bb;
      }
      else {
        fprintf(stdout,"  ## Eigenvalue problem.\n");
      }
      
      for (j=1; j<nf; j++)  fscanf(in,"%f",&dummy);
    }
  }
  else {
    fprintf(stderr," %%%% Solution not suitable. Ignored\n");
    mesh->nbb = 0;
  }

  fclose(in);
  return(np);
}
Beispiel #16
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;
}