-
Notifications
You must be signed in to change notification settings - Fork 0
/
pfasst.py
614 lines (576 loc) · 33.9 KB
/
pfasst.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
import numpy as np
from pint_task_graph import PintGraph
class Pfasst(PintGraph):
def __init__(self, level: object, cost_sweeper: object, cost_res_all: object, cost_res_single: object,
cost_pro_all: object, placing_conv_crit: object,
pfasst_style: object, cost_pro_single: object, cost_f_eval_all: object, cost_fas: object,
cost_f_eval_single: object, nsweeps: object,
predict_type: object = None, level_0_sweep_start: object = True, level_0_sweep_end: object = True,
*args: object, **kwargs: object) -> object:
"""
Constructor
:param level: Level
:param cost_sweeper: Sweeper costs per level
:param cost_res_all: Restriction all collocation points costs
:param cost_res_single: Restriction single time point
:param cost_pro_all: Prolongation all collocation points costs
:param placing_conv_crit: Different placing of the conv criterion
:param pfasst_style: Pfasst view (multigrid or classic)
:param cost_pro_single: Prolongation single time point
:param cost_f_eval_all: Evaluation all collocation points costs
:param cost_fas: FAS costs
:param cost_f_eval_single: Evaluation single time point
:param nsweeps: Number of sweeps per level
:param predict_type: Prediction variant
:param level_0_sweep_start: Sweep at level 0 at the beginning
:param level_0_sweep_end: Sweep at level 0 at the end
:param args:
:param kwargs:
"""
super().__init__(*args, **kwargs)
# Save to local parameters
self.L = level
self.cost_sweeper = cost_sweeper
self.cost_restriction_all = cost_res_all
self.cost_restriction_single = cost_res_single
self.cost_interpolation_all = cost_pro_all
self.cost_interpolation_single = cost_pro_single
self.cost_f_eval_all = cost_f_eval_all
self.cost_f_eval_single = cost_f_eval_single
self.cost_fas = cost_fas
self.placing_conv_crit = placing_conv_crit
self.pfasst_style = pfasst_style
self.predict_type = predict_type
self.nsweeps = nsweeps
self.sweep_level_0_start_iteration = level_0_sweep_start
self.sweep_level_0_end_iteration = level_0_sweep_end
self.cost_copy = np.zeros(self.L)
if predict_type is not None and predict_type not in ['null', 'libpfasst_style', 'fine_only', 'pfasst_burnin',
'libpfasst_true']:
raise Exception('unknown predict type')
else:
if self.predict_type == 'null':
self.predict_type = None
if self.pfasst_style not in ['multigrid', 'classic']:
raise Exception('unknown pfasst_style')
self.cc = {}
def update_cc(self, k: int) -> None:
"""
Convergence criterion
:param k: iteration
"""
self.cc = {}
if self.placing_conv_crit == 0:
for i in range(1, self.nt):
cc = self.create_node_name(var_name='f', var_dict=self.cr_dict(level=0, time_point=i, iteration=k,
colloc_node='all'))
self.cc[i] = cc
elif self.placing_conv_crit == 1:
for i in range(1, self.nt):
cc = self.create_node_name(var_name='f', var_dict=self.cr_dict(level=0, time_point=i, iteration=k,
colloc_node='all'))
self.cc[i] = cc
else:
raise Exception('Unknown placing')
def compute(self):
"""
Computes the graph
"""
self.predict()
if self.placing_conv_crit == 0:
self.update_cc(k=0)
self.convergence_criterion(poins_with_dependencies=self.cc)
for k in range(1, self.iterations + 1):
self.sychronize_nodes_plot()
self.pfasst(k=k)
if self.placing_conv_crit == 0:
self.update_cc(k=k)
self.convergence_criterion(poins_with_dependencies=self.cc)
def pfasst(self, k: int) -> None:
"""
k'th PFASST iteration
:param k: iteration
"""
for level in range(0, self.L - 1):
for i in range(1, self.nt):
if self.pfasst_style == 'multigrid':
if i > 1:
self.copy_and_f_eval_single(op_in=['u',
self.cr_dict(iteration=k - 1, level=level, time_point=i - 1,
colloc_node='last')],
op_out_1=['u',
self.cr_dict(iteration=k - 1, level=level, time_point=i,
colloc_node='first')],
op_out_2=['f',
self.cr_dict(iteration=k - 1, level=level, time_point=i,
colloc_node='first')],
level=level,
i=i)
else:
if k == 1 or level > 0:
self.f_eval_single(
op_in=['u', self.cr_dict(iteration=k - 1, level=level, time_point=i, colloc_node='first')],
op_out=['f',
self.cr_dict(iteration=k - 1, level=level, time_point=i, colloc_node='first')],
level=0,
i=i)
if self.sweep_level_0_start_iteration or level > 0:
for _ in range(self.nsweeps[level]):
self.sdc_sweep(
op_in_1=['u', self.cr_dict(iteration=k - 1, level=level, time_point=i, colloc_node='all')],
op_in_2=['f', self.cr_dict(iteration=k - 1, level=level, time_point=i, colloc_node='all')],
op_in_3=None if level == 0 else ['tau',
self.cr_dict(iteration=k, level=level, time_point=i,
colloc_node='all')],
op_out_1=['u', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_out_2=['f', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
else:
self.copy(op_in=['u', self.cr_dict(iteration=k - 1, level=level, time_point=i, colloc_node='all')],
op_out=['u', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
self.copy(op_in=['f', self.cr_dict(iteration=k - 1, level=level, time_point=i, colloc_node='all')],
op_out=['f', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
self.restrict_all(op_in=['u', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_out=['u', self.cr_dict(iteration=k - 1, level=level + 1, time_point=i,
colloc_node='all')],
level=level,
i=i)
self.f_eval_all(
op_in=['u', self.cr_dict(iteration=k - 1, level=level + 1, time_point=i, colloc_node='all')],
op_out=['f', self.cr_dict(iteration=k - 1, level=level + 1, time_point=i, colloc_node='all')],
level=level,
i=i,
cost=self.cost_f_eval_all[level + 1])
self.fas(op_in_1=['f', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_in_2=['f',
self.cr_dict(iteration=k - 1, level=level + 1, time_point=i, colloc_node='all')],
op_in_3=None if level == 0 else ['tau', self.cr_dict(iteration=k, level=level, time_point=i,
colloc_node='all')],
op_out=['tau', self.cr_dict(iteration=k, level=level + 1, time_point=i, colloc_node='all')],
level=level,
i=i)
if self.placing_conv_crit == 1:
self.update_cc(iteration=k)
self.convergence_criterion(poins_with_dependencies=self.cc)
# Coarsest level
for i in range(1, self.nt):
if i > 1:
self.copy_and_f_eval_single(
op_in=['u', self.cr_dict(iteration=k, level=self.L - 1, time_point=i - 1, colloc_node='last')],
op_out_1=['u', self.cr_dict(iteration=k - 1, level=self.L - 1, time_point=i, colloc_node='first')],
op_out_2=['f', self.cr_dict(iteration=k - 1, level=self.L - 1, time_point=i, colloc_node='first')],
level=self.L - 1,
i=i)
for _ in range(self.nsweeps[self.L - 1]):
self.sdc_sweep(
op_in_1=['u', self.cr_dict(iteration=k - 1, level=self.L - 1, time_point=i, colloc_node='all')],
op_in_2=['f', self.cr_dict(iteration=k - 1, level=self.L - 1, time_point=i, colloc_node='all')],
op_in_3=['tau', self.cr_dict(iteration=k, level=self.L - 1, time_point=i, colloc_node='all')],
op_out_1=['u', self.cr_dict(iteration=k, level=self.L - 1, time_point=i, colloc_node='all')],
op_out_2=['v', self.cr_dict(iteration=k, level=self.L - 1, time_point=i, colloc_node='all')],
level=self.L - 1,
i=i)
for level in range(self.L - 2, -1, -1):
for i in range(1, self.nt):
self.interpolate_and_correct_all(
op_in_1=['u', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_in_2=['u', self.cr_dict(iteration=k, level=level + 1, time_point=i, colloc_node='all')],
op_in_3=['u', self.cr_dict(iteration=k - 1, level=level + 1, time_point=i, colloc_node='all')],
op_out=['v', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
level=level,
i=i, )
self.f_eval_all(op_in=['v', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_out=['f', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
level=level,
i=i,
cost=self.cost_f_eval_all[level] if self.pfasst_style == 'classic' else
self.cost_f_eval_all[level] - self.cost_f_eval_single[level])
if i > 1:
if self.pfasst_style == 'multigrid':
self.copy_and_f_eval_single(
op_in=['v', self.cr_dict(iteration=k, level=level, time_point=i - 1, colloc_node='last')],
op_out_1=['v',
self.cr_dict(iteration=k - 1, level=level, time_point=i, colloc_node='first')],
op_out_2=['f',
self.cr_dict(iteration=k - 1, level=level, time_point=i, colloc_node='first')],
level=level,
i=i,
v=True)
else:
self.copy_and_error_correction(
op_in_1=['v',
self.cr_dict(iteration=k, level=level, time_point=i - 1, colloc_node='last')],
op_in_2=['v',
self.cr_dict(iteration=k, level=level + 1, time_point=i, colloc_node='first')],
op_out_1=['v', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='first')],
op_out_2=['f', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='first')],
level=level,
i=i)
for i in range(1, self.nt):
if level > 0 or self.sweep_level_0_end_iteration:
for _ in range(self.nsweeps[level]):
self.sdc_sweep(
op_in_1=['v', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_in_2=['f', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_in_3=None if level == 0 else ['tau',
self.cr_dict(iteration=k, level=level, time_point=i,
colloc_node='all')],
op_out_1=['u', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_out_2=['v', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
else:
self.copy(op_in=['v', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
op_out=['u', self.cr_dict(iteration=k, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
def sdc_sweep(self, op_in_1: list, op_in_2: list, op_in_3: list, op_out_1: list, op_out_2: list, level: int,
i: int) -> None:
"""
Models a sdc sweep
:param op_in_1: Data dependency
:param op_in_2: Data dependency
:param op_in_3: Data dependency
:param op_out_1: New data
:param op_out_2: New data
:param level: Level
:param i: time point
"""
pred = self.create_node_name(var_name=op_in_1[0], var_dict=op_in_1[1])
pred += self.create_node_name(var_name=op_in_2[0], var_dict=op_in_2[1])
if op_in_3 is not None:
pred += self.create_node_name(var_name=op_in_3[0], var_dict=op_in_3[1])
set_val = self.create_node_name(var_name=op_out_1[0], var_dict=op_out_1[1])
set_val += self.create_node_name(var_name=op_out_2[0], var_dict=op_out_2[1])
self.add_node(name="S|" + str(level),
predecessors=pred,
set_values=set_val,
cost=self.cost_sweeper[level],
point=i,
description='pfasst_sweeper' + str(level))
def restrict_all(self, op_in: list, op_out: list, level: int, i: int) -> None:
"""
Models restriction of all collocation nodes
:param op_in: Data dependency
:param op_out: New data
:param level: Level
:param i: iteration
"""
self.add_node(name="R|" + str(level),
predecessors=self.create_node_name(var_name=op_in[0], var_dict=op_in[1]),
set_values=self.create_node_name(var_name=op_out[0], var_dict=op_out[1]),
cost=self.cost_restriction_all[level],
point=i,
description='pfasst_res_all' + str(level))
def restrict_single(self, op_in: list, op_out: list, level: int, i: int) -> None:
"""
Models restriction of one point
:param op_in: Data dependency
:param op_out: New data
:param level: Level
:param i: iteration
"""
self.add_node(name="r|" + str(level),
predecessors=self.create_node_name(var_name=op_in[0], var_dict=op_in[1]),
set_values=self.create_node_name(var_name=op_out[0], var_dict=op_out[1]),
cost=self.cost_restriction_single[level],
point=i,
description='pfasst_res_single' + str(level))
def f_eval_all(self, op_in: list, op_out: list, level: int, i: int, cost: float) -> None:
"""
Models evaluation of all collocation nodes
:param op_in: Data dependency
:param op_out: New data
:param level: Level
:param i: iteration
:param cost: Operation costs
"""
self.add_node(name="FE|" + str(level),
predecessors=self.create_node_name(var_name=op_in[0], var_dict=op_in[1]),
set_values=self.create_node_name(var_name=op_out[0], var_dict=op_out[1]),
cost=cost,
point=i,
description='pfasst_f_eval_all' + str(level))
def f_eval_single(self, op_in: list, op_out: list, level: int, i: int) -> None:
"""
Models evaluation of one collocation nodes
:param op_in:
:param op_out:
:param level:
:param i:
"""
self.add_node(name="fe|" + str(level),
predecessors=self.create_node_name(var_name=op_in[0], var_dict=op_in[1]),
set_values=self.create_node_name(var_name=op_out[0], var_dict=op_out[1]),
cost=self.cost_f_eval_single[level],
point=i,
description='pfasst_f_eval_single' + str(level))
def fas(self, op_in_1: list, op_in_2: list, op_in_3: list, op_out: list, level: int, i: int) -> None:
"""
Models FAS
:param op_in_1: Data dependency
:param op_in_2: Data dependency
:param op_in_3: Data dependency
:param op_out: New data
:param level: Level
:param i: iteration
"""
pred = self.create_node_name(var_name=op_in_1[0], var_dict=op_in_1[1])
pred += self.create_node_name(var_name=op_in_2[0], var_dict=op_in_2[1])
if op_in_3 is not None:
pred += self.create_node_name(var_name=op_in_3[0], var_dict=op_in_3[1])
self.add_node(name="FAS|" + str(level),
predecessors=pred,
set_values=self.create_node_name(var_name=op_out[0], var_dict=op_out[1]),
cost=self.cost_fas[level],
point=i,
description='pfasst_fas_' + str(level))
def copy(self, op_in: list, op_out: list, level: int, i: int) -> None:
"""
Models a copy
:param op_in: Data dependency
:param op_out: New data
:param level: Level
:param i: iteration
"""
self.add_node(name="C|" + str(level),
predecessors=self.create_node_name(var_name=op_in[0], var_dict=op_in[1]),
set_values=self.create_node_name(var_name=op_out[0], var_dict=op_out[1]),
cost=self.cost_copy[level],
point=i,
description='pfasst_copy_' + str(level))
def copy_and_f_eval_single(self, op_in: list, op_out_1: list, op_out_2: list, level: int, i: int) -> None:
"""
Models copy with evaluation
:param op_in: Data dependency
:param op_out_1: New data
:param op_out_2: New data
:param level: Level
:param i: iteration
"""
self.add_node(name="c|" + str(level),
predecessors=self.create_node_name(var_name=op_in[0], var_dict=op_in[1]),
set_values=self.create_node_name(var_name=op_out_1[0], var_dict=op_out_1[1]),
cost=self.cost_copy[level],
point=i,
description='pfasst_copy_and_f_eval_single' + str(level))
self.add_node(name="f|" + str(level),
predecessors=self.create_node_name(var_name=op_out_1[0], var_dict=op_out_1[1]),
set_values=self.create_node_name(var_name=op_out_2[0], var_dict=op_out_2[1]),
cost=self.cost_f_eval_single[level],
point=i,
description='pfasst_commu_and_f_eval_single' + str(level))
def interpolate_and_correct_all(self, op_in_1: list, op_in_2: list, op_in_3: list, op_out: list, level: int,
i: int) -> None:
"""
Models interpolation and correction of all collocation nodes
:param op_in_1: Data dependency
:param op_in_2: Data dependency
:param op_in_3: Data dependency
:param op_out: New data
:param level: Level
:param i: iteration
"""
pred = self.create_node_name(var_name=op_in_1[0], var_dict=op_in_1[1])
pred += self.create_node_name(var_name=op_in_2[0], var_dict=op_in_2[1])
pred += self.create_node_name(var_name=op_in_3[0], var_dict=op_in_3[1])
self.add_node(name="I|" + str(level),
predecessors=pred,
set_values=self.create_node_name(var_name=op_out[0], var_dict=op_out[1]),
cost=self.cost_interpolation_all[level],
point=i,
description='pfasst_pro_all' + str(level))
def copy_and_error_correction(self, op_in_1: list, op_in_2: list, op_out_1: list, op_out_2: list, level: int,
i: int) -> None:
"""
Copy and correction
:param op_in_1: Data dependency
:param op_in_2: Data dependency
:param op_out_1: New data
:param op_out_2: New data
:param level: Level
:param i: iteration
"""
self.add_node(name="c|" + str(level),
predecessors=self.create_node_name(var_name=op_in_1[0], var_dict=op_in_1[1]),
set_values=self.create_node_name(var_name=op_out_1[0], var_dict=op_out_1[1]),
cost=self.cost_copy[level],
point=i,
description='pfasst_copy_single' + str(level))
self.add_node(name="r|" + str(level),
predecessors=self.create_node_name(var_name=op_out_1[0], var_dict=op_out_1[1]),
set_values=self.create_node_name(var_name='tmp', var_dict=op_out_1[1]),
cost=self.cost_restriction_single[level],
point=i,
description='pfasst_res_single' + str(level))
pre = self.create_node_name(var_name='tmp', var_dict=op_out_1[1])
pre += self.create_node_name(var_name=op_out_1[0], var_dict=op_out_1[1])
pre += self.create_node_name(var_name=op_in_2[0], var_dict=op_in_2[1])
self.add_node(name="i|" + str(level),
predecessors=pre,
set_values=self.create_node_name(var_name=op_out_1[0], var_dict=op_out_1[1]),
cost=self.cost_interpolation_single[level],
point=i,
description='pfasst_pro_single' + str(level))
self.add_node(name="f|" + str(level),
predecessors=self.create_node_name(var_name=op_out_1[0], var_dict=op_out_1[1]),
set_values=self.create_node_name(var_name=op_out_2[0], var_dict=op_out_2[1]),
cost=self.cost_f_eval_single[level],
point=i,
description='pfasst_f_eval_single' + str(level))
def predict(self) -> None:
"""
Predictor
"""
for i in range(1, self.nt):
self.add_node(name="c0|",
predecessors=['u_0'],
set_values=self.create_node_name(var_name='u',
var_dict=self.cr_dict(iteration=0, level=0, time_point=i,
colloc_node='first')),
cost=self.cost_copy[0],
point=i,
description='Set first point of every time step to initial value')
self.add_node(name="C0|",
predecessors=['0'],
set_values=self.create_node_name(var_name='u',
var_dict=self.cr_dict(iteration=0, level=0, time_point=i,
colloc_node='last')),
cost=self.cost_copy[0],
point=i,
description='Set last point of every time step to 0')
self.add_node(name="C0|",
predecessors=['0'],
set_values=self.create_node_name(var_name='f',
var_dict=self.cr_dict(iteration=0, level=0, time_point=i,
colloc_node='all')),
cost=self.cost_copy[0],
point=i,
description='Set f to 0')
if self.predict_type == 'fine_only':
level = 0
for i in range(1, self.nt):
self.f_eval_all(op_in=['u', self.cr_dict(iteration=0, level=0, time_point=i, colloc_node='all')],
op_out=['f', self.cr_dict(iteration=0, level=0, time_point=i, colloc_node='all')],
level=level,
i=i,
cost=self.cost_f_eval_all[level])
self.sdc_sweep(op_in_1=['u', self.cr_dict(iteration=0, level=0, time_point=i, colloc_node='all')],
op_in_2=['f', self.cr_dict(iteration=0, level=0, time_point=i, colloc_node='all')],
op_in_3=None,
op_out_1=['u', self.cr_dict(iteration=0, level=0, time_point=i, colloc_node='all')],
op_out_2=['f', self.cr_dict(iteration=0, level=0, time_point=i, colloc_node='all')],
level=level,
i=i)
elif self.predict_type == 'libpfasst_true':
for i in range(1, self.nt):
self.f_eval_single(op_in=['u', self.cr_dict(iteration=0, level=0, time_point=i, colloc_node='first')],
op_out=['f', self.cr_dict(iteration=0, level=0, time_point=i, colloc_node='first')],
level=0,
i=i)
for level in range(0, self.L - 1):
for i in range(1, self.nt):
self.restrict_single(
op_in=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='first')],
op_out=['u', self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='first')],
level=level,
i=i)
self.restrict_all(
op_in=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_out=['u', self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='all')],
level=level,
i=i)
self.f_eval_all(
op_in=['u', self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='all')],
op_out=['f', self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='all')],
level=level,
i=i,
cost=self.cost_f_eval_all[level + 1])
self.fas(op_in_1=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_in_2=['f',
self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='all')],
op_in_3=None if level == 0 else ['tau',
self.cr_dict(iteration=0, level=level, time_point=i,
colloc_node='all')],
op_out=['tau',
self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='all')],
level=level,
i=i)
level = self.L - 1
# burnin
for j in range(2, self.nt):
for i in range(self.nt - 1, j - 1, -1):
self.copy_and_f_eval_single(
op_in=['u', self.cr_dict(iteration=0, level=self.L - 1, time_point=i, colloc_node='last')],
op_out_1=['u', self.cr_dict(iteration=0, level=self.L - 1, time_point=i, colloc_node='first')],
op_out_2=['f', self.cr_dict(iteration=0, level=self.L - 1, time_point=i, colloc_node='first')],
level=self.L - 1,
i=i)
self.sdc_sweep(
op_in_1=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_in_2=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_in_3=['tau', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_out_1=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_out_2=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
# sweep
for i in range(1, self.nt):
self.copy_and_f_eval_single(
op_in=['u', self.cr_dict(iteration=0, level=self.L - 1, time_point=i, colloc_node='last')],
op_out_1=['u', self.cr_dict(iteration=0, level=self.L - 1, time_point=i, colloc_node='first')],
op_out_2=['f', self.cr_dict(iteration=0, level=self.L - 1, time_point=i, colloc_node='first')],
level=self.L - 1,
i=i)
self.sdc_sweep(op_in_1=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_in_2=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_in_3=['tau',
self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_out_1=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_out_2=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
for level in range(self.L - 2, -1, -1):
for i in range(1, self.nt):
self.interpolate_and_correct_all(
op_in_1=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_in_2=['u', self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='all')],
op_in_3=['u', self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='all')],
op_out=['v', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
self.f_eval_all(
op_in=['v', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_out=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
level=level,
i=i,
cost=self.cost_f_eval_all[level])
if i > 1:
self.copy_and_error_correction(
op_in_1=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='last')],
op_in_2=['u',
self.cr_dict(iteration=0, level=level + 1, time_point=i, colloc_node='first')],
op_out_1=['v', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='first')],
op_out_2=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='first')],
level=level,
i=i)
self.sdc_sweep(
op_in_1=['v', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_in_2=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_in_3=None if level == 0 else ['tau', self.cr_dict(iteration=0, level=level, time_point=i,
colloc_node='all')],
op_out_1=['u', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
op_out_2=['f', self.cr_dict(iteration=0, level=level, time_point=i, colloc_node='all')],
level=level,
i=i)
elif self.predict_type == 'libpfasst_style':
raise Exception("not implemented")
elif self.predict_type == 'pfasst_burnin':
raise Exception('not implemented')
elif self.predict_type is None:
raise Exception('not implemented')