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
112 if (present(mask_name)) then
113 if (mask_name .ne. "") then
114 this%has_mask = .true.
115 this%mask => neko_point_zone_registry%get_point_zone(mask_name)
116 end if
117 end if
118
119 if (present(start_time)) then
120 this%start_time = start_time
121 else
122 this%start_time = 0.0_rp
123 end if
124
125 if (present(end_time)) then
126 this%end_time = end_time
127 else
128 this%end_time = huge(0.0_rp)
129 end if
130
131 end subroutine constraint_init_base
132
134 subroutine constraint_free_base(this)
135 class(constraint_t), target, intent(inout) :: this
136
137 this%name = ""
138
139 this%value = 0.0_rp
140 this%value_weight = 0.0_rp
141 this%sensitivity_weight = 0.0_rp
142 this%start_time = 0.0_rp
143 this%end_time = huge(0.0_rp)
144 call this%sensitivity%free()
145
146 this%has_mask = .false.
147 if (associated(this%mask)) nullify(this%mask)
148
149 end subroutine constraint_free_base
150
151 ! -------------------------------------------------------------------------- !
152 ! Implementations for the wrapper
153
155 subroutine constraint_wrapper_free(this)
156 class(constraint_wrapper_t), intent(inout) :: this
157 if (allocated(this%constraint)) then
158 call this%constraint%free()
159 deallocate(this%constraint)
160 end if
161 end subroutine constraint_wrapper_free
162
163end module constraint
164
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