示例#1
0
import gmsh
import petram.mesh.gmsh_mesh_wrapper
import petram.geom.geom_utils
reload(petram.geom.geom_utils)
reload(petram.mesh.gmsh_mesh_wrapper)
from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper

mw = GMSHMeshWrapper()
model1 = mw.load_brep('brep/box_circle.brep')
mw.add('cl', '5', 0.03)
#mw.add('freeedge', [7], resolution=15)
mw.add('freeedge', '2, 3', resolution=10)
mw.add('freeface', '1', resolution=5, maxsize=0.15)
mw.generate(finalize=True)
mw.save_mesh_all('tmp')
示例#2
0
    def build_mesh(self,
                   geom_root,
                   stop1=None,
                   stop2=None,
                   filename='',
                   nochild=False,
                   finalize=False,
                   gui_parent=None):
        import gmsh
        from petram.geom.read_gmsh import read_pts_groups, read_loops

        self.vt.preprocess_params(self)
        clmax, clmin = self.vt.make_value_or_expression(self)
        dprint1("calling build mesh with", clmax, clmin)
        geom_root = self.geom_root

        if not geom_root.is_finalized:
            geom_root.build_geom4(no_mesh=True, finalize=True)

        #else:
        #    geom = geom_root._gmsh4_data[-1]

        from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper as GmshMesher
        mesher = GmshMesher(format=2.2,
                            CharacteristicLengthMax=clmax,
                            CharacteristicLengthMin=clmin,
                            EdgeResolution=3,
                            MeshAlgorithm=self.algorithm,
                            MeshAlgorithm3D=self.algorithm3d,
                            use_profiler=self.use_profiler,
                            use_expert_mode=self.use_expert_mode,
                            gen_all_phys_entity=self.gen_all_phys_entity)

        #mesher.load_brep(geom_root._geom_brep)

        children = [x for x in self.walk()]
        children = children[1:]

        if not nochild:
            for child in children:
                if not child.enabled: continue
                if child is stop1: break  # for build before
                child.vt.preprocess_params(child)
                #child.check_master_slave(mesher)
                child.add_meshcommand(mesher)
                if child is stop2: break  # for build after

        if mesher.count_sequence() > 0:
            self._mesher_data = None  # set None since mesher may die...

            L = mesher.count_sequence() * 4 + 3

            if gui_parent is not None:
                import wx
                gui_parent = wx.GetApp().TopWindow
                pgb = wx.ProgressDialog("Generating mesh...",
                                        "",
                                        L,
                                        parent=gui_parent,
                                        style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE
                                        | wx.PD_CAN_ABORT)

                def close_dlg(evt, dlg=pgb):
                    pgb.Destroy()

                pgb.Bind(wx.EVT_CLOSE, close_dlg)
            else:
                pgb = None

            max_mdim, done, data, msh_output = mesher.run_generater(
                geom_root._geom_brep,
                filename,
                finalize=finalize,
                progressbar=pgb)
            if pgb is not None: pgb.Destroy()

            self._mesher_data = data
            self._max_mdim = max_mdim
            if finalize:
                self._msh_output = msh_output
            else:
                self._msh_output = ''
        else:
            self._max_mdim = 0
            done = [], [], [], []

        self._mesh_fface = done[2]  # finished surfaces
        self._mesh_fline = done[1]  # finished lines

        return (mesher.count_sequence() > 0)
示例#3
0
import gmsh
import petram.mesh.gmsh_mesh_wrapper
import petram.geom.geom_utils
reload(petram.geom.geom_utils)
reload(petram.mesh.gmsh_mesh_wrapper)
from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper

mw = GMSHMeshWrapper()
model1 = mw.load_brep('brep/box2.brep')
'''
mw.add('transfinite_edge', '7', nseg = 6)
mw.add('transfinite_edge', '3', nseg = 7, bump=0.2)
mw.add('transfinite_edge', '11', nseg = 7, progression=1.03)
mw.add('freeface', '4', resolution=8)
mw.add('extrude_face', '1', '4', '3', nlayers=10)
#mw.add('freevolume', '1', resolution=7)
mw.add('freevolume', '2', resolution=7)
'''
mw.add('freevolume', '2', resolution=7)
mw.add('extrude_face', '1', '5', '2', nlayers=10)

mw.generate(dim=3)  # finalize=True)
mw.save_mesh_all('tmp')
示例#4
0
import gmsh
import petram.mesh.gmsh_mesh_wrapper
import petram.geom.geom_utils
reload(petram.geom.geom_utils)
reload(petram.mesh.gmsh_mesh_wrapper)
from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper

mw = GMSHMeshWrapper()
model1 = mw.load_brep('brep/torus.brep')
mw.add('freeface', '2, 10', resolution=3)
#mw.add('copyface', '2, 10', '4, 11')
mw.add('revolve_face', '1, 2', '2, 10', '4, 11', nlayers=10)
#mw.add('revolve_face', '1', '2', '4', nlayers=10)
'''
mw.add('transfinite_edge', '7', nseg = 6)
mw.add('transfinite_edge', '3', nseg = 7, bump=0.2)
mw.add('transfinite_edge', '11', nseg = 7, progression=1.03)
mw.add('freeface', '4', resolution=8)
mw.add('extrude_face', '1', '4', '3', nlayers=10)
#mw.add('freevolume', '1', resolution=7)
mw.add('freevolume', '2', resolution=7)
'''
#mw.add('freevolume', 'remaining', resolution=7)
mw.generate(dim=2)  # finalize=True)
mw.save_mesh_all('tmp')
示例#5
0
import gmsh
import petram.mesh.gmsh_mesh_wrapper
import petram.geom.geom_utils
reload(petram.geom.geom_utils)
reload(petram.mesh.gmsh_mesh_wrapper)
from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper

