예제 #1
0
void Line2SurfaceTension :: computeLoadVector(FloatArray &answer, ValueModeType mode, TimeStep *tStep)
{
    ///@todo Support axisymm.
    //domainType dt = this->giveDomain()->giveDomainType();
    IntegrationRule *iRule = this->integrationRulesArray [ 0 ];
    double t = 1, gamma_s;
    ///@todo Should i use this? Not used in FM module (but perhaps it should?) / Mikael.
    //t = this->giveDomain()->giveCrossSection(1)->give(CS_Thickness);
    gamma_s = this->giveMaterial()->give('g', NULL);

    FloatMatrix xy(2, 3);
    Node *node;
    for ( int i = 1; i <= 3; i++ ) {
        node = giveNode(i);
        xy.at(1, i) = node->giveCoordinate(1);
        xy.at(2, i) = node->giveCoordinate(2);
    }

    FloatArray A;
    FloatArray dNdxi(3);
    FloatArray es(2); // tangent vector to curve
    FloatMatrix BJ(2, 6);
    BJ.zero();

    answer.resize(6);
    answer.zero();

    for ( int k = 0; k < iRule->getNumberOfIntegrationPoints(); k++ ) {
        GaussPoint *gp = iRule->getIntegrationPoint(k);
        //interpolation.evaldNdx(dN, domain, dofManArray, * gp->giveCoordinates(), 0.0);
        double xi = gp->giveCoordinate(1);

        // Some simplifications can be performed, since the mapping J is a scalar.
        dNdxi.at(1) = -0.5 + xi;
        dNdxi.at(2) =  0.5 + xi;
        dNdxi.at(3) = -2.0 * xi;

        es.beProductOf(xy, dNdxi);
        double J = es.computeNorm();
        es.times(1 / J); //es.normalize();

        // dNds = dNdxi/J
        // B.at(1,1) = dNds.at(1); and so on.

        BJ.at(1, 1) = BJ.at(2, 2) = dNdxi.at(1);
        BJ.at(1, 3) = BJ.at(2, 4) = dNdxi.at(2);
        BJ.at(1, 5) = BJ.at(2, 6) = dNdxi.at(3);

        A.beTProductOf(BJ, es);
        answer.add( - gamma_s * t * gp->giveWeight(), A); // Note! Negative sign!
    }
}
예제 #2
0
파일: dbb.cpp 프로젝트: Rick00/rong_test
void main()
{
	int m;
	printf("1:复利计算\n");

	printf("2:单利计算\n");

	printf("3:求本金\n");
	printf("4:求时间\n");
	printf("5:求利率\n");
	printf("请输入序号");

	scanf("%d",&m);
	if(m==1)
		FL();
	 else if(m==2)
	    DL();
	 else if(m==3)
		BJ();
	 else if(m==4)
		Time();
	 else if(m==5)
		 LL();
}
예제 #3
0
void  
NineNodeMixedQuad::formResidAndTangent( int tang_flag ) 
{

  //strains ordered : eps11, eps22, eps33, 2*eps12 
  //volumtric strains projected onto {1, \xi, \eta} natural coordinates

  static const int ndm = 2 ;

  static const int ndf = 2 ; 

  static const int nstress = 4 ;
 
  static const int numberNodes = 9 ;

  static const int numberGauss = 9 ;

  static const int nShape = 3 ;

  static const int nMixed = 3 ;

  int i, j, k, p, q, r, s ;
  int jj, kk ;

  int success ;
  
  static double volume ;

  static double xsj ;  // determinant jacaobian matrix 

  static double dvol[numberGauss] ; //volume element

  static double gaussPoint[ndm] ;

  static double natCoorArray[ndm][numberGauss] ;

  static Vector strain(nstress) ;  //strain

  static double shp[nShape][numberNodes] ;  //shape functions at a gauss point

  static double Shape[nShape][numberNodes][numberGauss] ; //all the shape functions

  static double shpBar[nShape][numberNodes][nMixed] ; //mean value of shape functions

  static double rightHandSide[nShape][numberNodes][nMixed] ;

  static Vector residJ(ndf) ; //nodeJ residual 

  static Matrix stiffJK(ndf,ndf) ; //nodeJK stiffness 

  static Vector stress(nstress) ;  //stress

  static Matrix dd(nstress,nstress) ;  //material tangent

  static double interp[nMixed] ;

  static Matrix Proj(3,3) ;   //projection matrix 
  static Matrix ProjInv(3,3) ;

  static Matrix Iden(3,3) ;
  Iden(0,0) = 1.0 ;
  Iden(1,1) = 1.0 ;
  Iden(2,2) = 1.0 ;

  //---------B-matrices------------------------------------

    static Matrix BJ(nstress,ndf) ;      // B matrix node J

    static Matrix BJtran(ndf,nstress) ;

    static Matrix BK(nstress,ndf) ;      // B matrix node k

    static Matrix BJtranD(ndf,nstress) ;

  //-------------------------------------------------------

  
  //zero stiffness and residual 
  stiff.Zero( ) ;
  resid.Zero( ) ;

  //node coordinates
  computeBasis() ;

  //zero mean shape functions
  for ( p=0; p<nShape; p++ ) {
    for ( q=0; q<numberNodes; q++ ) {

      for (r=0; r<nMixed; r++ ) {
	shpBar[p][q][r] = 0.0 ;
	rightHandSide[p][q][r] = 0.0 ;
      }

    }//end for q
  } // end for p


  //zero volume
  volume = 0.0 ;

  //zero projection matrix  
  Proj.Zero( ) ;
  ProjInv.Zero( ) ;


  //gauss loop to compute and save shape functions 
  int count = 0 ;

  for ( i = 0; i < 3; i++ ) {
    for ( j = 0; j < 3; j++ ) {

        gaussPoint[0] = sg[i] ;        
	gaussPoint[1] = sg[j] ;        


	//save gauss point locations
	natCoorArray[0][count] = gaussPoint[0] ;
	natCoorArray[1][count] = gaussPoint[1] ;


	//get shape functions    
	shape2dNine( gaussPoint, xl, shp, xsj ) ;


	//save shape functions
	for ( p=0; p<nShape; p++ ) {
	  for ( q=0; q<numberNodes; q++ )
	    Shape[p][q][count] = shp[p][q] ;
	} // end for p

	
	//volume element to also be saved
	dvol[count] = ( wg[i]*wg[j] ) * xsj ;  


        //add to projection matrix
	interp[0] = 1.0 ;
	interp[1] = gaussPoint[0] ;
	interp[2] = gaussPoint[1] ;
	
	for ( r=0; r<nMixed; r++ ) {
	  for ( s=0; s<nMixed; s++ ) 
	    Proj(r,s) += ( interp[r]*interp[s] * dvol[count] ) ;
	}//end for r

	volume += dvol[count] ;
	
	
	//add to mean shape functions
	for ( p=0; p<nShape; p++ ) {
	  for ( q=0; q<numberNodes; q++ ) {

	    for ( s=0; s<nMixed; s++ ) 
	      rightHandSide[p][q][s] += ( shp[p][q] * interp[s] * dvol[count] ) ;

	  }//end for q 
	} // end for p


	//increment gauss point counter
	count++ ;

    } //end for j
  } // end for i 
  


  //invert projection matrix
  //int Solve(const Matrix &M, Matrix &res) const;
  Proj.Solve( Iden, ProjInv ) ;
  
  //mean value of shape functions
  for ( p=0; p<nShape; p++ ) {
    for ( q=0; q<numberNodes; q++ ) {

      for (r=0; r<nMixed; r++ ) {
	for (s=0; s<nMixed; s++ ) 
	  shpBar[p][q][r] += ( ProjInv(r,s) * rightHandSide[p][q][s] ) ;
      }//end for r

    }//end for q
  }//end for p


  //gauss loop 
  for ( i=0; i<numberGauss; i++ ) {
    
    //extract gauss point location
    gaussPoint[0] = natCoorArray[0][i] ;
    gaussPoint[1] = natCoorArray[1][i] ;

    //extract shape functions from saved array
    for ( p=0; p<nShape; p++ ) {
       for ( q=0; q<numberNodes; q++ )
	  shp[p][q]  = Shape[p][q][i] ;
    } // end for p


    //zero the strains
    strain.Zero( ) ;

    // j-node loop to compute strain 
    for ( j=0; j<numberNodes; j++ )  {

      //compute B matrix 

      BJ = computeBbar( j, gaussPoint, shp, shpBar ) ;
      
      //nodal displacements 
      const Vector &ul = nodePointers[j]->getTrialDisp( ) ;

      //compute the strain
      //strain += (BJ*ul) ; 
      strain.addMatrixVector(1.0,  BJ,ul,1.0 ) ;

    } // end for j
  


    //send the strain to the material 
    success = materialPointers[i]->setTrialStrain( strain ) ;

    //compute the stress
    stress = materialPointers[i]->getStress( ) ;


    //multiply by volume element
    stress  *= dvol[i] ;

    if ( tang_flag == 1 ) {
      dd = materialPointers[i]->getTangent( ) ;
      dd *= dvol[i] ;
    } //end if tang_flag


    //residual and tangent calculations node loops

    jj = 0 ;
    for ( j=0; j<numberNodes; j++ ) {

      BJ = computeBbar( j, gaussPoint, shp, shpBar ) ;
   
      //transpose 
      //BJtran = transpose( nstress, ndf, BJ ) ;
      for (p=0; p<ndf; p++) {
	for (q=0; q<nstress; q++) 
	  BJtran(p,q) = BJ(q,p) ;
      }//end for p


      //residual
      //residJ = BJtran * stress ;
      residJ.addMatrixVector(0.0,  BJtran,stress,1.0);

      //residual 
      for ( p=0; p<ndf; p++ )
        resid( jj + p ) += residJ(p)  ;


      if ( tang_flag == 1 ) {

	//BJtranD = BJtran * dd ;
	BJtranD.addMatrixProduct(0.0,  BJtran,dd,1.0);

         kk = 0 ;
         for ( k=0; k<numberNodes; k++ ) {

            BK = computeBbar( k, gaussPoint, shp, shpBar ) ;
  
 
            //stiffJK =  BJtranD * BK  ;
	    stiffJK.addMatrixProduct(0.0,  BJtranD,BK,1.0) ;

            for ( p=0; p<ndf; p++ )  {
               for ( q=0; q<ndf; q++ )
                  stiff( jj+p, kk+q ) += stiffJK( p, q ) ;
            } //end for p

            kk += ndf ;
	 }//end for k loop

      }//end if tang_flag 

      jj += ndf ;
    }//end for j loop


  }//end for i gauss loop 

  
  return ;
}
예제 #4
0
//return secant matrix 
const Matrix& 
NineNodeMixedQuad::getInitialStiff( ) 
{
  if (Ki != 0)
    return *Ki;

  static const int ndm = 2 ;

  static const int ndf = 2 ; 

  static const int nstress = 4 ;
 
  static const int numberNodes = 9 ;

  static const int numberGauss = 9 ;

  static const int nShape = 3 ;

  static const int nMixed = 3 ;

  int i, j, k, p, q, r, s ;
  int jj, kk ;

  static double volume ;

  static double xsj ;  // determinant jacaobian matrix 

  static double dvol[numberGauss] ; //volume element

  static double gaussPoint[ndm] ;

  static double natCoorArray[ndm][numberGauss] ;

  static Vector strain(nstress) ;  //strain

  static double shp[nShape][numberNodes] ;  //shape functions at a gauss point

  static double Shape[nShape][numberNodes][numberGauss] ; //all the shape functions

  static double shpBar[nShape][numberNodes][nMixed] ; //mean value of shape functions

  static double rightHandSide[nShape][numberNodes][nMixed] ;

  static Vector residJ(ndf) ; //nodeJ residual 

  static Matrix stiffJK(ndf,ndf) ; //nodeJK stiffness 

  static Vector stress(nstress) ;  //stress

  static Matrix dd(nstress,nstress) ;  //material tangent

  static double interp[nMixed] ;

  static Matrix Proj(3,3) ;   //projection matrix 
  static Matrix ProjInv(3,3) ;

  static Matrix Iden(3,3) ;
  Iden(0,0) = 1.0 ;
  Iden(1,1) = 1.0 ;
  Iden(2,2) = 1.0 ;

  //---------B-matrices------------------------------------

    static Matrix BJ(nstress,ndf) ;      // B matrix node J

    static Matrix BJtran(ndf,nstress) ;

    static Matrix BK(nstress,ndf) ;      // B matrix node k

    static Matrix BJtranD(ndf,nstress) ;

  //-------------------------------------------------------

  
  //zero stiffness and residual 
  stiff.Zero( ) ;

  //node coordinates
  computeBasis() ;

  //zero mean shape functions
  for ( p=0; p<nShape; p++ ) {
    for ( q=0; q<numberNodes; q++ ) {

      for (r=0; r<nMixed; r++ ) {
	shpBar[p][q][r] = 0.0 ;
	rightHandSide[p][q][r] = 0.0 ;
      }

    }//end for q
  } // end for p


  //zero volume
  volume = 0.0 ;

  //zero projection matrix  
  Proj.Zero( ) ;
  ProjInv.Zero( ) ;

  //gauss loop to compute and save shape functions 
  int count = 0 ;

  for ( i = 0; i < 3; i++ ) {
    for ( j = 0; j < 3; j++ ) {

        gaussPoint[0] = sg[i] ;        
	gaussPoint[1] = sg[j] ;        


	//save gauss point locations
	natCoorArray[0][count] = gaussPoint[0] ;
	natCoorArray[1][count] = gaussPoint[1] ;


	//get shape functions    
	shape2dNine( gaussPoint, xl, shp, xsj ) ;


	//save shape functions
	for ( p=0; p<nShape; p++ ) {
	  for ( q=0; q<numberNodes; q++ )
	    Shape[p][q][count] = shp[p][q] ;
	} // end for p

	
	//volume element to also be saved
	dvol[count] = ( wg[i]*wg[j] ) * xsj ;  


        //add to projection matrix
	interp[0] = 1.0 ;
	interp[1] = gaussPoint[0] ;
	interp[2] = gaussPoint[1] ;
	
	for ( r=0; r<nMixed; r++ ) {
	  for ( s=0; s<nMixed; s++ ) 
	    Proj(r,s) += ( interp[r]*interp[s] * dvol[count] ) ;
	}//end for r

	volume += dvol[count] ;
	
	
	//add to mean shape functions
	for ( p=0; p<nShape; p++ ) {
	  for ( q=0; q<numberNodes; q++ ) {

	    for ( s=0; s<nMixed; s++ ) 
	      rightHandSide[p][q][s] += ( shp[p][q] * interp[s] * dvol[count] ) ;

	  }//end for q 
	} // end for p


	//increment gauss point counter
	count++ ;

    } //end for j
  } // end for i 
  


  //invert projection matrix
  //int Solve(const Matrix &M, Matrix &res) const;
  Proj.Solve( Iden, ProjInv ) ;
  
  //mean value of shape functions
  for ( p=0; p<nShape; p++ ) {
    for ( q=0; q<numberNodes; q++ ) {

      for (r=0; r<nMixed; r++ ) {
	for (s=0; s<nMixed; s++ ) 
	  shpBar[p][q][r] += ( ProjInv(r,s) * rightHandSide[p][q][s] ) ;
      }//end for r

    }//end for q
  }//end for p


  //gauss loop 
  for ( i=0; i<numberGauss; i++ ) {
    
    //extract gauss point location
    gaussPoint[0] = natCoorArray[0][i] ;
    gaussPoint[1] = natCoorArray[1][i] ;

    //extract shape functions from saved array
    for ( p=0; p<nShape; p++ ) {
       for ( q=0; q<numberNodes; q++ )
	  shp[p][q]  = Shape[p][q][i] ;
    } // end for p

    dd = materialPointers[i]->getInitialTangent( ) ;
    dd *= dvol[i] ;


    //residual and tangent calculations node loops

    jj = 0 ;
    for ( j=0; j<numberNodes; j++ ) {

      BJ = computeBbar( j, gaussPoint, shp, shpBar ) ;
   
      //transpose 
      //BJtran = transpose( nstress, ndf, BJ ) ;
      for (p=0; p<ndf; p++) {
	for (q=0; q<nstress; q++) 
	  BJtran(p,q) = BJ(q,p) ;
      }//end for p


      //BJtranD = BJtran * dd ;
      BJtranD.addMatrixProduct(0.0,  BJtran,dd,1.0);

      kk = 0 ;
      for ( k=0; k<numberNodes; k++ ) {
	
	BK = computeBbar( k, gaussPoint, shp, shpBar ) ;
  
	
	//stiffJK =  BJtranD * BK  ;
	stiffJK.addMatrixProduct(0.0,  BJtranD,BK,1.0) ;

	for ( p=0; p<ndf; p++ )  {
	  for ( q=0; q<ndf; q++ )
	    stiff( jj+p, kk+q ) += stiffJK( p, q ) ;
	} //end for p
	
	kk += ndf ;
      }//end for k loop

      jj += ndf ;
    }//end for j loop
  }//end for i gauss loop 

  Ki = new Matrix(stiff);

  return stiff;
}
예제 #5
0
//form residual and tangent
void  
ShellMITC9::formResidAndTangent( int tang_flag ) 
{
  //
  //  six(6) nodal dof's ordered :
  //
  //    -        - 
  //   |    u1    |   <---plate membrane
  //   |    u2    |
  //   |----------|
  //   |  w = u3  |   <---plate bending
  //   |  theta1  | 
  //   |  theta2  | 
  //   |----------|
  //   |  theta3  |   <---drill 
  //    -        -  
  //
  // membrane strains ordered :
  //
  //            strain(0) =   eps00     i.e.   (11)-strain
  //            strain(1) =   eps11     i.e.   (22)-strain
  //            strain(2) =   gamma01   i.e.   (12)-shear
  //
  // curvatures and shear strains ordered  :
  //
  //            strain(3) =     kappa00  i.e.   (11)-curvature
  //            strain(4) =     kappa11  i.e.   (22)-curvature
  //            strain(5) =   2*kappa01  i.e. 2*(12)-curvature 
  //
  //            strain(6) =     gamma02  i.e.   (13)-shear
  //            strain(7) =     gamma12  i.e.   (23)-shear
  //
  //  same ordering for moments/shears but no 2 
  //  
  //  Then, 
  //              epsilon00 = -z * kappa00      +    eps00_membrane
  //              epsilon11 = -z * kappa11      +    eps11_membrane
  //  gamma01 = 2*epsilon01 = -z * (2*kappa01)  +  gamma01_membrane 
  //
  //  Shear strains gamma02, gamma12 constant through cross section
  //

  static const int ndf = 6 ; //two membrane plus three bending plus one drill

  static const int nstress = 8 ; //three membrane, three moment, two shear

  static const int ngauss = 9 ;

  static const int numnodes = 9 ;

  int i,  j,  k, p, q ;
  int jj, kk ;
  int node ;

  int success ;
  
  double volume = 0.0 ;

  static double xsj ;  // determinant jacaobian matrix 

  static double dvol[ngauss] ; //volume element

  static Vector strain(nstress) ;  //strain

  static double shp[3][numnodes] ;  //shape functions at a gauss point

  static Vector residJ(ndf) ; //nodeJ residual 

  static Matrix stiffJK(ndf,ndf) ; //nodeJK stiffness 

  static Vector stress(nstress) ;  //stress resultants

  static Matrix dd(nstress,nstress) ;  //material tangent

  double epsDrill = 0.0 ;  //drilling "strain"

  double tauDrill = 0.0 ; //drilling "stress"

  //---------B-matrices------------------------------------

    static Matrix BJ(nstress,ndf) ;      // B matrix node J

    static Matrix BJtran(ndf,nstress) ;

    static Matrix BK(nstress,ndf) ;      // B matrix node k

    static Matrix BJtranD(ndf,nstress) ;


    static Matrix Bbend(3,3) ;  // bending B matrix

    static Matrix Bshear(2,3) ; // shear B matrix

    static Matrix Bmembrane(3,2) ; // membrane B matrix


    static double BdrillJ[ndf] ; //drill B matrix

    static double BdrillK[ndf] ;  

    double *drillPointer ;

    static double saveB[nstress][ndf][numnodes] ;

  //-------------------------------------------------------

    

  //zero stiffness and residual 
  stiff.Zero( ) ;
  resid.Zero( ) ;

  //compute Jacobian and inverse at center
  double L1 = 0.0 ;
  double L2 = 0.0 ;
  
  //gauss loop 
  for ( i = 0; i < ngauss; i++ ) {

    //get shape functions
    shape2d( sg[i], tg[i], xl, shp, xsj ) ;

    //volume element to also be saved
    dvol[i] = wg[i] * xsj ;
	volume += dvol[i] ;

    //zero the strains
    strain.Zero( ) ;
    epsDrill = 0.0 ;

    // j-node loop to compute strain 
    for ( j = 0; j < numnodes; j++ )  {

      //compute B matrix 

      Bmembrane = computeBmembrane( j, shp ) ;

      Bbend = computeBbend( j, shp ) ;

	  Bshear = computeBshear( j, shp ) ;
	  
      BJ = assembleB( Bmembrane, Bbend, Bshear ) ;

	  //save the B-matrix
	  for (p=0; p<nstress; p++) {
		for (q=0; q<ndf; q++ ) {
		  saveB[p][q][j] = BJ(p,q) ;
		}//end for q
	  }//end for p

      //nodal "displacements" 
      const Vector &ul = nodePointers[j]->getTrialDisp( ) ;

      //compute the strain
      //strain += (BJ*ul) ; 
      strain.addMatrixVector(1.0, BJ,ul,1.0 ) ;

      //drilling B matrix
      drillPointer = computeBdrill( j, shp ) ;
      for (p=0; p<ndf; p++ ) {
	    //BdrillJ[p] = *drillPointer++ ;
	    BdrillJ[p] = *drillPointer ; //set p-th component
	    drillPointer++ ;             //pointer arithmetic
      }//end for p

      //drilling "strain" 
      for ( p = 0; p < ndf; p++ )
	    epsDrill +=  BdrillJ[p]*ul(p) ;
	} // end for j
  

    //send the strain to the material 
    success = materialPointers[i]->setTrialSectionDeformation( strain ) ;

    //compute the stress
    stress = materialPointers[i]->getStressResultant( ) ;

    //drilling "stress" 
    tauDrill = Ktt * epsDrill ;

    //multiply by volume element
    stress   *= dvol[i] ;
    tauDrill *= dvol[i] ;

    if ( tang_flag == 1 ) {
      dd = materialPointers[i]->getSectionTangent( ) ;
      dd *= dvol[i] ;
    } //end if tang_flag


    //residual and tangent calculations node loops
    jj = 0 ;
    for ( j = 0; j < numnodes; j++ ) {

      //extract BJ
      for (p=0; p<nstress; p++) {
	    for (q=0; q<ndf; q++ )
	      BJ(p,q) = saveB[p][q][j]   ;
      }//end for p

      //multiply bending terms by (-1.0) for correct statement
      // of equilibrium  
      for ( p = 3; p < 6; p++ ) {
	    for ( q = 3; q < 6; q++ ) 
	      BJ(p,q) *= (-1.0) ;
      } //end for p

      //transpose 
      //BJtran = transpose( 8, ndf, BJ ) ;
      for (p=0; p<ndf; p++) {
	    for (q=0; q<nstress; q++) 
	      BJtran(p,q) = BJ(q,p) ;
      }//end for p

      //residJ = BJtran * stress ;
      residJ.addMatrixVector(0.0, BJtran,stress,1.0 ) ;

      //drilling B matrix
      drillPointer = computeBdrill( j, shp ) ;
      for (p=0; p<ndf; p++ ) {
	    BdrillJ[p] = *drillPointer ;
	    drillPointer++ ;
      }//end for p

      //residual including drill
      for ( p = 0; p < ndf; p++ )
        resid( jj + p ) += ( residJ(p) + BdrillJ[p]*tauDrill ) ;

      if ( tang_flag == 1 ) {

        //BJtranD = BJtran * dd ;
	    BJtranD.addMatrixProduct(0.0, BJtran,dd,1.0 ) ;
        
	    for (p=0; p<ndf; p++) {
	      BdrillJ[p] *= ( Ktt*dvol[i] ) ;
        }//end for p

        kk = 0 ;
        for ( k = 0; k < numnodes; k++ ) {
          //extract BK
	      for (p=0; p<nstress; p++) {
	        for (q=0; q<ndf; q++ ){
	          BK(p,q) = saveB[p][q][k];
              
			}//end for q
		  }//end for p
	  
    	  //drilling B matrix
	      drillPointer = computeBdrill( k, shp ) ;
	      for (p=0; p<ndf; p++ ) {
	        BdrillK[p] = *drillPointer ;
	        drillPointer++ ;
		  }//end for p
  
          //stiffJK = BJtranD * BK  ;
	      // +  transpose( 1,ndf,BdrillJ ) * BdrillK ; 
	      stiffJK.addMatrixProduct(0.0, BJtranD,BK,1.0 ) ;

          for ( p = 0; p < ndf; p++ )  {
	        for ( q = 0; q < ndf; q++ ) {
	           stiff( jj+p, kk+q ) += stiffJK(p,q)
		                 + ( BdrillJ[p]*BdrillK[q] ) ;
			}//end for q
		  }//end for p
          kk += ndf ;
		} // end for k loop
	  } // end if tang_flag 
      jj += ndf ;
    } // end for j loop
  } //end for i gauss loop

  return ;
}
예제 #6
0
//return secant matrix 
const Matrix&  ShellMITC9::getInitialStiff( ) 
{
  if (Ki != 0)
    return *Ki;

  static const int ndf = 6 ; //two membrane plus three bending plus one drill

  static const int nstress = 8 ; //three membrane, three moment, two shear

  static const int ngauss = 9 ; 

  static const int numnodes = 9 ;

  int i,  j,  k, p, q ;
  int jj, kk ;
  int node ;

  double volume = 0.0 ;

  static double xsj ;  // determinant jacaobian matrix 

  static double dvol[ngauss] ; //volume element

  static double shp[3][numnodes] ;  //shape functions at a gauss point

  static Matrix stiffJK(ndf,ndf) ; //nodeJK stiffness 

  static Matrix dd(nstress,nstress) ;  //material tangent

  //static Matrix J0(2,2) ;  //Jacobian at center
 
  //static Matrix J0inv(2,2) ; //inverse of Jacobian at center

  //---------B-matrices------------------------------------

    static Matrix BJ(nstress,ndf) ;      // B matrix node J

    static Matrix BJtran(ndf,nstress) ;

    static Matrix BK(nstress,ndf) ;      // B matrix node k

    static Matrix BJtranD(ndf,nstress) ;


    static Matrix Bbend(3,3) ;  // bending B matrix

    static Matrix Bshear(2,3) ; // shear B matrix

    static Matrix Bmembrane(3,2) ; // membrane B matrix


    static double BdrillJ[ndf] ; //drill B matrix

    static double BdrillK[ndf] ;  

    double *drillPointer ;

    static double saveB[nstress][ndf][numnodes] ;

  //-------------------------------------------------------

  stiff.Zero( ) ;


  //compute Jacobian and inverse at center
  double L1 = 0.0 ;
  double L2 = 0.0 ;
  //computeJacobian( L1, L2, xl, J0, J0inv ) ; 

  //gauss loop 
  for ( i = 0; i < ngauss; i++ ) {

    //get shape functions
    shape2d( sg[i], tg[i], xl, shp, xsj ) ;

    //volume element to also be saved
    dvol[i] = wg[i] * xsj ;  

    volume += dvol[i] ;

    // j-node loop to compute strain 
    for ( j = 0; j < numnodes; j++ )  {

      //compute B matrix 

      Bmembrane = computeBmembrane( j, shp ) ;

      Bbend = computeBbend( j, shp ) ;

	  Bshear = computeBshear( j, shp ) ;

      BJ = assembleB( Bmembrane, Bbend, Bshear ) ;

      //save the B-matrix
      for (p=0; p<nstress; p++) {
	    for (q=0; q<ndf; q++ )
	    saveB[p][q][j] = BJ(p,q) ;
      }//end for p

      //drilling B matrix
      drillPointer = computeBdrill( j, shp ) ;
      for (p=0; p<ndf; p++ ) {
	    //BdrillJ[p] = *drillPointer++ ;
	    BdrillJ[p] = *drillPointer ; //set p-th component
	    drillPointer++ ;             //pointer arithmetic
	  }//end for p
    } // end for j
  

    dd = materialPointers[i]->getInitialTangent( ) ;
    dd *= dvol[i] ;

    //residual and tangent calculations node loops

    jj = 0 ;
    for ( j = 0; j < numnodes; j++ ) {

      //extract BJ
      for (p=0; p<nstress; p++) {
	    for (q=0; q<ndf; q++ )
	      BJ(p,q) = saveB[p][q][j]   ;
      }//end for p

      //multiply bending terms by (-1.0) for correct statement
      // of equilibrium  
      for ( p = 3; p < 6; p++ ) {
	    for ( q = 3; q < 6; q++ ) 
	      BJ(p,q) *= (-1.0) ;
      } //end for p


      //transpose 
      //BJtran = transpose( 8, ndf, BJ ) ;
      for (p=0; p<ndf; p++) {
	    for (q=0; q<nstress; q++) 
	      BJtran(p,q) = BJ(q,p) ;
      }//end for p

      //drilling B matrix
      drillPointer = computeBdrill( j, shp ) ;
      for (p=0; p<ndf; p++ ) {
	    BdrillJ[p] = *drillPointer ;
	    drillPointer++ ;
      }//end for p

      //BJtranD = BJtran * dd ;
      BJtranD.addMatrixProduct(0.0, BJtran,dd,1.0 ) ;
	  

      for (p=0; p<ndf; p++) 
	    BdrillJ[p] *= ( Ktt*dvol[i] ) ;


      kk = 0 ;
      for ( k = 0; k < numnodes; k++ ) {
	
	    //extract BK
	    for (p=0; p<nstress; p++) {
	      for (q=0; q<ndf; q++ )
	        BK(p,q) = saveB[p][q][k]   ;
		}//end for p
	
	    //drilling B matrix
	    drillPointer = computeBdrill( k, shp ) ;
	    for (p=0; p<ndf; p++ ) {
	      BdrillK[p] = *drillPointer ;
	      drillPointer++ ;
		}//end for p
	
	    //stiffJK = BJtranD * BK  ;
	    // +  transpose( 1,ndf,BdrillJ ) * BdrillK ; 
	    stiffJK.addMatrixProduct(0.0, BJtranD,BK,1.0 ) ;
	
	    for ( p = 0; p < ndf; p++ )  {
	      for ( q = 0; q < ndf; q++ ) {
	        stiff( jj+p, kk+q ) += stiffJK(p,q) 
	          + ( BdrillJ[p]*BdrillK[q] ) ;
		  }//end for q
		}//end for p
	    kk += ndf ;
	  } // end for k loop
      jj += ndf ;
    } // end for j loop
  } //end for i gauss loop 
  Ki = new Matrix(stiff);
  return stiff ;
}
예제 #7
0
void Line2SurfaceTension :: computeTangent(FloatMatrix &answer, TimeStep *tStep)
{
#if 1
    answer.resize(6, 6);
    answer.zero();
#else
    ///@todo Support axisymm.
    domainType dt = this->giveDomain()->giveDomainType();
    if (dt == _3dAxisymmMode) {
        OOFEM_ERROR("Line2SurfaceTension :: computeTangent - Axisymm not implemented");
    }
    IntegrationRule *iRule = this->integrationRulesArray [ 0 ];
    double t = 1, gamma_s;
    ///@todo Should i use this? Not that meaningful for flow problems.
    //t = this->giveDomain()->giveCrossSection(1)->give(CS_Thickness);
    gamma_s = this->giveMaterial()->give('g', NULL);

    FloatMatrix xy(2,3);
    Node *node;
    for (int i = 1; i <= 3; i++) {
        node = giveNode(i);
        xy.at(1,i) = node->giveCoordinate(1);
        xy.at(2,i) = node->giveCoordinate(2);
    }

    FloatArray A;
    FloatArray dNdxi(3);
    FloatArray es(2); // tangent vector to curve
    FloatMatrix BJ(2,6);
    BJ.zero();
    FloatMatrix temp1,temp2;

    answer.resize(6,6);
    answer.zero();
    for (int k = 0; k < iRule->getNumberOfIntegrationPoints(); k++ ) {
        GaussPoint *gp = iRule->getIntegrationPoint(k);

        double xi = gp->giveCoordinate(1);

        dNdxi.at(1) = -0.5+xi;
        dNdxi.at(2) =  0.5+xi;
        dNdxi.at(3) = -2.0*xi;

        es.beProductOf(xy,dNdxi);
        double J = es.computeNorm();
        es.times(1/J); //es.normalize();

        BJ.at(1,1) = BJ.at(2,2) = dNdxi.at(1);
        BJ.at(1,3) = BJ.at(2,4) = dNdxi.at(2);
        BJ.at(1,5) = BJ.at(2,6) = dNdxi.at(3);

        A.beTProductOf(BJ,es);

        temp1.beTProductOf(BJ,BJ);
        temp2.beDyadicProductOf(A,A);
        temp1.subtract(temp2);
        temp1.times(t*gp->giveWeight()/J*(tStep->giveTimeIncrement()));
        answer.add(temp1);
    }
    answer.times(gamma_s);
#endif
}
예제 #8
0
//*********************************************************************
//form residual and tangent
void  BbarBrick::formResidAndTangent( int tang_flag )
{

  //strains ordered : eps11, eps22, eps33, 2*eps12, 2*eps23, 2*eps31

  static const int ndm = 3 ;

  static const int ndf = 3 ;

  static const int nstress = 6 ;

  static const int numberNodes = 8 ;

  static const int numberGauss = 8 ;

  static const int nShape = 4 ;

  int i, j, k, p, q ;
  int jj, kk ;

  int success ;

  static double volume ;

  static double xsj ;  // determinant jacaobian matrix

  static double dvol[numberGauss] ; //volume element

  static double gaussPoint[ndm] ;

  static Vector strain(nstress) ;  //strain

  static double shp[nShape][numberNodes] ;  //shape functions at a gauss point

  static double Shape[nShape][numberNodes][numberGauss] ; //all the shape functions

  static double shpBar[nShape][numberNodes] ;  //mean value of shape functions

  static Vector residJ(ndf) ; //nodeJ residual

  static Matrix stiffJK(ndf,ndf) ; //nodeJK stiffness

  static Vector stress(nstress) ;  //stress

  static Matrix dd(nstress,nstress) ;  //material tangent


  //---------B-matrices------------------------------------

    static Matrix BJ(nstress,ndf) ;      // B matrix node J

    static Matrix BJtran(ndf,nstress) ;

    static Matrix BK(nstress,ndf) ;      // B matrix node k

    static Matrix BJtranD(ndf,nstress) ;

  //-------------------------------------------------------


  //zero stiffness and residual
  stiff.Zero( ) ;
  resid.Zero( ) ;

  //compute basis vectors and local nodal coordinates
  computeBasis( ) ;


  //zero mean shape functions
  for ( p = 0; p < nShape; p++ ) {
    for ( q = 0; q < numberNodes; q++ )
      shpBar[p][q] = 0.0 ;
  } // end for p

  //zero volume
  volume = 0.0 ;


  //gauss loop to compute and save shape functions
  int count = 0 ;

  for ( i = 0; i < 2; i++ ) {
    for ( j = 0; j < 2; j++ ) {
      for ( k = 0; k < 2; k++ ) {

        gaussPoint[0] = sg[i] ;
	gaussPoint[1] = sg[j] ;
	gaussPoint[2] = sg[k] ;

	//get shape functions
	shp3d( gaussPoint, xsj, shp, xl ) ;

	//save shape functions
	for ( p = 0; p < nShape; p++ ) {
	  for ( q = 0; q < numberNodes; q++ )
	    Shape[p][q][count] = shp[p][q] ;
	} // end for p

	//volume element to also be saved
	dvol[count] = wg[count] * xsj ;

        //add to volume
	volume += dvol[count] ;

	//add to mean shape functions
	for ( p = 0; p < nShape; p++ ) {
	  for ( q = 0; q < numberNodes; q++ )
	    shpBar[p][q] += ( dvol[count] * shp[p][q] ) ;
	} // end for p

	count++ ;

      } //end for k
    } //end for j
  } // end for i


  //mean value of shape functions
  for ( p = 0; p < nShape; p++ ) {
    for ( q = 0; q < numberNodes; q++ )
      shpBar[p][q] /= volume ;
  } // end for p


  //gauss loop
  for ( i = 0; i < numberGauss; i++ ) {

    //extract shape functions from saved array
    for ( p = 0; p < nShape; p++ ) {
       for ( q = 0; q < numberNodes; q++ )
	  shp[p][q]  = Shape[p][q][i] ;
    } // end for p


    //zero the strains
    strain.Zero( ) ;


    // j-node loop to compute strain
    for ( j = 0; j < numberNodes; j++ )  {

      //compute B matrix

      BJ = computeBbar( j, shp, shpBar ) ;

      //nodal displacements
      const Vector &ul = nodePointers[j]->getTrialDisp( ) ;

      //compute the strain
      //strain += (BJ*ul) ;
      strain.addMatrixVector(1.0,  BJ,ul,1.0 ) ;

    } // end for j



    //send the strain to the material
    success = materialPointers[i]->setTrialStrain( strain ) ;

    //compute the stress
    stress = materialPointers[i]->getStress( ) ;


    //multiply by volume element
    stress  *= dvol[i] ;

    if ( tang_flag == 1 ) {
      dd = materialPointers[i]->getTangent( ) ;
      dd *= dvol[i] ;
    } //end if tang_flag


    //residual and tangent calculations node loops

    jj = 0 ;
    for ( j = 0; j < numberNodes; j++ ) {

      BJ = computeBbar( j, shp, shpBar ) ;

      //transpose
      //BJtran = transpose( nstress, ndf, BJ ) ;
      for (p=0; p<ndf; p++) {
	for (q=0; q<nstress; q++)
	  BJtran(p,q) = BJ(q,p) ;
      }//end for p


      //residual
      //residJ = BJtran * stress ;
      residJ.addMatrixVector(0.0,  BJtran,stress,1.0);

      //residual
      for ( p = 0; p < ndf; p++ ) {
        resid( jj + p ) += residJ(p)  ;
		if (applyLoad == 0) {
	    	resid( jj + p ) -= dvol[i]*b[p]*shp[3][j];
		} else {
			resid( jj + p ) -= dvol[i]*appliedB[p]*shp[3][j];
		}
      }

      if ( tang_flag == 1 ) {

	//BJtranD = BJtran * dd ;
	BJtranD.addMatrixProduct(0.0,  BJtran,dd,1.0);

         kk = 0 ;
         for ( k = 0; k < numberNodes; k++ ) {

            BK = computeBbar( k, shp, shpBar ) ;


            //stiffJK =  BJtranD * BK  ;
	    stiffJK.addMatrixProduct(0.0,  BJtranD,BK,1.0) ;

            for ( p = 0; p < ndf; p++ )  {
               for ( q = 0; q < ndf; q++ )
                  stiff( jj+p, kk+q ) += stiffJK( p, q ) ;
            } //end for p

            kk += ndf ;
          } // end for k loop

      } // end if tang_flag

      jj += ndf ;
    } // end for j loop


  } //end for i gauss loop


  return ;
}
예제 #9
0
//return stiffness matrix
const Matrix&  BbarBrick::getInitialStiff( )
{
  if (Ki != 0)
    return *Ki;

  //strains ordered : eps11, eps22, eps33, 2*eps12, 2*eps23, 2*eps31

  static const int ndm = 3 ;

  static const int ndf = 3 ;

  static const int nstress = 6 ;

  static const int numberNodes = 8 ;

  static const int numberGauss = 8 ;

  static const int nShape = 4 ;

  int i, j, k, p, q ;
  int jj, kk ;

  static double volume ;

  static double xsj ;  // determinant jacaobian matrix

  static double dvol[numberGauss] ; //volume element

  static double gaussPoint[ndm] ;

  static Vector strain(nstress) ;  //strain

  static double shp[nShape][numberNodes] ;  //shape functions at a gauss point

  static double Shape[nShape][numberNodes][numberGauss] ; //all the shape functions

  static double shpBar[nShape][numberNodes] ;  //mean value of shape functions

  static Matrix stiffJK(ndf,ndf) ; //nodeJK stiffness

  static Matrix dd(nstress,nstress) ;  //material tangent


  //---------B-matrices------------------------------------

    static Matrix BJ(nstress,ndf) ;      // B matrix node J

    static Matrix BJtran(ndf,nstress) ;

    static Matrix BK(nstress,ndf) ;      // B matrix node k

    static Matrix BJtranD(ndf,nstress) ;

  //-------------------------------------------------------


  //zero stiffness and residual
  stiff.Zero( ) ;


  //compute basis vectors and local nodal coordinates
  computeBasis( ) ;

  //zero mean shape functions
  for ( p = 0; p < nShape; p++ ) {
    for ( q = 0; q < numberNodes; q++ )
      shpBar[p][q] = 0.0 ;
  } // end for p

  //zero volume
  volume = 0.0 ;


  //gauss loop to compute and save shape functions
  int count = 0 ;

  for ( i = 0; i < 2; i++ ) {
    for ( j = 0; j < 2; j++ ) {
      for ( k = 0; k < 2; k++ ) {

        gaussPoint[0] = sg[i] ;
	gaussPoint[1] = sg[j] ;
	gaussPoint[2] = sg[k] ;

	//get shape functions
	shp3d( gaussPoint, xsj, shp, xl ) ;

	//save shape functions
	for ( p = 0; p < nShape; p++ ) {
	  for ( q = 0; q < numberNodes; q++ )
	    Shape[p][q][count] = shp[p][q] ;
	} // end for p

	//volume element to also be saved
	dvol[count] = wg[count] * xsj ;

        //add to volume
	volume += dvol[count] ;

	//add to mean shape functions
	for ( p = 0; p < nShape; p++ ) {
	  for ( q = 0; q < numberNodes; q++ )
	    shpBar[p][q] += ( dvol[count] * shp[p][q] ) ;
	} // end for p

	count++ ;

      } //end for k
    } //end for j
  } // end for i


  //mean value of shape functions
  for ( p = 0; p < nShape; p++ ) {
    for ( q = 0; q < numberNodes; q++ )
      shpBar[p][q] /= volume ;
  } // end for p


  //gauss loop
  for ( i = 0; i < numberGauss; i++ ) {

    //extract shape functions from saved array
    for ( p = 0; p < nShape; p++ ) {
       for ( q = 0; q < numberNodes; q++ )
	  shp[p][q]  = Shape[p][q][i] ;
    } // end for p

    dd = materialPointers[i]->getInitialTangent( ) ;
    dd *= dvol[i] ;

    //residual and tangent calculations node loops

    jj = 0 ;
    for ( j = 0; j < numberNodes; j++ ) {

      BJ = computeBbar( j, shp, shpBar ) ;

      //transpose
      //BJtran = transpose( nstress, ndf, BJ ) ;
      for (p=0; p<ndf; p++) {
	for (q=0; q<nstress; q++)
	  BJtran(p,q) = BJ(q,p) ;
      }//end for p

      //BJtranD = BJtran * dd ;
      BJtranD.addMatrixProduct(0.0,  BJtran,dd,1.0);

      kk = 0 ;
      for ( k = 0; k < numberNodes; k++ ) {

	BK = computeBbar( k, shp, shpBar ) ;

	//stiffJK =  BJtranD * BK  ;
	stiffJK.addMatrixProduct(0.0,  BJtranD,BK,1.0) ;

	for ( p = 0; p < ndf; p++ )  {
	  for ( q = 0; q < ndf; q++ )
	    stiff( jj+p, kk+q ) += stiffJK( p, q ) ;
	} //end for p

	kk += ndf ;
      } // end for k loop

      jj += ndf ;

    } // end for j loop
  } //end for i gauss loop

  Ki = new Matrix(stiff);

  return stiff ;
}