Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
constraint.f90
Go to the documentation of this file.
1
34
38 use simulation_m, only: simulation_t
39 use design, only: design_t
40 use num_types, only: rp
41 use point_zone_registry, only: neko_point_zone_registry
42 use json_module, only: json_file
43 implicit none
44 private
45
47
51 type, abstract, extends(base_functional_t) :: constraint_t
52 contains
53
55 procedure, pass(this) :: init_base => constraint_init_base
57 procedure, pass(this) :: free_base => constraint_free_base
58
59 end type constraint_t
60
63 class(constraint_t), allocatable :: constraint
64 contains
65 procedure, pass(this) :: free => constraint_wrapper_free
67
68 ! -------------------------------------------------------------------------- !
69 ! Explicit interfaces
70
78 module subroutine constraint_factory(object, json, design, simulation)
79 class(constraint_t), allocatable, intent(inout) :: object
80 type(json_file), intent(inout) :: json
81 class(design_t), intent(in) :: design
82 type(simulation_t), target, optional, intent(inout) :: simulation
83 end subroutine constraint_factory
84 end interface constraint_factory
85
86contains
87
88 ! -------------------------------------------------------------------------- !
89 ! Implementations for the base class
90
98 subroutine constraint_init_base(this, name, design_size, mask_name, &
99 start_time, end_time)
100 class(constraint_t), intent(inout) :: this
101 character(len=*), intent(in) :: name
102 integer, intent(in) :: design_size
103 character(len=*), intent(in), optional :: mask_name
104 real(kind=rp), intent(in), optional :: start_time
105 real(kind=rp), intent(in), optional :: end_time
106
107 call this%free_base()
108
109 this%name = name
110 call this%sensitivity%init(design_size)
111 call this%sensitivity_old%init(design_size)
112
113 if (present(mask_name)) then
114 if (mask_name .ne. "") then
115 this%has_mask = .true.
116 this%mask => neko_point_zone_registry%get_point_zone(mask_name)
117 end if
118 end if
119
120 if (present(start_time)) then
121 this%start_time = start_time
122 else
123 this%start_time = 0.0_rp
124 end if
125
126 if (present(end_time)) then
127 this%end_time = end_time
128 else
129 this%end_time = huge(0.0_rp)
130 end if
131
132 end subroutine constraint_init_base
133
135 subroutine constraint_free_base(this)
136 class(constraint_t), target, intent(inout) :: this
137
138 this%name = ""
139
140 this%value = 0.0_rp
141 this%value_old = 0.0_rp
142 this%start_time = 0.0_rp
143 this%end_time = huge(0.0_rp)
144 call this%sensitivity%free()
145 call this%sensitivity_old%free()
146
147 this%has_mask = .false.
148 if (associated(this%mask)) nullify(this%mask)
149
150 end subroutine constraint_free_base
151
152 ! -------------------------------------------------------------------------- !
153 ! Implementations for the wrapper
154
156 subroutine constraint_wrapper_free(this)
157 class(constraint_wrapper_t), intent(inout) :: this
158 if (allocated(this%constraint)) then
159 call this%constraint%free()
160 deallocate(this%constraint)
161 end if
162 end subroutine constraint_wrapper_free
163
164end module constraint
165
Factory function Allocates and initializes an constraint function object.
Defines the abstract the base_functional_t type.
Implements the constraint_t type.
Implements the design_t.
Definition design.f90:36
Implements the steady_problem_t type.
The abstract constraint type.
Wrapper for constraints for use in lists.
An abstract design type.
Definition design.f90:53