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
96 subroutine constraint_init_base(this, name, design_size, mask_name)
97 class(constraint_t), intent(inout) :: this
98 character(len=*), intent(in) :: name
99 integer, intent(in) :: design_size
100 character(len=*), intent(in), optional :: mask_name
101
102 call this%free_base()
103
104 this%name = name
105 call this%sensitivity%init(design_size)
106 call this%sensitivity_old%init(design_size)
107
108 if (present(mask_name)) then
109 if (mask_name .ne. "") then
110 this%has_mask = .true.
111 this%mask => neko_point_zone_registry%get_point_zone(mask_name)
112 end if
113 end if
114
115 end subroutine constraint_init_base
116
118 subroutine constraint_free_base(this)
119 class(constraint_t), target, intent(inout) :: this
120
121 this%name = ""
122
123 this%value = 0.0_rp
124 this%value_old = 0.0_rp
125 call this%sensitivity%free()
126 call this%sensitivity_old%free()
127
128 this%has_mask = .false.
129 if (associated(this%mask)) nullify(this%mask)
130
131 end subroutine constraint_free_base
132
133 ! -------------------------------------------------------------------------- !
134 ! Implementations for the wrapper
135
137 subroutine constraint_wrapper_free(this)
138 class(constraint_wrapper_t), intent(inout) :: this
139 if (allocated(this%constraint)) then
140 call this%constraint%free()
141 deallocate(this%constraint)
142 end if
143 end subroutine constraint_wrapper_free
144
145end module constraint
146
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:54