Controlling mesh resolution

Controlling mesh resolution#

Coarse global resolution#

The keyword arguments default_resolution_min and default_resolution_max set the minimum and maximum characteristic lengths used by gmsh when computing the mesh.

They are used when other resolutions are not provided, and default_resolution_max effectively sets the minimum length possible, since when conflicting resolution at a point are given, the smallest one is taken.

import gdsfactory as gf
import meshio
from gdsfactory.generic_tech import get_generic_pdk
from gdsfactory.pdk import get_layer_stack
from gdsfactory.technology import LayerStack
from skfem.io import from_meshio

from gplugins.gmsh.get_mesh import create_physical_mesh, get_mesh

PDK = get_generic_pdk()
PDK.activate()
gf.config.rich_output()

waveguide = gf.components.straight_pin(length=10, taper=None)
waveguide.trim(left=3, right=5, top=+4, bottom=-4)
waveguide.plot()


filtered_layer_stack = LayerStack(
    layers={
        k: get_layer_stack().layers[k]
        for k in (
            "slab90",
            "core",
            "via_contact",
        )
    }
)

filename = "mesh"


def mesh_with_physicals(mesh, filename):
    mesh_from_file = meshio.read(f"{filename}.msh")
    return create_physical_mesh(mesh_from_file, "triangle")

../_images/ed0ca27f166eefbface2185caa83cedcddad4697134b9d05cb0fb4b7285afd1b.png

With default_resolution_max set to 1 um and default_resolution_min set to 100 nm:

mesh = get_mesh(
    component=waveguide,
    type="uz",
    xsection_bounds=[(4, -4), (4, 4)],
    layer_stack=filtered_layer_stack,
    filename=f"{filename}.msh",
    background_tag="oxide",
    background_padding=(2.0, 2.0, 2.0, 2.0),
    default_resolution_min=0.1,
    default_resolution_max=1,
)

mesh = mesh_with_physicals(mesh, filename)
mesh = from_meshio(mesh)
mesh.draw().plot()
Info    : [  0%] Union                                                                                  
Info    : [ 10%] Union - Performing intersection of shapes                                                                                
Info    : [ 80%] Union - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference - Performing intersection of shapes                                                                                
Info    : [ 80%] Difference - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments - Performing intersection of shapes                                                                                
Info    : [ 80%] Fragments - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference - Making faces                                                                                
Info    : [ 90%] Difference                                                                                  
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Filling splits of edges                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference - Making faces                                                                                
Info    : [ 90%] Difference - Adding holes                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Building splits of containers                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
                                                                                
Info    : Meshing 1D...
Info    : [  0%] Meshing curve 4 (Line)
Info    : [  0%] Meshing curve 2 (Line)
Info    : [  0%] Meshing curve 1 (Line)
Info    : [ 10%] Meshing curve 5 (Line)
Info    : [  0%] Meshing curve 3 (Line)
Info    : [ 10%] Meshing curve 6 (Line)
Info    : [ 20%] Meshing curve 7 (Line)
Info    : [ 20%] Meshing curve 8 (Line)
Info    : [ 20%] Meshing curve 15 (Line)
Info    : [ 20%] Meshing curve 16 (Line)
Info    : [ 20%] Meshing curve 17 (Line)
Info    : [ 30%] Meshing curve 18 (Line)
Info    : [ 30%] Meshing curve 19 (Line)
Info    : [ 30%] Meshing curve 20 (Line)
Info    : [ 40%] Meshing curve 21 (Line)
Info    : [ 40%] Meshing curve 22 (Line)
Info    : [ 50%] Meshing curve 23 (Line)
Info    : [ 50%] Meshing curve 24 (Line)
Info    : [ 50%] Meshing curve 25 (Line)
Info    : [ 60%] Meshing curve 26 (Line)
Info    : [ 60%] Meshing curve 27 (Line)
Info    : [ 60%] Meshing curve 28 (Line)
Info    : [ 70%] Meshing curve 29 (Line)
Info    : [ 70%] Meshing curve 30 (Line)
Info    : [ 70%] Meshing curve 31 (Line)
Info    : [ 80%] Meshing curve 32 (Line)
Info    : [ 80%] Meshing curve 33 (Line)
Info    : [ 80%] Meshing curve 34 (Line)
Info    : Done meshing 1D (Wall 0.00338448s, CPU 0.003647s)
Info    : Meshing 2D...
Info    : [  0%] Meshing surface 3 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 4 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 1 (Plane, Frontal-Delaunay)
Info    : [ 20%] Meshing surface 5 (Plane, Frontal-Delaunay)
Info    : [ 20%] Meshing surface 6 (Plane, Frontal-Delaunay)
Info    : [ 70%] Meshing surface 2 (Plane, Frontal-Delaunay)
Info    : Done meshing 2D (Wall 0.0136721s, CPU 0.038654s)
Info    : 504 nodes 1093 elements
Info    : Writing 'mesh.msh'...
Info    : Done writing 'mesh.msh'
Info    : Writing '/tmp/tmp2rx0rw32/mesh.msh'...
Info    : Done writing '/tmp/tmp2rx0rw32/mesh.msh'

