|
| 1 | +# The Vault |
| 2 | +struct CircStrandedShape{L, T <: Real, U <: Integer} <: AbstractShape{L, T} |
| 3 | + r_in::T |
| 4 | + r_ex::T |
| 5 | + r_w::T |
| 6 | + n_w::U |
| 7 | + lay_r::T |
| 8 | + lay_d::U |
| 9 | +end |
| 10 | + |
| 11 | +# The Janitor |
| 12 | +function CircStrandedShape{L}( |
| 13 | + r_in, r_ex, r_w, n_w::U, lay_r, lay_d::U, |
| 14 | +) where {L, U <: Integer} |
| 15 | + T = promote_type(typeof(r_in), typeof(r_ex), typeof(r_w), typeof(lay_r)) |
| 16 | + return CircStrandedShape{L, T, U}( |
| 17 | + convert(T, r_in), |
| 18 | + convert(T, r_ex), |
| 19 | + convert(T, r_w), |
| 20 | + n_w, |
| 21 | + convert(T, lay_r), |
| 22 | + lay_d, |
| 23 | + ) |
| 24 | +end |
| 25 | + |
| 26 | +# The Diplomat |
| 27 | +function Base.convert( |
| 28 | + ::Type{<:AbstractShape{L, T}}, |
| 29 | + s::CircStrandedShape{L}, |
| 30 | +) where {L, T <: Real} |
| 31 | + return CircStrandedShape{L, T, typeof(s.n_w)}( |
| 32 | + convert(T, s.r_in), |
| 33 | + convert(T, s.r_ex), |
| 34 | + convert(T, s.r_w), |
| 35 | + s.n_w, |
| 36 | + convert(T, s.lay_r), |
| 37 | + s.lay_d, |
| 38 | + ) |
| 39 | +end |
| 40 | + |
| 41 | +struct CircStrandedBuilder{P, Tgeom <: Real, Tmat <: Real, U <: Integer} |
| 42 | + cmp::Symbol |
| 43 | + r_w::Tgeom |
| 44 | + n_w::U |
| 45 | + lay_r::Tgeom |
| 46 | + lay_d::U |
| 47 | + mat::Material{Tmat} |
| 48 | +end |
| 49 | + |
| 50 | +@inline function CircStrandedBuilder{P}( |
| 51 | + cmp::Symbol, r_w::Tgeom, n_w::U, lay_r::Tgeom, lay_d::U, mat::Material{Tmat}, |
| 52 | +) where {P, Tgeom, Tmat, U <: Integer} |
| 53 | + return CircStrandedBuilder{P, Tgeom, Tmat, U}(cmp, r_w, n_w, lay_r, lay_d, mat) |
| 54 | +end |
| 55 | + |
| 56 | +@inline function (b::CircStrandedBuilder{P})(current_r::T) where {P, T <: Real} |
| 57 | + # Strict geometric continuation. r_ex is fully determined by current_r + diameter. |
| 58 | + r_ex = current_r + 2 * b.r_w |
| 59 | + shape = CircStrandedShape{Concentric}(current_r, r_ex, b.r_w, b.n_w, b.lay_r, b.lay_d) |
| 60 | + |
| 61 | + # P is the ConductorPart. This call will trigger the T = promote_type(...) rule. |
| 62 | + return P(b.cmp, shape, b.mat) |
| 63 | +end |
| 64 | + |
| 65 | +struct CircStrandedSpec{P, Tcmp, Trw, Tnw, Tlayr, Tlayd, M <: AbstractSpec{Material}} <: |
| 66 | + AbstractSpec{CircStrandedBuilder{P}} |
| 67 | + cmp::Tcmp |
| 68 | + r_w::Trw |
| 69 | + n_w::Tnw |
| 70 | + lay_r::Tlayr |
| 71 | + lay_d::Tlayd |
| 72 | + mat::M |
| 73 | +end |
| 74 | + |
| 75 | +@inline function CircStrandedSpec( |
| 76 | + ::Type{P}, cmp::Tcmp, r_w::Trw, n_w::Tnw, lay_r::Tlayr, lay_d::Tlayd, mat::M, |
| 77 | +) where {P, Tcmp, Trw, Tnw, Tlayr, Tlayd, M <: AbstractSpec{Material}} |
| 78 | + return CircStrandedSpec{P, Tcmp, Trw, Tnw, Tlayr, Tlayd, M}( |
| 79 | + cmp, r_w, n_w, lay_r, lay_d, mat, |
| 80 | + ) |
| 81 | +end |
0 commit comments