def execute( the_smesh_mesh, the_foam_time ): """ This function defines procedure like Python API for this utility """ import os, os.path import tempfile a_tmp_file = tempfile.NamedTemporaryFile() a_tmp_file_name = a_tmp_file.name the_smesh_mesh.ExportUNV( a_tmp_file_name ) import unv2foam from Foam.OpenFOAM import fileName return unv2foam.engine( fileName( a_tmp_file_name), the_foam_time )
import os from Foam import FOAM_VERSION argv = None if FOAM_VERSION( "<", "010500" ) : a_dir = os.path.join( os.environ[ "HYBRIDFLU_ROOT_DIR" ], 'hybridFlu', 'examples' ) argv = [ __file__, a_dir, 'case_unv2foam' ] else: a_dir = os.path.join( os.environ[ "HYBRIDFLU_ROOT_DIR" ], 'hybridFlu', 'examples', 'case_unv2foam' ) argv = [ __file__, '-case', a_dir ] pass args = ref.setRootCase( len( argv ), argv ) runTime = man.createTime( args ) a_path = str( runTime.path() ) a_root_dir, a_case = os.path.split( a_path ) an_unv_file_name = os.path.join( a_path, "mesh" + os.path.extsep + "unv" ) import unv2foam a_fvMesh = unv2foam.engine( ref.fileName( an_unv_file_name ), runTime ) print "OK" os._exit( os.EX_OK ) pass #--------------------------------------------------------------------------------------