What does the 'distance' argument do in the mesh generation? #149
-
I am following the tutorials to recreate some results from an RF coplanar waveguide and I am stuck on what the argument "distance" does, as I can never see any changes to the mesh. Can anyone clarify? Maybe we can use the code snippet for the rectangular waveguide as an example: from collections import OrderedDict
import matplotlib.pyplot as plt
import numpy as np
import shapely
import shapely.affinity
from scipy.constants import epsilon_0, speed_of_light
from shapely.ops import clip_by_rect
from skfem import Basis, ElementTriP0
from skfem.io.meshio import from_meshio
from femwell.maxwell.waveguide import compute_modes
from femwell.mesh import mesh_from_OrderedDict
from femwell.visualization import plot_domains
wg_width = 2.5
wg_thickness = 0.3
core = shapely.geometry.box(-wg_width / 2, 0, +wg_width / 2, wg_thickness)
env = shapely.affinity.scale(core.buffer(5, resolution=8), xfact=0.5)
polygons = OrderedDict(
core=core,
box=clip_by_rect(env, -np.inf, -np.inf, np.inf, 0),
clad=clip_by_rect(env, -np.inf, 0, np.inf, np.inf),
)
resolutions = dict(core={"resolution": 0.03, "distance": 0.5})
mesh = from_meshio(mesh_from_OrderedDict(polygons, resolutions, default_resolution_max=10))
mesh.draw().show()
print(mesh.nelements) if I change the distance from 0.5 to 10 it changes from ~4800 to ~5200 mesh elements, but I don't see any significant changes. When is this parameter useful? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Distance defines over which distance the mesh get's back to the We recently added, that you can also define SizeMax to define the max size after this distance. We should probably q this further in the docs 🤔 |
Beta Was this translation helpful? Give feedback.
Distance defines over which distance the mesh get's back to the
default_resolution_max
. Therefore, for this example it doesn't make too much difference.We recently added, that you can also define SizeMax to define the max size after this distance.
Maybe try something like
core={"resolution": 0.03, "distance": 0.5, "SizeMax": 0.04}
and you should see a significant difference which often helps to get what you want :)We should probably q this further in the docs 🤔