Mercurial > repos > public > sbplib_julia
comparison src/Grids/manifolds.jl @ 1914:e7f8d11c4670 feature/grids/manifolds
Delete functions related to geometries as they don't belong on this branch
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Mon, 03 Feb 2025 15:39:26 +0100 |
| parents | 04c251bccbd4 |
| children | 71d218593cac |
comparison
equal
deleted
inserted
replaced
| 1913:e97f4352b8d0 | 1914:e7f8d11c4670 |
|---|---|
| 70 connections | 70 connections |
| 71 end | 71 end |
| 72 | 72 |
| 73 charts(a::UnstructuredAtlas) = a.charts | 73 charts(a::UnstructuredAtlas) = a.charts |
| 74 connections(a::UnstructuredAtlas) = nothing | 74 connections(a::UnstructuredAtlas) = nothing |
| 75 | |
| 76 | |
| 77 ### | |
| 78 # Geometry | |
| 79 ### | |
| 80 | |
| 81 abstract type Curve end | |
| 82 abstract type Surface end | |
| 83 | |
| 84 | |
| 85 struct Line{PT} <: Curve | |
| 86 p::PT | |
| 87 tangent::PT | |
| 88 end | |
| 89 | |
| 90 (c::Line)(s) = c.p + s*c.tangent | |
| 91 | |
| 92 | |
| 93 struct LineSegment{PT} <: Curve | |
| 94 a::PT | |
| 95 b::PT | |
| 96 end | |
| 97 | |
| 98 (c::LineSegment)(s) = (1-s)*c.a + s*c.b | |
| 99 | |
| 100 | |
| 101 function linesegments(ps...) | |
| 102 return [LineSegment(ps[i], ps[i+1]) for i ∈ 1:length(ps)-1] | |
| 103 end | |
| 104 | |
| 105 | |
| 106 function polygon_edges(ps...) | |
| 107 n = length(ps) | |
| 108 return [LineSegment(ps[i], ps[mod1(i+1,n)]) for i ∈ eachindex(ps)] | |
| 109 end | |
| 110 | |
| 111 struct Circle{T,PT} <: Curve | |
| 112 c::PT | |
| 113 r::T | |
| 114 end | |
| 115 | |
| 116 function (C::Circle)(θ) | |
| 117 (;c, r) = C | |
| 118 c + r*@SVector[cos(θ), sin(θ)] | |
| 119 end | |
| 120 | |
| 121 struct TransfiniteInterpolationSurface{T1,T2,T3,T4} <: Surface | |
| 122 c₁::T1 | |
| 123 c₂::T2 | |
| 124 c₃::T3 | |
| 125 c₄::T4 | |
| 126 end | |
| 127 | |
| 128 function (s::TransfiniteInterpolationSurface)(u,v) | |
| 129 c₁, c₂, c₃, c₄ = s.c₁, s.c₂, s.c₃, s.c₄ | |
| 130 P₀₀ = c₁(0) | |
| 131 P₁₀ = c₂(0) | |
| 132 P₁₁ = c₃(0) | |
| 133 P₀₁ = c₄(0) | |
| 134 return (1-v)*c₁(u) + u*c₂(v) + v*c₃(1-u) + (1-u)*c₄(1-v) - ( | |
| 135 (1-u)*(1-v)*P₀₀ + u*(1-v)*P₁₀ + u*v*P₁₁ + (1-u)*v*P₀₁ | |
| 136 ) | |
| 137 end | |
| 138 | |
| 139 function (s::TransfiniteInterpolationSurface)(ξ̄::AbstractArray) | |
| 140 s(ξ̄...) | |
| 141 end | |
| 142 | |
| 143 # TODO: Implement jacobian() for the different mapping helpers | |
| 144 |
