Skip to content

Commit 8e1c962

Browse files
committed
add more docstrings
1 parent 76fb36f commit 8e1c962

File tree

4 files changed

+76
-44
lines changed

4 files changed

+76
-44
lines changed

docs/src/DuctAPE/private_api.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,18 @@ DuctAPE.extract_state_variables
241241
```@docs
242242
DuctAPE.post_process
243243
```
244+
TODO: add the rest of the post-process functions
244245

245246
## Utility Functions
246247
```@docs
247248
DuctAPE.promote_propulosor_type
249+
DuctAPE.update_operating_point!
250+
DuctAPE.isscalar
251+
DuctAPE.dot
252+
DuctAPE.norm
253+
DuctAPE.cross2mag
254+
DuctAPE.linear_transform
255+
DuctAPE.extract_primals!
256+
DuctAPE.lfs
257+
DuctAPE.reset_containers!
248258
```
249-
TODO; add contents of update-propulsor.jl here
250-
TODO; add contents of misc.jl

src/process/residuals/CSORresidual.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,19 @@ end
100100
Description
101101
102102
# Arguments
103-
- `resid::type` :
104-
- `solver_options::type` :
105-
- `solve_containers::type` :
106-
- `Gamr::type` :
107-
- `sigr::type` :
108-
- `gamw::type` :
109-
- `operating_point::type` :
110-
- `ivr::type` :
111-
- `ivw::type` :
112-
- `linsys::type` :
113-
- `blade_elements::type` :
114-
- `wakeK::type` :
115-
- `idmaps::type` :;
103+
- `resid::Vector{Float}` : the residual vector
104+
- `solver_options::SolverOptionsType` : solver options (used for convergence criteria)
105+
- `solve_containers::NamedTuple` : cache for intermediate solve values
106+
- `Gamr::type` : Blade element circulation strengths
107+
- `sigr::type` : Rotor source panel strengths
108+
- `gamw::type` : Wake vortex panel strengths
109+
- `operating_point::NamedTuple` : Named tuple containing operating_point information
110+
- `ivr::NamedTuple` : unit induced velocities on rotor(s)
111+
- `ivw::NamedTuple` : unit induced velocities on wake
112+
- `linsys::NamedTuple` : vectors and matricies comprising the panel method linear system
113+
- `blade_elements::NamedTuple` : blade element geometry and airfoil polar information
114+
- `wakeK::Vector{Float}` : geometric constants used in caculating wake strengths
115+
- `idmaps::NamedTuple` : index maps used throughout solve
116116
117117
# Keyword Arguments
118118
- `verbose::Bool=false` : Flag to print verbose statements

src/utilities/misc.jl

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
# - Functions to check if the input is a scalar - #
22
import Base.BroadcastStyle
3+
"""
4+
isscalar(x::T) where {T} = isscalar(T)
5+
isscalar(::Type{T}) where {T} = BroadcastStyle(T) isa Broadcast.DefaultArrayStyle{0}
6+
7+
Determines if the input is a scalar. Note that `Base.BroadcastStyle` is imported.
8+
"""
39
isscalar(x::T) where {T} = isscalar(T)
410
isscalar(::Type{T}) where {T} = BroadcastStyle(T) isa Broadcast.DefaultArrayStyle{0}
511

6-
# """
7-
# """
8-
# import Base.getproperty
9-
# function Base.getproperty(obj::AbstractVector{<:NamedTuple}, sym::Symbol)
10-
# return getfield.(obj, sym)
11-
# end
12-
13-
# - Function for adding in xlocations - #
14-
# from https://stackoverflow.com/questions/25678112/insert-item-into-a-sorted-list-with-julia-with-and-without-duplicates
15-
function insert_and_dedup!(v, x)
16-
for i in eachindex(x)
17-
# find ranges and replace with discrete values (thus deleting duplicates if present)
18-
v = (splice!(v, searchsorted(v, x[i]), x[i]); v)
19-
end
20-
end
12+
"""
13+
printval(text, val)
2114
15+
Used for debugging; prints values of `val`, preceeded by `text` for floats, strings, ints and ForwardDiff duals without the user having to know if duals are being used or not.
16+
"""
2217
function printval(text, val)
2318
if eltype(val) == Float64
2419
println(text, val, " (Float)")
@@ -36,25 +31,39 @@ function printval(text, val)
3631
return nothing
3732
end
3833

