nschloe/pygmsh

Raw code alternative for periodic curve

dthillaithevan opened this issue · 0 comments

Hi,

I am trying to generate a 2D mesh with periodic nodes on opposite faces. Looking at past discussions (#193) it seems add_raw_code with Periodic Curve was used, however since this has been depreciated is there a new alternative method ensure periodicity constraints in pygmsh?

I've included a simple test case on a squre domain below.

import pygmsh
import gmsh
import meshio

verts = [[0,0], [0,1], [1,1],[1,0]]
lcar = 0.1
with pygmsh.geo.Geometry() as geom:
    p1 = geom.add_point(verts[0], lcar/2)
    p2 = geom.add_point(verts[1], lcar/2)
    p3 = geom.add_point(verts[2], lcar)
    p4 = geom.add_point(verts[3], lcar)
  
    l1 = geom.add_line(p1, p2)
    l2 = geom.add_line(p2, p3)
    l3 = geom.add_line(p3, p4)
    l4 = geom.add_line(p4, p1)
    
    ll = geom.add_curve_loop([l1, l2, l3, l4])
    pl = geom.add_plane_surface(ll)
    
    # Raw code no longer supported
    # geom.add_raw_code("Periodic Curve {{{}}} = {{{}}};".format(l1.id, l3.id))
    
    # I thought setPeriodic might be used but does not seem to work either
    # translation = [1, 0, 0, 1,
                   # 0, 1, 0, 0,
                   # 0, 0, 1, 0,
                   # 0, 0, 0, 1]
    # gmsh.model.mesh.setPeriodic(0, [l3.dim_tag[1]], [l1.dim_tag[1]], translation)
    
    mesh = geom.generate_mesh(2)

Many thanks,
D