Comments (7)
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.
Absolutely.
from meshio.
FYI, meshio now supports cell data for the legacy Dolfin format (i.e., *_physical_region.xml
and friends).
from meshio.
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.
@mrambausek Hm, tough. As a workaround, you could use XDMF meshes -- that's Dolfin's default now anyways.
from meshio.
@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.
@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)
- [BUG] `AssertionError` sometimes raised in Nastran float -> string conversion HOT 1
- [BUG] Error when writing SU2 boundary data
- hexahedron20. Incorrect convertation into vtu file HOT 1
- [BUG] Numpy min. version is not respected by `pip` and `conda`.
- Error when install meshio plugin for paraview,need help! HOT 2
- [BUG] Exodus File containing lower dimensional block fails - KeyError: 'TRUSS' HOT 1
- Having trouble with saving file as in-memory buffer
- [BUG] meshio CLI fails to read Abaqus .inp file HOT 2
- [BUG] Xdmf TimeSeriesWriter h5 location
- [BUG] Writing STL to buffer fails
- [BUG] Reading VTU only gets last piece
- Storing a scalar property of the whole grid in a VTK file HOT 1
- [REQUEST] WRL file convert
- [BUG] meshio command not being detected after installation? HOT 1
- [BUG] package broken in numpy==2
- [BUG] mehsio does not write faces coordinates
- Does not parse all parts for .inp files
- [BUG] VTK CELL_DATA is not written in correct format
- Saving more than one point_data using TimeSeries HOT 1
- [BUG] crash when writing xdmf file with "line" cells
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meshio.