Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
optimizer.f90
1module optimizer
2 !-----------------------------------------------------------!
3 ! An abstract type optimizer is defined to solve the design !
4 ! optimization problem using a specific type of optimizer !
5 ! algorithm, e.g. MMA. !
6 !-----------------------------------------------------------!
7
8 use json_module, only: json_file
10 use problem, only: problem_t
11 use design, only: design_t
12 use num_types, only: rp
13 use csv_file, only: csv_file_t
14 implicit none
15 private
16
18 type, abstract :: optimizer_t
19 private
20
22 integer, public :: max_iterations
24 real(kind=rp), public :: tolerance
26 type(csv_file_t), public :: logger
27
28 contains
30 procedure(optimizer_init_from_json), pass(this), public, deferred :: &
31 init_from_json
33 procedure(optimizer_run), pass(this), public, deferred :: run
35 procedure(optimizer_free), pass(this), public, deferred :: free
36
38 procedure(optimizer_validate), pass(this), public, deferred :: validate
39
41 procedure, pass(this) :: init_base => optimizer_init_base
42
43
44 end type optimizer_t
45
46 ! -------------------------------------------------------------------------- !
47 ! Interface for the optimizer module.
48
49 abstract interface
50
51 subroutine optimizer_init_from_json(this, parameters, problem, design, &
52 max_iterations, tolerance, simulation)
53 import optimizer_t, json_file, simulation_t, problem_t, design_t, rp
54 class(optimizer_t), intent(inout) :: this
55 type(json_file), intent(inout) :: parameters
56 class(problem_t), intent(in) :: problem
57 class(design_t), intent(in) :: design
58 integer, intent(in) :: max_iterations
59 real(kind=rp), intent(in) :: tolerance
60 type(simulation_t), optional, intent(in) :: simulation
61 end subroutine optimizer_init_from_json
62
64 subroutine optimizer_run(this, problem, design, simulation)
66 class(optimizer_t), intent(inout) :: this
67 class(problem_t), intent(inout) :: problem
68 class(design_t), intent(inout) :: design
69 type(simulation_t), optional, intent(inout) :: simulation
70 end subroutine optimizer_run
71
73 subroutine optimizer_free(this)
74 import optimizer_t
75 class(optimizer_t), intent(inout) :: this
76 end subroutine optimizer_free
77
79 subroutine optimizer_validate(this, problem, design)
81 class(optimizer_t), intent(inout) :: this
82 class(problem_t), intent(in) :: problem
83 class(design_t), intent(in) :: design
84 end subroutine optimizer_validate
85 end interface
86
87 ! -------------------------------------------------------------------------- !
88 ! Interfaces for the factory functions
89
97 module subroutine optimizer_factory(object, parameters, problem, design, &
98 simulation)
99 class(optimizer_t), allocatable, intent(inout) :: object
100 type(json_file), intent(inout) :: parameters
101 class(problem_t), intent(in) :: problem
102 class(design_t), intent(in) :: design
103 class(simulation_t), optional, intent(in) :: simulation
104 end subroutine optimizer_factory
105 end interface optimizer_factory
106
107 public :: optimizer_t, optimizer_factory
108
109contains
110
115 subroutine optimizer_init_base(this, max_iterations, tolerance)
116 class(optimizer_t), intent(inout) :: this
117 integer, intent(in) :: max_iterations
118 real(kind=rp), intent(in) :: tolerance
119
120 this%max_iterations = max_iterations
121 this%tolerance = tolerance
122
123 end subroutine optimizer_init_base
124
125end module optimizer
Factory function for the optimizer.
Definition optimizer.f90:96
Interface for optimizer initialization.
Definition optimizer.f90:51
Implements the design_t.
Definition design.f90:34
Module for handling the optimization problem.
Definition problem.f90:35
Implements the steady_problem_t type.
An abstract design type.
Definition design.f90:52
Abstract optimizer class.
Definition optimizer.f90:18
The abstract problem type.
Definition problem.f90:61