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
Beispiel #3
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
Beispiel #4
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
Beispiel #5
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