-
Notifications
You must be signed in to change notification settings - Fork 0
/
09_createLookupTableEntry.py
79 lines (70 loc) · 3.28 KB
/
09_createLookupTableEntry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import numpy as np
from blockops import BlockOperator, BlockIteration, I, PintRun
from blockops.lookup.lookupTable import picklePintRun
from blockops import BlockProblem
nBlocks = 100
kMax = 10
g = BlockOperator('G', cost=1) # coarse solver
f = BlockOperator('F', cost=10) # fine solver
r = BlockOperator('R', cost=0.2) # restriction
p = BlockOperator('P', cost=0.2) # prolongation (interpolation)
rules = [(r * p, I)]
phi = BlockOperator(r'\phi') # integration operator
phiD = BlockOperator(r'\phi_{\Delta}') # approximate integration operator
chi = BlockOperator(r'\chi') # transmission operator
blockOps = dict(I=I, phi=phi, phiD=phiD, chi=chi)
PFASST = BlockProblem(1j, 2 * np.pi - 0.2, nBlocks, nPoints=5, scheme='Collocation')
PFASST.setApprox('RungeKutta', rkScheme='BE')
PFASST.setCoarseLevel(2)
PFASST = PFASST.getBlockIteration('PFASST')
algs = {
'PararealPhiChi.pickle': BlockIteration(
update="(phi**(-1)-phiD**(-1))*chi*u_{n}^k + phiD**(-1)*chi* u_{n}^{k+1}",
propagator=phi ** (-1) * chi, predictor=phiD ** (-1) * chi,
**blockOps),
'PararealFGNoPredictor.pickle' : BlockIteration(
"(f - g) u_{n}^k + g * u_{n}^{k+1}", # block iteration update formula
propagator=f,
rules=rules, # list of rules (optional)
f=f, g=g),
'PararealFG.pickle' : BlockIteration(
"(f - g) u_{n}^k + g * u_{n}^{k+1}", # block iteration update formula
propagator=f, predictor=g,
rules=rules, # list of rules (optional)
f=f, g=g),
'PararealSCFGNoPredictor.pickle' : BlockIteration(
"(f - p*g*r) u_{n}^k + p*g*r * u_{n}^{k+1}", # block iteration update formula
propagator=f,
rules=rules, # list of rules (optional)
f=f, g=g, p=p, r=r),
'testPararealSCFG.pickle' : BlockIteration(
"(f - p*g*r) u_{n}^k + p*g*r * u_{n}^{k+1}", # block iteration update formula
propagator=f, predictor="p*g*r",
rules=rules, # list of rules (optional)
f=f, g=g, p=p, r=r),
'BlockJacobiPredictorI.pickle' : BlockIteration(
"phiD**(-1)*chi*u_{n}^k + (I-phiD**(-1)*phi)* u_{n+1}^{k}",
propagator=phi ** (-1) * chi, predictor=I,
**blockOps),
'BlockJacobiNoPredictor.pickle' : BlockIteration(
"phiD**(-1)*chi*u_{n}^k + (I-phiD**(-1)*phi)* u_{n+1}^{k}",
propagator=phi ** (-1) * chi,
**blockOps),
'BlockJacobi.pickle' : BlockIteration(
"phiD**(-1)*chi*u_{n}^k + (I-phiD**(-1)*phi)* u_{n+1}^{k}",
propagator=phi ** (-1) * chi, predictor=phiD ** (-1) * chi,
**blockOps),
'ApproxBlockGaussSeidelNoPredictor.pickle' : BlockIteration(
update="phiD**(-1)*chi*u_{n}^{k+1} + (I-phiD**(-1)*phi)* u_{n+1}^{k}",
propagator=phi ** (-1) * chi,
**blockOps),
'ApproxBlockGaussSeidel.pickle' : BlockIteration(
update="phiD**(-1)*chi*u_{n}^{k+1} + (I-phiD**(-1)*phi)* u_{n+1}^{k}",
propagator=phi ** (-1) * chi, predictor=phiD ** (-1) * chi,
**blockOps),
'PFASST.pickle' : PFASST,
}
for key, value in algs.items():
K = value.checkK(N=nBlocks, K=kMax)
run = PintRun(blockIteration=value, nBlocks=nBlocks, kMax=K)
picklePintRun(key, run, value)