Problem with GMSH

Hello FEniCS family,
Problem in generating a msh file (fenics 19):

File “/Users/mac/Projects/PCMFlow/Domain.py”, line 38, in channelMesh
lg = geometry.add_line_loop(lines)

AttributeError: ‘Geometry’ object has no attribute ‘add_line_loop’

See the following code :
#!/usr/bin/env python3

-- coding: utf-8 --

“”"
Created on Thu Jun 1 11:32:51 2023

@author: mac
“”"

from dolfin import *
from fenics import *
import pygmsh
#from fipy import CellVariable, Gmsh2D
import pyvista
import meshio
inflow = 1
outflow = 2
walls = 3
obstacle = 4

x = 5
y = 0.5
c_x = 0.3
c_y = 0.4
r_x = 0.04
d = 0.2

def channelMesh(res=0.03):
lcar=res
llcar=5*res
with pygmsh.geo.Geometry() as geometry:
points = [geometry.add_point((0, 0, 0),lcar),
geometry.add_point((x, 0, 0),llcar),
geometry.add_point((x, y, 0),llcar),
geometry.add_point((0, y, 0),lcar)]
lines = [geometry.add_line(points[i], points[i+1])
for i in range(len(points)-1)]
lines.append(geometry.add_line(points[-1], points[0]))
lg = geometry.add_line_loop(lines)
sf = geometry.add_plane_surface(lg)
outflow_list = [lines[1]]
flow_list = [lines[-1]]
wall_list = [lines[0], lines[2]]

    geometry.add_physical_surface(sf,label=12)
    geometry.add_physical_line(flow_list, label=inflow)
    geometry.add_physical_line(outflow_list, label=outflow)
    geometry.add_physical_line(wall_list, label=walls)

    (points, cells, point_data,
     cell_data, field_data) = geometry.generate_mesh()
                                            
meshio.write("meshFile.xdmf", meshio.Mesh(
    points=points, cells={"triangle": cells["triangle"]}))

meshio.write("MeshFile.xdmf", meshio.Mesh(
    points=points, cells={"line": cells["line"]},
    cell_data={"line": {"name_to_read":
                        cell_data["line"]["gmsh:physical"]}}))

if name==“main”:

channelMesh(0.03)

Any help is greatly appreciated!

This is a pygmsh question, not fenics related, and is better directed at the pygmsh developers

My first guess is that add_line_loop has been replaced with add_curve_loop in newer pygmsh releases.

1 Like