Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 08e216b3 authored by PATTE Cecile's avatar PATTE Cecile
Browse files

Allow for reference mesh with PartId but no local basis in compute_strains

parent 2795d2d3
No related branches found
No related tags found
No related merge requests found
...@@ -27,9 +27,9 @@ def compute_strains( ...@@ -27,9 +27,9 @@ def compute_strains(
disp_array_name="displacement", disp_array_name="displacement",
defo_grad_array_name="DeformationGradient", defo_grad_array_name="DeformationGradient",
strain_array_name="Strain", strain_array_name="Strain",
mesh_w_local_basis_folder=None, ref_mesh_folder=None,
mesh_w_local_basis_basename=None, ref_mesh_basename=None,
mesh_w_local_basis_ext="vtk", ref_mesh_ext="vtk",
CYL_or_PPS="PPS", CYL_or_PPS="PPS",
write_strains=1, write_strains=1,
temporal_offset=None, temporal_offset=None,
...@@ -40,17 +40,17 @@ def compute_strains( ...@@ -40,17 +40,17 @@ def compute_strains(
write_binned_strains_vs_radius=0, write_binned_strains_vs_radius=0,
verbose=1): verbose=1):
if (mesh_w_local_basis_folder is not None) and (mesh_w_local_basis_basename is not None): if (ref_mesh_folder is not None) and (ref_mesh_basename is not None):
mesh_w_local_basis = myvtk.readUGrid( ref_mesh = myvtk.readUGrid(
filename=mesh_w_local_basis_folder+"/"+mesh_w_local_basis_basename+"."+mesh_w_local_basis_ext, filename=ref_mesh_folder+"/"+ref_mesh_basename+"."+ref_mesh_ext,
verbose=verbose) verbose=verbose)
mesh_w_local_basis_n_cells = mesh_w_local_basis.GetNumberOfCells() ref_mesh_n_cells = ref_mesh.GetNumberOfCells()
if (verbose): print "mesh_w_local_basis_n_cells = " + str(mesh_w_local_basis_n_cells) if (verbose): print "ref_mesh_n_cells = " + str(ref_mesh_n_cells)
if (mesh_w_local_basis.GetCellData().HasArray("sector_id")): if (ref_mesh.GetCellData().HasArray("sector_id")):
iarray_sector_id = mesh_w_local_basis.GetCellData().GetArray("sector_id") iarray_sector_id = ref_mesh.GetCellData().GetArray("sector_id")
n_sector_ids = 0 n_sector_ids = 0
for k_cell in xrange(mesh_w_local_basis_n_cells): for k_cell in xrange(ref_mesh_n_cells):
sector_id = int(iarray_sector_id.GetTuple1(k_cell)) sector_id = int(iarray_sector_id.GetTuple1(k_cell))
if (sector_id < 0): continue if (sector_id < 0): continue
if (sector_id > n_sector_ids-1): if (sector_id > n_sector_ids-1):
...@@ -59,7 +59,7 @@ def compute_strains( ...@@ -59,7 +59,7 @@ def compute_strains(
else: else:
n_sector_ids = 0 n_sector_ids = 0
else: else:
mesh_w_local_basis = None ref_mesh = None
n_sector_ids = 0 n_sector_ids = 0
working_filenames = glob.glob(working_folder+"/"+working_basename+"_[0-9]*."+working_ext) working_filenames = glob.glob(working_folder+"/"+working_basename+"_[0-9]*."+working_ext)
...@@ -102,10 +102,12 @@ def compute_strains( ...@@ -102,10 +102,12 @@ def compute_strains(
filename=mesh_filename, filename=mesh_filename,
verbose=verbose) verbose=verbose)
n_cells = mesh.GetNumberOfCells() n_cells = mesh.GetNumberOfCells()
if (mesh_w_local_basis is not None): if (ref_mesh is not None):
assert (n_cells == mesh_w_local_basis_n_cells), "mesh_w_local_basis_n_cells ("+str(mesh_w_local_basis_n_cells)+") ≠ n_cells ("+str(n_cells)+"). Aborting." assert (n_cells == ref_mesh_n_cells), "ref_mesh_n_cells ("+str(ref_mesh_n_cells)+") ≠ n_cells ("+str(n_cells)+"). Aborting."
mesh.GetCellData().AddArray(mesh_w_local_basis.GetCellData().GetArray("part_id")) if (ref_mesh.GetCellData().HasArray("part_id")):
mesh.GetCellData().AddArray(mesh_w_local_basis.GetCellData().GetArray("sector_id")) mesh.GetCellData().AddArray(ref_mesh.GetCellData().GetArray("part_id"))
if (ref_mesh.GetCellData().HasArray("sector_id")):
mesh.GetCellData().AddArray(ref_mesh.GetCellData().GetArray("sector_id"))
myvtk.addDeformationGradients( myvtk.addDeformationGradients(
mesh=mesh, mesh=mesh,
disp_array_name=disp_array_name, disp_array_name=disp_array_name,
...@@ -122,7 +124,7 @@ def compute_strains( ...@@ -122,7 +124,7 @@ def compute_strains(
mesh=mesh, mesh=mesh,
defo_grad_array_name=defo_grad_array_name, defo_grad_array_name=defo_grad_array_name,
strain_array_name=strain_array_name, strain_array_name=strain_array_name,
mesh_w_local_basis=mesh_w_local_basis, mesh_w_local_basis=ref_mesh,
verbose=verbose) verbose=verbose)
myvtk.writeUGrid( myvtk.writeUGrid(
ugrid=mesh, ugrid=mesh,
...@@ -130,8 +132,7 @@ def compute_strains( ...@@ -130,8 +132,7 @@ def compute_strains(
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):
if (mesh_w_local_basis is not None): if (ref_mesh is not None) and (mesh.GetCellData().HasArray(strain_array_name+"_"+CYL_or_PPS)):
assert (mesh.GetCellData().HasArray(strain_array_name+"_"+CYL_or_PPS))
farray_strain = mesh.GetCellData().GetArray(strain_array_name+"_"+CYL_or_PPS) farray_strain = mesh.GetCellData().GetArray(strain_array_name+"_"+CYL_or_PPS)
else: else:
farray_strain = mesh.GetCellData().GetArray(strain_array_name) farray_strain = mesh.GetCellData().GetArray(strain_array_name)
...@@ -171,16 +172,16 @@ def compute_strains( ...@@ -171,16 +172,16 @@ def compute_strains(
strain_file.write("\n") strain_file.write("\n")
if (write_strains_vs_radius): if (write_strains_vs_radius):
assert (mesh_w_local_basis.GetCellData().HasArray("rr")) assert (ref_mesh.GetCellData().HasArray("rr"))
farray_rr = mesh_w_local_basis.GetCellData().GetArray("rr") farray_rr = ref_mesh.GetCellData().GetArray("rr")
for k_cell in xrange(n_cells): for k_cell in xrange(n_cells):
strain_vs_radius_file.write(" ".join([str(val) for val in [k_frame, farray_rr.GetTuple1(k_cell)]+list(farray_strain.GetTuple(k_cell))]) + "\n") strain_vs_radius_file.write(" ".join([str(val) for val in [k_frame, farray_rr.GetTuple1(k_cell)]+list(farray_strain.GetTuple(k_cell))]) + "\n")
strain_vs_radius_file.write("\n") strain_vs_radius_file.write("\n")
strain_vs_radius_file.write("\n") strain_vs_radius_file.write("\n")
if (write_binned_strains_vs_radius): if (write_binned_strains_vs_radius):
assert (mesh_w_local_basis.GetCellData().HasArray("rr")) assert (ref_mesh.GetCellData().HasArray("rr"))
farray_rr = mesh_w_local_basis.GetCellData().GetArray("rr") farray_rr = ref_mesh.GetCellData().GetArray("rr")
n_r = 10 n_r = 10
binned_strains = [[] for k_r in xrange(n_r)] binned_strains = [[] for k_r in xrange(n_r)]
for k_cell in xrange(n_cells): for k_cell in xrange(n_cells):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment