示例#1
0
    def getULInternalForce(self, elemdat):

        n = self.dofCount()

        state0 = elemdat.state - elemdat.Dstate
        curCrds = elemdat.coords + reshape(state0, elemdat.coords.shape)

        sData0 = getElemShapeData(elemdat.coords)
        sDataC = getElemShapeData(curCrds)

        for iOrig, iCurr in zip(sData0, sDataC):

            r = dot(curCrds[:, 0], iOrig.h)
            r0 = dot(elemdat.coords[:, 0], iOrig.h)

            weight = 2.0 * pi * r * iCurr.weight

            kin = self.getKinematics(iOrig.dhdx, iOrig.h, elemdat, r0)
            B = self.getULBmatrix(iCurr.dhdx, iCurr.h, r)

            sigma, tang = self.mat.getStress(kin)

            s4 = self.stress6to4(sigma)

            elemdat.fint += dot(B.transpose(), s4) * weight

            self.appendNodalOutput(self.mat.outLabels(), self.mat.outData())
示例#2
0
    def getTangentStiffness(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        kin = Kinematics(3, 6)

        elemdat.outlabel.append(["s11", "s22", "s33", "s23", "s13", "s12"])

        elemdat.outdata = zeros(shape=(len(elemdat.nodes), 6))

        for iData in sData:

            b = self.getBmatrix(iData.dhdx)

            kin.strain = dot(b, elemdat.state)
            kin.dstrain = dot(b, elemdat.Dstate)

            sigma, tang = self.mat.getStress(kin)

            elemdat.stiff += dot(b.transpose(), dot(tang, b)) * iData.weight
            elemdat.fint += dot(b.transpose(), sigma) * iData.weight

            elemdat.outdata += outer(ones(len(elemdat.nodes)), sigma)

        elemdat.outdata *= 1.0 / len(sData)
示例#3
0
    def getInternalForce(self, elemdat):

        sData = getElemShapeData(elemdat.coords, -1)

        elemdat.outlabel.append(self.outputLabels)
        elemdat.outdata = zeros(shape=(len(elemdat.nodes), 6))

        eps0 = zeros(3)
        kappa = zeros(3)

        for iData in sData:
            eps0[0] = dot(iData.dhdx[:, 0], elemdat.state[0:20:5])
            eps0[1] = dot(iData.dhdx[:, 1], elemdat.state[1:20:5])
            eps0[2] = dot(iData.dhdx[:,1],elemdat.state[0:20:5])+\
                      dot(iData.dhdx[:,0],elemdat.state[1:20:5])

            kappa[0] = dot(iData.dhdx[:, 0], elemdat.state[3:20:5])
            kappa[1] = dot(iData.dhdx[:, 1], elemdat.state[4:20:5])
            kappa[2]= dot(iData.dhdx[:,1],elemdat.state[3:20:5])+\
                      dot(iData.dhdx[:,0],elemdat.state[4:20:5])

            for i, pp in enumerate(self.postProcess):
                eps = eps0 + pp.z * kappa
                sigma = stressTransformation(dot(pp.Qbar, eps), pp.theta)

                self.appendNodalOutput(pp.labels, sigma)
  def getTangentStiffness ( self, elemdat ):

    n = self.dofCount()

    sData = getElemShapeData( elemdat.coords )
    
    elemdat.outlabel.append("stresses")
    elemdat.outdata  = zeros( shape=(len(elemdat.nodes),3) )
   
    for iData in sData:

      kin = self.getKinematics( iData.dhdx , elemdat.state ) 
      B   = self.getBmatrix   ( iData.dhdx , kin.F )
      
      sigma,tang = self.mat.getStress( kin )
        
      elemdat.stiff += dot ( B.transpose() , dot ( tang , B ) ) * iData.weight

      T   = self.stress2matrix( sigma )
      Bnl = self.getBNLmatrix ( iData.dhdx )
   
      elemdat.stiff += dot ( Bnl.transpose() , dot( T , Bnl ) ) * iData.weight
      elemdat.fint  += dot ( B.transpose() , sigma ) * iData.weight
      
      elemdat.outdata += outer( ones(len(elemdat.nodes)), sigma )
      
    elemdat.outdata *= 1.0 / len(sData)  
示例#5
0
    def getInternalForce(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        for iData in sData:

            r = dot(elemdat.coords[:, 0], iData.h)
            weight = 2.0 * pi * r * iData.weight

            b = self.getBmatrix(iData.dhdx, iData.h, r)

            strain = dot(b, elemdat.state)
            #self.kin.dstrain = dot ( b , elemdat.Dstate )

            self.kin.strain[0] = strain[0]
            self.kin.strain[1] = strain[1]
            self.kin.strain[2] = strain[2]
            self.kin.strain[3] = 0.
            self.kin.strain[4] = 0.
            self.kin.strain[5] = strain[3]

            #self.kin.dstrain = dot ( b , elemdat.Dstate )

            sigma, tang = self.mat.getStress(self.kin)

            s4 = self.stress6to4(sigma)

            elemdat.fint += dot(b.transpose(), s4) * weight

            self.appendNodalOutput(self.mat.outLabels(), self.mat.outData())
    def getTangentStiffness(self, elemdat):

        n = self.dofCount()

        sData = getElemShapeData(elemdat.coords)

        elemdat.outlabel.append("stresses")
        elemdat.outdata = zeros(shape=(len(elemdat.nodes), 3))

        for iData in sData:

            kin = self.getKinematics(iData.dhdx, elemdat.state)
            B = self.getBmatrix(iData.dhdx, kin.F)

            sigma, tang = self.mat.getStress(kin)

            elemdat.stiff += dot(B.transpose(), dot(tang, B)) * iData.weight

            T = self.stress2matrix(sigma)
            Bnl = self.getBNLmatrix(iData.dhdx)

            elemdat.stiff += dot(Bnl.transpose(), dot(T, Bnl)) * iData.weight
            elemdat.fint += dot(B.transpose(), sigma) * iData.weight

            elemdat.outdata += outer(ones(len(elemdat.nodes)), sigma)

        elemdat.outdata *= 1.0 / len(sData)
示例#7
0
    def getTangentStiffness(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        nDof = len(elemdat.coords)

        temp0 = elemdat.state - elemdat.Dstate

        if self.transient:
            ctt = zeros(shape=(nDof, nDof))
            invdtime = 1.0 / self.solverStat.dtime

        for iInt, iData in enumerate(sData):
            gradTemp = dot(iData.dhdx.transpose(), elemdat.state)

            elemdat.stiff += \
              dot ( iData.dhdx , dot( self.D , iData.dhdx.transpose() ) ) * iData.weight

            if self.transient:
                ctt += self.capac * outer(iData.h, iData.h) * iData.weight

            self.appendNodalOutput(self.labels, dot(self.D, gradTemp))

        if self.transient:
            ktt0 = invdtime * ctt - elemdat.stiff * (1.0 - self.theta)

            elemdat.stiff *= self.theta

            elemdat.stiff += invdtime * ctt

        elemdat.fint += dot(elemdat.stiff, elemdat.state)

        if self.transient:
            elemdat.fint += -dot(ktt0, temp0)
 def getTangentStiffness(self, elemdat):
     n = self.dofCount()
     sData = getElemShapeData(elemdat.coords)
     elemdat.outlabel.append("stresses")
     elemdat.outdata = zeros(shape=(len(elemdat.nodes), 3))
     for iData in sData:
         kin = self.getKinematics(iData.dhdx, elemdat.state)
         firstPiola, K4tang = self.mat.getStress(kin)
         K4 = ut.transform_4thTensor_to_2ndTensor_inlargestrain(K4tang)
         firstPiola_vector = ut.transform_matrix_to_vector(firstPiola)
         Bnl = self.getBNLmatrix(iData.dhdx)
         elemdat.stiff += dot(Bnl.transpose(), dot(K4, Bnl)) * iData.weight
         elemdat.fint += dot(Bnl.transpose(),
                             firstPiola_vector) * iData.weight
         secondPiola = dot(np.linalg.inv(kin.F), firstPiola)
         secondPiola_vector = np.array(
             [secondPiola[0, 0], secondPiola[1, 1], secondPiola[0, 1]])
         elemdat.outdata += outer(ones(len(elemdat.nodes)),
                                  secondPiola_vector)
         # elemdat.stiff += dot(B.transpose(), dot(tang, B)) * iData.weight  # nonlinear material: dF : (F . DS) -> (dF.F) : C DE -> (dF.F) : C : (DF.F)
         # T = self.stress2matrix(sigma)
         # Bnl = self.getBNLmatrix(iData.dhdx)
         # elemdat.stiff += dot(Bnl.transpose(), dot(T, Bnl)) * iData.weight  # nonlinear geometry: dF : (DF . S)
         # elemdat.fint += dot(B.transpose(), sigma) * iData.weight  # power conjugate: chuyen tu F:P sang E:S -> 1/2(FT.F + F.FT):S -> FT.F : S (vi S symmetry)
         # elemdat.outdata += outer(ones(len(elemdat.nodes)), sigma)
     elemdat.outdata *= 1.0 / len(sData)
示例#9
0
文件: Plate.py 项目: csutjf/PyFEM-1
  def getInternalForce ( self, elemdat ):

    sData = getElemShapeData( elemdat.coords , -1 )

    elemdat.outlabel.append(self.outputLabels)
    elemdat.outdata  = zeros( shape=(len(elemdat.nodes),6) )

    eps0  = zeros(3)
    epss  = zeros(2)
    kappa = zeros(3)

    for iData in sData:
      eps0[0] = dot(iData.dhdx[:,0],elemdat.state[0:20:5])
      eps0[1] = dot(iData.dhdx[:,1],elemdat.state[1:20:5])
      eps0[2] = dot(iData.dhdx[:,1],elemdat.state[0:20:5])+\
                dot(iData.dhdx[:,0],elemdat.state[1:20:5])
      epss[0] = dot(iData.dhdx[:,1],elemdat.state[2:20:5])+\
                dot(iData.h        ,elemdat.state[4:20:5])
      epss[1] = dot(iData.dhdx[:,0],elemdat.state[2:20:5])+\
                dot(iData.h        ,elemdat.state[3:20:5])

      kappa[0]= dot(iData.dhdx[:,0],elemdat.state[3:20:5])
      kappa[1]= dot(iData.dhdx[:,1],elemdat.state[4:20:5])
      kappa[2]= dot(iData.dhdx[:,1],elemdat.state[3:20:5])+\
                dot(iData.dhdx[:,0],elemdat.state[4:20:5])

#      for pp in postProcess:
#        eps   = eps0 + pp.z*kappa
#        sigma = com

      elemdat.outdata += 0.0#eps0 #outer( ones(len(self)), sigma )
      
    elemdat.outdata *= 1.0 / len(sData)  
示例#10
0
    def getTangentStiffness(self, elemdat):

        n = self.dofCount()

        sData = getElemShapeData(elemdat.coords)

        elemdat.outlabel.append("stresses")
        elemdat.outdata = zeros(shape=(len(elemdat.nodes), 3))

        for iData in sData:

            kin = self.getKinematics(iData.dhdx, elemdat.state)
            B = self.getBmatrix(iData.dhdx, kin.F)

            sigma, tang = self.mat.getStress(kin)

            elemdat.stiff += dot(
                B.transpose(), dot(tang, B)
            ) * iData.weight  # nonlinear material: dF : (F . DS) -> (dF.F) : C DE -> (dF.F) : C : (DF.F)

            T = self.stress2matrix(sigma)
            Bnl = self.getBNLmatrix(iData.dhdx)

            elemdat.stiff += dot(Bnl.transpose(), dot(
                T, Bnl)) * iData.weight  # nonlinear geometry: dF : (DF . S)
            elemdat.fint += dot(
                B.transpose(), sigma
            ) * iData.weight  # power conjugate: chuyen tu F:P sang E:S -> 1/2(FT.F + F.FT):S -> FT.F : S (vi S symmetry)

            elemdat.outdata += outer(ones(len(elemdat.nodes)), sigma)

        elemdat.outdata *= 1.0 / len(sData)
示例#11
0
  def getTangentStiffness ( self, elemdat ):

    n = self.dofCount()

    sData = getElemShapeData( elemdat.coords )
    
    elemdat.outlabel.append(self.outputLabels)
    elemdat.outdata  = zeros( shape=(len(elemdat.nodes),self.nstr) )
   
    for iData in sData:

      self.kin = self.getKinematics( iData.dhdx , elemdat.state ) 
      B        = self.getBmatrix   ( iData.dhdx , self.kin.F )
      
      sigma,tang = self.mat.getStress( self.kin )
        
      elemdat.stiff += dot ( B.transpose() , dot ( tang , B ) ) * iData.weight

      T   = self.stress2matrix( sigma )
      Bnl = self.getBNLmatrix ( iData.dhdx )
   
      elemdat.stiff += dot ( Bnl.transpose() , dot( T , Bnl ) ) * iData.weight
      elemdat.fint  += dot ( B.transpose() , sigma ) * iData.weight
      
      self.appendNodalOutput( self.mat.outLabels() , self.mat.outData() )
示例#12
0
  def getTangentStiffness ( self, elemdat ):

    print(self.rank)
    sData = getElemShapeData( elemdat.coords )
    
    uDofs,pDofs = self.splitDofIDs( len(elemdat.coords) )
                 
    for iInt,iData in enumerate(sData):
      
      B = self.getBmatrix( iData.dhdx )

      self.kin.strain  = dot ( B , elemdat.state [uDofs] )
      self.kin.dstrain = dot ( B , elemdat.Dstate[uDofs] )
      
      phase     = dot( iData.h    , elemdat.state[pDofs] )
      gradPhase = dot( iData.dhdx.transpose() , elemdat.state[pDofs] )
      
      sigma,tang = self.mat.getStress( self.kin )

      energy = 0.5*sum(self.kin.strain*sigma)

      if energy > self.hisOld[iInt]:
        self.hisNew[iInt] = energy
      else:
        self.hisNew[iInt] = self.hisOld[iInt]
            
      factor = 1.0-phase*phase+self.k
                   
      # -- Displacement contributions
      
      uStiff = dot ( B.transpose() , dot ( factor*tang , B ) ) 
      elemdat.stiff[ix_(uDofs,uDofs)] += uStiff * iData.weight
  
      dispForce = dot ( B.transpose() , factor*sigma )
      elemdat.fint[uDofs] += dispForce * iData.weight
      
      pStiff = (self.Gc/self.l0+2.0*self.hisNew[iInt])*outer(iData.h , iData.h )
      pStiff += self.Gc*self.l0*dot( iData.dhdx,iData.dhdx.transpose() )
      pStiff = iData.weight * pStiff
      
      elemdat.stiff[ix_(pDofs,pDofs)] += pStiff
      
      # -- Phase field contributions
      
      pfint =  self.Gc*self.l0*dot( iData.dhdx , gradPhase );
      pfint += self.Gc/self.l0*iData.h*phase;
      pfint += 2.0*( phase-1.0 ) * iData.h * self.hisNew[iInt]
            
      elemdat.fint[pDofs] += pfint * iData.weight
      
      # -- Coupling terms
      
      vecu = -2.0 * ( 1.0 - phase ) * dot( B.transpose() , sigma ) * iData.weight
      elemdat.stiff[ix_(uDofs,pDofs)] += outer( vecu , iData.h )       
      elemdat.stiff[ix_(pDofs,uDofs)] += outer( iData.h , vecu ) 
      
      # Coupling terms need TOBEIMPLEMENTED
      
      self.appendNodalOutput( self.mat.outLabels() , self.mat.outData() )
示例#13
0
  def getTangentStiffness ( self, elemdat ):
       
    sData = getElemShapeData( elemdat.coords )
    
    dDofs,tDofs = self.splitDofIDs( len(elemdat.coords) )
    
    temp0 = elemdat.state [tDofs] - elemdat.Dstate[tDofs]
    
    if self.transient:
      ctt      = zeros(shape=(len(tDofs),len(tDofs)))
      invdtime = 1.0/self.solverStat.dtime
                       
    for iInt,iData in enumerate(sData):
      
      B = self.getBmatrix( iData.dhdx )

      self.kin.strain  = dot ( B , elemdat.state [dDofs] )
      self.kin.dstrain = dot ( B , elemdat.Dstate[dDofs] )
      
      temp     = sum( iData.h * elemdat.state [tDofs] )
      dtemp    = sum( iData.h * elemdat.Dstate[tDofs] )
      gradTemp = dot( iData.dhdx.transpose() , elemdat.state [tDofs] )
            
      self.kin.strain[:self.nstr]  += -self.alpha * temp
      self.kin.dstrain[:self.nstr] += -self.alpha * dtemp 
            
      sigma,tang = self.mat.getStress( self.kin )
      
      elemdat.stiff[ix_(dDofs,dDofs)] += \
        dot ( B.transpose() , dot ( tang , B ) ) * iData.weight
        
      dsdt = -1.0 * dot( tang , self.alpha )  
      elemdat.stiff[ix_(dDofs,tDofs)] += \
        dot ( B.transpose() , outer ( dsdt , iData.h ) ) * iData.weight
      
      elemdat.stiff[ix_(tDofs,tDofs)] += \
        dot ( iData.dhdx , dot( self.D , iData.dhdx.transpose() ) ) * iData.weight
  
      elemdat.fint[dDofs] += dot ( B.transpose() , sigma ) * iData.weight
      
      if self.transient:
        ctt += self.capac * outer( iData.h , iData.h ) * iData.weight
              
      self.appendNodalOutput( self.mat.outLabels() , self.mat.outData() )
      self.appendNodalOutput( self.labels , dot(self.D,gradTemp) ) 
    
    if self.transient:  
      ktt0 = invdtime * ctt - elemdat.stiff[ix_(tDofs,tDofs)] * \
        ( 1.0-self.theta )
      
      elemdat.stiff *= self.theta
      
      elemdat.stiff[ix_(tDofs,tDofs)] += invdtime * ctt 
        
    elemdat.fint[tDofs] += \
      dot ( elemdat.stiff[ix_(tDofs,tDofs)] , elemdat.state[tDofs] )
      
    if self.transient:
      elemdat.fint[tDofs] += -dot ( ktt0 , temp0 )
示例#14
0
    def getULTangentStiffness(self, elemdat):

        state0 = elemdat.state - elemdat.Dstate
        curCrds = elemdat.coords + reshape(state0, elemdat.coords.shape)

        sData0 = getElemShapeData(elemdat.coords)
        sDataC = getElemShapeData(curCrds)

        for iOrig, iCurr in zip(sData0, sDataC):

            r = dot(curCrds[:, 0], iOrig.h)
            r0 = dot(elemdat.coords[:, 0], iOrig.h)

            weight = 2.0 * pi * r * iCurr.weight

            kin = self.getKinematics(iOrig.dhdx, iOrig.h, elemdat, r0)
            B = self.getULBmatrix(iCurr.dhdx, iCurr.h, r)

            sigma, tang = self.mat.getStress(kin)

            t4 = self.tang6to4(tang)
            s4 = self.stress6to4(sigma)

            stiff = dot(B.transpose(), dot(t4, B))

            for i, dpi in enumerate(iCurr.dhdx):
                for j, dpj in enumerate(iCurr.dhdx):
                    stiff[
                        2 * i, 2 *
                        j] += s4[0] * dpi[0] * dpj[0] + s4[1] * dpi[1] * dpj[1]
                    stiff[2 * i,
                          2 * j] += s4[2] * iCurr.h[i] * iCurr.h[j] / (r * r)
                    stiff[2 * i,
                          2 * j] += s4[3] * (dpi[0] * dpj[1] + dpi[1] * dpj[0])

                    stiff[
                        2 * i + 1, 2 * j +
                        1] += s4[0] * dpi[0] * dpj[0] + s4[1] * dpi[1] * dpj[1]
                    stiff[2 * i + 1, 2 * j +
                          1] += s4[3] * (dpi[0] * dpj[1] + dpi[1] * dpj[0])

            elemdat.stiff += stiff * weight
            elemdat.fint += dot(B.transpose(), s4) * weight

            self.appendNodalOutput(self.mat.outLabels(), self.mat.outData())
示例#15
0
    def getULInternalForce(self, elemdat):

        state0 = elemdat.state - elemdat.Dstate
        curCrds = elemdat.coords + reshape(state0, elemdat.coords.shape)

        sData0 = getElemShapeData(elemdat.coords)
        sDataC = getElemShapeData(curCrds)

        for iOrig, iCurr in zip(sData0, sDataC):

            self.kin = self.getKinematics(iOrig.dhdx, elemdat)
            B = self.getULBmatrix(iCurr.dhdx)

            sigma, tang = self.mat.getStress(self.kin)

            elemdat.fint += dot(B.transpose(), sigma) * iCurr.weight

            self.appendNodalOutput(self.mat.outLabels(), self.mat.outData())
示例#16
0
    def getInternalForce(self, elemdat):

        sData = getElemShapeData(elemdat.coords, elemType="Line2")

        for iData in sData:
            temp = sum(iData.h * elemdat.state)

            elemdat.fint += iData.h * ( self.convection * ( temp - self.extTemp ) + \
              self.Boltzman * self.emissivity * ( temp**4 - self.extTemp4 ) ) * iData.weight
示例#17
0
  def getShapeData( self , elemdat ):
 
   crd  = elemdat.coords  
   nNod = crd.shape[0]
     
   if self.rank == 2:
     b = zeros(3)
     b[2] = 1.0
     
     if nNod == 2:
       sData = getElemShapeData( elemdat.coords , elemType = "Line2" )
       a     = self.getDirection(crd,1,0)
     elif nNod == 3:
       sData = getElemShapeData( elemdat.coords , elemType = "Line3" )
       a     = self.getDirection(crd,2,0)
     else:
       raise RuntimeError("The rank is 2, the number of nodes must be 2 or 3.")
   elif self.rank == 3:
     if nNod == 3:
       a     = self.getDirection(crd,1,0)
       b     = self.getDirection(crd,2,0)
     elif nNod == 4:
       sData = getElemShapeData( elemdat.coords , elemType = "Quad4" )  
       a     = self.getDirection(crd,1,0)
       b     = self.getDirection(crd,2,0)
     elif nNod == 6:
       sData = getElemShapeData( elemdat.coords , elemType = "Tria6" ) 
       a     = self.getDirection(crd,1,0)
       b     = self.getDirection(crd,2,0) 
     elif nNod == 8:
       sData = getElemShapeData( elemdat.coords , elemType = "Quad8" )  
       a     = self.getDirection(crd,1,0)
       b     = self.getDirection(crd,2,0)       
     else:
       raise RuntimeError("The rank is 3, the number of nodes must be 3, 4, 6 or 8.")
   else:
     raise RuntimeError("The element must be rank 3.")
     
   for iData in sData:
     iData.normal = cross(a,b)
     iData.normal *= 1.0/sqrt(dot(iData.normal,iData.normal))
     
   return sData     
示例#18
0
    def getMassMatrix(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        rho = elemdat.matprops.rho

        for iData in sData:
            N = self.getNmatrix(iData.h)
            elemdat.mass += dot(N.transpose(), N) * rho * iData.weight

        elemdat.lumped = sum(elemdat.mass)
示例#19
0
  def getMassMatrix ( self, elemdat ):
      
    sData = getElemShapeData( elemdat.coords )

    rho = elemdat.matprops.rho

    for iData in sData:
      N  = self.getNmatrix( iData.h )
      elemdat.mass += dot ( N.transpose() , N ) * rho * iData.weight
     
    elemdat.lumped = sum(elemdat.mass)
示例#20
0
    def getTangentStiffness(self, elemdat):

        sData = getElemShapeData(elemdat.coords, elemType="Line2")

        for iData in sData:
            temp = sum(iData.h * elemdat.state)

            elemdat.stiff += outer ( iData.h , iData.h ) * \
              ( self.convection + 4.0 * self.Boltzman * self.emissivity * temp**3 ) * iData.weight

            elemdat.fint += iData.h * ( self.convection * ( temp - self.extTemp ) + \
              self.Boltzman * self.emissivity * ( temp**4 - self.extTemp4 ) ) * iData.weight
示例#21
0
    def getShapeData(self, elemdat):

        nNod = elemdat.coords.shape[0]

        if self.rank == 2:
            if nNod == 2:
                return getElemShapeData(elemdat.coords, elemType="Line2")
            elif nNod == 3:
                return getElemShapeData(elemdat.coords, elemType="Line3")
            else:
                raise RuntimeError(
                    "The rank is 2, the number of nodes must be 2 or 3.")
        elif self.rank == 3:
            if nNod == 3:
                return getElemShapeData(elemdat.coords, elemType="Tria3")
            elif nNod == 4:
                return getElemShapeData(elemdat.coords, elemType="Quad4")
            elif nNod == 6:
                return getElemShapeData(elemdat.coords, elemType="Tria6")
            elif nNod == 8:
                return getElemShapeData(elemdat.coords, elemType="Quad8")
            else:
                raise RuntimeError(
                    "The rank is 3, the number of nodes must be 3, 4, 6 or 8.")
        else:
            raise RuntimeError("The element must be rank 3.")

        return None
示例#22
0
  def getMassMatrix ( self, elemdat ):
      
    sData = getElemShapeData( elemdat.coords )

    rho = self.rho * eye(2)

    for iData in sData:
      N  = self.getNmatrix( iData.h )
      Nt = N.transpose()

      elemdat.mass += dot ( Nt , dot( rho , N ) ) * iData.weight
      
    elemdat.lumped = sum(elemdat.mass)
    def getMassMatrix(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        rho = self.rho * eye(2)

        for iData in sData:
            N = self.getNmatrix(iData.h)
            Nt = N.transpose()

            elemdat.mass += dot(Nt, dot(rho, N)) * iData.weight

        elemdat.lumped = sum(elemdat.mass)
示例#24
0
    def getTLInternalForce(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        for iData in sData:

            self.kin = self.getKinematics(iData.dhdx, elemdat)
            B = self.getBmatrix(iData.dhdx, self.kin.F)

            sigma, tang = self.mat.getStress(self.kin)

            elemdat.fint += dot(B.transpose(), sigma) * iData.weight

            self.appendNodalOutput(self.mat.outLabels(), self.mat.outData())
示例#25
0
    def getULTangentStiffness(self, elemdat):

        state0 = elemdat.state - elemdat.Dstate
        curCrds = elemdat.coords + reshape(state0, elemdat.coords.shape)

        sData0 = getElemShapeData(elemdat.coords)
        sDataC = getElemShapeData(curCrds)

        for iOrig, iCurr in zip(sData0, sDataC):

            self.kin = self.getKinematics(iOrig.dhdx, elemdat)
            B = self.getULBmatrix(iCurr.dhdx)

            sigma, tang = self.mat.getStress(self.kin)

            elemdat.stiff += dot(B.transpose(), dot(tang, B)) * iCurr.weight

            T = self.stress2matrix(sigma)
            Bnl = self.getBNLmatrix(iCurr.dhdx)

            elemdat.stiff += dot(Bnl.transpose(), dot(T, Bnl)) * iCurr.weight
            elemdat.fint += dot(B.transpose(), sigma) * iCurr.weight

            self.appendNodalOutput(self.mat.outLabels(), self.mat.outData())
示例#26
0
    def getDissipation(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        for iData in sData:
            self.kin = self.getKinematics(iData.dhdx, elemdat)
            B = self.getBmatrix(iData.dhdx, self.kin.F)

            self.mat.getStress(self.kin)

            self.kin.dgdstrain = zeros(3)
            self.kin.g = 0.0

            elemdat.fint += dot(B.transpose(),
                                self.kin.dgdstrain) * iData.weight
            elemdat.diss += self.kin.g * iData.weight
 def getTangentStiffness(self, element_data):
     sData = getElemShapeData(element_data.coords)
     kinematic = Kinematics(2, 3)
     element_data.outlabel.append("stresses")
     element_data.outdata = zeros(shape=(len(element_data.nodes), 3))
     for iData in sData:
         B_matrix = self.getBmatrix(iData.dhdx)
         kinematic.strain = dot(B_matrix, element_data.state)
         kinematic.dstrain = dot(B_matrix, element_data.Dstate)
         sigma, tangent_moduli = self.mat.getStress(kinematic)
         element_data.stiff += dot(B_matrix.transpose(),
                                   dot(tangent_moduli,
                                       B_matrix)) * iData.weight
         element_data.fint += dot(B_matrix.transpose(),
                                  sigma) * iData.weight
         element_data.outdata += outer(ones(len(element_data.nodes)), sigma)
     element_data.outdata *= 1.0 / len(sData)
示例#28
0
    def initIntShapeFuncs(self):

        isoCoords = zeros(shape=(4, 2))

        isoCoords[0, 0] = -1.0
        isoCoords[0, 1] = -1.0
        isoCoords[1, 0] = 1.0
        isoCoords[1, 1] = -1.0
        isoCoords[2, 0] = 1.0
        isoCoords[2, 1] = 1.0
        isoCoords[3, 0] = -1.0
        isoCoords[3, 1] = 1.0

        intshape = getElemShapeData(isoCoords)

        for sdat, idat in zip(self.shape, intshape):
            sdat.psi = idat.h
示例#29
0
  def getInternalForce ( self, elemdat ):
      
    sData = getElemShapeData( elemdat.coords )

    uDofs,pDofs = self.splitDofIDs( len(elemdat.coords) )

    for iInt,iData in enumerate(sData):
    
      B = self.getBmatrix( iData.dhdx )

      self.kin.strain  = dot ( B , elemdat.state [uDofs] )
      self.kin.dstrain = dot ( B , elemdat.Dstate[uDofs] )
      
      phase     = dot( iData.h    , elemdat.state[pDofs] )
      gradPhase = dot( iData.dhdx.transpose() , elemdat.state[pDofs] )
      
      sigma,tang = self.mat.getStress( self.kin )

      energy = 0.5*sum(self.kin.strain*sigma)

      if energy > self.hisOld[iInt]:
        self.hisNew[iInt] = energy
      else:
        self.hisNew[iInt] = self.hisOld[iInt]
            
      factor = 1.0-phase*phase+self.k
                   
      # -- Displacement contributions
        
      dispForce = dot ( B.transpose() , factor*sigma )
      elemdat.fint[uDofs] += dispForce * iData.weight
           
      # -- Phase field contributions
      
      pfint =  self.Gc*self.l0*dot( iData.dhdx , gradPhase );
      pfint += self.Gc/self.l0*iData.h*phase;
      pfint += 2.0*( phase-1.0 ) * iData.h * self.hisNew[iInt]
            
      elemdat.fint[pDofs] += pfint * iData.weight
      
      # -- Coupling terms
  
      # Coupling terms need TOBEIMPLEMENTED
      
      self.appendNodalOutput( self.mat.outLabels() , self.mat.outData() )
示例#30
0
    def initExtShapeFuncs(self):

        isoCoords = zeros(shape=(4, 2))

        isoCoords[0, 0] = -1.0
        isoCoords[0, 1] = -1.0
        isoCoords[1, 0] = 1.0
        isoCoords[1, 1] = -1.0
        isoCoords[2, 0] = 1.0
        isoCoords[2, 1] = 1.0
        isoCoords[3, 0] = -1.0
        isoCoords[3, 1] = 1.0

        self.shape = getElemShapeData(isoCoords)

        for sdat in self.shape:
            sdat.h *= 0.5
            sdat.dhdx *= 0.5
示例#31
0
    def getDissipation(self, elemdat):

        rot = self.getRotation(elemdat.coords, elemdat.state)

        sData = getElemShapeData(elemdat.coords[:2, :],
                                 method=self.intMethod,
                                 elemType="Line2")

        kin = Kinematics(2, 2)

        for iData in sData:
            B = self.getBmatrix(iData.h, rot)
            kin.strain = dot(B, elemdat.state)

            sigma, tang = self.mat.getStress(kin)

            elemdat.fint += dot(B.transpose(), kin.dgdstrain) * iData.weight
            elemdat.diss += kin.g * iData.weight
示例#32
0
    def getInternalForce(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        elemdat.outlabel.append(self.outputLabels)
        elemdat.outdata = zeros(shape=(len(elemdat.nodes), self.nstr))

        for iData in sData:
            b = self.getBmatrix(iData.dhdx)

            self.kin.strain = dot(b, elemdat.state)
            self.kin.dstrain = dot(b, elemdat.Dstate)

            sigma, tang = self.mat.getStress(self.kin)

            elemdat.fint += dot(b.transpose(), sigma) * iData.weight

            self.appendNodalOutput(self.mat.outLabels(), self.mat.outData())
示例#33
0
    def getDissipation(self, elemdat):

        sData = getElemShapeData(elemdat.coords)

        for iData in sData:
            b = self.getBmatrix(iData.dhdx)

            self.kin.strain = dot(b, elemdat.state)
            self.kin.dstrain = dot(b, elemdat.Dstate)

            self.mat.getStress(self.kin)

            self.kin.dgdstrain = zeros(3)
            self.kin.g = 0.0

            elemdat.fint += dot(b.transpose(),
                                self.kin.dgdstrain) * iData.weight
            elemdat.diss += self.kin.g * iData.weight
示例#34
0
  def getInternalForce ( self, elemdat ):
   
    rot = self.getRotation( elemdat.coords , elemdat.state )

    sData = getElemShapeData( elemdat.coords[:2,:] , method = self.intMethod , elemType = "Line2" )
    
    elemdat.outlabel.append("tractions")
    elemdat.outdata  = zeros( shape=(len(elemdat.nodes),2) )

    kin = Kinematics(2,2)

    for iData in sData:
      B              = self.getBmatrix( iData.h , rot )
      kin.strain     = dot( B , elemdat.state )

      sigma,tang = self.mat.getStress( kin )
     
      elemdat.fint  += dot ( B.transpose() , sigma ) * iData.weight
      
      elemdat.outdata += outer( ones(len(elemdat.nodes)), sigma )
示例#35
0
  def getInternalForce ( self, elemdat ):
   
    n = self.dofCount()
   
    sData = getElemShapeData( elemdat.coords )

    elemdat.outlabel.append("stresses")
    elemdat.outdata  = zeros( shape=(len(elemdat.nodes),3) )

    for iData in sData:
            
      kin = self.getKinematics( iData.dhdx , elemdat.state ) 
      B   = self.getBmatrix   ( iData.dhdx , kin.F )
      
      sigma,tang = self.mat.getStress( kin )
       
      elemdat.fint    += dot ( B.transpose() , sigma ) * iData.weight
      elemdat.outdata += outer( ones(len(elemdat.nodes)), sigma )
      
    elemdat.outdata *= 1.0 / len(sData)  
示例#36
0
  def getInternalForce ( self, elemdat ):
      
    sData = getElemShapeData( elemdat.coords )

    elemdat.outlabel.append("stresses")
    elemdat.outdata  = zeros( shape=(len(elemdat.nodes),3) )

    kin = Kinematics(2,3)

    for iData in sData:
      b = self.getBmatrix( iData.dhdx )

      kin.strain  = dot ( b , elemdat.state )
      kin.dstrain = dot ( b , elemdat.Dstate )

      sigma,tang = self.mat.getStress( kin )

      elemdat.fint    += dot ( b.transpose() , sigma ) * iData.weight
      elemdat.outdata += outer( ones(len(self)), sigma )
      
    elemdat.outdata *= 1.0 / len(sData)  
示例#37
0
presVals[2 * presNodes] = [upres(crd) for crd in coords[presNodes, :]]
presVals[2 * presNodes + 1] = [vpres(crd) for crd in coords[presNodes, :]]

# ----------------------------------------------------------------------
#  Calculate K
# ----------------------------------------------------------------------

totDof = 2 * len(coords)

K = zeros(shape=(totDof, totDof))

for elem in elems:
    elemDofs = getDofs(elem)

    sData = getElemShapeData(coords[elem, :])

    for iData in sData:
        b = getBmatrix(iData.dhdx)
        K[ix_(elemDofs, elemDofs)] += dot(b.transpose(), dot(D, b)) * iData.weight

# ----------------------------------------------------------------------
#  Solve Ka=f
# ----------------------------------------------------------------------

consDof = len(presInds)

C = zeros(shape=(totDof, totDof - consDof))

j = 0