Skip to content
Snippets Groups Projects
Commit 40b07a9b authored by Stephan Hilb's avatar Stephan Hilb
Browse files

add norm gradient calculation

parent 3c41733a
No related branches found
No related tags found
No related merge requests found
...@@ -400,6 +400,23 @@ end ...@@ -400,6 +400,23 @@ end
mesh_size(mesh) = mapreduce(cell -> diam(mesh, cell), max, cells(mesh)) mesh_size(mesh) = mapreduce(cell -> diam(mesh, cell), max, cells(mesh))
# https://en.wikipedia.org/wiki/Incircle_and_excircles_of_a_triangle#Radius
function inradius(mesh, cell)
A = SArray{Tuple{ndims_space(mesh), nvertices_cell(mesh)}}(
view(mesh.vertices, :, view(mesh.cells, :, cell)))
a, b, c =
norm(A[:, 1] - A[:, 2]),
norm(A[:, 2] - A[:, 3]),
norm(A[:, 3] - A[:, 1])
s = (a + b + c) / 2
return sqrt((s - a) * (s - b) * (s - c) / s)
end
function norm_gradient(mesh, cell)
min_inradius = mapreduce(cell -> inradius(mesh, cell), min, cells(mesh))
return 2 * sqrt(6) / (2 * min_inradius)
end
function elmap(mesh, cell) function elmap(mesh, cell)
@boundscheck cell in axes(mesh.cells, 2) @boundscheck cell in axes(mesh.cells, 2)
# TODO: can be improved, how? # TODO: can be improved, how?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment