How to claculate the cell length in the direction of the convection velocity in supg stablization
I wonder how to code this in python? For me, I don't know how to access the basis function deravatives used in the formula, and how to code this with ufl language? Any ideas?
from adaptivity import mesh_metric M = mesh_metric(mesh) v_times_hinv = dot(dot(v,M),v)
where v is the velocity and the mesh_metric is defined in https://github.com/meshadaptation/pragmatic/blob/master/python/adaptivity.py.in
Your test function then becomes
u_tst = TestFunction(V) u_tst += dot(grad(u_tst),v)/v_times_hinv
Multiply the normalized velocity vector by CellSize(mesh) -- plus some amount to ensure that the point this vector ends on lies entirely within the cell in the upwind direction, say 1/2 Cellsize(mesh) -- then create a Point for use with the mesh BoundingBoxTree to get the cell index, which can be used to set the upwind cell size for the source Cell's SUPG formulation.