Пример #1
0
def computeAharm_offline():
    aRefListSingle, _, _, _, _ = algorithms.computeCSI_offline(
        world, Nepsilon // NCoarse, 0, boundaryConditions, model)
    return [
        world.NWorldFine / (world.NWorldCoarse * np.sum(1. / aRefSingle))
        for aRefSingle in aRefListSingle
    ]
Пример #2
0
        return np.abs(aharmT - aharmT_combined)

    error_harmList = list(map(compute_errorHarmT, range(world.NtCoarse)))
    return np.max(error_harmList)


for Nc in NList:
    NCoarse = np.array([Nc])
    NCoarseElement = NFine // NCoarse
    world = World(NCoarse, NCoarseElement, boundaryConditions)

    xpFine = util.pCoordinates(NFine)
    ffunc = lambda x: 8 * np.pi**2 * np.sin(2 * np.pi * x)
    f = ffunc(xpFine).flatten()

    aRefList, KmsijList, muTPrimeList, _, _ = algorithms.computeCSI_offline(
        world, Nepsilon // NCoarse, k, boundaryConditions, model)
    aharmList = computeAharm_offline()

    harmErrorList = np.zeros((len(pList), NSamples))
    absErrorList = np.zeros((len(pList), NSamples))
    relErrorList = np.zeros((len(pList), NSamples))

    ii = 0
    for p in pList:
        for N in range(NSamples):
            aPert = build_coefficient.build_randomcheckerboard(
                Nepsilon, NFine, alpha, beta, p)

            MFull = fem.assemblePatchMatrix(world.NWorldFine, world.MLocFine)
            basis = fem.assembleProlongationMatrix(world.NWorldCoarse,
                                                   world.NCoarseElement)
beta = 1.
pList = [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1]
percentage_comp = 0.15
model = {'name': 'check', 'alpha': alpha, 'beta': beta}
np.random.seed(123)

NCoarseElement = NFine // NCoarse
world = World(NCoarse, NCoarseElement, boundaryConditions)

xpFine = util.pCoordinates(NFine)
ffunc = lambda x: 8 * np.pi**2 * np.sin(2 * np.pi * x[:, 0]) * np.cos(
    2 * np.pi * x[:, 1])
f = ffunc(xpFine).flatten()

aRefList, KmsijList,muTPrimeList, timeBasis, timeMatrixList, correctorsList\
    = algorithms.computeCSI_offline(world, Nepsilon // NCoarse,k,boundaryConditions,model,correctors=True)
aRef = np.copy(aRefList[-1])
KmsijRef = np.copy(KmsijList[-1])
muTPrimeRef = muTPrimeList[-1]
correctorsRef = correctorsList[-1]

print('offline time for new approach {}'.format(
    timeBasis + np.sum(np.array(timeMatrixList))))
print('offline time for perturbed LOD {}'.format(timeMatrixList[-1]))

relerr_comb = np.zeros((len(pList), NSamples))
relerr_noup = np.zeros((len(pList), NSamples))
relerr_up = np.zeros((len(pList), NSamples))
relerr_comb_H1Coarse = np.zeros((len(pList), NSamples))
relerr_comb_H1Fine = np.zeros((len(pList), NSamples))
relerr_comb_energyCoarse = np.zeros((len(pList), NSamples))