Skip to content

Commit

Permalink
fix typos, minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
juddmehr committed Sep 28, 2024
1 parent 441e0b2 commit 3018693
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 21 deletions.
11 changes: 6 additions & 5 deletions src/analysis/analyses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
return_inputs=false,
)
Analyze ducted_rotor, including preprocessing.
Analyze `ducted_rotor`, including preprocessing.
# Arguments
- `ducted_rotor::DuctedRotor` : DuctedRotor input object (see docstring for `DuctedRotor` type)
Expand Down Expand Up @@ -109,7 +109,7 @@ end
solve_container_caching=nothing,
)
Analyze ducted_rotor, assuming `setup_analysis` has been called and the outputs thereof are being passed in here.
Analyze `ducted_rotor`, assuming `setup_analysis` has been called and the outputs thereof are being passed in here.
# Arguments
- `ducted_rotor::DuctedRotor` : DuctedRotor input object (see docstring for `DuctedRotor` type)
Expand Down Expand Up @@ -230,7 +230,7 @@ end
return_inputs=false,
)
Analyze ducted_rotor, including preprocessing, for a set of operating points.
Analyze `ducted_rotor`, including preprocessing, for a set of operating points.
# Arguments
- `ducted_rotor::DuctedRotor` : DuctedRotor input object
Expand Down Expand Up @@ -285,7 +285,8 @@ function analyze(
#TODO: write a function that returns the same as outs below, but all zeros
#TODO: probably just call the post-process function directly and return a reset_container! of the output
return [],#zero_outputs(),
(; solve_parameter_tuple..., ivb, airfoils, idmaps, panels, problem_dimensions),
# (; solve_parameter_tuple..., ivb, airfoils, idmaps, panels, problem_dimensions),
(;),
false
end

Expand Down Expand Up @@ -323,7 +324,7 @@ end
solve_container_caching=nothing,
)
Analyze ducted_rotor, assuming `setup_analysis` has been called and the inputs are being passed in here.
Analyze `ducted_rotor`, assuming `setup_analysis` has been called and the inputs are being passed in here.
# Arguments
- `ducted_rotor::DuctedRotor` : DuctedRotor input object
Expand Down
10 changes: 5 additions & 5 deletions src/postprocess/boundary_layer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,12 @@ function solve_turbulent_boundary_layer_rk4!(f, init, params, svec; s_init_defau
end

if sep[1] == true
u1sep = FLOWMath(Cfs[(sepid - 1):sepid], us[1, (sepid - 1):sepid], 0.0)
u2sep = FLOWMath(Cfs[(sepid - 1):sepid], us[2, (sepid - 1):sepid], 0.0)
u3sep = FLOWMath(Cfs[(sepid - 1):sepid], us[3, (sepid - 1):sepid], 0.0)
u1sep = FLOWMath.akima(Cfs[(sepid - 1):sepid], us[1, (sepid - 1):sepid], 0.0)
u2sep = FLOWMath.akima(Cfs[(sepid - 1):sepid], us[2, (sepid - 1):sepid], 0.0)
u3sep = FLOWMath.akima(Cfs[(sepid - 1):sepid], us[3, (sepid - 1):sepid], 0.0)
usep = [u1sep; u2sep; u3sep]
H12sep = FLOWMath(Cfs[(sepid - 1):sepid], H12s[(sepid - 1):sepid], 0.0)
ssep = FLOWMath(Cfs[(sepid - 1):sepid], svec[(sepid - 1):sepid], 0.0)
H12sep = FLOWMath.akima(Cfs[(sepid - 1):sepid], H12s[(sepid - 1):sepid], 0.0)
ssep = FLOWMath.akima(Cfs[(sepid - 1):sepid], svec[(sepid - 1):sepid], 0.0)
else
usep = us[:, end]
H12sep = H12s[end]
Expand Down
1 change: 1 addition & 0 deletions src/preprocess/geometry/elliptic_grid_residuals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ function solve_elliptic_grid(x, p)
method=p.algorithm,
autodiff=p.autodiff,
linsolve=(x, A, b) -> x .= ImplicitAD.implicit_linear(A, b),
# linesearch=LineSearches.Backtracking(),
ftol=p.atol,
iterations=p.iteration_limit,
show_trace=p.verbose,
Expand Down
11 changes: 11 additions & 0 deletions src/preprocess/geometry/wake_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,17 @@ function relax_grid!(
println(tabchar^ntab * "Solving Elliptic Grid System using $(grid_solver_options.algorithm) Method")
end

# # precondition
# relax_grid!(
# wake_grid;
# iteration_limit=grid_solver_options.iteration_limit,
# atol=grid_solver_options.atol,
# converged=grid_solver_options.converged,
# verbose=verbose,
# tabchar="\t",
# ntab=1,
# )

# solve
solve_elliptic_grid!(
wake_grid;
Expand Down
28 changes: 20 additions & 8 deletions src/process/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function solve(
TF = eltype(sensitivity_parameters)

# resid = 999 * ones(TF, length(state_variables))
resid = 999*ones(TF,2)
resid = 999 * ones(TF, 2)
conv = @view(solver_options.converged[multipoint_index[]])
iter = @view(solver_options.iterations[multipoint_index[]]) .= 0

Expand Down Expand Up @@ -887,8 +887,13 @@ function solve(
# If there is only one solver, or if the first solver converged, return the solution
if length(solver_options.solvers) == 1 ||
solver_options.solvers[1].converged[const_cache.multipoint_index[]]
solver_options.converged[const_cache.multipoint_index[]] = solver_options.solvers[1].converged[const_cache.multipoint_index[]]
solver_options.iterations[const_cache.multipoint_index[]] = solver_options.solvers[1].iterations[const_cache.multipoint_index[]]

# set converged flags for the first solver across all solvers
solver_options.converged[:, const_cache.multipoint_index[]] .= solver_options.solvers[1].converged[const_cache.multipoint_index[]]

# set iteration count for only the first solver
solver_options.iterations[1, const_cache.multipoint_index[]] = solver_options.solvers[1].iterations[const_cache.multipoint_index[]]

return solution
end

Expand All @@ -902,25 +907,32 @@ function solve(
initial_guess=initial_guess,
)

# set this and the remaining convergence flags
solver_options.converged[(s + 1):end, const_cache.multipoint_index[]] .= sopt.converged[const_cache.multipoint_index[]]

# set this iteration count
solver_options.iterations[s + 1, const_cache.multipoint_index[]] = sopt.iterations[const_cache.multipoint_index[]]

# if the solver converged, return
if sopt.converged[const_cache.multipoint_index[]]
solver_options.converged[s + 1, const_cache.multipoint_index[]] = sopt.converged[const_cache.multipoint_index[]]
solver_options.iterations[s + 1, const_cache.multipoint_index[]] = sopt.iterations[const_cache.multipoint_index[]]
return solution
else
solver_options.converged[s + 1, const_cache.multipoint_index[]] = solver_options.solvers[end].converged[const_cache.multipoint_index[]]
solver_options.iterations[s + 1, const_cache.multipoint_index[]] = solver_options.solvers[end].iterations[const_cache.multipoint_index[]]
end
end

# run final solver
solution = solve(
solver_options.solvers[end],
sensitivity_parameters,
(; const_cache..., solver_options=solver_options.solvers[end]);
initial_guess=initial_guess,
)

# set final convergence flag
solver_options.converged[end, const_cache.multipoint_index[]] = solver_options.solvers[end].converged[const_cache.multipoint_index[]]

# set final iteration count
solver_options.iterations[end, const_cache.multipoint_index[]] = solver_options.solvers[end].iterations[const_cache.multipoint_index[]]

return solution
else

Expand Down
6 changes: 3 additions & 3 deletions src/utilities/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,9 @@ Options for SLOR + Newton elliptic grid solver.
- `iterations::AbstractArray{Int} = [0]` : iteration counter
"""
@kwdef struct GridSolverOptions{TB,TF,TI,TSym} <: GridSolverOptionsType
iteration_limit::TI = 100
atol::TF = 1e-10
algorithm::TSym = :trust_region
iteration_limit::TI = 10
atol::TF = 2e-10
algorithm::TSym = :newton
autodiff::TSym = :forward
converged::AbstractArray{TB} = [false]
iterations::AbstractArray{TI} = [0]
Expand Down

0 comments on commit 3018693

Please sign in to comment.