v0.14.0
Functions | Variables
convert Namespace Reference

Functions

def print_progress (iteration, total, decimals=1, bar_length=50)
 
def is_not_h5m (file)
 
def is_older_than_vtk (file)
 
def mb_convert (file)
 
def init (l)
 

Variables

 parser
 
 help
 
 nargs
 
 type
 
 int
 
 default
 
 SUPPRESS
 
 action
 
 args = parser.parse_args()
 
 file_list = list(filterfalse(is_not_h5m, args.file))
 
 N = mp.Value('i', len(file_list))
 
 n = mp.Value('i', 0)
 
 l = mp.Lock()
 
 pool = mp.Pool(processes=args.np, initializer=init, initargs=(l,))
 

Function Documentation

◆ init()

def convert.init (   l)

Definition at line 55 of file convert.py.

55 def init(l):
56  global lock
57  lock = l
58 

◆ is_not_h5m()

def convert.is_not_h5m (   file)

Definition at line 34 of file convert.py.

34 def is_not_h5m(file):
35  return not file.endswith('h5m')
36 

◆ is_older_than_vtk()

def convert.is_older_than_vtk (   file)

Definition at line 37 of file convert.py.

37 def is_older_than_vtk(file):
38  file_vtk = path.splitext(file)[0] + ".vtk"
39  if path.exists(file_vtk):
40  return path.getmtime(file) < path.getmtime(file_vtk)
41  return False
42 

◆ mb_convert()

def convert.mb_convert (   file)

Definition at line 43 of file convert.py.

43 def mb_convert(file):
44  file = path.splitext(file)[0]
45  p = subprocess.Popen(["mbconvert", file + ".h5m", file + ".vtk"],
46  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
47  (out, err) = p.communicate()
48  lock.acquire()
49  if p.returncode:
50  print('\n' + err.decode())
51  n.value += 1
52  print_progress(n.value, N.value)
53  lock.release()
54 

◆ print_progress()

def convert.print_progress (   iteration,
  total,
  decimals = 1,
  bar_length = 50 
)

Definition at line 24 of file convert.py.

24 def print_progress(iteration, total, decimals=1, bar_length=50):
25  str_format = "{0:." + str(decimals) + "f}"
26  percents = str_format.format(100 * (iteration / float(total)))
27  filled_length = int(round(bar_length * iteration / float(total)))
28  bar = '█' * filled_length + '-' * (bar_length - filled_length)
29 
30  sys.stdout.write('\r |%s| %s%s (%s of %s)' %
31  (bar, percents, '%', str(iteration), str(total)))
32  sys.stdout.flush()
33 

Variable Documentation

◆ action

convert.action

Definition at line 65 of file convert.py.

◆ args

convert.args = parser.parse_args()

Definition at line 66 of file convert.py.

◆ default

convert.default

Definition at line 64 of file convert.py.

◆ file_list

convert.file_list = list(filterfalse(is_not_h5m, args.file))

Definition at line 71 of file convert.py.

◆ help

convert.help

Definition at line 63 of file convert.py.

◆ int

convert.int

◆ l

convert.l = mp.Lock()

Definition at line 84 of file convert.py.

◆ N

convert.N = mp.Value('i', len(file_list))

Definition at line 81 of file convert.py.

◆ n

convert.n = mp.Value('i', 0)

◆ nargs

convert.nargs

Definition at line 63 of file convert.py.

◆ parser

convert.parser
Initial value:
1 = argparse.ArgumentParser(
2  description="Convert multiple h5m files to vtk files using the mbconvert tool (part of the MOAB library). The input files can be distributed between multiple processes to speed-up the conversion.")

Definition at line 60 of file convert.py.

◆ pool

convert.pool = mp.Pool(processes=args.np, initializer=init, initargs=(l,))

Definition at line 85 of file convert.py.

◆ SUPPRESS

convert.SUPPRESS

Definition at line 65 of file convert.py.

◆ type

convert.type
Examples
ADOLCPlasticityMaterialModels.hpp, analytical_poisson_field_split.cpp, approx_sphere.cpp, boundary_marker.cpp, child_and_parent.cpp, ContactOps.hpp, continuity_check_on_contact_prism_side_ele.cpp, continuity_check_on_skeleton_3d.cpp, continuity_check_on_skeleton_with_simple_2d_for_h1.cpp, continuity_check_on_skeleton_with_simple_2d_for_hcurl.cpp, continuity_check_on_skeleton_with_simple_2d_for_hdiv.cpp, dg_projection.cpp, dynamic_first_order_con_law.cpp, eigen_elastic.cpp, ElasticityMixedFormulation.hpp, EshelbianOperators.cpp, EshelbianPlasticity.cpp, field_evaluator.cpp, forces_and_sources_testing_edge_element.cpp, forces_and_sources_testing_flat_prism_element.cpp, forces_and_sources_testing_users_base.cpp, free_surface.cpp, hanging_node_approx.cpp, hcurl_check_approx_in_2d.cpp, hcurl_curl_operator.cpp, hcurl_divergence_operator_2d.cpp, hdiv_divergence_operator.cpp, heat_method.cpp, hello_world.cpp, higher_derivatives.cpp, HookeElement.cpp, HookeElement.hpp, HookeInternalStressElement.hpp, level_set.cpp, lorentz_force.cpp, mesh_smoothing.cpp, meshset_to_vtk.cpp, mixed_poisson.cpp, mortar_contact_thermal.cpp, NavierStokesElement.cpp, NavierStokesElement.hpp, NonlinearElasticElementInterface.hpp, phase.cpp, photon_diffusion.cpp, plastic.cpp, PlasticOps.hpp, PlasticOpsGeneric.hpp, plate.cpp, poisson_2d_dis_galerkin.cpp, PoissonDiscontinousGalerkin.hpp, prism_elements_from_surface.cpp, prism_polynomial_approximation.cpp, quad_polynomial_approximation.cpp, reaction_diffusion.cpp, Remodeling.cpp, Remodeling.hpp, scalar_check_approximation.cpp, seepage.cpp, simple_contact_thermal.cpp, simple_elasticity.cpp, simple_interface.cpp, simple_l2_only.cpp, SmallStrainPlasticity.hpp, test_cache_on_entities.cpp, thermo_elastic.cpp, ThermoElasticOps.hpp, and UnsaturatedFlow.hpp.

Definition at line 64 of file convert.py.

convert.mb_convert
def mb_convert(file)
Definition: convert.py:43
convert.is_not_h5m
def is_not_h5m(file)
Definition: convert.py:34
convert.is_older_than_vtk
def is_older_than_vtk(file)
Definition: convert.py:37
convert.int
int
Definition: convert.py:64
convert.print_progress
def print_progress(iteration, total, decimals=1, bar_length=50)
Definition: convert.py:24
convert.init
def init(l)
Definition: convert.py:55