Skip to content

Commit 98a26e4

Browse files
committed
switch to json format
1 parent 48bd3ef commit 98a26e4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

turtleFSI/monolithic.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from dolfin import *
1212
from pathlib import Path
13-
import pickle
13+
import json
1414
import time
1515
from pprint import pprint
1616

@@ -44,8 +44,8 @@
4444
if default_variables["restart_folder"] is not None:
4545
restart_folder = Path(default_variables["restart_folder"])
4646
restart_folder = restart_folder if "Checkpoint" in restart_folder.__str__() else restart_folder.joinpath("Checkpoint")
47-
with open(restart_folder.joinpath("default_variables.pickle"), "rb") as f:
48-
restart_dict = pickle.load(f)
47+
with open(restart_folder.joinpath("default_variables.json"), "r") as f:
48+
restart_dict = json.load(f)
4949
default_variables.update(restart_dict)
5050
default_variables["restart_folder"] = restart_folder
5151

@@ -168,7 +168,6 @@
168168
first_step_num = counter # This is so that the solver will recompute the jacobian on the first step of the simulation
169169
while t <= T + dt / 10 and not stop: # + dt / 10 is a hack to ensure that we take the final time step t == T
170170
t += dt
171-
172171
# Pre solve hook
173172
tmp_dict = pre_solve(**vars())
174173
if tmp_dict is not None:

turtleFSI/problems/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
from dolfin import parameters, XDMFFile, MPI, assign, Mesh, refine, project, VectorElement, FiniteElement, PETScDMCollection, FunctionSpace, Function
11-
import pickle
11+
import json
1212
from pathlib import Path
1313
from xml.etree import ElementTree as ET
1414
import numpy as np
@@ -187,8 +187,9 @@ def checkpoint(dvp_, default_variables, checkpoint_folder, mesh, **namespace):
187187

188188
# Dump default parameters
189189
if MPI.rank(MPI.comm_world) == 0:
190-
with open(str(checkpoint_folder.joinpath("default_variables.pickle")), "bw") as f:
191-
pickle.dump(default_variables, f)
190+
with open(str(checkpoint_folder.joinpath("default_variables.json")), "w") as f:
191+
default_variables["restart_folder"] = str(default_variables["restart_folder"])
192+
json.dump(default_variables, f)
192193

193194
# Dump physical fields
194195
fields = _get_fields(dvp_, mesh)

0 commit comments

Comments
 (0)