Skip to content
Snippets Groups Projects
Select Git revision
  • fcecb101c342200368734ba25499b15bffcf4b34
  • master default protected
  • dof-renumbering
  • test-dof-hash
  • gdemesy-master-patch-30528
  • eval-space-time
  • oscillating_multiharm
  • MH_movement
  • axisqu
  • write_vtu_and_ensight_formats
  • movingband
  • CP_1972_add_vtu_file_writing
  • mortar
  • fast_freq_sweep_Resolution
  • applyresolvent_again
  • marteaua-master-patch-54323
  • patch-1
  • binde-master-patch-08072
  • binde-master-patch-52461
  • BCGSL
  • resolvent
  • getdp_3_5_0
  • getdp_3_4_0
  • getdp_3_3_0
  • getdp_3_2_0
  • getdp_3_1_0
  • getdp_3_0_4
  • getdp_3_0_3
  • getdp_3_0_2
  • getdp_3_0_1
  • getdp_3_0_0
  • onelab_mobile_2.1.0
  • getdp_2_11_3 protected
  • getdp_2_11_2 protected
  • getdp_2_11_1 protected
  • getdp_2_11_0 protected
  • getdp_2_10_0 protected
  • getdp_2_9_2 protected
  • getdp_2_9_1 protected
  • getdp_2_9_0 protected
  • getdp_2_8_0 protected
41 results

Get_Geometry.cpp

Blame
  • aneurysm.py 2.20 KiB
    import gmsh
    import sys
    import os
    import math
    
    gmsh.initialize(sys.argv)
    
    # merge STL, create surface patches that are reparametrizable (so we can remesh
    # them) and compute the parametrizations
    path = os.path.dirname(os.path.abspath(__file__))
    gmsh.merge(os.path.join(path, 'aneurysm_data.stl'))
    gmsh.model.mesh.classifySurfaces(math.pi, True, True)
    gmsh.model.mesh.createGeometry()
    
    extrude = True
    #extrude = False
    
    if extrude:
        # make extrusions only return "top" surfaces and volumes, not lateral
        # surfaces
        gmsh.option.setNumber('Geometry.ExtrudeReturnLateralEntities', 0)
    
        # extrude a boundary layer of 4 elements using mesh normals (thickness =
        # 0.5)
        e1 = gmsh.model.geo.extrudeBoundaryLayer(gmsh.model.getEntities(2),
                                                 [4], [0.5], True)
    
        # extrude a second boundary layer in the opposite direction (note the
        # `second == True' argument to distinguish it from the first one)
        e2 = gmsh.model.geo.extrudeBoundaryLayer(gmsh.model.getEntities(2), [4], [-0.5],
                                                 True, True)
    
        # get "top" surfaces created by extrusion
        top_ent = [s for s in e2 if s[0] == 2]
        top_surf = [s[1] for s in top_ent]
    
        # get boundary of top surfaces, i.e. boundaries of holes
        gmsh.model.geo.synchronize()
        bnd_ent = gmsh.model.getBoundary(top_ent)
        bnd_curv = [c[1] for c in bnd_ent]
    
        # create plane surfaces filling the holes
        loops = gmsh.model.geo.addCurveLoops(bnd_curv)
        bnd_surf = []
        for l in loops:
            bnd_surf.append(gmsh.model.geo.addPlaneSurface([l]))
    
        # create the inner volume
        vf = gmsh.model.geo.addVolume([gmsh.model.geo.addSurfaceLoop(top_surf + bnd_surf)])
        gmsh.model.geo.synchronize()
    
        gmsh.model.addPhysicalGroup(3, [v[1] for v in e1 if v[0] == 3], name="solid")
        gmsh.model.addPhysicalGroup(3, [v[1] for v in e2 if v[0] == 3], name="fluid bl")
        gmsh.model.addPhysicalGroup(3, [vf], name="fluid")
    
        # to do: identify useful boundaries
    
    # use MeshAdapt for the resulting not-so-smooth parametrizations
    gmsh.option.setNumber('Mesh.Algorithm', 1)
    gmsh.option.setNumber('Mesh.MeshSizeFactor', 0.1)
    
    if '-nopopup' not in sys.argv:
        gmsh.fltk.run()
    
    gmsh.finalize()