def initialize_library(logmsg=None): import os import ocaml if logmsg == None: logmsg = lambda msg: None def logmsg(msg): print msg logmsg("Initialisation of HLib: looking for the library DLL...") pythonpath = os.getenv('PYTHONPATH') if pythonpath == None: logmsg("PYTHONPATH is not defined: Failure!") return False logmsg("PYTHONPATH is '%s'" % pythonpath) search_paths = pythonpath.split(':') for path in search_paths: logmsg("Searching inside '%s'" % path) if os.path.isdir(path): candidate = \ os.path.join(path, 'extra', 'lib', 'libhmatrix-1.3.so') if os.path.isfile(candidate): logmsg("Found a candidate '%s'" % candidate) try: ocaml.init_hlib(candidate) except: return False return True else: logmsg("'%s' is not there!" % candidate) return False
# This example demonstrates periodic exchange. import os, time, sys, math import nmesh import ocaml import nfem, nfem.visual execfile("../../interface/nsim/linalg_machine.py") #ocaml.init_hlib("/home/fangohr/build/HLib-1.3/Library/.libs/libhmatrix-1.3.so") ocaml.init_hlib("/home/tf/HLib-1.3/Library/.libs/libhmatrix-1.3.so") #raw_mesh=ocaml.mesh_readfile("periodic/periodic.nmesh",False) mesh = nmesh.load_ascii("periodic/periodic-1d-2.nmesh") raw_mesh = mesh.raw_mesh print "MESH: ", raw_mesh sys.stdout.flush() if ocaml.petsc_is_mpi(): print "*** PARALLEL EXECUTION *** (not yet supported here!)" sys.exit(0) # DDD add parallel support! elem_phi = ocaml.make_element("phi", [], 1, 1) # scalar element mwe_phi = ocaml.make_mwe("phi", raw_mesh, [(0, ocaml.empty_element), (1, elem_phi)], []) mwe_dphi_dt = ocaml.mwe_sibling(mwe_phi, "dphi_dt", "dphi_dt/phi", [("phi", "dphi_dt")]) mwe_laplace_phi = ocaml.mwe_sibling(mwe_phi, "laplace_phi", "laplace_phi/phi", [("phi", "laplace_phi")])
# This example demonstrates periodic exchange. import os, time, sys, math import nmesh import ocaml import nfem, nfem.visual execfile("../../interface/nsim/linalg_machine.py") # ocaml.init_hlib("/home/fangohr/build/HLib-1.3/Library/.libs/libhmatrix-1.3.so") ocaml.init_hlib("/home/tf/HLib-1.3/Library/.libs/libhmatrix-1.3.so") # raw_mesh=ocaml.mesh_readfile("periodic/periodic.nmesh",False) mesh = nmesh.load_ascii("periodic/periodic-1d-2.nmesh") raw_mesh = mesh.raw_mesh print "MESH: ", raw_mesh sys.stdout.flush() if ocaml.petsc_is_mpi(): print "*** PARALLEL EXECUTION *** (not yet supported here!)" sys.exit(0) # DDD add parallel support! elem_phi = ocaml.make_element("phi", [], 1, 1) # scalar element mwe_phi = ocaml.make_mwe("phi", raw_mesh, [(0, ocaml.empty_element), (1, elem_phi)], []) mwe_dphi_dt = ocaml.mwe_sibling(mwe_phi, "dphi_dt", "dphi_dt/phi", [("phi", "dphi_dt")]) mwe_laplace_phi = ocaml.mwe_sibling(mwe_phi, "laplace_phi", "laplace_phi/phi", [("phi", "laplace_phi")]) def fun_phi0(dof_name, dof_pos):