Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
optimizer.f90
Go to the documentation of this file.
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
9 use simulation, only: simulation_t
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, pass(this) :: init_base => optimizer_init_base
39
40
41 end type optimizer_t
42
43 ! -------------------------------------------------------------------------- !
44 ! Interface for the optimizer module.
45
46 abstract interface
47
48 subroutine optimizer_init_from_json(this, parameters, problem, design, &
49 simulation, max_iterations, tolerance)
50 import optimizer_t, json_file, simulation_t, problem_t, design_t, rp
51 class(optimizer_t), intent(inout) :: this
52 type(json_file), intent(inout) :: parameters
53 class(problem_t), intent(in) :: problem
54 class(design_t), intent(in) :: design
55 type(simulation_t), intent(in) :: simulation
56 integer, intent(in) :: max_iterations
57 real(kind=rp), intent(in) :: tolerance
58 end subroutine optimizer_init_from_json
59
61 subroutine optimizer_run(this, problem, design, simulation)
63 class(optimizer_t), intent(inout) :: this
64 class(problem_t), intent(inout) :: problem
65 class(design_t), intent(inout) :: design
66 type(simulation_t), intent(inout) :: simulation
67 end subroutine optimizer_run
68
70 subroutine optimizer_free(this)
71 import optimizer_t
72 class(optimizer_t), intent(inout) :: this
73 end subroutine optimizer_free
74 end interface
75
76 ! -------------------------------------------------------------------------- !
77 ! Interfaces for the factory functions
78
79 interface
80
86 module subroutine optimizer_factory(object, parameters, problem, design, &
88 class(optimizer_t), allocatable, intent(inout) :: object
89 type(json_file), intent(inout) :: parameters
90 class(problem_t), intent(in) :: problem
91 class(design_t), intent(in) :: design
92 class(simulation_t), intent(in) :: simulation
93 end subroutine optimizer_factory
94 end interface
95
96 public :: optimizer_t, optimizer_factory
97
98contains
99
104 subroutine optimizer_init_base(this, max_iterations, tolerance)
105 class(optimizer_t), intent(inout) :: this
106 integer, intent(in) :: max_iterations
107 real(kind=rp), intent(in) :: tolerance
108
109 this%max_iterations = max_iterations
110 this%tolerance = tolerance
111
112 end subroutine optimizer_init_base
113
114end module optimizer
Interface for freeing resources.
Definition optimizer.f90:70
Interface for optimizer initialization.
Definition optimizer.f90:48
Interface for running the optimization loop.
Definition optimizer.f90:61
Implements the design_t.
Definition design.f90:34
subroutine optimizer_init_base(this, max_iterations, tolerance)
Factory function for the optimizer.
Module for handling the optimization problem.
Definition problem.f90:35
Implements the steady_problem_t type.
An abstract design type.
Definition design.f90:48
Abstract optimizer class.
Definition optimizer.f90:18
The abstract problem type.
Definition problem.f90:61