Skip to content

Commit d088529

Browse files
committedMar 7, 2025
Formatting
1 parent 23aaeef commit d088529

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed
 

‎fenicsprecice/fenicsprecice.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def initialize(self, coupling_subdomain, read_function_space=None, write_object=
432432

433433
self._participant.initialize()
434434

435-
def store_checkpoint(self, payload, t = None, n = None):
435+
def store_checkpoint(self, payload, t=None, n=None):
436436
"""
437437
Defines an object of class SolverState which stores the current state of the variable and the time stamp.
438438
@@ -459,17 +459,17 @@ def retrieve_checkpoint(self):
459459
-------
460460
u : FEniCS Function
461461
Current state of the physical variable of interest for this participant.
462-
t : double
462+
t : double
463463
Current simulation time or None if not specified in store_checkpoint
464-
n : int
464+
n : int
465465
Current time window (iteration) number or None if not specified in store_checkpoint
466466
"""
467467
assert (not self.is_time_window_complete())
468468
logger.debug("Restore solver state")
469469

470470
# since t and n are optional, they should not be returned, if not specified
471471
return self._checkpoint.get_state()
472-
472+
473473
def advance(self, dt):
474474
"""
475475
Advances coupling in preCICE.

‎tests/integration/test_write_read.py

+16-24
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ def return_dummy_data(n_points):
185185
self.fail(f"Unexpected combination of arg: {arg}, expected_arg: {expected_arg}")
186186

187187
np.testing.assert_almost_equal(list(read_data.values()), return_dummy_data(self.n_vertices))
188-
188+
189189
def test_optional_parameters(self):
190190
from precice import Participant
191191
import fenicsprecice
192-
192+
193193
def test_all_parameters(adapter):
194-
#init variables that are tested against
194+
# init variables that are tested against
195195
nx = 10
196196
mesh = UnitIntervalMesh(nx)
197197
V = FunctionSpace(mesh, 'P', 2)
@@ -201,14 +201,14 @@ def test_all_parameters(adapter):
201201
t = 0.5
202202
n = 42
203203
# test adapter
204-
adapter.store_checkpoint(u, t, n) # is the old implementation still working?
204+
adapter.store_checkpoint(u, t, n) # is the old implementation still working?
205205
res_u, res_t, res_n = adapter.retrieve_checkpoint()
206206
self.assertEqual(res_t, t)
207207
self.assertEqual(res_n, n)
208208
np.testing.assert_array_equal(res_u.vector(), u.vector())
209-
209+
210210
def test_opt_parameters(adapter):
211-
#init variables that are tested against
211+
# init variables that are tested against
212212
nx = 10
213213
mesh = UnitIntervalMesh(nx)
214214
V = FunctionSpace(mesh, 'P', 2)
@@ -218,22 +218,22 @@ def test_opt_parameters(adapter):
218218
t = 0.5
219219
n = 42
220220
# test adapter
221-
adapter.store_checkpoint(u, t) # without n
221+
adapter.store_checkpoint(u, t) # without n
222222
res = adapter.retrieve_checkpoint()
223-
self.assertEqual(len(res), 2) # correct number of return values
223+
self.assertEqual(len(res), 2) # correct number of return values
224224
res_u, res_t, res_n = res
225225
self.assertEqual(res_t, t)
226226
self.assertEqual(res_n, None)
227227
np.testing.assert_array_equal(res_u.vector(), u.vector())
228-
229-
adapter.store_checkpoint(u, n) # without t
228+
229+
adapter.store_checkpoint(u, n) # without t
230230
res = adapter.retrieve_checkpoint()
231-
self.assertEqual(len(res), 2) # correct number of return values
231+
self.assertEqual(len(res), 2) # correct number of return values
232232
res_u, res_t, res_n = res
233233
self.assertEqual(res_n, n)
234234
self.assertEqual(res_t, None)
235235
np.testing.assert_array_equal(res_u.vector(), u.vector())
236-
236+
237237
def test_payload_only(adapter):
238238
nx = 10
239239
mesh = UnitIntervalMesh(nx)
@@ -242,25 +242,17 @@ def test_payload_only(adapter):
242242
E = Expression("t", t=dummy_value, degree=2)
243243
u = interpolate(E, V)
244244
# test adapter
245-
adapter.store_checkpoint(u) # no optional parameters
245+
adapter.store_checkpoint(u) # no optional parameters
246246
res_u, res_t, res_n = adapter.retrieve_checkpoint()
247247
self.assertEqual(res_t, None)
248248
self.assertEqual(res_n, None)
249249
np.testing.assert_array_equal(res_u.vector(), u.vector())
250-
251-
252-
250+
253251
Participant.is_time_window_complete = MagicMock(return_value=False)
254-
252+
255253
precice = fenicsprecice.Adapter(self.dummy_config)
256-
254+
257255
# call the tests
258256
test_all_parameters(precice)
259257
test_opt_parameters(precice)
260258
test_payload_only(precice)
261-
262-
263-
264-
265-
266-

0 commit comments

Comments
 (0)