[]

../_images/a444d2d39e02a3c3a656bc40e8f98996365fc99ff6436c4bd3bc466434f909b4.png

With default_resolution_max set to 300 nm and default_resolution_max set to 50 nm:

mesh = get_mesh(
    component=waveguide,
    type="uz",
    xsection_bounds=[(4, -4), (4, 4)],
    layer_stack=filtered_layer_stack,
    filename=f"{filename}.msh",
    background_tag="oxide",
    background_padding=(2.0, 2.0, 2.0, 2.0),
    default_resolution_min=0.05,
    default_resolution_max=0.3,
)
mesh = mesh_with_physicals(mesh, filename)
mesh = from_meshio(mesh)
mesh.draw().show()
Info    : [  0%] Union                                                                                  
Info    : [ 10%] Union - Performing intersection of shapes                                                                                
Info    : [ 80%] Union - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference - Performing intersection of shapes                                                                                
Info    : [ 80%] Difference - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments - Performing intersection of shapes                                                                                
Info    : [ 80%] Fragments - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference                                                                                  
Info    : [ 90%] Difference                                                                                  
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Filling splits of edges                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference - Making faces                                                                                
Info    : [ 90%] Difference - Adding holes                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Building splits of containers                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
                                                                                
Info    : Meshing 1D...
Info    : [  0%] Meshing curve 2 (Line)
Info    : [  0%] Meshing curve 3 (Line)
Info    : [  0%] Meshing curve 1 (Line)
Info    : [  0%] Meshing curve 4 (Line)
Info    : [  0%] Meshing curve 5 (Line)
Info    : [  0%] Meshing curve 6 (Line)
Info    : [  0%] Meshing curve 7 (Line)
Info    : [  0%] Meshing curve 8 (Line)
Info    : [  0%] Meshing curve 15 (Line)
Info    : [  0%] Meshing curve 16 (Line)
Info    : [  0%] Meshing curve 17 (Line)
Info    : [  0%] Meshing curve 18 (Line)
Info    : [  0%] Meshing curve 19 (Line)
Info    : [  0%] Meshing curve 20 (Line)
Info    : [  0%] Meshing curve 21 (Line)
Info    : [  0%] Meshing curve 22 (Line)
Info    : [  0%] Meshing curve 23 (Line)
Info    : [  0%] Meshing curve 24 (Line)
Info    : [  0%] Meshing curve 25 (Line)
Info    : [  0%] Meshing curve 26 (Line)
Info    : [  0%] Meshing curve 27 (Line)
Info    : [  0%] Meshing curve 28 (Line)
Info    : [  0%] Meshing curve 29 (Line)
Info    : [  0%] Meshing curve 30 (Line)
Info    : [  0%] Meshing curve 31 (Line)
Info    : [  0%] Meshing curve 32 (Line)
Info    : [  0%] Meshing curve 33 (Line)
Info    : [  0%] Meshing curve 34 (Line)
Info    : Done meshing 1D (Wall 0.0259531s, CPU 0.076386s)
Info    : Meshing 2D...
Info    : [  0%] Meshing surface 4 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 2 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 1 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 3 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 5 (Plane, Frontal-Delaunay)
Info    : [ 40%] Meshing surface 6 (Plane, Frontal-Delaunay)
Info    : Done meshing 2D (Wall 0.0174901s, CPU 0.051652s)
Info    : 504 nodes 1093 elements
Info    : Writing 'mesh.msh'...
Info    : Done writing 'mesh.msh'
Info    : Writing '/tmp/tmpclxe_6t1/mesh.msh'...
Info    : Done writing '/tmp/tmpclxe_6t1/mesh.msh'

