|
2 | 2 | # Misc. Internal Tools
|
3 | 3 | ################################################################################
|
4 | 4 |
|
5 |
| -# Calculate Gauss-Legendre nodes/weights and convert to type T |
6 |
| -function _gausslegendre(T, n) |
7 |
| - xs, ws = FastGaussQuadrature.gausslegendre(n) |
8 |
| - return T.(xs), T.(ws) |
9 |
| -end |
10 |
| - |
11 | 5 | # Common error message structure
|
12 | 6 | function _error_unsupported_combination(geometry, rule)
|
13 | 7 | msg = "Integrating a $geometry using a $rule rule not supported."
|
14 | 8 | throw(ArgumentError(msg))
|
15 | 9 | end
|
16 | 10 |
|
17 |
| -# Return an NTuple{N, T} of zeros; same interface as Base.zeros() but faster |
18 |
| -_zeros(T::DataType, N::Int64) = ntuple(_ -> zero(T), N) |
19 |
| -_zeros(N::Int) = _zeros(Float64, N) |
20 |
| - |
21 |
| -# Return an NTuple{N, T} of ones; same interface as Base.ones() but faster |
22 |
| -_ones(T::DataType, N::Int64) = ntuple(_ -> one(T), N) |
23 |
| -_ones(N::Int) = _ones(Float64, N) |
24 |
| - |
25 | 11 | ################################################################################
|
26 | 12 | # DifferentiationMethod
|
27 | 13 | ################################################################################
|
28 | 14 |
|
29 | 15 | # Return the default DifferentiationMethod instance for a particular geometry type
|
30 |
| -function _default_method( |
| 16 | +function _default_diff_method( |
31 | 17 | g::Type{G}
|
32 | 18 | ) where {G <: Geometry}
|
33 | 19 | return FiniteDifference()
|
34 | 20 | end
|
35 | 21 |
|
36 | 22 | # Return the default DifferentiationMethod instance for a particular geometry instance
|
37 |
| -_default_method(g::G) where {G <: Geometry} = _default_method(G) |
| 23 | +_default_diff_method(g::G) where {G <: Geometry} = _default_diff_method(G) |
38 | 24 |
|
39 | 25 | ################################################################################
|
40 |
| -# CliffordNumbers and Units |
| 26 | +# Numerical Tools |
41 | 27 | ################################################################################
|
42 | 28 |
|
43 |
| -# Meshes.Vec -> Unitful.Quantity{CliffordNumber.KVector} |
| 29 | +""" |
| 30 | + _KVector(v::Meshes.Vec) -> Unitful.Quantity{CliffordNumbers.KVector} |
| 31 | +
|
| 32 | +Convert a `Vec` to a Unitful KVector. |
| 33 | +""" |
44 | 34 | function _KVector(v::Meshes.Vec{Dim, T}) where {Dim, T}
|
45 | 35 | ucoords = Iterators.map(Unitful.ustrip, v.coords)
|
46 | 36 | return CliffordNumbers.KVector{1, VGA(Dim)}(ucoords...) * _units(v)
|
47 | 37 | end
|
48 | 38 |
|
49 |
| -# Extract the length units used by the CRS of a Geometry |
| 39 | +""" |
| 40 | + _units(geometry) |
| 41 | +
|
| 42 | +Return the Unitful.jl units associated with a particular `geometry`. |
| 43 | +""" |
50 | 44 | _units(::Geometry{M, CRS}) where {M, CRS} = Unitful.unit(CoordRefSystems.lentype(CRS))
|
51 | 45 | _units(::Meshes.Vec{Dim, T}) where {Dim, T} = Unitful.unit(T)
|
| 46 | + |
| 47 | +""" |
| 48 | + _zeros(T = Float64, N) |
| 49 | +
|
| 50 | +Return an `NTuple{N, T}` filled with zeros. This method avoids allocating an array, which |
| 51 | +happens when using `Base.zeros`. |
| 52 | +""" |
| 53 | +_zeros(T::DataType, N::Int64) = ntuple(_ -> zero(T), N) |
| 54 | +_zeros(N::Int) = _zeros(Float64, N) |
| 55 | + |
| 56 | +""" |
| 57 | + _ones(T = Float64, N) |
| 58 | +
|
| 59 | +Return an `NTuple{N, T}` filled with ones. This method avoids allocating an array, which |
| 60 | +happens when using `Base.ones`. |
| 61 | +""" |
| 62 | +_ones(T::DataType, N::Int64) = ntuple(_ -> one(T), N) |
| 63 | +_ones(N::Int) = _ones(Float64, N) |
0 commit comments