Skip to content

Commit

Permalink
switch to json format
Browse files Browse the repository at this point in the history
  • Loading branch information
keiyamamo committed Sep 23, 2023
1 parent 48bd3ef commit 98a26e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions turtleFSI/monolithic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from dolfin import *
from pathlib import Path
import pickle
import json
import time
from pprint import pprint

Expand Down Expand Up @@ -44,8 +44,8 @@
if default_variables["restart_folder"] is not None:
restart_folder = Path(default_variables["restart_folder"])
restart_folder = restart_folder if "Checkpoint" in restart_folder.__str__() else restart_folder.joinpath("Checkpoint")
with open(restart_folder.joinpath("default_variables.pickle"), "rb") as f:
restart_dict = pickle.load(f)
with open(restart_folder.joinpath("default_variables.json"), "r") as f:
restart_dict = json.load(f)
default_variables.update(restart_dict)
default_variables["restart_folder"] = restart_folder

Expand Down Expand Up @@ -168,7 +168,6 @@
first_step_num = counter # This is so that the solver will recompute the jacobian on the first step of the simulation
while t <= T + dt / 10 and not stop: # + dt / 10 is a hack to ensure that we take the final time step t == T
t += dt

# Pre solve hook
tmp_dict = pre_solve(**vars())
if tmp_dict is not None:
Expand Down
7 changes: 4 additions & 3 deletions turtleFSI/problems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

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

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

# Dump physical fields
fields = _get_fields(dvp_, mesh)
Expand Down

0 comments on commit 98a26e4

Please sign in to comment.