../_images/a444d2d39e02a3c3a656bc40e8f98996365fc99ff6436c4bd3bc466434f909b4.png

Label-wise coarse resolution control#

An advantage of finite-volume and finite-element schemes is the ability for different nodes to have different characteristics lengths.

This simply achieved to first order here by supplying a resolutions dict with keys referencing the LayerStack names, and for value a second dict with keys resolution and DistMax / SizeMax (see gmsh documentation) which control, respectively, the characteristic length within a region and the dropoff away from interfaces with this region.

For example, to refine within the core only, one could use:

resolutions = {"core": {"resolution": 0.05, "distance": 0}}
mesh = get_mesh(
    component=waveguide,
    type="uz",
    xsection_bounds=[(4, -4), (4, 4)],
    layer_stack=filtered_layer_stack,
    filename=f"{filename}.msh",
    background_tag="oxide",
    background_padding=(2.0, 2.0, 2.0, 2.0),
    resolutions=resolutions,
)
mesh = mesh_with_physicals(mesh, filename)
mesh = from_meshio(mesh)
mesh.draw().show()
Info    : [  0%] Union                                                                                  
Info    : [ 10%] Union - Performing intersection of shapes                                                                                
Info    : [ 80%] Union - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference - Performing intersection of shapes                                                                                
Info    : [ 80%] Difference - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments - Performing intersection of shapes                                                                                
Info    : [ 80%] Fragments - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference - Making faces                                                                                
Info    : [ 90%] Difference                                                                                  
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Filling splits of edges                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference - Making faces                                                                                
Info    : [ 90%] Difference - Adding holes                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Building splits of containers                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
                                                                                
Info    : Meshing 1D...
Info    : [  0%] Meshing curve 1 (Line)
Info    : [  0%] Meshing curve 2 (Line)
Info    : [  0%] Meshing curve 3 (Line)
Info    : [  0%] Meshing curve 4 (Line)
Info    : [  0%] Meshing curve 5 (Line)
Info    : [  0%] Meshing curve 6 (Line)
Info    : [  0%] Meshing curve 7 (Line)
Info    : [  0%] Meshing curve 8 (Line)
Info    : [  0%] Meshing curve 15 (Line)
Info    : [  0%] Meshing curve 16 (Line)
Info    : [  0%] Meshing curve 17 (Line)
Info    : [  0%] Meshing curve 18 (Line)
Info    : [  0%] Meshing curve 19 (Line)
Info    : [  0%] Meshing curve 20 (Line)
Info    : [  0%] Meshing curve 21 (Line)
Info    : [  0%] Meshing curve 22 (Line)
Info    : [  0%] Meshing curve 23 (Line)
Info    : [  0%] Meshing curve 24 (Line)
Info    : [  0%] Meshing curve 25 (Line)
Info    : [  0%] Meshing curve 26 (Line)
Info    : [  0%] Meshing curve 27 (Line)
Info    : [  0%] Meshing curve 28 (Line)
Info    : [  0%] Meshing curve 29 (Line)
Info    : [  0%] Meshing curve 30 (Line)
Info    : [  0%] Meshing curve 31 (Line)
Info    : [  0%] Meshing curve 32 (Line)
Info    : [  0%] Meshing curve 33 (Line)
Info    : [  0%] Meshing curve 34 (Line)
Info    : Done meshing 1D (Wall 0.0356341s, CPU 0.072965s)
Info    : Meshing 2D...
Info    : [  0%] Meshing surface 3 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 1 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 2 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 4 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 5 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 6 (Plane, Frontal-Delaunay)
Info    : Done meshing 2D (Wall 0.0183342s, CPU 0.043246s)
Info    : 786 nodes 1691 elements
Info    : Writing 'mesh.msh'...
Info    : Done writing 'mesh.msh'
Info    : Writing '/tmp/tmptwt28s1m/mesh.msh'...
Info    : Done writing '/tmp/tmptwt28s1m/mesh.msh'

../_images/ce2f285fea9054cef64d09a80cc93ea9a73d3cb9b78614bd5d1854a129b23073.png