mw = GMSHMeshWrapper()
model1 = mw.load_brep('brep/box2.brep')
#mw.add('cl', [2], 0.02)
#mw.add('freeedge', [7], resolution=15)
mw.add('freeface', '2', resolution=5)
mw.add('copyface', '2', '5')
mw.add('copyface', '2', '10')
mw.add('freeface', '11,3,8,6', resolution=20)
mw.add('freevolume', '1,2', resolution=10)
#mw.generate(dim = 3)# finalize=True)
ret = mw.run_generater(dim=3)  # finalize=True)
print(ret)
#mw.save_mesh_all('tmp')
示例#6
0
import gmsh
import petram.mesh.gmsh_mesh_wrapper
import petram.geom.geom_utils
reload(petram.geom.geom_utils)
reload(petram.mesh.gmsh_mesh_wrapper)
from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper

mw = GMSHMeshWrapper()
model1 = mw.load_brep('brep/torus2.brep')
#mw.add('transfinite_edge', '81', nseg = 7)
#mw.add('freeface', '17', resolution=3)
#mw.add('copyface', '17', '45')

mw.add('freeface', '8, 17', resolution=3)

mw.add('revolve_face', '2, 3', '8, 17', '10, 18', nlayers=10)
mw.add('revolve_face', '4, 6', '10, 18', '25, 40', nlayers=4)
mw.add('revolve_face', '5, 7', '25, 40', '33, 45', nlayers=10)
'''
#mw.add('freevolume', 'remaining', resolution=7)
#mw.add('freeface', '6', resolution=3)
'''
mw.add('freevolume', 'remaining', resolution=4)
mw.generate(dim=3, finalize=True)
mw.save_mesh_all('tmp')
示例#7
0
import gmsh
import petram.mesh.gmsh_mesh_wrapper 
import petram.geom.geom_utils
reload(petram.geom.geom_utils)
reload(petram.mesh.gmsh_mesh_wrapper)
from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper

mw = GMSHMeshWrapper()
model1 = mw.load_brep('brep/snake.brep') 
mw.add('transfinite_edge', '10', nseg = 20)
#print(gmsh.model.getEntities())
#gmsh.model.mesh.setTransfiniteCurve(10, 20)
#gmsh.model.mesh.generate(1)
#mw.add('freeface', '2, 10', resolution=3)
#mw.add('copyface', '2, 10', '4, 11')
#mw.add('revolve_face', '1, 2', '2, 10', '4, 11', nlayers=10)
#mw.add('revolve_face', '1', '2', '4', nlayers=10)
#mw.add('freevolume', 'remaining', resolution=7)
mw.generate(dim = 1)# finalize=True)
mw.save_mesh_all('tmp')


示例#8
0
import gmsh
import petram.mesh.gmsh_mesh_wrapper
import petram.geom.geom_utils
reload(petram.geom.geom_utils)
reload(petram.mesh.gmsh_mesh_wrapper)
from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper

mw = GMSHMeshWrapper()
model1 = mw.load_brep('brep/box2.brep')
#mw.add('cl', [2], 0.02)
mw.add('transfinite_edge', '7', nseg=5)
mw.add('transfinite_edge', '3', nseg=15, bump=0.2)
mw.add('transfinite_edge', '11', nseg=15, progression=1.03)
mw.add('freeface', '4', resolution=5)
#mw.add('freeface', '2', resolution=5)
mw.add('copyface', '4', '3')
#mw.add('copyface', '2', '10')
#mw.add('freeface', '1,3,4,6', resolution=15)
#mw.add('freeface', 'remaining', resolution=10)
#mw.add('freevolume', '1,2', resolution=10)
mw.generate(dim=3, finalize=True)
mw.save_mesh_all('tmp')
示例#9
0
import gmsh
import petram.mesh.gmsh_mesh_wrapper
import petram.geom.geom_utils
reload(petram.geom.geom_utils)
reload(petram.mesh.gmsh_mesh_wrapper)
from petram.mesh.gmsh_mesh_wrapper import GMSHMeshWrapper

mw = GMSHMeshWrapper()
model1 = mw.load_brep('brep/box2.brep')
#mw.add('cl', [2], 0.02)
mw.add('transfinite_edge', '1, 4', nseg=5)
mw.add('transfinite_edge', '2', nseg=15, bump=1)
mw.add('transfinite_edge', '3', nseg=15, bump=0.2)
#mw.add('transfinite_edge', '5', nseg = 15, progression=1.03)
mw.add('transfinite_face', '1', corner=[2, 1, 3, 4])
mw.add('recombine_face', '1')
#mw.add('transfinite_volume', '1')
#mw.add('freeface', '4', resolution=5)
#mw.add('freeface', '2', resolution=5)
#mw.add('extrude_face', '2', '5', '10')
#mw.add('copyface', '2', '10')
#mw.add('freeface', '1,3,4,6', resolution=15)
#mw.add('freeface', 'remaining', resolution=10)
#mw.add('freevolume', '1,2', resolution=10)
mw.generate(dim=2)
mw.save_mesh_all('tmp')