Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 769f59d7 authored by Martin Genet's avatar Martin Genet
Browse files

sol_folder is now working_folder in compute_strains

parent a2292f90
No related branches found
No related tags found
No related merge requests found
...@@ -20,9 +20,9 @@ import dolfin_dic as ddic ...@@ -20,9 +20,9 @@ import dolfin_dic as ddic
################################################################################ ################################################################################
def compute_strains( def compute_strains(
sol_folder, working_folder,
sol_basename, working_basename,
sol_ext="vtu", working_ext="vtu",
ref_frame=None, ref_frame=None,
disp_array_name="displacement", disp_array_name="displacement",
defo_grad_array_name="DeformationGradient", defo_grad_array_name="DeformationGradient",
...@@ -59,28 +59,28 @@ def compute_strains( ...@@ -59,28 +59,28 @@ def compute_strains(
mesh_w_local_basis = None mesh_w_local_basis = None
n_sector_ids = 0 n_sector_ids = 0
sol_filenames = glob.glob(sol_folder+"/"+sol_basename+"_[0-9]*."+sol_ext) working_filenames = glob.glob(working_folder+"/"+working_basename+"_[0-9]*."+working_ext)
sol_zfill = len(sol_filenames[0].rsplit("_",1)[-1].split(".")[0]) working_zfill = len(working_filenames[0].rsplit("_",1)[-1].split(".")[0])
if (verbose): print "sol_zfill = " + str(sol_zfill) if (verbose): print "working_zfill = " + str(working_zfill)
n_frames = len(sol_filenames) n_frames = len(working_filenames)
if (verbose): print "n_frames = " + str(n_frames) if (verbose): print "n_frames = " + str(n_frames)
if (write_strains): if (write_strains):
strain_file = open(sol_folder+"/"+sol_basename+"-strains.dat", "w") strain_file = open(working_folder+"/"+working_basename+"-strains.dat", "w")
strain_file.write("#t Err_avg Err_std Ecc_avg Ecc_std Ell_avg Ell_std Erc_avg Erc_std Erl_avg Erl_std Ecl_avg Ecl_std\n") strain_file.write("#t Err_avg Err_std Ecc_avg Ecc_std Ell_avg Ell_std Erc_avg Erc_std Erl_avg Erl_std Ecl_avg Ecl_std\n")
if (write_strains_vs_radius): if (write_strains_vs_radius):
strain_vs_radius_file = open(sol_folder+"/"+sol_basename+"-strains_vs_radius.dat", "w") strain_vs_radius_file = open(working_folder+"/"+working_basename+"-strains_vs_radius.dat", "w")
strain_vs_radius_file.write("#t rr Err Ecc Ell Erc Erl Ecl\n") strain_vs_radius_file.write("#t rr Err Ecc Ell Erc Erl Ecl\n")
if (write_binned_strains_vs_radius): if (write_binned_strains_vs_radius):
binned_strain_vs_radius_file = open(sol_folder+"/"+sol_basename+"-binned_strains_vs_radius.dat", "w") binned_strain_vs_radius_file = open(working_folder+"/"+working_basename+"-binned_strains_vs_radius.dat", "w")
binned_strain_vs_radius_file.write("#t rr Err Ecc Ell Erc Erl Ecl\n") binned_strain_vs_radius_file.write("#t rr Err Ecc Ell Erc Erl Ecl\n")
if (ref_frame is not None): if (ref_frame is not None):
ref_mesh_filename = sol_folder+"/"+sol_basename+"_"+str(ref_frame).zfill(sol_zfill)+"."+sol_ext ref_mesh_filename = working_folder+"/"+working_basename+"_"+str(ref_frame).zfill(working_zfill)+"."+working_ext
ref_mesh = myvtk.readUGrid( ref_mesh = myvtk.readUGrid(
filename=ref_mesh_filename, filename=ref_mesh_filename,
verbose=verbose) verbose=verbose)
...@@ -91,7 +91,7 @@ def compute_strains( ...@@ -91,7 +91,7 @@ def compute_strains(
farray_F0 = ref_mesh.GetCellData().GetArray(defo_grad_array_name) farray_F0 = ref_mesh.GetCellData().GetArray(defo_grad_array_name)
for k_frame in xrange(n_frames): for k_frame in xrange(n_frames):
mesh_filename = sol_folder+"/"+sol_basename+"_"+str(k_frame).zfill(sol_zfill)+"."+sol_ext mesh_filename = working_folder+"/"+working_basename+"_"+str(k_frame).zfill(working_zfill)+"."+working_ext
mesh = myvtk.readUGrid( mesh = myvtk.readUGrid(
filename=mesh_filename, filename=mesh_filename,
verbose=verbose) verbose=verbose)
...@@ -120,7 +120,7 @@ def compute_strains( ...@@ -120,7 +120,7 @@ def compute_strains(
verbose=verbose) verbose=verbose)
myvtk.writeUGrid( myvtk.writeUGrid(
ugrid=mesh, ugrid=mesh,
filename=sol_folder+"/"+sol_basename+"_"+str(k_frame).zfill(sol_zfill)+"."+sol_ext, filename=working_folder+"/"+working_basename+"_"+str(k_frame).zfill(working_zfill)+"."+working_ext,
verbose=verbose) verbose=verbose)
if (write_strains) or (write_strains_vs_radius) or (write_binned_strains_vs_radius): if (write_strains) or (write_strains_vs_radius) or (write_binned_strains_vs_radius):
...@@ -195,8 +195,8 @@ def compute_strains( ...@@ -195,8 +195,8 @@ def compute_strains(
if (plot_strains): if (plot_strains):
ddic.plot_strains( ddic.plot_strains(
working_folder=sol_folder, working_folder=working_folder,
working_basenames=[sol_basename], working_basenames=[working_basename],
suffix=None, suffix=None,
verbose=verbose) verbose=verbose)
......
...@@ -87,12 +87,22 @@ set xrange [0:'''+str(n_frames)+'''] ...@@ -87,12 +87,22 @@ set xrange [0:'''+str(n_frames)+''']
elif (comp_name == "radial-circumferential" ): k_comp = 3 elif (comp_name == "radial-circumferential" ): k_comp = 3
elif (comp_name == "radial-longitudinal" ): k_comp = 4 elif (comp_name == "radial-longitudinal" ): k_comp = 4
elif (comp_name == "circumferential-longitudinal"): k_comp = 5 elif (comp_name == "circumferential-longitudinal"): k_comp = 5
if (k_comp == 0):
plotfile.write('''\
set key bottom
''')
else:
plotfile.write('''\
set key top
''')
plotfile.write('''\ plotfile.write('''\
set ylabel "'''+comp_name+''' strain (%)" set ylabel "'''+comp_name+''' strain (%)"
''') ''')
if ("-" in comp_name): if ("-" in comp_name):
plotfile.write('''\ plotfile.write('''\
set yrange [-10:10] set yrange [-20:20]
''') ''')
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment