Hi,
I am implementing SUPG for a magnetostatic problem as presented in this work. There is a stabilization parameter \tau which depends upon the height of each mesh element parallel to the direction of a given velocity field. Following is the expression I have to evaluate:
h_E = \frac{2}{\sum_n|\frac{\mathbf{v}}{v} \cdot \nabla \tilde{V}_n|},
where \tilde{V}_n is the test function of the unknown scalar potential evaluated and summed on each node n of the mesh element.
I would appreciate if someone could show how it is done. Below is the MWE in which this step can be added.
import dolfinx, ufl, gmsh, mpi4py, petsc4py
import numpy as np
from dolfinx.io import gmshio
gmsh.initialize()
gmsh.clear()
occ = gmsh.model.occ
occ.addCylinder(0, 0, 0, 0, 0, 1, 0.5)
occ.synchronize()
gdim = 3
all_doms = occ.getEntities(gdim)
frag, _ = occ.fragment([all_doms[0]], all_doms[1:])
occ.synchronize()
# add_sub physical tags
all_doms = occ.getEntities(gdim)
for j, dom in enumerate(all_doms):
gmsh.model.addPhysicalGroup(dom[0], [dom[1]], j + 1) # create the main group/node
# number all boundaries
all_edges = gmsh.model.getEntities(gdim - 1)
for j, edge in enumerate(all_edges):
gmsh.model.addPhysicalGroup(edge[0], [edge[1]], edge[1]) # create the main group/node
gmsh.model.mesh.generate()
mpi_rank = 0
mesh, ct, ft = gmshio.model_to_mesh(gmsh.model, mpi4py.MPI.COMM_WORLD, mpi_rank, gdim)
Omega_V = dolfinx.fem.functionspace(mesh, ("CG", 1))
Vt = ufl.TestFunction(Omega_V)
x_ufl, y_ufl, z_ufl = ufl.SpatialCoordinate(mesh)
velocity_vec = ufl.as_vector((-y_ufl, x_ufl, 0)) # known velocity field
# calculate mesh height along velocity field in each element