BoundaryLayer2 issues

Hello everyone. I’ve been trying to build a 2d mesh with boundary layers on only two edges.
The problem is that sometimes my code deletes parts of the boundary on the creation of the mesh. I think it may have to do with the BoundaryLayer2 function, but I’m not sure about it.

Here is an example of what is happening:

As you can see, there is a sliver of the domain that is not covered by any element. This image was obtained with the attached code on what would be the file Mesh_04.stl. I also include the code in this post.

from ngsolve import *


def Create2DMesh(hmax, thicknesses, name=""):

    geo = unit_square
    ngmsh = geo.GenerateMesh(maxh=hmax)
    ngmsh.BoundaryLayer2(domain=1, 
                         thicknesses=thicknesses, 
                         make_new_domain=False,
                         boundaries=[2, 3])

    ngmsh.Split2Tets()
    ngmsh.Export(name+".stl", "STL Format")
    return Mesh(ngmsh)


if __name__ == '__main__':


    for i in range(5):

        mesh_name = f"Mesh_0{i}"
        hmax = 0.5*2.0**(-i)

        # Set layer parameters
        layer_thickness = 0.03
        n_layers = 2*(i+1) + 1
        growth_ratio = 1.1
        h0 = layer_thickness*(1 - growth_ratio)/(1 - growth_ratio**n_layers)
        thicknesses = [h0*growth_ratio**j for j in range(n_layers)]

        mesh = Create2DMesh(hmax=hmax, thicknesses=thicknesses, name=mesh_name)


    pass

I would really appreciate any help with this.

Best,
Joaquín.
mesh-issue.py (877 Bytes)

Hi, this was a bug in the 2d boundarylayer. On newest master it should be fixed, but the syntax is now the same as in 3d, giving the boundarylayer arguments already to the GenerateMesh function instead of adding them into the already existing mesh
Best
Christopher