import math import re import os import os.path import types from nsim.setup import get_exec_path nsim_raw = get_exec_path("nsim-raw") netgen_bin = "netgen" nmeshpp_bin = "%s %s" % (nsim_raw, get_exec_path("nmeshpp")) nmeshimport_bin = "%s %s" % (nsim_raw, get_exec_path("nmeshimport")) def netgen_mesh_from_file(geo_filename, mesh_filename, mesh_type=None, keep_neu=False, keep_logs=False): """Run Netgen on the given GEO file (first arg) creating a mesh with the desired name (second arg). The function examines the extension of the mesh file name to understand what is the desired output. If the extension is 'neu', then a Neutral file is produced. If the extension is 'h5' or 'nmesh', then the neutral file created by Netgen is converted to the given format and it is removed. If 'keep_neu' is true, the intermediate neutral file is kept. If 'keep_logs' is true, the Netgen logs are kept, otherwise they are removed. If 'mesh_type' is provided, it specifies the type of the output format (and the extension of the mesh file is ingored).""" if mesh_type == None: mesh_type = os.path.splitext(mesh_filename)[1][1:] if mesh_type not in ["neu", "nmesh", "h5", "nmesh.h5"]: raise ValueError("Cannot determine mesh type from extension. " "Please specify the mesh type explicitly using " "the optional argument \"mesh_type\".")
import os from nsim.setup import get_exec_path import inspect netgen_bin = "netgen" nmeshpp_bin = "nmeshpp" nmeshimport_bin = "nmeshimport" nmeshpp_exec = get_exec_path(nmeshpp_bin) my_path = os.path.split(inspect.getfile(inspect.currentframe()))[0] suggested_meshinfo_file = os.path.join(my_path, "mesh.info") def netgen_mesh_from_file(geo_filename, mesh_filename, mesh_type=None, keep_neu=False, keep_logs=False): if mesh_type == None: mesh_type = os.path.splitext(mesh_filename)[1][1:] print mesh_type if mesh_type not in ["neu", "nmesh", "h5", "nmesh.h5"]: raise ValueError( "Cannot determine mesh type from extension. " "Please specify the mesh type explicitly using " 'the optional argument "mesh_type".' ) if mesh_type == "neu": tmp_filename = mesh_filename
import os from nsim.setup import get_exec_path import nmag nmeshmirror_exec = get_exec_path("nmeshmirror") #work out in which directory the data files are org_dir = os.getcwd() def test_nmeshmirror(): os.chdir(os.path.split(__file__)[0]) #define my non-periodic mesh points = [[0,0],[1,0],[0,1],[1,1]] simplices = [[0,2,3],[0,1,3]] regions=[1,1] import nmesh mesh = nmesh.mesh_from_points_and_simplices(points,simplices,regions,[],0,False) mesh.save('org.nmesh') import nmesh.visual nmesh.visual.plot2d_ps(mesh,'org.ps')
import math import re import os import os.path import types from nsim.setup import get_exec_path nsim_raw = get_exec_path("nsim-raw") netgen_bin = "netgen" nmeshpp_bin = "%s %s" % (nsim_raw, get_exec_path("nmeshpp")) nmeshimport_bin = "%s %s" % (nsim_raw, get_exec_path("nmeshimport")) def netgen_mesh_from_file(geo_filename, mesh_filename, mesh_type=None, keep_neu=False, keep_logs=False): """Run Netgen on the given GEO file (first arg) creating a mesh with the desired name (second arg). The function examines the extension of the mesh file name to understand what is the desired output. If the extension is 'neu', then a Neutral file is produced. If the extension is 'h5' or 'nmesh', then the neutral file created by Netgen is converted to the given format and it is removed. If 'keep_neu' is true, the intermediate neutral file is kept. If 'keep_logs' is true, the Netgen logs are kept, otherwise they are removed. If 'mesh_type' is provided, it specifies the type of the output format (and the extension of the mesh file is ingored).""" if mesh_type == None: mesh_type = os.path.splitext(mesh_filename)[1][1:]