diff src/Grids/manifolds.jl @ 1998:6dd00ea0511a feature/grids/manifolds

Add check if the logical coordinates are in the parameter space when calling a chart
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 25 Apr 2025 08:28:34 +0200
parents ebe883807b62
children a1b2453c02c9
line wrap: on
line diff
--- a/src/Grids/manifolds.jl	Fri Apr 25 08:18:36 2025 +0200
+++ b/src/Grids/manifolds.jl	Fri Apr 25 08:28:34 2025 +0200
@@ -9,9 +9,15 @@
 end
 
 Base.ndims(::Chart{D}) where D = D
-(c::Chart)(ξ) = c.mapping(ξ)
 parameterspace(c::Chart) = c.parameterspace
 
+function (c::Chart)(ξ)
+    if ξ ∉ parameterspace(c)
+        throw(DomainError(ξ, "chart was called logical coordinates outside the parameterspace. If this was inteded, use the `mapping` field from the Chart struct instead."))
+    end
+    return c.mapping(ξ)
+end
+
 """
     jacobian(c::Chart, ξ)