def computeIndicators(TInd):
    print('.', end='', flush=True)
    aPatch = lambda: coef.localizeCoefficient(patchT[TInd], aFine_ref)
    rPatch = lambda: coef.localizeCoefficient(patchT[TInd],
                                              a_Fine_to_be_approximated)

    epsCoarse = lod.computeErrorIndicatorCoarseFromCoefficients(
        patchT[TInd], csiT[TInd].muTPrime, aPatch, rPatch)

    # New for E_ft
    f_ref_patch = f_ref[util.extractElementFine(
        world.NWorldCoarse,
        world.NCoarseElement,
        patchT[TInd].iElementWorldCoarse,
        extractElements=False)]
    f_patch = f_trans[util.extractElementFine(world.NWorldCoarse,
                                              world.NCoarseElement,
                                              patchT[TInd].iElementWorldCoarse,
                                              extractElements=False)]

    E_f = lod.computeEftErrorIndicatorCoarse(patchT[TInd], cetaTPrimeT[TInd],
                                             etaTT[TInd], aPatch, rPatch,
                                             f_ref_patch, f_patch)

    return epsCoarse, E_f
Ejemplo n.º 2
0
    def computeIndicator(TInd):
        aPatch = lambda: lod_periodic.localizeCoefficient(
            patchT[TInd], aPert, periodic=True)  # true coefficient
        E_vh = lod.computeErrorIndicatorCoarseFromCoefficients(
            patchT[TInd], muTPrimeRef, aRef, aPatch)

        return E_vh
def computeIndicators(TInd):
    aPatch = lambda: coef.localizeCoefficient(patchT[TInd], aFine_ref)
    rPatch = lambda: coef.localizeCoefficient(patchT[TInd],
                                              a_Fine_to_be_approximated)

    epsCoarse = lod.computeErrorIndicatorCoarseFromCoefficients(
        patchT[TInd], csiT[TInd].muTPrime, aPatch, rPatch)
    return epsCoarse
Ejemplo n.º 4
0
def computeIndicators(TInd):
    aPatch = lambda: coef.localizeCoefficient(patchT[TInd], ABase)
    rPatch = lambda: coef.localizeCoefficient(patchT[TInd], Defect)

    epsFine = lod.computeBasisErrorIndicatorFine(patchT[TInd],
                                                 correctorsListT[TInd], aPatch,
                                                 rPatch)
    epsCoarse = lod.computeErrorIndicatorCoarseFromCoefficients(
        patchT[TInd], csiT[TInd].muTPrime, aPatch, rPatch)
    return epsFine, epsCoarse
Ejemplo n.º 5
0
    def test_computeErrorIndicatorCoarseFromCoefficients(self):
        ## Setup
        # 2D, variables x0 and x1
        NCoarse = np.array([4, 3])
        NCoarseElement = np.array([2, 3])
        world = World(NCoarse, NCoarseElement)
        patch = Patch(world, 4, 0)
        NFine = NCoarse*NCoarseElement
        NtCoarse = world.NtCoarse
        
        # muTPrime = 1, ..., NtCoarse
        muTPrime = np.arange(NtCoarse) + 1

        ## Case
        # aOld = aNew = 1
        # Expect: 0 error indicator
        aOld = np.ones(world.NtFine, dtype=np.float64)
        aNew = aOld

        self.assertAlmostEqual(lod.computeErrorIndicatorCoarseFromCoefficients(patch, muTPrime, aOld, aNew), 0)

        #### Same test for Matrix valued ####
        Aeye = np.tile(np.eye(2), [np.prod(NFine), 1, 1])
        aNew = np.einsum('tji, t -> tji', Aeye, aNew)

        self.assertAlmostEqual(lod.computeErrorIndicatorCoarseFromCoefficients(patch, muTPrime, aOld, aNew), 0)

        ## Case
        # aOld = 1
        # aNew = 10
        # Expect: sqrt(1/10 * 1/10*(10-1)**2*1 * (NtCoarse)*(NtCoarse+1)/2)
        aOld = np.ones(world.NtFine, dtype=np.float64)
        aNew = 10*aOld

        self.assertAlmostEqual(lod.computeErrorIndicatorCoarseFromCoefficients(patch, muTPrime, aOld, aNew),
                               np.sqrt(1/10 * 1/10*(10-1)**2*1 * (NtCoarse)*(NtCoarse+1)/2))

        #### Same test for Matrix valued ####
        aNew = np.einsum('tji, t -> tji', Aeye, aNew)
        aOld = np.einsum('tji, t-> tji', Aeye, aOld)

        self.assertAlmostEqual(lod.computeErrorIndicatorCoarseFromCoefficients(patch, muTPrime, aOld, aNew),
                               np.sqrt(1/10 * 1/10*(10-1)**2*1 * (NtCoarse)*(NtCoarse+1)/2))
        
        ## Case
        # aOld = 1
        # aNew = 1 except in TInd=2 (where muTPrime == 3), where it is 10
        # Expect: sqrt(1 * 1/10*(10-1)**2*1 * 3)
        aOld = np.ones(world.NtFine, dtype=np.float64)
        aNew = np.ones(world.NtFine, dtype=np.float64)
        
        elementFinetIndexMap = util.extractElementFine(NCoarse,
                                                       NCoarseElement,
                                                       np.array([2, 0]),
                                                       extractElements=True)
        aNew[elementFinetIndexMap] = 10

        self.assertAlmostEqual(lod.computeErrorIndicatorCoarseFromCoefficients(patch, muTPrime, aOld, aNew),
                               np.sqrt(1 * 1/10*(10-1)**2*1 * 3))

        #### Same test for Matrix valued ####
        aOld = np.einsum('tji, t-> tji', Aeye, aOld)

        self.assertAlmostEqual(lod.computeErrorIndicatorCoarseFromCoefficients(patch, muTPrime, aOld, aNew),
                               np.sqrt(1 * 1/10*(10-1)**2*1 * 3))