Merged Mesh Boundaries Names Problem

Hi,

I’m working on glue two meshes and then applying a load to them. I tried using the geo.Glue() function that I found on this forum, and it works almost perfectly. However, I’ve encountered an issue: the command removes the name of the adjacent face where the two meshes are joined.

I haven’t found a way to resolve this problem yet. Any suggestions?

Thomas

please post a minimal example

My code works with a STEP file that contains the geometry and faces names.

Here is the stp file :

PoutreCoupe.stp (13.4 KB)

Here is my code:

    from netgen.occ import *
    from ngsolve import *
    
    # Variable
    E = 210000
    nu = 0.3
    
    # Dirichlet Boundaries
    Face_Dirichletx = 'Face7'
    Face_Dirichlety = 'Face7'
    Face_Dirichletz = 'Face7'
    
    # Loaded Faces
    FaceForce = 'Face1'
    
    # Mesh the geometry and get the boundaries --------------------------------------------------
    geo = OCCGeometry('PoutreCoupe.stp')
    geo.Glue()
    mesh = Mesh(geo.GenerateMesh(maxh=5))
    boundaries = list(mesh.GetBoundaries())
    print(boundaries)
    
    def stress(strain, mu, lam):
        return 2 * mu * strain + lam * Trace(strain) * Id(3)
    
    def mu(E, nu):
        return E / 2 / (1 + nu)
    
    def lam(E, nu):
        return E * nu / ((1 + nu) * (1 - 2 * nu))
    
    # FE Space ---------------------------------------------------------------------------------
    fes = VectorH1(mesh, order=2, dirichletx=Face_Dirichletx, dirichlety=Face_Dirichlety, dirichletz=Face_Dirichletz)
    u, v = fes.TnT()
    gfu = GridFunction(fes)
    
    # Assemble a ----------------------------------------------------------------------------
    a = BilinearForm(fes)
    a += SymbolicBFI(InnerProduct(stress(Sym(Grad(u)), mu=mu(E, nu), lam=lam(E, nu)), Sym(Grad(v))))
    pre = Preconditioner(a, "bddc")
    a.Assemble()
    
    # Load ----------------------------------------------------------------------------
    domaine = mesh.Boundaries(FaceForce)
    area = Integrate(1, domaine)
    Load = 200/area
    force = CF((0, 0, Load))
    f = LinearForm(fes)
    f += force * v * ds(FaceForce)
    f.Assemble()
    
    # Run the Solver --------------------------------------------------------------------------
    from ngsolve.krylovspace import CGSolver
    inv = CGSolver(a.mat, pre, printrates='\r', tol=1e-6, maxiter=500)
    gfu.vec.data = inv * f.vec
    
    # Print Result --------------------------------------------------------------------------
    with TaskManager():
        EFstress = MatrixValued(H1(mesh, order=2), symmetric=True)
        StressT = GridFunction(EFstress)
        volumes = geo.shape
        StressT.Interpolate(stress(Sym(Grad(gfu)),mu(E, nu),lam(E, nu)))

In this code, the boundaries list printed is:
[‘default’, ‘default’, ‘default’, ‘Face3’, ‘default’, ‘default’, ‘default’, ‘Face7’, ‘default’, ‘default’, ‘default’]

But, if you delete the “geo.Glue()”, the boundaries list print:
[‘Face0’, ‘Face1’, ‘Face2’, ‘Face3’, ‘Face4’, ‘Face5’, ‘Face6’, ‘Face7’, ‘Face8’, ‘Face9’, ‘Face10’, ‘Face11’]

I need the face names to apply the force (“Face1”).

Thomas

I see, the Glue of OCCGeometry seems to loose properties.

If you glue occ-shape objects, it works:

geo = OCCGeometry('PoutreCoupe.stp')
geo2 = OCCGeometry(Glue(geo.shape))
mesh2 = Mesh(geo2.GenerateMesh(maxh=5))
print(mesh2.GetBoundaries())

With that I get the output

('Face0', 'Face1', 'Face2', 'Face3', 'Face4', 'Face5', 'Face6', 'Face7', 'Face8', 'Face10', 'Face11')

Thanks a lot for your help,
It work perfectly. :clap::grinning:

Hi,

I’ve worked with a different geometry and encountered a new problem. :confused:
I want to extract only the external (skin) faces of the new glued geometry, but it’s giving me boundaries that are inside the mesh. This also happens in the current example in this topic.
Do you have any ideas?

Thanks,
Thomas