39-
# dot product
34+
"""
35+
dot(A, B) = sum(a * b for (a, b) in zip(A, B))
36+
37+
A faster dot product.
38+
"""
4039
dot(A, B) = sum(a * b for (a, b) in zip(A, B))
41-
# norm of vector
40+
41+
"""
42+
norm(A) = sqrt(mapreduce(x -> x^2, +, A))
43+
44+
A faster 2-norm.
45+
"""
4246
norm(A) = sqrt(mapreduce(x -> x^2, +, A))
43-
# 2D "cross product" magnitude
47+
48+
"""
49+
cross2mag(A, B) = A[1] * B[2] - A[2] * B[1]
50+
51+
2D "cross product" magnitude
52+
"""
4453
cross2mag(A, B) = A[1] * B[2] - A[2] * B[1]
4554

4655
"""
4756
linear_transform(range1, range2, values)
4857
49-
Linear transfrom of values from range (source_range[1], raend) to (target_range[1], target_range[end])
58+
Linear transfrom of values from range `(source_range[1], source_range[end])` to `(target_range[1], target_range[end])`
5059
51-
# Arguments:
52-
- `source_range::Vector{Float{` : range values come from
53-
- `target_range::Vector{Float}` : range onto which we are transforming
54-
- `source_values::Array{Float}` : array of source_values to transform
60+
# Arguments
61+
- `source_range::Vector{Float}` : range values come from (can also be a Tuple)
62+
- `target_range::Vector{Float}` : range onto which we are transforming (can also be a Tuple)
63+
- `source_values::Array{Float}` : array of source values to transform
5564
56-
# Returns:
57-
- `target_values::Array{Float}` : array of transformed source_values onto target range
65+
# Returns
66+
- `target_values::Array{Float}` : array of transformed sourcevalues onto target range
5867
"""
5968
function linear_transform(source_range, target_range, source_values)
6069
return target_range[1] .+
@@ -63,6 +72,9 @@ function linear_transform(source_range, target_range, source_values)
6372
end
6473

6574
"""
75+
extract_primals!(Avalue, A::AbstractMatrix{T}) where {T}
76+
77+
Extracts primals of A and places them in Avalue.
6678
"""
6779
function extract_primals!(Avalue, A::AbstractMatrix{T}) where {T}
6880
if T <: ForwardDiff.Dual #|| T<:ReverseDiff.TrackedReal # Automatic differentiation case
@@ -81,8 +93,9 @@ function extract_primals!(Avalue, A::AbstractMatrix{T}) where {T}
8193
end
8294

8395
"""
84-
length from size
85-
move to utilities
96+
lfs(shape)
97+
98+
Determines length from shape (output of `size` function).
8699
"""
87100
function lfs(shape)
88101
if length(shape) == 1
@@ -93,8 +106,9 @@ function lfs(shape)
93106
end
94107

95108
"""
96-
note: containers must be Arrays, structs of arrays, or tuples of arrays
97-
move to utilities
109+
reset_containers!(containers; exception_keys=[])
110+
111+
Resets all fields (not incluing any contained in exception keys) of containers---which must be arrays, structs of arrays, or tuples of arrays---to zeros.
98112
"""
99113
function reset_containers!(c; exception_keys=[])
100114
if typeof(c) <: AbstractArray
@@ -132,6 +146,9 @@ Convenience function for promoting types based on any potential elements of the
132146
133147
# Arguments
134148
- `propulsor::Propulsor` : the propulsor input
149+
150+
# Returns
151+
- `TP::Type` : the promoted type
135152
"""
136153
function promote_propulosor_type(p)
137154
return promote_type(

src/utilities/update_propulsor.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
"""
2+
update_operating_point!(op_old, op_new)
3+
4+
Overwrites all the values of an OperatingPoint object with another OperatingPoint object's values (or NamedTuple with the same field names).
5+
6+
# Arguments
7+
- `op_old::OperatingPoint` : the OperatingPoint to be overwritten (can also be a NamedTuple with the same field names as an OperatingPoint).
8+
- `op_new::OperatingPoint` : the OperatingPoint values to be used (can also be a NamedTuple with the same field names as an OperatingPoint).
29
"""
310
function update_operating_point!(op_old, op_new)
411
op_old.Vinf .= op_new.Vinf

0 commit comments

Comments
 (0)