Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
objective.f90
Go to the documentation of this file.
1
33
37 use simulation, only: simulation_t
38 use design, only: design_t
39 use num_types, only: rp
40 use point_zone_registry, only: neko_point_zone_registry
41 use json_module, only: json_file
42 implicit none
43 private
44
45 public :: objective_t, objective_factory, objective_wrapper_t
46
51 type, abstract, extends(base_functional_t) :: objective_t
52 real(kind=rp) :: weight = 1.0_rp
53
54 contains
55
57 procedure, pass(this) :: init_base => objective_init_base
59 procedure, pass(this) :: free_base => objective_free_base
60
61 end type objective_t
62
65 class(objective_t), allocatable :: objective
66 contains
67 procedure, pass(this) :: free => objective_wrapper_free
68 end type objective_wrapper_t
69
70 ! -------------------------------------------------------------------------- !
71 ! Explicit interfaces
72
74 interface
75 module subroutine objective_factory(object, json, design, simulation)
76 class(objective_t), allocatable, intent(inout) :: object
77 type(json_file), intent(inout) :: json
78 class(design_t), intent(in) :: design
79 type(simulation_t), target, intent(inout) :: simulation
80 end subroutine objective_factory
81 end interface
82
83contains
84
85 ! -------------------------------------------------------------------------- !
86 ! Implementations for the base class
87
92 subroutine objective_init_base(this, name, design_size, weight, mask_name)
93 class(objective_t), intent(inout) :: this
94 character(len=*), intent(in) :: name
95 integer, intent(in) :: design_size
96 real(kind=rp), intent(in) :: weight
97 character(len=*), intent(in), optional :: mask_name
98
99 this%name = name
100 this%value = 0.0_rp
101 call this%sensitivity%init(design_size)
102
103 this%weight = weight
104
105 this%has_mask = .false.
106 if (trim(mask_name) .ne. "") then
107 this%has_mask = .true.
108 this%mask => neko_point_zone_registry%get_point_zone(mask_name)
109 end if
110
111 end subroutine objective_init_base
112
114 subroutine objective_free_base(this)
115 class(objective_t), target, intent(inout) :: this
116
117 this%value = 0.0_rp
118 call this%sensitivity%free()
119 this%weight = 1.0_rp
120 this%has_mask = .false.
121 if (associated(this%mask)) nullify(this%mask)
122
123 end subroutine objective_free_base
124
125 ! -------------------------------------------------------------------------- !
126 ! Implementations for the wrapper
127
129 subroutine objective_wrapper_free(this)
130 class(objective_wrapper_t), intent(inout) :: this
131 if (allocated(this%objective)) then
132 call this%objective%free()
133 deallocate(this%objective)
134 end if
135 end subroutine objective_wrapper_free
136
137end module objective
138
Defines the abstract the base_functional_t type.
Implements the design_t.
Definition design.f90:34
Implements the objective_t type.
Definition objective.f90:35
subroutine objective_wrapper_free(this)
Free the objective wrapper.
subroutine objective_free_base(this)
Free the base class.
subroutine objective_init_base(this, name, design_size, weight, mask_name)
Factory function interface.
Definition objective.f90:93
Implements the steady_problem_t type.
An abstract design type.
Definition design.f90:48
The abstract objective type.
Definition objective.f90:51
Wrapper for objectives for use in lists.
Definition objective.f90:64