Skip to content
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

Using GridapGmsh with mixed triangle-quad meshes #63

Open
gijswl opened this issue Oct 15, 2022 · 1 comment
Open

Using GridapGmsh with mixed triangle-quad meshes #63

gijswl opened this issue Oct 15, 2022 · 1 comment

Comments

@gijswl
Copy link

gijswl commented Oct 15, 2022

Hi all,

I would like to use Gridap with a mesh consisting of regions of unstructured triangles and structured quads.
The mesh is generated in Gmsh, so I would like to load it using GridapGmsh.
Doing so at the moment results in an error:

Only one element type per dimension allowed for the moment.
Dimension 2 has 2 different element types

Digging through the GridapGmsh code a little bit, it seems that most of the required functionality is present to allow this mixed mesh to be imported. By modifying the _setup_reffe function, I managed to load the mesh and use Gridap to compute a simple problem (see this Jupyter Notebook).

function _setup_reffes(gmsh,d,orient_if_simplex)
    elemTypes, elemTags, nodeTags = gmsh.model.mesh.getElements(d)

    ncells, nmin, nmax = _check_cell_tags(elemTags)
    cell_to_type = fill(Int8(0), ncells)
    
    noffset = nmin - 1;
    for (i, etype) in enumerate(elemTypes)
        cell_to_type[elemTags[i] .- noffset] .= i   # Correctly fill the cell_to_type array, instead of filling '1'
    
        # Check that the elements are first order; higher-order elements are not yet supported
        name, dim, order::Int, numv, parv = gmsh.model.mesh.getElementProperties(etype)
        if order == 0 && etype == POINT
            order = 1
        end
        
        if order != 1
            gmsh.finalize()
            error("For the moment only for first-order elements")
        end
    end
    
    # Retrieve RefFEs for the element types
    reffes = [_reffe_from_etype(etype) for etype in elemTypes];

    # Check mesh orientation
    boo = [(is_simplex(get_polytope(reffe)) && orient_if_simplex) for reffe in reffes];
    orientation = any(boo) ? Oriented() : NonOriented()

    (cell_to_type, reffes, orientation)
end

However, I am unsure of whether the mesh being partially structured and partially unstructured has any effect on the orientation part. Could this lead to issues with other types of meshes?

@jav-ed
Copy link

jav-ed commented Feb 3, 2023

I do not know the answer to your question, but I have a similar issue. A mesh generated with gmsh which contains 1d and 2d elements is unfortunately not able to be read by GridapGmsh for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants