Example #1
0
def fluxDomainBoundaryIntegral(dS,nValueArray,mesh):
    partialSum = cfemIntegrals.fluxDomainBoundaryIntegral(mesh.nElementBoundaries_owned,
                                                          mesh.elementBoundaryMaterialTypes,
                                                          mesh.exteriorElementBoundariesArray,
                                                          dS,
                                                          nValueArray)
    return globalSum(partialSum)
Example #2
0
def L1errorSFEM(quadratureWeightArray,aSolutionValueArray,nSolutionValueArray,T=None):
    error=0.0
    range_nQuadraturePoints_element = range(aSolutionValueArray.shape[1])
    for eN in range(aSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            error += abs(aSolutionValueArray[eN,k] - nSolutionValueArray[eN,k])*quadratureWeightArray[eN,k]
    return globalSum(error)
Example #3
0
def L1errorSFEM2(abs_det_J,quadratureWeightArray,aSolutionValueArray,nSolutionValueArray,T=None):
    error=0.0
    range_nQuadraturePoints_element = range(aSolutionValueArray.shape[1])
    for eN in range(aSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            error += abs(aSolutionValueArray[eN,k] - nSolutionValueArray[eN,k])*quadratureWeightArray[k]*abs_det_J[eN,k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #4
0
def L2normSFEM(quadratureWeightArray,nSolutionValueArray):
    error=0.0
    range_nQuadraturePoints_element = range(nSolutionValueArray.shape[1])
    for eN in range(nSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            error += (nSolutionValueArray[eN,k]**2)*quadratureWeightArray[eN,k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #5
0
def L1errorVFEM2(quadratureWeightArray,aSolutionValueArray,nSolutionValueArray,T=None):
    error=0.0
    range_nQuadraturePoints_element = range(aSolutionValueArray.shape[1])
    for eN in range(aSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            e      = numpy.sum(numpy.absolute(aSolutionValueArray[eN,k,:] - nSolutionValueArray[eN,k,:]))
            error += e*quadratureWeightArray[k]*abs_det_J[eN,k]
    return globalSum(error)
Example #6
0
def L1errorSFEMvsAF(analyticalFunction,quadraturePointArray,quadratureWeightArray,functionValueArray,T=None):
    error=0.0
    range_nQuadraturePoints_element = range(quadraturePointArray.shape[1])
    for eN in range(quadraturePointArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            AF = analyticalFunction.uOfXT(quadraturePointArray[eN,k],T)
            error += abs(functionValueArray[eN,k] - AF)*quadratureWeightArray[eN,k]
    return globalSum(error)
Example #7
0
def scalarHeavisideDomainIntegral(dV, nValueArray, nElements=None):
    if nElements == None:
        partialSum = cfemIntegrals.scalarHeavisideDomainIntegral(
            dV, nValueArray, nValueArray.shape[0])
    else:
        partialSum = cfemIntegrals.scalarHeavisideDomainIntegral(
            dV, nValueArray, nElements)
    return globalSum(partialSum)
Example #8
0
def L1errorVFEMvsAF2(analyticalFunction,quadraturePointArray,quadratureWeightArray,functionValueArray,T=None):
    error=0.0
    range_nQuadraturePoints_element = range(quadraturePointArray.shape[1])
    for eN in range(quadraturePointArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            AF = analyticalFunction.uOfXT(quadraturePointArray[eN,k],T)
            e1 = numpy.sum(numpy.absolute(functionValueArray[eN,k,:] - AF))
            error += e1*quadratureWeightArray[k]*abs_det_J[eN,k]
    return globalSum(error)
Example #9
0
def L2normSFEM(quadratureWeightArray, nSolutionValueArray):
    error = 0.0
    range_nQuadraturePoints_element = range(nSolutionValueArray.shape[1])
    for eN in range(nSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            error += (nSolutionValueArray[eN, k]**
                      2) * quadratureWeightArray[eN, k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #10
0
def L2errorVFEM2(quadratureWeightArray,aSolutionValueArray,nSolutionValueArray,T=None):
    error=0.0
    range_nQuadraturePoints_element = range(aSolutionValueArray.shape[1])
    for eN in range(aSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            e2    = numpy.inner(aSolutionValueArray[eN,k,:] - nSolutionValueArray[eN,k,:],
                                aSolutionValueArray[eN,k,:] - nSolutionValueArray[eN,k,:])
            error += e2*quadratureWeightArray[k]*abs_det_J[eN,k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #11
0
def L2errorSFEMvsAF2(analyticalFunction,quadraturePointArray,abs_det_J,
                     quadratureWeightArray,functionValueArray,T=None):
    error=0.0
    range_nQuadraturePoints_element = range(quadraturePointArray.shape[1])
    for eN in range(quadraturePointArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            AF = analyticalFunction.uOfXT(quadraturePointArray[eN,k],T)
            error += ((functionValueArray[eN,k] - AF)**2)*quadratureWeightArray[k]*abs_det_J[eN,k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #12
0
def L2errorSFEM_local(quadratureWeightArray,aSolutionValueArray,nSolutionValueArray,elementError,T=None):
    error=0.0
    elementError.flat[:]=0.0
    range_nQuadraturePoints_element = range(nSolutionValueArray.shape[1])
    for eN in range(nSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            elementError[eN] += ((aSolutionValueArray[eN,k] - nSolutionValueArray[eN,k])**2)*quadratureWeightArray[eN,k]
        error += elementError[eN]
        elementError[eN] = sqrt(abs(elementError[eN]))
    error = sqrt(abs(globalSum(error)))
    return error
Example #13
0
def L2errorVFEMvsAF(analyticalFunction,quadraturePointArray,quadratureWeightArray,functionValueArray,T=None):
    error=0.0
    range_nQuadraturePoints_element = range(quadraturePointArray.shape[1])
    for eN in range(quadraturePointArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            AF = analyticalFunction.uOfXT(quadraturePointArray[eN,k],T)
            e2 = numpy.inner(functionValueArray[eN,k,:] - AF,
                             functionValueArray[eN,k,:] - AF)
            error += e2*quadratureWeightArray[eN,k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #14
0
def globalScalarDomainIntegral(abs_det_J,quadratureWeightArray,nValueArray):
    integral = 0.0
    if useC:
        integral = cfemIntegrals.scalarDomainIntegral(abs_det_J,quadratureWeightArray,nValueArray)
    else:
        integral=0.0
        range_nQuadraturePoints_element = range(nValueArray.shape[1])
        for eN in range(nValueArray.shape[0]):
            for k in range_nQuadraturePoints_element:
                integral += nValueArray[eN,k]*quadratureWeightArray[k]*abs_det_J[eN,k]

    return globalSum(integral)
Example #15
0
def L1errorSFEM(quadratureWeightArray,
                aSolutionValueArray,
                nSolutionValueArray,
                T=None):
    error = 0.0
    range_nQuadraturePoints_element = range(aSolutionValueArray.shape[1])
    for eN in range(aSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            error += abs(aSolutionValueArray[eN, k] -
                         nSolutionValueArray[eN,
                                             k]) * quadratureWeightArray[eN, k]
    return globalSum(error)
Example #16
0
def scalarSmoothedHeavisideDomainIntegral(epsFact,
                                          elementDiameters,
                                          dV,
                                          nValueArray,
                                          nElements=None):
    if nElements == None:
        partialSum = cfemIntegrals.scalarSmoothedHeavisideDomainIntegral(
            epsFact, elementDiameters, dV, nValueArray, nValueArray.shape[0])
    else:
        partialSum = cfemIntegrals.scalarSmoothedHeavisideDomainIntegral(
            epsFact, elementDiameters, dV, nValueArray, nElements)
    return globalSum(partialSum)
Example #17
0
def L1errorSFEM2(abs_det_J,
                 quadratureWeightArray,
                 aSolutionValueArray,
                 nSolutionValueArray,
                 T=None):
    error = 0.0
    range_nQuadraturePoints_element = range(aSolutionValueArray.shape[1])
    for eN in range(aSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            error += abs(aSolutionValueArray[eN, k] - nSolutionValueArray[
                eN, k]) * quadratureWeightArray[k] * abs_det_J[eN, k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #18
0
def L1errorVFEMvsAF(analyticalFunction,
                    quadraturePointArray,
                    quadratureWeightArray,
                    functionValueArray,
                    T=None):
    error = 0.0
    range_nQuadraturePoints_element = range(quadraturePointArray.shape[1])
    for eN in range(quadraturePointArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            AF = analyticalFunction.uOfXT(quadraturePointArray[eN, k], T)
            e1 = numpy.sum(numpy.absolute(functionValueArray[eN, k, :] - AF))
            error += e1 * quadratureWeightArray[eN, k]
    return globalSum(error)
Example #19
0
def L1errorVFEM2(quadratureWeightArray,
                 aSolutionValueArray,
                 nSolutionValueArray,
                 T=None):
    error = 0.0
    range_nQuadraturePoints_element = range(aSolutionValueArray.shape[1])
    for eN in range(aSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            e = numpy.sum(
                numpy.absolute(aSolutionValueArray[eN, k, :] -
                               nSolutionValueArray[eN, k, :]))
            error += e * quadratureWeightArray[k] * abs_det_J[eN, k]
    return globalSum(error)
Example #20
0
def scalarDomainIntegral(dV,nValueArray,nElements=None):
    if useC:
        if nElements is None:
            partialSum = cfemIntegrals.scalarDomainIntegral(dV,nValueArray,nValueArray.shape[0])
        else:
            partialSum = cfemIntegrals.scalarDomainIntegral(dV,nValueArray,nElements)
    else:
        partialSum=0.0
        range_nQuadraturePoints_element = range(nValueArray.shape[1])
        for eN in range(nValueArray.shape[0]):
            for k in range_nQuadraturePoints_element:
                partialSum += nValueArray[eN,k]*dV[eN,k]
    return globalSum(partialSum)
Example #21
0
def L2errorSFEMvsAF(analyticalFunction,
                    quadraturePointArray,
                    quadratureWeightArray,
                    functionValueArray,
                    T=None):
    error = 0.0
    range_nQuadraturePoints_element = range(quadraturePointArray.shape[1])
    for eN in range(quadraturePointArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            AF = analyticalFunction.uOfXT(quadraturePointArray[eN, k], T)
            error += ((functionValueArray[eN, k] - AF)**
                      2) * quadratureWeightArray[eN, k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #22
0
def TVseminormSFEM(dofArray,l2gMap):
    tv = 0.0
    nElements_global = l2gMap.shape[0]; nDOF_element = l2gMap.shape[1]
    for eN in range(nElements_global):
        for i in range(nDOF_element):
            I = l2gMap[eN,i]
            for j in range(i+1,nDOF_element):
                jj = int(fmod(j,nDOF_element))
                JJ = l2gMap[eN,jj]
                tv+= abs(dofArray[I]-dofArray[JJ])
            #neighbors on element
        #local dofs
    #elements
    return globalSum(tv)
Example #23
0
def L2errorVFEM2(quadratureWeightArray,
                 aSolutionValueArray,
                 nSolutionValueArray,
                 T=None):
    error = 0.0
    range_nQuadraturePoints_element = range(aSolutionValueArray.shape[1])
    for eN in range(aSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            e2 = numpy.inner(
                aSolutionValueArray[eN, k, :] - nSolutionValueArray[eN, k, :],
                aSolutionValueArray[eN, k, :] - nSolutionValueArray[eN, k, :])
            error += e2 * quadratureWeightArray[k] * abs_det_J[eN, k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #24
0
def L1errorSFEMvsAF2(analyticalFunction,
                     quadraturePointArray,
                     abs_det_J,
                     quadratureWeightArray,
                     functionValueArray,
                     T=None):
    error = 0.0
    range_nQuadraturePoints_element = range(quadraturePointArray.shape[1])
    for eN in range(quadraturePointArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            AF = analyticalFunction.uOfXT(quadraturePointArray[eN, k], T)
            error += abs(functionValueArray[eN, k] -
                         AF) * quadratureWeightArray[k] * abs_det_J[eN, k]
    return globalSum(error)
Example #25
0
def scalarDomainIntegral(dV, nValueArray, nElements=None):
    if useC:
        if nElements == None:
            partialSum = cfemIntegrals.scalarDomainIntegral(
                dV, nValueArray, nValueArray.shape[0])
        else:
            partialSum = cfemIntegrals.scalarDomainIntegral(
                dV, nValueArray, nElements)
    else:
        partialSum = 0.0
        range_nQuadraturePoints_element = range(nValueArray.shape[1])
        for eN in range(nValueArray.shape[0]):
            for k in range_nQuadraturePoints_element:
                partialSum += nValueArray[eN, k] * dV[eN, k]
    return globalSum(partialSum)
Example #26
0
def globalScalarDomainIntegral(abs_det_J, quadratureWeightArray, nValueArray):
    integral = 0.0
    if useC:
        integral = cfemIntegrals.scalarDomainIntegral(abs_det_J,
                                                      quadratureWeightArray,
                                                      nValueArray)
    else:
        integral = 0.0
        range_nQuadraturePoints_element = range(nValueArray.shape[1])
        for eN in range(nValueArray.shape[0]):
            for k in range_nQuadraturePoints_element:
                integral += nValueArray[
                    eN, k] * quadratureWeightArray[k] * abs_det_J[eN, k]

    return globalSum(integral)
Example #27
0
def TVseminormSFEM(dofArray, l2gMap):
    tv = 0.0
    nElements_global = l2gMap.shape[0]
    nDOF_element = l2gMap.shape[1]
    for eN in range(nElements_global):
        for i in range(nDOF_element):
            I = l2gMap[eN, i]
            for j in range(i + 1, nDOF_element):
                jj = int(fmod(j, nDOF_element))
                JJ = l2gMap[eN, jj]
                tv += abs(dofArray[I] - dofArray[JJ])
            #neighbors on element
        #local dofs
    #elements
    return globalSum(tv)
Example #28
0
def L2errorVFEMvsAF2(analyticalFunction,
                     quadraturePointArray,
                     abs_det_J,
                     quadratureWeightArray,
                     functionValueArray,
                     T=None):
    error = 0.0
    range_nQuadraturePoints_element = range(quadraturePointArray.shape[1])
    for eN in range(quadraturePointArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            AF = analyticalFunction.uOfXT(quadraturePointArray[eN, k], T)
            e2 = numpy.inner(functionValueArray[eN, k, :] - AF,
                             functionValueArray[eN, k, :] - AF)
            error += e2 * quadratureWeightArray[k] * abs_det_J[eN, k]
    error = sqrt(abs(globalSum(error)))
    return error
Example #29
0
def L2errorSFEM_local(quadratureWeightArray,
                      aSolutionValueArray,
                      nSolutionValueArray,
                      elementError,
                      T=None):
    error = 0.0
    elementError.flat[:] = 0.0
    range_nQuadraturePoints_element = range(nSolutionValueArray.shape[1])
    for eN in range(nSolutionValueArray.shape[0]):
        for k in range_nQuadraturePoints_element:
            elementError[eN] += (
                (aSolutionValueArray[eN, k] - nSolutionValueArray[eN, k])**
                2) * quadratureWeightArray[eN, k]
        error += elementError[eN]
        elementError[eN] = sqrt(abs(elementError[eN]))
    error = sqrt(abs(globalSum(error)))
    return error
Example #30
0
def wDot(x, y, h):
    """
    Compute the parallel weighted dot product of vectors x and y using
    weight vector h.
    
    The weighted dot product is defined for a weight vector
    :math:`\mathbf{h}` as

    .. math:: 

       (\mathbf{x},\mathbf{y})_h = \sum_{i} h_{i} x_{i} y_{i}
    
    All weight vector components should be positive.

    :param x,y,h: numpy arrays for vectors and weight 
    :return: the weighted dot product
    """
    return flcbdfWrappers.globalSum(numpy.sum(x * y * h))
Example #31
0
def wDot(x,y,h):
    """
    Compute the parallel weighted dot product of vectors x and y using
    weight vector h.
    
    The weighted dot product is defined for a weight vector
    :math:`\mathbf{h}` as

    .. math:: 

       (\mathbf{x},\mathbf{y})_h = \sum_{i} h_{i} x_{i} y_{i}
    
    All weight vector components should be positive.

    :param x,y,h: numpy arrays for vectors and weight 
    :return: the weighted dot product
    """
    return flcbdfWrappers.globalSum(numpy.sum(x*y*h))
Example #32
0
def l1Norm(x):
    """
    Compute the parallel :math:`l_1` norm
    
    The :math:`l_1` norm of a vector :math:`\mathbf{x} \in
    \mathbb{R}^n` is
    
    .. math:: 
    
       \| \mathbf{x} \|_{1} = \sum_{i=0} |x_i|
    
    If Python is running in parallel, then the sum is over all
    dimensions on all processors so that the input must not contain
    "ghost" entries.
    
    This implemtation works for a distributed array with no ghost
    components (each component must be on a single processor).
    
    :param x: numpy array of length n
    :return: float
    """
    return flcbdfWrappers.globalSum(numpy.sum(numpy.abs(x)))
Example #33
0
def l1Norm(x):
    """
    Compute the parallel :math:`l_1` norm
    
    The :math:`l_1` norm of a vector :math:`\mathbf{x} \in
    \mathbb{R}^n` is
    
    .. math:: 
    
       \| \mathbf{x} \|_{1} = \sum_{i=0} |x_i|
    
    If Python is running in parallel, then the sum is over all
    dimensions on all processors so that the input must not contain
    "ghost" entries.
    
    This implemtation works for a distributed array with no ghost
    components (each component must be on a single processor).
    
    :param x: numpy array of length n
    :return: float
    """
    return flcbdfWrappers.globalSum(numpy.sum(numpy.abs(x)))
Example #34
0
def l2Norm(x):
    """
    Compute the parallel :math:`l_2` norm
    """
    return math.sqrt(flcbdfWrappers.globalSum(numpy.dot(x, x)))
Example #35
0
def fluxDomainBoundaryIntegralFromVector(dS, nValueArray, normal, mesh):
    partialSum = cfemIntegrals.fluxDomainBoundaryIntegralFromVector(
        mesh.nElementBoundaries_owned, mesh.elementBoundaryMaterialTypes,
        mesh.exteriorElementBoundariesArray, dS, nValueArray, normal)
    return globalSum(partialSum)
Example #36
0
def l2Norm(x):
    """
    Compute the parallel l_2 norm
    """
    return numpy.sqrt(flcbdfWrappers.globalSum(numpy.dot(x,x)))
Example #37
0
def l1Norm(x):
    """
    Compute the parallel l_1 norm
    """
    return flcbdfWrappers.globalSum(numpy.sum(numpy.abs(x)))
Example #38
0
def wDot(x,y,h):
    """
    Compute the parallel weighted dot product with weight h
    """
    return flcbdfWrappers.globalSum(numpy.sum(x*y*h))
Example #39
0
def l2Norm(x):
    """
    Compute the parallel :math:`l_2` norm
    """
    return math.sqrt(flcbdfWrappers.globalSum(numpy.dot(x,x)))
Example #40
0
def wl1Norm(x, h):
    """
    Compute the parallel weighted l_1 norm with weight h
    """
    return flcbdfWrappers.globalSum(numpy.sum(numpy.abs(h * x)))
Example #41
0
def scalarSmoothedHeavisideDomainIntegral(epsFact,elementDiameters,dV,nValueArray,nElements=None):
    if nElements is None:
        partialSum = cfemIntegrals.scalarSmoothedHeavisideDomainIntegral(epsFact,elementDiameters,dV,nValueArray,nValueArray.shape[0])
    else:
        partialSum = cfemIntegrals.scalarSmoothedHeavisideDomainIntegral(epsFact,elementDiameters,dV,nValueArray,nElements)
    return globalSum(partialSum)
Example #42
0
def scalarHeavisideDomainIntegral(dV,nValueArray,nElements=None):
    if nElements is None:
        partialSum = cfemIntegrals.scalarHeavisideDomainIntegral(dV,nValueArray,nValueArray.shape[0])
    else:
        partialSum = cfemIntegrals.scalarHeavisideDomainIntegral(dV,nValueArray,nElements)
    return globalSum(partialSum)
Example #43
0
def l2NormAvg(x):
    """
    Compute the arithmetic averaged l_2 norm (root mean squared norm)
    """
    scale = 1.0/flcbdfWrappers.globalSum(len(x.flat))
    return math.sqrt(scale*flcbdfWrappers.globalSum(numpy.dot(x,x)))
Example #44
0
def wl2Norm(x, h):
    """
    Compute the parallel weighted l_2 norm with weight h
    """
    return math.sqrt(flcbdfWrappers.globalSum(wDot(x, x, h)))
Example #45
0
def wl2Norm(x,h):
    """
    Compute the parallel weighted l_2 norm with weight h
    """
    return math.sqrt(flcbdfWrappers.globalSum(wDot(x,x,h)))
Example #46
0
def l2NormAvg(x):
    """
    Compute the arithmetic averaged l_2 norm (root mean squared norm)
    """
    scale = 1.0 / flcbdfWrappers.globalSum(len(x.flat))
    return math.sqrt(scale * flcbdfWrappers.globalSum(numpy.dot(x, x)))
Example #47
0
def wl1Norm(x,h):
    """
    Compute the parallel weighted l_1 norm with weight h
    """
    return flcbdfWrappers.globalSum(numpy.sum(numpy.abs(h*x)))