Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
optimizer_factory.f90
Go to the documentation of this file.
1
2
3submodule(optimizer) optimizer_factory_mod
4 use json_utils, only: json_get, json_get_or_default
5 use utils, only: neko_type_error
6
8
9 implicit none
10
12 character(len=25), parameter :: KNOWN_TYPES(1) = [ character(len=25) :: &
13 "mma"]
14
15contains
16
17 ! -------------------------------------------------------------------------- !
18 ! Interfaces for the factory functions
19
29 module subroutine optimizer_factory(object, parameters, problem, design, &
31 class(optimizer_t), allocatable, intent(inout) :: object
32 type(json_file), intent(inout) :: parameters
33 class(problem_t), intent(in) :: problem
34 class(design_t), intent(in) :: design
35 class(simulation_t), intent(in) :: simulation
36
37 character(len=:), allocatable :: type
38 integer :: max_iterations
39 real(kind=rp) :: tolerance
40
41 if (allocated(object)) then
42 call object%free()
43 deallocate(object)
44 end if
45
46 ! Get the type of the optimizer
47 call json_get(parameters, "optimization.solver.type", type)
48 call json_get_or_default(parameters, "optimization.solver.max_iterations", &
49 max_iterations, 100)
50 call json_get_or_default(parameters, "optimization.solver.tolerance", &
51 tolerance, 1.0e-3_rp)
52
53 ! Select the optimizer type
54 select case (trim(type))
55 case ("mma")
56 allocate(mma_optimizer_t::object)
57
58 case default
59 call neko_type_error("Optimizer", type, KNOWN_TYPES)
60 end select
61
62 call object%init_from_json(parameters, problem, design, simulation, &
63 max_iterations, tolerance)
64 end subroutine optimizer_factory
65
66
67end submodule optimizer_factory_mod
Implements the design_t.
Definition design.f90:34
Module for handling the optimization problem.
Definition problem.f90:35
Implements the steady_problem_t type.