comparison src/Grids/geometry.jl @ 1954:b0915f43b122 feature/sbp_operators/laplace_curvilinear

Merge feature/grids/geometry_functions
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 08 Feb 2025 09:38:58 +0100
parents 6859089b361e
children 478b233999c5
comparison
equal deleted inserted replaced
1953:835b1dcee38e 1954:b0915f43b122
1 struct Line{PT}
2 p::PT
3 tangent::PT
4 end
5
6 (c::Line)(s) = c.p + s*c.tangent
7
8
9 struct LineSegment{PT}
10 a::PT
11 b::PT
12 end
13
14 (c::LineSegment)(s) = (1-s)*c.a + s*c.b
15
16
17 function linesegments(ps...)
18 return [LineSegment(ps[i], ps[i+1]) for i ∈ 1:length(ps)-1]
19 end
20
21
22 function polygon_edges(ps...)
23 n = length(ps)
24 return [LineSegment(ps[i], ps[mod1(i+1,n)]) for i ∈ eachindex(ps)]
25 end
26
27 struct Circle{T,PT}
28 c::PT
29 r::T
30 end
31
32 function (C::Circle)(θ)
33 (;c, r) = C
34 c + r*@SVector[cos(θ), sin(θ)]
35 end
36
37 struct TransfiniteInterpolationSurface{T1,T2,T3,T4}
38 c₁::T1
39 c₂::T2
40 c₃::T3
41 c₄::T4
42 end
43
44 function (s::TransfiniteInterpolationSurface)(u,v)
45 c₁, c₂, c₃, c₄ = s.c₁, s.c₂, s.c₃, s.c₄
46 P₀₀ = c₁(0)
47 P₁₀ = c₂(0)
48 P₁₁ = c₃(0)
49 P₀₁ = c₄(0)
50 return (1-v)*c₁(u) + u*c₂(v) + v*c₃(1-u) + (1-u)*c₄(1-v) - (
51 (1-u)*(1-v)*P₀₀ + u*(1-v)*P₁₀ + u*v*P₁₁ + (1-u)*v*P₀₁
52 )
53 end
54
55 function (s::TransfiniteInterpolationSurface)(ξ̄::AbstractArray)
56 s(ξ̄...)
57 end
58
59 # TODO: Implement jacobian() for the different mapping helpers