Skip to content

Instantly share code, notes, and snippets.

@amartinhuertas
Last active September 21, 2021 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amartinhuertas/20d5301ee4f94011f5c754593ea01591 to your computer and use it in GitHub Desktop.
Save amartinhuertas/20d5301ee4f94011f5c754593ea01591 to your computer and use it in GitHub Desktop.
Minimal Gridap working code used to evaluate equivalence among R J^{-T} and 1/sqrt(det(g)) J R
using Gridap
# Distorted mesh
function rndm(p::Point)
r, s = p
x = r + 0.1*sin(2π*r)*sin(2π*s)
y = s + 0.1*sin(2π*r)*sin(2π*s)
Point(x,y)
end
function perp()
TensorValue{2,2}(0, -1, 1, 0)
end
model =CartesianDiscreteModel((0,1,0,1),(20,20),map=rndm)
ξₖ = get_cell_map(model)
Jt = lazy_map(Broadcasting(∇), ξₖ)
pinvJt = lazy_map(Operation(Gridap.Fields.pinvJt),Jt)
p=Point(0.5,0.5)
for cell=1:length(Jt)
Jtp = evaluate(Jt[cell] ,p)
pinvJtp = evaluate(pinvJt[cell],p)
lhs=perp()⋅pinvJtp # R J^{-T}
rhs=(1.0/sqrt(det(Jtp⋅transpose(Jtp))))*transpose(Jtp)⋅perp() # 1/sqrt(det(g)) J R
@assert norm(lhs-rhs)/norm(rhs) < 1.0e-15
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment