Skip to content

Incompatibility with dolfinx.mesh.geometry: cmap is now a method #116

@il1yasvie1

Description

@il1yasvie1

Hi! I'm new to the fenicsx and ngspetsc, so I'm not sure if this is a bug or something wrong with my implementation.

The minimum working example is:

########################################
from netgen.csg import OrthoBrick, Pnt, CSGeometry
from mpi4py import MPI
import ngsPETSc.utils.fenicsx as ngfx

cube = OrthoBrick(Pnt(0,0,0), Pnt(1,1,1))
geo = CSGeometry()
geo.Add(cube)

geoModel = ngfx.GeometricModel(geo, MPI.COMM_WORLD)
domain, (ct, ft), region_map = geoModel.model_to_mesh(gdim=3, hmax=0.5)
########################################

When I run this, I get:

Traceback (most recent call last):
File "***.py", line 10, in
domain, (ct, ft), region_map = geoModel.model_to_mesh(gdim=3, hmax=0.5)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../ngsPETSc/utils/fenicsx.py", line 136, in model_to_mesh
ct, ft = self.extract_linear_mesh(gdim=gdim, partitioner=partitioner)
File ".../ngsPETSc/utils/fenicsx.py", line 302, in extract_linear_mesh
ct = extract_element_tags(self.comm_rank, ngmesh, mesh, dim=mesh.topology.dim)
File ".../ngsPETSc/utils/fenicsx.py", line 668, in extract_element_tags
assert dolfinx_mesh.geometry.cmap.degree == 1, (
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute 'degree'

The code worked with an older version of dolfinx. I think this is caused by a change in the definition of cmap.

In my old version it was a property:

@Property
def cmap(self) -> _CoordinateElement:
"""Element that describes the geometry map."""
return _CoordinateElement(self._cpp_object.cmap)

But now it is a method:

def cmap(self, i=None) -> _CoordinateElement:
"""Element that describes the ith geometry map."""
return _CoordinateElement(self._cpp_object.cmap(i))

See (FEniCS/dolfinx@e2e69ab)

I believe the possible fix is to replace .cmap.degree with .cmap().degree in ngsPETSc/utils/fenicsx.py (at least for lines 668).

Thank you for this very useful package!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions