@@ -59,7 +59,6 @@ def neumann_boundary(x, on_boundary):
59
59
v = TestFunction (V )
60
60
61
61
u_np1 = Function (V )
62
- saved_u_old = Function (V )
63
62
64
63
# function known from previous timestep
65
64
u_n = Function (V )
@@ -80,15 +79,18 @@ def neumann_boundary(x, on_boundary):
80
79
81
80
precice_dt = precice .get_max_time_step_size ()
82
81
fenics_dt = precice_dt # if fenics_dt == precice_dt, no subcycling is applied
83
- # fenics_dt = 0.02 # if fenics_dt < precice_dt, subcycling is applied
82
+ # n_substeps = 5 # number of substeps per window
83
+ # fenics_dt = precice_dt / n_substeps # if fenics_dt < precice_dt, subcycling is applied
84
84
dt = Constant (np .min ([precice_dt , fenics_dt ]))
85
85
86
86
# clamp the beam at the bottom
87
87
bc = DirichletBC (V , Constant ((0 , 0 )), fixed_boundary )
88
88
89
89
# alpha method parameters
90
- alpha_m = Constant (0 )
91
- alpha_f = Constant (0 )
90
+ alpha_m = Constant (0.2 )
91
+ alpha_f = Constant (0.4 )
92
+ # alpha_m = Constant(0)
93
+ # alpha_f = Constant(0)
92
94
93
95
"""
94
96
Check requirements for alpha_m and alpha_f from
@@ -196,13 +198,14 @@ def avg(x_old, x_new, alpha):
196
198
while precice .is_coupling_ongoing ():
197
199
198
200
if precice .requires_writing_checkpoint (): # write checkpoint
199
- precice .store_checkpoint (u_n , t , n )
201
+ precice .store_checkpoint (( u_n , v_n , a_n ) , t , n )
200
202
201
203
precice_dt = precice .get_max_time_step_size ()
202
204
dt = Constant (np .min ([precice_dt , fenics_dt ]))
203
205
204
206
# read data from preCICE and get a new coupling expression
205
- read_data = precice .read_data (dt )
207
+ # sample force F at $F(t_{n+1-\alpha_f})$ (see generalized alpha paper)
208
+ read_data = precice .read_data ((1 - float (alpha_f )) * dt )
206
209
207
210
# Update the point sources on the coupling boundary with the new read data
208
211
Forces_x , Forces_y = precice .get_point_sources (read_data )
@@ -227,17 +230,20 @@ def avg(x_old, x_new, alpha):
227
230
228
231
# Either revert to old step if timestep has not converged or move to next timestep
229
232
if precice .requires_reading_checkpoint (): # roll back to checkpoint
230
- u_cp , t_cp , n_cp = precice .retrieve_checkpoint ()
233
+ uva_cp , t_cp , n_cp = precice .retrieve_checkpoint ()
234
+ u_cp , v_cp , a_cp = uva_cp
231
235
u_n .assign (u_cp )
236
+ v_n .assign (v_cp )
237
+ a_n .assign (a_cp )
232
238
t = t_cp
233
239
n = n_cp
234
240
else :
241
+ update_fields (u_np1 , u_n , v_n , a_n )
235
242
u_n .assign (u_np1 )
236
243
t += float (dt )
237
244
n += 1
238
245
239
246
if precice .is_time_window_complete ():
240
- update_fields (u_np1 , saved_u_old , v_n , a_n )
241
247
if n % 10 == 0 :
242
248
displacement_out << (u_n , t )
243
249
0 commit comments