Adding a dropoff at the interface:

resolutions = {"core": {"resolution": 0.05, "DistMax": 1, "SizeMax": 0.2}}
mesh = get_mesh(
    component=waveguide,
    type="uz",
    xsection_bounds=[(4, -4), (4, 4)],
    layer_stack=filtered_layer_stack,
    filename=f"{filename}.msh",
    background_tag="oxide",
    background_padding=(2.0, 2.0, 2.0, 2.0),
    resolutions=resolutions,
)
mesh = mesh_with_physicals(mesh, filename)
mesh = from_meshio(mesh)
mesh.draw().show()
Info    : [  0%] Union                                                                                  
Info    : [ 10%] Union - Performing intersection of shapes                                                                                
Info    : [ 80%] Union - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference - Performing intersection of shapes                                                                                
Info    : [ 80%] Difference - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments - Performing intersection of shapes                                                                                
Info    : [ 80%] Fragments - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference                                                                                  
Info    : [ 90%] Difference                                                                                  
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Filling splits of edges                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference - Making faces                                                                                
Info    : [ 90%] Difference - Adding holes                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Building splits of containers                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
                                                                                
Info    : Meshing 1D...
Info    : [  0%] Meshing curve 2 (Line)
Info    : [  0%] Meshing curve 1 (Line)
Info    : [  0%] Meshing curve 3 (Line)
Info    : [  0%] Meshing curve 4 (Line)
Info    : [  0%] Meshing curve 5 (Line)
Info    : [  0%] Meshing curve 6 (Line)
Info    : [  0%] Meshing curve 7 (Line)
Info    : [  0%] Meshing curve 8 (Line)
Info    : [  0%] Meshing curve 15 (Line)
Info    : [  0%] Meshing curve 16 (Line)
Info    : [  0%] Meshing curve 17 (Line)
Info    : [  0%] Meshing curve 18 (Line)
Info    : [  0%] Meshing curve 19 (Line)
Info    : [  0%] Meshing curve 20 (Line)
Info    : [  0%] Meshing curve 21 (Line)
Info    : [  0%] Meshing curve 22 (Line)
Info    : [  0%] Meshing curve 23 (Line)
Info    : [  0%] Meshing curve 24 (Line)
Info    : [  0%] Meshing curve 25 (Line)
Info    : [  0%] Meshing curve 26 (Line)
Info    : [  0%] Meshing curve 27 (Line)
Info    : [  0%] Meshing curve 28 (Line)
Info    : [  0%] Meshing curve 29 (Line)
Info    : [  0%] Meshing curve 30 (Line)
Info    : [  0%] Meshing curve 31 (Line)
Info    : [  0%] Meshing curve 32 (Line)
Info    : [  0%] Meshing curve 33 (Line)
Info    : [  0%] Meshing curve 34 (Line)
Info    : Done meshing 1D (Wall 0.0332809s, CPU 0.060305s)
Info    : Meshing 2D...
Info    : [  0%] Meshing surface 3 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 2 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 1 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 4 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 5 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 6 (Plane, Frontal-Delaunay)
Info    : Done meshing 2D (Wall 0.023985s, CPU 0.054403s)
Info    : 1040 nodes 2223 elements
Info    : Writing 'mesh.msh'...
Info    : Done writing 'mesh.msh'
Info    : Writing '/tmp/tmprr4pkdyi/mesh.msh'...
Info    : Done writing '/tmp/tmprr4pkdyi/mesh.msh'

../_images/0c8f74bd1618c0b3d05421ae55b96c03c8099121f0e02888af7dfe8a405e0086.png

Refining multiple elements simultaneously:

resolutions = {
    "core": {"resolution": 0.05, "DistMax": 1, "SizeMax": 0.2},
    "slab90": {"resolution": 0.02, "DistMax": 1, "SizeMax": 0.2},
    "via_contact": {"resolution": 0.2},
    "oxide": {"resolution": 1},
}
mesh = get_mesh(
    component=waveguide,
    type="uz",
    xsection_bounds=[(4, -4), (4, 4)],
    layer_stack=filtered_layer_stack,
    filename=f"{filename}.msh",
    background_tag="oxide",
    background_padding=(2.0, 2.0, 2.0, 2.0),
    resolutions=resolutions,
)
mesh = mesh_with_physicals(mesh, filename)
mesh = from_meshio(mesh)
mesh.draw().show()
Info    : [  0%] Union                                                                                  
Info    : [ 10%] Union - Performing intersection of shapes                                                                                
Info    : [ 80%] Union - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference - Performing intersection of shapes                                                                                
Info    : [ 80%] Difference - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments - Performing intersection of shapes                                                                                
Info    : [ 80%] Fragments - Building splits of containers                                                                                
                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference - Making faces                                                                                
