-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unification of point / cell sets among formats #619
Comments
I think the answer to this is pretty much negative without a lot of cleverness? I envisage internally a Union of two representations, one isomorphic to MEDIT or MSH2, the other fulfilling #290. Conversion between the two, imperfect, as discussed previously, but independent of format as far as possible. |
Maybe I need a quick catch up here, but what are the reasons why we can not represent sets in MSH4 by mesh.point_sets = {
"Red": [1, 2, 4],
"Green": [3],
}
mesh.cell_sets = {
"Orange": {"line": [0, 2], "quad": [1, 10, 11]},
"Blue": {"line": [1, 4]},
} |
None, I think, except historical. This looks better, a better reflection of the Gmsh MSH4.1 intent, capable of fixing the outstanding issues. I think you're on the right track. Oh, do you mean why not dump the |
Thanks the for the nice write-up. Small remark: The original example doesn't contain the case where one point/cell belongs to multiple sets (e.g., "iron" and "boundary"). |
For points / cells that are "tagged" with multiple sets,
|
Let me add that, coming from a PDE background, the material would probably be implemented as a function. As opposed to tags, the limitation here is that every point/cell has exactly one value. I like this representation mesh.cell_sets = {
"Orange": {"line": [0, 2]},
"Blue": {"line": [1, 4]},
} for sets. |
Note also that gmsh calls "tag" what we'd rather refer to as a function, i.e., mesh.cell_data["line"]["cell_tags"] = [-1, -2, -1, 0, -2] You probably realize that already. |
That's MSH2, not MSH4. |
In MSH2, each cell was assigned exactly one ‘physical entity’. If one defined two physical entities that both contained a particular cell, that cell was actually duplicated so that each only had to belong to a single physical entity. (Remember the comment 2018-02-05 from #175.) But MSH4 did away with this. If I take the same Gmsh GEO snippet from that comment Point (1) = {0, 0, 0, 1};
Point (2) = {1, 0, 0, 1};
Point (3) = {2, 0, 0, 1};
Line (1) = {1, 2};
Line (2) = {2, 3};
Physical Line("left", 1) = {1};
Physical Line("all", 2) = {1, 2}; and run it today through Gmsh 4.5.0-git-0c1b63c8d with gmsh -1 twoseg.geo I get
This MSH4.1 is quite different to the MSH2.2 generated by Gmsh two years ago. (I can get the same today with The problem is that
The |
Yes. I think the 1st representation is natural for MEDIT and MSH2, but it's definitely defective for MED and MSH4.1, maybe Exodus II, XDMF, … There's not much benefit for MEDIT & MSH2 in using the second representation that I can think of. Possibly convenient for meshio in not having two representations, but then if read-writing MEDIT/MSH2, it would mean a pointless roundtrip conversion between first and second representations. Maybe not that big a negative, but meanwhile: would it be a reasonable step to just get all the meshio implementations of the second representation into line under the banner of ‘uniformation of point / cell sets among formats’. Then after that we can think about whether the first representation can be dropped from formats for which it's adequate. |
I wouldn't worry about MSH2.2 at all. So yeah, let's see if we can get representation 2 to work. Let's best start with those formats where it's native. |
I mostly mentioned MSH2.2 as our current implementation of MSH4.1 basically coerces the latter into the former. Also though MSH2.2 is still the latest MSH version written by Gmsh 3.0.6 which is the one in the official Ubuntu package for Ubuntu 18.04, the latest Ubuntu LTS. MSH2.2 was an important format for many years so there are a few meshes out there written in it; e.g. scikit-fem/docs/examples/box.msh. I don't think we need to touch it here though, no. |
Actually in the same spirit of unification, it would be good to see all meshio implementations of the first representation unified ( |
Yes these two representations are both valid and can be inter-converted if needed. For points / cells belonging to multiple subsets, the 1st method involves introducing new cell tags corresponding to intersections of sets, while the 2nd method is more convenient. Note that internally the MED format actually adopts the 1st method! mesh.point_tags =
{2: ['Side'],
3: ['Side', 'Top'],
4: ['Top']}
mesh.cell_tags =
{-6: ['Top circle'],
-7: ['Top', 'Top and down'],
-8: ['Top and down'],
-9: ['A', 'B'],
-10: ['B'],
-11: ['A', 'B', 'C'],
-12: ['B', 'C'],
-13: ['C']} so the tag 3 (which is automatically created internally by MED) is assigned to nodes that belong both to "Side" and "Top"; the tag -11 is for cells that belong to the subsets "A", "B" and "C". From this the user can reconstruct the 2nd representation if he wants. What I suggest is that if these additional tags for intersections of sets are already pre-computed and available in the mesh format, then the 1st representation can be used. Otherwise (for MSH4 as I understand), construct and expose these subsets using the 2nd method is more feasible, as the computation of set intersections could be tedious. In practice,
|
I vote for a unique name. That makes is trivial for meshio to convert cell-tags between any formats using the first representation, e.g. MSH2.2 and MEDIT, which it currently does not attempt. It also means that any downstream program wanting to open a mesh and find the cell-tags (e.g. signifying subdomains or parts of the boundary in a mixed boundary value problem) can do so via meshio without worrying about whether the input mesh was written in MSH2.2 or MEDIT or whatever. For a real code example, see: |
Yes I also vote for a unique name. Should some special treatment (underscore, add a "meshio" prefix, ...) be used for its name to reflect that it is a special point / cell data? |
Yes, I guess so. I don't foresee the particular choice being that important. I think either of your suggestions will work fine. Say "meshio:tag"? |
@nschloe @gdmcbain @keurfonluu I begin to work on an idea yesterday. Since several formats (GMSH in particular) may define several tag possibilities ( What I propose now, is to
The name What do you think? |
Thanks for taking this up again. I wouldn't be too worried about "gmsh:geometrical"; I don't believe that it is ever used in applications. Also it's only MSH 2.2, isn't it? In referring to Gmsh formats, the latter must be distinguished from MSH 4.1, they're incompatible and far from isomorphic. One other thing with MSH 4.1 is that cells (or rather cellblocks, but cells through their membership of blocks) can have zero or more physical tags. This was supposed to be the case in MSH 2.2 too but Gmsh itself didn't write MSH 2.2 like this, duplicating or multiplying elements when they were specified according to the GEO file to have two or more physical tags. (This is.documented here a few hundred issues back.) I'm not sure whether there are other file formats that allow other than one physical tag per cell, probably. MEDIT has exactly one tag per cell. To handle this, should each cell in Besides MSH 2.2, which formats have 'several tag possibilities'? I particularly like the idea of starting to get the physical tags out of Also, I'm not sure whether this is the right place to ask, but could you elaborate a little on |
How does GMSH treat exactly points / cells that are tagged by several sets? In your example (#619 (comment))
It appears to me that the 1st element is only tagged by 1, although in the GEO file it is also tagged by 2. In MED, when cells / points belong to several subsets defined by the user, then internally intersections of subsets are created with a new tag (#619 (comment)), so meshio can easily read these new tags for each point / cell. If in GMSH no new tags are created for represent intersections of original subsets, I suggest adopt first the
In
the name of each tag can be directly put into this structure. |
The tags aren't given directly in the MSH 4.1 $Elements section. This one has two blocks of elements. The first block of elements belongs to 1-dimensional 'entity' 1, the second to 1-dimensional entity 2. Those element blocks belonging to entity (1, 1) have 2 physical tags, 1 and 2, corresponding to the names "left" and "all". The element blocks belonging to entity (1, 2) have only 1 physical tag, 2, "all". |
I like As opposed to that, many formats define regions in terms an integer-valued function on cells. Each cell has exactly one value. meshio shouldn't care about that. "You give me an integer function? Okay, here's your For the interoperability ideas: |
Thanks for the explanation of |
Sorry to ask, you probably have explained that somewhere before: Are those gmsh 4.1 blocks always of the same cell type? |
Yes. The four ints beginning each block of elements are
so exactly one elementType. |
I'll try to first work on a version that covers all formats but msh4.1. |
A first draft is now in https://github.com/tianyikillua/meshio/commits/unification-point-cell-tags. Already done
TODO
Repr of mesh also now prints point / cell tags.
Now point / cell tags can be transferred among formats, through
|
@gdmcbain As you can see from the previous flac3d example, the 1st (hexa) block contains two tags. So each cell block is not necessarily associated with a unique tag. |
That (heterogeneous tags within a block) seems like a terrible design decision, but that's not our call. I haven't heard of flac3d but I guess it's out there and meshio has to support it. Thank you for highlighting this. |
I will push a draft PR for easy review and discussion. |
FLAC3D is not a proper meshing software. It's a commercial mechanical simulator mostly used in civil engineering. It has a meshing tool that stitches pre-meshed grids all together. For instance, you can create a big pyramid made of smaller hexs and tets that corresponds to the roof of a house for instance. The order of cells in FLAC3D is defined by the order you create your objects. |
Objectives
Unify the names (
gmsh:physical
,medit:ref
,flac3d:zone
...) and implementations of point / cell sets among formats.Names
Currently these different names need to be hard-coded when the subsets are transferred among formats, like
Two solutions
Implementations
An example of mesh composed of 5 line elements and 6 nodes. We have two point sets: "Red" and "Green", and two cell sets: "Orange" and "Blue".
point_data
andcell_data
as indicator functions. Using the current terminology for MED, we haveNote that with this implementation, we need two lists: the indicator function list that assigns a unique value to each point / cell, as well as a list that indicates the actual names corresponding to these unique values. This implementation is suited when we want to visualize point / cell sets in ParaView, since they are modeled as a
point_data
/cell_data
.This implementation is currently adopted by (to be completed)
This implementation uses less memory and is more explicit. However it needs to be converted to the 1st method when visualizing them under ParaView. A universal conversion function can be provided in the
Mesh
class.This method is already sketched (not yet exposed) in various formats
Question: can this 2nd method adopted universally for all mesh formats, considering their own specificities?
The text was updated successfully, but these errors were encountered: