Ejemplo n.º 1
0
  def _calculateStiffnessMat(self):
    """
    Calculate stiffness matrix.

    """
    import feutils

    K = numpy.zeros( (self.spaceDim*self.numVertices,
                      self.spaceDim*self.numVertices),
                     dtype=numpy.float64)

    # Matrix of elasticity values
    D = self._calculateElasticityMat()
    
    for cell in self.cells:
      cellK = numpy.zeros( (self.spaceDim*self.numBasis,
                            self.spaceDim*self.numBasis),
                           dtype=numpy.float64)
      vertices = self.vertices[cell, :]
      (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
                 feutils.calculateJacobian(self.quadrature, vertices)
      fieldTpdt = self.fieldT + self.fieldTIncr
      for iQuad in xrange(self.numQuadPts):
        wt = self.quadWts[iQuad] * jacobianDet[iQuad]
        BL0 = self._calculateBasisDerivMatLinear0(basisDeriv, iQuad)
        BL1 = self._calculateBasisDerivMatLinear1(basisDeriv, iQuad, fieldTpdt)
        BL = BL0 + BL1
        cellK[:] += wt * numpy.dot(numpy.dot(BL.transpose(), D), BL)
        BNL = self._calculateBasisDerivMatNonlinear(basisDeriv, iQuad)
        strain = self._calculateStrain(basisDeriv, iQuad, fieldTpdt)
        S = self._calculateStress(strain, D)
        cellK[:] += wt * numpy.dot(numpy.dot(BNL.transpose(), S), BNL)
      feutils.assembleMat(K, cellK, cell, self.spaceDim)
    return K
Ejemplo n.º 2
0
  def calculateResidual(self, integrator):
    """
    Calculate contribution to residual of operator for integrator.

    {r} = -Sum(wt * [BL]^T [S})
    """
    import feutils

    residual = numpy.zeros( (integrator.spaceDim*integrator.numVertices),
                            dtype=numpy.float64)

    # Matrix of elasticity values
    D = integrator._calculateElasticityMat()
    
    for cell in integrator.cells:
      cellR = numpy.zeros( (integrator.spaceDim*integrator.numBasis, 1),
                           dtype=numpy.float64)
      vertices = integrator.vertices[cell, :]
      (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
          feutils.calculateJacobian(integrator.quadrature, vertices)
      fieldTpdt = integrator.fieldT + integrator.fieldTIncr
      for iQuad in xrange(integrator.numQuadPts):
        wt = integrator.quadWts[iQuad] * jacobianDet[iQuad]
        BL0 = integrator._calculateBasisDerivMatLinear0(basisDeriv, iQuad)
        BL1 = integrator._calculateBasisDerivMatLinear1(basisDeriv, iQuad, fieldTpdt)
        BL = BL0 + BL1
        strain = integrator._calculateStrain(basisDeriv, iQuad, fieldTpdt)
        S = numpy.dot(D, strain.transpose())
        cellR -= wt * numpy.dot(BL.transpose(), S)
      
      feutils.assembleVec(residual, cellR.flatten(), cell, integrator.spaceDim)

    return residual
  def _elasticityResidual(self, integrator, dispAdj):
    """
    Calculate action for elasticity.
    """
    residual = numpy.zeros( (integrator.numBasis*integrator.spaceDim),
                            dtype=numpy.float64)

    # Matrix of elasticity values
    D = integrator._calculateElasticityMat()
    
    for cell in integrator.cells:
      cellR = numpy.zeros( (integrator.spaceDim*integrator.numBasis, 1),
                           dtype=numpy.float64)
      vertices = integrator.vertices[cell, :]
      (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
          feutils.calculateJacobian(integrator.quadrature, vertices)

      for iQuad in xrange(integrator.numQuadPts):
        wt = integrator.quadWts[iQuad] * jacobianDet[iQuad]
        BL0 = integrator._calculateBasisDerivMatLinear0(basisDeriv, iQuad)
        BL1 = integrator._calculateBasisDerivMatLinear1(basisDeriv, iQuad, dispAdj)
        BL = BL0 + BL1
        strain = integrator._calculateStrain(basisDeriv, iQuad, dispAdj)
        S = numpy.dot(D, strain.transpose())
        cellR -= wt * numpy.dot(BL.transpose(), S)
      
      feutils.assembleVec(residual, cellR.flatten(), cell, integrator.spaceDim)
    return residual
Ejemplo n.º 4
0
  def _calculateStiffnessMat(self):
    """
    Calculate stiffness matrix.

    """
    import feutils

    K = numpy.zeros( (self.spaceDim*self.numVertices,
                      self.spaceDim*self.numVertices),
                     dtype=numpy.float64)

    # Matrix of elasticity values
    D = self._calculateElasticityMat()
    
    for cell in self.cells:
      cellK = numpy.zeros( (self.spaceDim*self.numBasis,
                            self.spaceDim*self.numBasis),
                           dtype=numpy.float64)
      vertices = self.vertices[cell, :]
      (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
                 feutils.calculateJacobian(self.quadrature, vertices)
      for iQuad in xrange(self.numQuadPts):
        wt = self.quadWts[iQuad] * jacobianDet[iQuad]
        B = self._calculateBasisDerivMat(basisDeriv, iQuad)
        cellK[:] += wt * numpy.dot(numpy.dot(B.transpose(), D), B)
      feutils.assembleMat(K, cellK, cell, self.spaceDim)
    return K
Ejemplo n.º 5
0
  def _calculateStiffnessMat(self):
    """
    Calculate stiffness matrix.

    """
    import feutils

    K = numpy.zeros( (self.spaceDim*self.numVertices,
                      self.spaceDim*self.numVertices),
                     dtype=numpy.float64)

    # Matrix of elasticity values
    D = self._calculateElasticityMat()
    
    for cell in self.cells:
      cellK = numpy.zeros( (self.spaceDim*self.numBasis,
                            self.spaceDim*self.numBasis),
                           dtype=numpy.float64)
      vertices = self.vertices[cell, :]
      (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
                 feutils.calculateJacobian(self.quadrature, vertices)
      for iQuad in xrange(self.numQuadPts):
        wt = self.quadWts[iQuad] * jacobianDet[iQuad]
        B = self._calculateBasisDerivMat(basisDeriv, iQuad)
        cellK[:] += wt * numpy.dot(numpy.dot(B.transpose(), D), B)
      feutils.assembleMat(K, cellK, cell, self.spaceDim)
    return K
Ejemplo n.º 6
0
    def _elasticityResidual(self, integrator, dispAdj):
        """
    Calculate action for elasticity.
    """
        residual = numpy.zeros((integrator.numBasis * integrator.spaceDim),
                               dtype=numpy.float64)

        # Matrix of elasticity values
        D = integrator._calculateElasticityMat()

        for cell in integrator.cells:
            cellR = numpy.zeros((integrator.spaceDim * integrator.numBasis, 1),
                                dtype=numpy.float64)
            vertices = integrator.vertices[cell, :]
            (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
                feutils.calculateJacobian(integrator.quadrature, vertices)

            for iQuad in xrange(integrator.numQuadPts):
                wt = integrator.quadWts[iQuad] * jacobianDet[iQuad]
                BL0 = integrator._calculateBasisDerivMatLinear0(
                    basisDeriv, iQuad)
                BL1 = integrator._calculateBasisDerivMatLinear1(
                    basisDeriv, iQuad, dispAdj)
                BL = BL0 + BL1
                strain = integrator._calculateStrain(basisDeriv, iQuad,
                                                     dispAdj)
                S = numpy.dot(D, strain.transpose())
                cellR -= wt * numpy.dot(BL.transpose(), S)

            feutils.assembleVec(residual, cellR.flatten(), cell,
                                integrator.spaceDim)
        return residual
Ejemplo n.º 7
0
    def _calculateStiffnessMat(self):
        """
    Calculate stiffness matrix.

    """
        import feutils

        K = numpy.zeros((self.spaceDim * self.numVertices,
                         self.spaceDim * self.numVertices),
                        dtype=numpy.float64)

        # Matrix of elasticity values
        D = self._calculateElasticityMat()

        for cell in self.cells:
            cellK = numpy.zeros(
                (self.spaceDim * self.numBasis, self.spaceDim * self.numBasis),
                dtype=numpy.float64)
            vertices = self.vertices[cell, :]
            (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
                       feutils.calculateJacobian(self.quadrature, vertices)
            fieldTpdt = self.fieldT + self.fieldTIncr
            for iQuad in xrange(self.numQuadPts):
                wt = self.quadWts[iQuad] * jacobianDet[iQuad]
                BL0 = self._calculateBasisDerivMatLinear0(basisDeriv, iQuad)
                BL1 = self._calculateBasisDerivMatLinear1(
                    basisDeriv, iQuad, fieldTpdt)
                BL = BL0 + BL1
                cellK[:] += wt * numpy.dot(numpy.dot(BL.transpose(), D), BL)
                BNL = self._calculateBasisDerivMatNonlinear(basisDeriv, iQuad)
                strain = self._calculateStrain(basisDeriv, iQuad, fieldTpdt)
                S = self._calculateStress(strain, D)
                cellK[:] += wt * numpy.dot(numpy.dot(BNL.transpose(), S), BNL)
            feutils.assembleMat(K, cellK, cell, self.spaceDim)
        return K
Ejemplo n.º 8
0
  def main(self):
    """
    Run the application.
    """
    self._collectData()

    (self.basis, self.basisDerivRef) = self.quadrature.calculateBasis()
    self.quadPts = numpy.dot(self.basis, self.vertices)

    import feutils
    (self.jacobian, self.jacobianInv, self.jacobianDet, self.basisDeriv) = \
                    feutils.calculateJacobian(self.quadrature, self.vertices)

    self._initData()
    self.data.write(self.name)
    return
Ejemplo n.º 9
0
    def main(self):
        """
    Run the application.
    """
        self._collectData()

        (self.basis, self.basisDerivRef) = self.quadrature.calculateBasis()
        self.quadPts = numpy.dot(self.basis, self.vertices)

        import feutils
        (self.jacobian, self.jacobianInv, self.jacobianDet, self.basisDeriv) = \
                        feutils.calculateJacobian(self.quadrature, self.vertices)

        self._initData()
        self.data.write(self.name)
        return
Ejemplo n.º 10
0
 def _calculateGravityVec(self):
     """
 Calculate body force vector.
 """
     gravityGlobal = numpy.zeros((self.numVertices * self.spaceDim), dtype=numpy.float64)
     for cell in self.cells:
         gravityCell = numpy.zeros((self.spaceDim * self.numBasis))
         vertices = self.vertices[cell, :]
         (jacobian, jacobianInv, jacobianDet, basisDeriv) = feutils.calculateJacobian(self.quadrature, vertices)
         for iQuad in xrange(self.numQuadPts):
             wt = self.quadWts[iQuad] * jacobianDet[iQuad] * self.density
             for iBasis in xrange(self.numBasis):
                 valI = wt * self.basis[iQuad, iBasis]
                 for iDim in xrange(self.spaceDim):
                     gravityCell[iDim + iBasis * self.spaceDim] += valI * self.gravityVec[iDim]
         feutils.assembleVec(gravityGlobal, gravityCell, cell, self.spaceDim)
     return gravityGlobal
Ejemplo n.º 11
0
    def _calculateMassMat(self):
        """
    Calculate mass matrix.
    """

        M = numpy.zeros((self.spaceDim * self.numVertices, self.spaceDim * self.numVertices), dtype=numpy.float64)

        for cell in self.cells:
            cellM = numpy.zeros((self.spaceDim * self.numBasis, self.spaceDim * self.numBasis), dtype=numpy.float64)
            vertices = self.vertices[cell, :]
            (jacobian, jacobianInv, jacobianDet, basisDeriv) = feutils.calculateJacobian(self.quadrature, vertices)
            for iQuad in xrange(self.numQuadPts):
                wt = self.quadWts[iQuad] * jacobianDet[iQuad]
                N = self._calculateBasisMat(iQuad)
                cellM[:] += self.density * wt * numpy.dot(N.transpose(), N)
            feutils.assembleMat(M, cellM, cell, self.spaceDim)
        return M
Ejemplo n.º 12
0
 def _calculateGravityVec(self):
   """
   Calculate body force vector.
   """
   gravityGlobal = numpy.zeros((self.numVertices*self.spaceDim),
                               dtype=numpy.float64)
   for cell in self.cells:
     gravityCell = numpy.zeros((self.spaceDim*self.numBasis))
     vertices = self.vertices[cell, :]
     (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
                feutils.calculateJacobian(self.quadrature, vertices)
     for iQuad in xrange(self.numQuadPts):
       wt = self.quadWts[iQuad] * jacobianDet[iQuad] * self.density
       for iBasis in xrange(self.numBasis):
         valI = wt * self.basis[iQuad, iBasis]
         for iDim in xrange(self.spaceDim):
           gravityCell[iDim + iBasis * self.spaceDim] += \
                            valI * self.gravityVec[iDim]
     feutils.assembleVec(gravityGlobal, gravityCell, cell, self.spaceDim)
   return gravityGlobal
Ejemplo n.º 13
0
  def _calculateMassMat(self):
    """
    Calculate mass matrix.
    """

    M = numpy.zeros( (self.spaceDim*self.numVertices,
                      self.spaceDim*self.numVertices),
                     dtype=numpy.float64)

    for cell in self.cells:
      cellM = numpy.zeros( (self.spaceDim*self.numBasis,
                            self.spaceDim*self.numBasis),
                           dtype=numpy.float64)
      vertices = self.vertices[cell, :]
      (jacobian, jacobianInv, jacobianDet, basisDeriv) = \
                 feutils.calculateJacobian(self.quadrature, vertices)
      for iQuad in xrange(self.numQuadPts):
        wt = self.quadWts[iQuad] * jacobianDet[iQuad]
        N = self._calculateBasisMat(iQuad)
        cellM[:] += self.density * wt * numpy.dot(N.transpose(), N)
      feutils.assembleMat(M, cellM, cell, self.spaceDim)
    return M