Info    : [ 90%] Difference                                                                                  
                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Filling splits of edges                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
Info    : [  0%] Difference                                                                                  
Info    : [ 10%] Difference                                                                                  
Info    : [ 20%] Difference                                                                                  
Info    : [ 30%] Difference                                                                                  
Info    : [ 40%] Difference                                                                                  
Info    : [ 50%] Difference                                                                                  
Info    : [ 60%] Difference                                                                                  
Info    : [ 70%] Difference - Filling splits of edges                                                                                
Info    : [ 80%] Difference - Making faces                                                                                
Info    : [ 90%] Difference - Adding holes                                                                                
Info    : [  0%] Fragments                                                                                  
Info    : [ 10%] Fragments                                                                                  
Info    : [ 20%] Fragments                                                                                  
Info    : [ 30%] Fragments                                                                                  
Info    : [ 40%] Fragments                                                                                  
Info    : [ 50%] Fragments                                                                                  
Info    : [ 60%] Fragments                                                                                  
Info    : [ 70%] Fragments - Building splits of containers                                                                                
Info    : [ 80%] Fragments - Splitting faces                                                                                
                                                                                
Info    : Meshing 1D...
Info    : [  0%] Meshing curve 1 (Line)
Info    : [  0%] Meshing curve 2 (Line)
Info    : [  0%] Meshing curve 3 (Line)
Info    : [  0%] Meshing curve 4 (Line)
Info    : [  0%] Meshing curve 5 (Line)
Info    : [  0%] Meshing curve 6 (Line)
Info    : [  0%] Meshing curve 7 (Line)
Info    : [ 20%] Meshing curve 8 (Line)
Info    : [ 20%] Meshing curve 15 (Line)
Info    : [ 20%] Meshing curve 16 (Line)
Info    : [ 20%] Meshing curve 17 (Line)
Info    : [ 20%] Meshing curve 18 (Line)
Info    : [ 20%] Meshing curve 19 (Line)
Info    : [ 20%] Meshing curve 20 (Line)
Info    : [ 20%] Meshing curve 21 (Line)
Info    : [ 20%] Meshing curve 22 (Line)
Info    : [ 20%] Meshing curve 23 (Line)
Info    : [ 20%] Meshing curve 24 (Line)
Info    : [ 20%] Meshing curve 25 (Line)
Info    : [ 20%] Meshing curve 26 (Line)
Info    : [ 20%] Meshing curve 27 (Line)
Info    : [ 20%] Meshing curve 28 (Line)
Info    : [ 20%] Meshing curve 29 (Line)
Info    : [ 20%] Meshing curve 30 (Line)
Info    : [ 20%] Meshing curve 31 (Line)
Info    : [ 20%] Meshing curve 32 (Line)
Info    : [ 20%] Meshing curve 33 (Line)
Info    : [ 20%] Meshing curve 34 (Line)
Info    : Done meshing 1D (Wall 0.0347312s, CPU 0.102558s)
Info    : Meshing 2D...
Info    : [  0%] Meshing surface 3 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 2 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 1 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 4 (Plane, Frontal-Delaunay)
Info    : [ 20%] Meshing surface 5 (Plane, Frontal-Delaunay)
Info    : [ 20%] Meshing surface 6 (Plane, Frontal-Delaunay)
Info    : Done meshing 2D (Wall 0.180603s, CPU 0.277526s)
Info    : 8368 nodes 17629 elements
Info    : Writing 'mesh.msh'...
Info    : Done writing 'mesh.msh'
Info    : Writing '/tmp/tmpczgoq0xs/mesh.msh'...
Info    : Done writing '/tmp/tmpczgoq0xs/mesh.msh'

../_images/3d2f8bcbea75d2726b501c0b71da321d36d79da48f0a969fa5ca1a330fe7e2df.png