@@ -103,14 +103,15 @@ def determine_gradient(V_g, u, flux):
103
103
# Initialize the adapter according to the specific participant
104
104
if problem is ProblemType .DIRICHLET :
105
105
precice = Adapter (adapter_config_filename = "precice-adapter-config-D.json" )
106
- precice_dt = precice .initialize (coupling_boundary , read_function_space = V , write_object = f_N_function )
106
+ precice .initialize (coupling_boundary , read_function_space = V , write_object = f_N_function )
107
107
elif problem is ProblemType .NEUMANN :
108
108
precice = Adapter (adapter_config_filename = "precice-adapter-config-N.json" )
109
- precice_dt = precice .initialize (coupling_boundary , read_function_space = V_g , write_object = u_D_function )
109
+ precice .initialize (coupling_boundary , read_function_space = V_g , write_object = u_D_function )
110
110
111
111
boundary_marker = False
112
112
113
113
dt = Constant (0 )
114
+ precice_dt = precice .get_max_time_step_size ()
114
115
dt .assign (np .min ([fenics_dt , precice_dt ]))
115
116
116
117
# Define variational problem
@@ -173,7 +174,7 @@ def determine_gradient(V_g, u, flux):
173
174
# output solution and reference solution at t=0, n=0
174
175
n = 0
175
176
print ('output u^%d and u_ref^%d' % (n , n ))
176
- temperature_out << u_n
177
+ temperature_out << ( u_n , t )
177
178
ref_out << u_ref
178
179
ranks << mesh_rank
179
180
@@ -191,10 +192,12 @@ def determine_gradient(V_g, u, flux):
191
192
while precice .is_coupling_ongoing ():
192
193
193
194
# write checkpoint
194
- if precice .is_action_required ( precice . action_write_iteration_checkpoint () ):
195
+ if precice .requires_writing_checkpoint ( ):
195
196
precice .store_checkpoint (u_n , t , n )
196
197
197
- read_data = precice .read_data ()
198
+ precice_dt = precice .get_max_time_step_size ()
199
+ dt .assign (np .min ([fenics_dt , precice_dt ]))
200
+ read_data = precice .read_data (dt )
198
201
if problem is ProblemType .DIRICHLET and (domain_part is DomainPart .CIRCULAR or domain_part is DomainPart .RECTANGLE ):
199
202
# We have to data for an arbitrary point that is not on the circle, to obtain exact solution.
200
203
# See https://github.com/precice/fenics-adapter/issues/113 for details.
@@ -203,8 +206,6 @@ def determine_gradient(V_g, u, flux):
203
206
# Update the coupling expression with the new read data
204
207
precice .update_coupling_expression (coupling_expression , read_data )
205
208
206
- dt .assign (np .min ([fenics_dt , precice_dt ]))
207
-
208
209
# Compute solution u^n+1, use bcs u_D^n+1, u^n and coupling bcs
209
210
solve (a == L , u_np1 , bcs )
210
211
@@ -217,10 +218,10 @@ def determine_gradient(V_g, u, flux):
217
218
# Neumann problem reads flux and writes temperature on boundary to Dirichlet problem
218
219
precice .write_data (u_np1 )
219
220
220
- precice_dt = precice .advance (dt (0 ))
221
+ precice .advance (dt (0 ))
221
222
222
223
# roll back to checkpoint
223
- if precice .is_action_required ( precice . action_read_iteration_checkpoint () ):
224
+ if precice .requires_reading_checkpoint ( ):
224
225
u_cp , t_cp , n_cp = precice .retrieve_checkpoint ()
225
226
u_n .assign (u_cp )
226
227
t = t_cp
@@ -237,7 +238,7 @@ def determine_gradient(V_g, u, flux):
237
238
print ('n = %d, t = %.2f: L2 error on domain = %.3g' % (n , t , error ))
238
239
# output solution and reference solution at t_n+1
239
240
print ('output u^%d and u_ref^%d' % (n , n ))
240
- temperature_out << u_n
241
+ temperature_out << ( u_n , t )
241
242
ref_out << u_ref
242
243
error_out << error_pointwise
243
244
0 commit comments