def createFvMesh(runTime): # Read temporary mesh from file - done only so we can get the list of points, faces and cells tmpMesh = man.fvMesh( man.IOobject( ref.word("tmp"), runTime.caseConstant(), runTime, ref.IOobject.NO_READ, ref.IOobject.NO_WRITE ) ) # Get points, faces & Cells - SFOAM implementation should populate these lists from Salome mesh points = tmpMesh.points() faces = tmpMesh.faces() cells = tmpMesh.cells() # Now create the mesh - Nothing read from file, although fvSchemes and fvSolution created above must be present # It is necessary to store tmpMesh, because fvMesh::points(), faces(), and cells() return const T& # and fvMesh in next line will be broken, after exiting from this function (tmpMesh are deleted) mesh = man.fvMesh( ref.fvMesh( ref.IOobject( ref.word("region0"), runTime.caseConstant(), runTime, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), points, faces, cells ), man.Deps( tmpMesh ) ) # Create boundary patches patches = ref.polyPatchListPtr( 4, ref.polyPatch.nullPtr() ) patches.set(0, ref.polyPatch.New( ref.word("patch"), ref.word("inlet_F"), 606, 102308, 0, mesh.boundaryMesh() ) ) patches.set(1, ref.polyPatch.New( ref.word("patch"), ref.word("outlet_F1"), 818, 102914, 1, mesh.boundaryMesh() ) ) patches.set(2, ref.polyPatch.New( ref.word("patch"), ref.word("outlet_F2"), 522, 103732, 2, mesh.boundaryMesh() ) ) patches.set(3, ref.polyPatch.New( ref.word("wall"), ref.word("pipe"), 5842, 104254, 3, mesh.boundaryMesh() ) ) mesh.addFvPatches(patches) return mesh, patches
def _createFvMesh( self ) : """ Creates fvMesh """ # Connect to SALOME import hybridFlu.pysalome import salome aStudyId = salome.myStudy._get_StudyId() # Generation of the mesh from hybridFlu.examples import test_create_smesh [ aMesh, GroupList ] = test_create_smesh.createMesh() # Restoring values for the "root" and OpenFOAM "case" directories import os, os.path a_path = str( self.run_time.path() ) a_root_dir, a_case = os.path.split( a_path ) print_d( "a_root_dir = \"%s\"" % a_root_dir ) print_d( "a_case = \"%s\"" % a_case ) import tempfile a_tmp_file = tempfile.NamedTemporaryFile() an_unv_file_name = a_tmp_file.name aMesh.ExportUNV( an_unv_file_name ) if os.environ[ "WM_PROJECT_VERSION" ] < "1.5" : os.system( "unv2foam %s %s %s" %( a_root_dir, a_case, an_unv_file_name )) pass else : os.system( "unv2foam %s -case %s" %( an_unv_file_name, a_path )) pass a_fvMesh = ref.fvMesh( ref.IOobject( ref.word( "" ), self.run_time.caseConstant(), self.run_time, ref.IOobject.MUST_READ, ref.IOobject.NO_WRITE ) ) return a_fvMesh, None