nschloe / meshio

:spider_web: input/output for many mesh formats
MIT License
1.93k stars 399 forks source link

GRDECL reader #675

Open keurfonluu opened 4 years ago

keurfonluu commented 4 years ago

So, I've been hesitating to add partial support for the GRDECL format (which is widely used in oil and gas). The reason is that we can only implement the reader since the format is some kind of structured grid. Some kind because each cell is represented by an independent hexahedron which means that the number of nodes in the file is eight times the number of cells.

It reproduces complex geological structures by vertically collapsing the pillars of the hexahedra so we usually end up with non-conformal meshes that may contain zero-volume cells or cells with non flat quad faces (so impossible to calculate normal vectors).

However, I still think it might be useful to be able to convert it to VTK, for instance, so that users can visualize it on ParaView.

What do you think?

nschloe commented 4 years ago

I'd love to reader and writer for this. I think there is some motivation of handling structured meshes properly, see #404. Perhaps this is a good time to start things off.

I'm imagining storing the info in the Mesh object, and if that is passed to a writer, there should be a conversion function that creates the usual points, cells while spitting out a warning.

keurfonluu commented 4 years ago

Yeah, I also think it is time to add support for structured meshes. As far as I know, structured grids are defined by a shape tuple (NX, NY) in 2D and (NX, NY, NZ) in 3D.

However, as I said, GRDECL meshes are not conventional structured grids. ParaView seems to call this kind of mesh as explicit structured grids. All classic structured meshes can be converted to an explicit structured grid, but not the opposite (and everything can be converted to unstructured).

from / to STRUCTURED EXPLICIT STRUCTURED UNSTRUCTURED
STRUCTURED
EXPLICIT STRUCTURED
UNSTRUCTURED

We could add an attribute to meshio.Mesh that stores a (named)tuple that contains the type and shape of the mesh such as:

nschloe commented 4 years ago

The names are cool. I'd vote for attributes type and structure_shape or shape. All downstream conversion functions can go into the mesh object itself. Do you want to start something? I'm feeling quite lenient about merging rn. Might change later. :cat:

keurfonluu commented 4 years ago

The names are cool. I'd vote for attributes type and structure_shape or shape. All downstream conversion functions can go into the mesh object itself. Do you want to start something? I'm feeling quite lenient about merging rn. Might change later. 🐱

I'll try to come up with something but need to think about how to efficiently store the data. Mostly because cells are usually not defined for structured grids (since we know how to reconstruct the grid from the shape and points). Or we still create cells and then reverse engineer cells when writing a structured grid?

nschloe commented 4 years ago

because cells are usually not defined for structured grids

I'd be fine with a Mesh that doesn't have cells or points at all, just the info provided from the file. Or, perhaps, since this such a different beast, we should open up a whole new class, StructuredMesh.

reverse engineer

Nah. If an unstructured mesh can always be created from a structured one, we should provide for that, but no heuristics in meshio please.