Giter VIP home page Giter VIP logo

Comments (7)

mrambausek avatar mrambausek commented on May 17, 2024 1

Yeah, the xdmf works (tried with FEniCS 2017.1.0), thanks for pointing out!.
Below I nevertheless provide the MWE which fails:


import pygmsh as pg
import meshio

geom = pg.Geometry()

P_00 = geom.add_point([0.0, 0.0, 0.0], 1)
P_01 = geom.add_point([1.0, 0.0, 0.0], 1)
P_02 = geom.add_point([1.0, 1.0, 0.0], 1)
P_03 = geom.add_point([0.0, 1.0, 0.0], 1)

line_0 = geom.add_line(P_00, P_01)
line_1 = geom.add_line(P_00, P_02)
line_2 = geom.add_line(P_00, P_03)
line_3 = geom.add_line(P_01, P_02)
line_4 = geom.add_line(P_02, P_03)

ll_01 = geom.add_line_loop([line_0, line_3, -line_1])
ll_02 = geom.add_line_loop([line_1, line_4, -line_2])

s_01 = geom.add_plane_surface(ll_01)
s_02 = geom.add_plane_surface(ll_02)
p_01 = geom.add_physical_surface(s_01)
p_02 = geom.add_physical_surface(s_02)

points, cells, point_data, cell_data, field_data =    pg.generate_mesh(geom, num_quad_lloyd_steps=0, num_lloyd_steps=0)

meshio.write('mwe.xml', points, cells, cell_data=cell_data)

from dolfin import *

try:
    mesh = Mesh("mwe.xml")
    subdomains = MeshFunction("int", mesh, "mwe_physical.xml")
    dx = dx(domain=mesh, subdomain_data=subdomains)
    print(assemble(1*dx))
except Exception as e:
    print("EXCEPTION OCCURRED:")
    print(e)


try:
    mesh = Mesh("mwe.xml")
    subdomains = MeshFunction("size_t", mesh, "mwe_physical.xml")
    dx = dx(domain=mesh, subdomain_data=subdomains)
    print(assemble(1*dx))
except Exception as e:
    print("EXCEPTION OCCURRED:")
    print(e)

from meshio.

nschloe avatar nschloe commented on May 17, 2024

Absolutely.

from meshio.

nschloe avatar nschloe commented on May 17, 2024

FYI, meshio now supports cell data for the legacy Dolfin format (i.e., *_physical_region.xml and friends).

from meshio.

mrambausek avatar mrambausek commented on May 17, 2024

Great tool, thanks, in particular in combination with pygmsh!

Just installed via pip and came across an issue here:
These *_physical.xml files contain a mesh function of type "int",
whereas "size_t" seems to be required for a MeshFunction representing subdomains.
The type error occurs when calling assemble(...), at least in fenics/dolfin version 2016.2.0

from meshio.

nschloe avatar nschloe commented on May 17, 2024

@mrambausek Hm, tough. As a workaround, you could use XDMF meshes -- that's Dolfin's default now anyways.

from meshio.

nschloe avatar nschloe commented on May 17, 2024

@mrambausek I've seen meshes in the wild type="uint" now which appear to work, so size_t is probably not the only appropriate type. Anyways, without an MWE I cannot reproduce the problem.

from meshio.

nschloe avatar nschloe commented on May 17, 2024

@mrambausek Thanks for the MWE!

This seems to be more of a Dolfin issue, really. If it absolutely needs uint cell_data, you can convert the arrays with astype,

cell_data['triangle']['geometrical'] = \
    cell_data['triangle']['geometrical'].astype(numpy.dtype('uint'))
cell_data['triangle']['physical'] = \
    cell_data['triangle']['physical'].astype(numpy.dtype('uint'))

Then again, using XDMF fixes all issues anyways.

from meshio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.