Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of "periodic line" from gmsh in pygmsh #193

Closed
chrissHugo opened this issue May 31, 2018 · 1 comment
Closed

Use of "periodic line" from gmsh in pygmsh #193

chrissHugo opened this issue May 31, 2018 · 1 comment

Comments

@chrissHugo
Copy link

chrissHugo commented May 31, 2018

Dear sirs,

I just hopped into gmsh and pygmsh. I try to enforce a periodic boundary condition on a 2D mesh (a square, constructed by 4 line elements).
The attached py-file combines the "raw code"-command from pygmsh with the "periodic line" command from gmsh. I got the error message:

'Unknown environment \'{}\'.'.format(environ)
 AssertionError: Unknown environment 'Periodic'.

I generated a quite similar geo file which I can mesh in gmsh directly without any Trouble.

Do you have any idea?

import pygmsh
import numpy as np
import meshio


geom = pygmsh.built_in.Geometry()

point_list = []

lcar = 0.1
p0 = geom.add_point([0.0, 0.0, 0.0], lcar)
p1 = geom.add_point([1.0, 0.0, 0.0], lcar)
p2 = geom.add_point([1.0, 1.0, 0.0], lcar)
p3 = geom.add_point([0.0, 1.0, 0.0], lcar)
# p4 = geom.add_point([1.0, 1.0, 0.0], lcar)

l0 = geom.add_line(p0, p1)
l1 = geom.add_line(p1, p2)
l2 = geom.add_line(p2, p3)
l3 = geom.add_line(p3, p0)
# l4 = geom.add_line(p4, p0)

ll = geom.add_line_loop([l0, l1, l2, l3])

surf = geom.add_plane_surface(ll)

geom.add_raw_code("Periodic Line {{ {0} }} = {{ {1} }};".format(l0.id, l2.id))

points, cells, point_data, cell_data, field_data = pygmsh.generate_mesh(geom)

meshio.write("test.msh", points, cells, cell_data=cell_data)
@nschloe
Copy link
Owner

nschloe commented Apr 1, 2019

This has been fixed in the meantime. Try

import pygmsh
import meshio

geom = pygmsh.built_in.Geometry()

point_list = []

lcar = 0.1
p0 = geom.add_point([0.0, 0.0, 0.0], lcar)
p1 = geom.add_point([1.0, 0.0, 0.0], lcar)
p2 = geom.add_point([1.0, 1.0, 0.0], lcar)
p3 = geom.add_point([0.0, 1.0, 0.0], lcar)
# p4 = geom.add_point([1.0, 1.0, 0.0], lcar)

l0 = geom.add_line(p0, p1)
l1 = geom.add_line(p1, p2)
l2 = geom.add_line(p2, p3)
l3 = geom.add_line(p3, p0)
# l4 = geom.add_line(p4, p0)

ll = geom.add_line_loop([l0, l1, l2, l3])

surf = geom.add_plane_surface(ll)

geom.add_raw_code("Periodic Curve {{{}}} = {{{}}};".format(l0.id, l2.id))

points, cells, point_data, cell_data, field_data = pygmsh.generate_mesh(geom, geo_filename="out.geo")

meshio.write_points_cells("test.msh", points, cells, cell_data=cell_data)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants