Skip to content

Commit

Permalink
switch from os to pathlib
Browse files Browse the repository at this point in the history
  • Loading branch information
keiyamamo committed Nov 1, 2024
1 parent a72d2d5 commit 143bf0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/vasp/simulations/aneurysm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Problem file for aneurysm FSI simulation
"""
import os
from pathlib import Path
import numpy as np

from vampy.simulation.Womersley import make_womersley_bcs, compute_boundary_geometry_acrn
Expand Down Expand Up @@ -34,7 +34,7 @@ def set_problem_parameters(default_variables, **namespace):

default_variables.update(dict(
# Temporal parameters
T=1.902, # Simulation end time
T=0.002, # Simulation end time
dt=0.001, # Timne step size
theta=0.501, # Theta scheme parameter
save_step=1, # Save frequency of files for visualisation
Expand Down Expand Up @@ -122,7 +122,7 @@ def create_bcs(t, DVP, mesh, boundaries, mu_f,
Q_mean, P_FC_File, P_mean, T_Cycle, **namespace):

# Load fourier coefficients for the velocity and scale by flow rate
An, Bn = np.loadtxt(os.path.join(os.path.dirname(os.path.abspath(__file__)), FC_file)).T
An, Bn = np.loadtxt(Path(__file__).parent / FC_file).T
# Convert to complex fourier coefficients
Cn = (An - Bn * 1j) * Q_mean
_, tmp_center, tmp_radius, tmp_normal = compute_boundary_geometry_acrn(mesh, inlet_id, boundaries)
Expand All @@ -147,7 +147,7 @@ def create_bcs(t, DVP, mesh, boundaries, mu_f,
bcs = u_inlet + [d_inlet, u_inlet_s, d_inlet_s, d_rigid]

# Load Fourier coefficients for the pressure
An_P, Bn_P = np.loadtxt(os.path.join(os.path.dirname(os.path.abspath(__file__)), P_FC_File)).T
An_P, Bn_P = np.loadtxt(Path(__file__).parent / P_FC_File).T

# Apply pulsatile pressure at the fsi interface by modifying the variational form
n = FacetNormal(mesh)
Expand Down Expand Up @@ -229,6 +229,6 @@ def finished(d_mean, u_mean, p_mean, visualization_folder, save_solution_after_t
]

for vector, data_name in data_names:
file_path = os.path.join(visualization_folder, data_name)
with XDMFFile(MPI.comm_world, file_path) as f:
file_path = Path(visualization_folder) / data_name
with XDMFFile(MPI.comm_world, str(file_path)) as f:
f.write_checkpoint(vector, data_name, 0, XDMFFile.Encoding.HDF5)
8 changes: 4 additions & 4 deletions src/vasp/simulations/offset_stenosis.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Problem file for offset stenosis FSI simulation
"""
import os
from pathlib import Path
import numpy as np

from vampy.simulation.Womersley import make_womersley_bcs, compute_boundary_geometry_acrn
from vampy.simulation.simulation_common import print_mesh_information
from turtleFSI.problems import *
from turtleFSI.problems import * # noqa: F401
from dolfin import HDF5File, Mesh, MeshFunction, facets, assemble, sqrt, cells, FacetNormal, ds, \
DirichletBC, Measure, inner, parameters

Expand Down Expand Up @@ -153,7 +153,7 @@ def create_bcs(t, DVP, mesh, boundaries, mu_f,
Q_mean, P_FC_File, P_mean, T_Cycle, **namespace):

# Load Fourier coefficients for the velocity and scale by flow rate
An, Bn = np.loadtxt(os.path.join(os.path.dirname(os.path.abspath(__file__)), FC_file)).T
An, Bn = np.loadtxt(Path(__file__).parent / FC_file).T
# Convert to complex fourier coefficients
Cn = (An - Bn * 1j) * Q_mean
_, tmp_center, tmp_radius, tmp_normal = compute_boundary_geometry_acrn(mesh, inlet_id, boundaries)
Expand All @@ -178,7 +178,7 @@ def create_bcs(t, DVP, mesh, boundaries, mu_f,
bcs = u_inlet + [d_inlet, u_inlet_s, d_inlet_s, d_rigid]

# Load Fourier coefficients for the pressure
An_P, Bn_P = np.loadtxt(os.path.join(os.path.dirname(os.path.abspath(__file__)), P_FC_File)).T
An_P, Bn_P = np.loadtxt(Path(__file__).parent / P_FC_File).T

# Apply pulsatile pressure at the fsi interface by modifying the variational form
n = FacetNormal(mesh)
Expand Down

0 comments on commit 143bf0e

Please sign in to comment.