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 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 type(simulation_t), optional, intent(in) :: simulation
59 end subroutine optimizer_init_from_json
60
62 subroutine optimizer_run(this, problem, design, simulation)
64 class(optimizer_t), intent(inout) :: this
65 class(problem_t), intent(inout) :: problem
66 class(design_t), intent(inout) :: design
67 type(simulation_t), optional, intent(inout) :: simulation
68 end subroutine optimizer_run
69
71 subroutine optimizer_free(this)
72 import optimizer_t
73 class(optimizer_t), intent(inout) :: this
74 end subroutine optimizer_free
75
77 subroutine optimizer_validate(this, problem, design)
79 class(optimizer_t), intent(inout) :: this
80 class(problem_t), intent(in) :: problem
81 class(design_t), intent(in) :: design
82 end subroutine optimizer_validate
83 end interface
84
85 ! -------------------------------------------------------------------------- !
86 ! Interfaces for the factory functions
87
95 module subroutine optimizer_factory(object, parameters, problem, design, &
96 simulation)
97 class(optimizer_t), allocatable, intent(inout) :: object
98 type(json_file), intent(inout) :: parameters
99 class(problem_t), intent(inout) :: problem
100 class(design_t), intent(in) :: design
101 type(simulation_t), optional, intent(in) :: simulation
102 end subroutine optimizer_factory
103 end interface optimizer_factory
104
105 public :: optimizer_t, optimizer_factory
106
107contains
108
113 subroutine optimizer_init_base(this, max_iterations, tolerance)
114 class(optimizer_t), intent(inout) :: this
115 integer, intent(in) :: max_iterations
116 real(kind=rp), intent(in) :: tolerance
117
118 this%max_iterations = max_iterations
119 this%tolerance = tolerance
120
121 end subroutine optimizer_init_base
122
123end module optimizer
Factory function for the optimizer.
Definition optimizer.f90:94
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:62