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
33
37 use simulation_m, 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 :: constraint_t, constraint_factory, constraint_wrapper_t
46
50 type, abstract, extends(base_functional_t) :: constraint_t
51
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
72 interface
73 module subroutine constraint_factory(object, json, design, simulation)
74 class(constraint_t), allocatable, intent(inout) :: object
75 type(json_file), intent(inout) :: json
76 class(design_t), intent(in) :: design
77 type(simulation_t), target, optional, intent(inout) :: simulation
78 end subroutine constraint_factory
79 end interface
80
81contains
82
83 ! -------------------------------------------------------------------------- !
84 ! Implementations for the base class
85
91 subroutine constraint_init_base(this, name, design_size, mask_name)
92 class(constraint_t), intent(inout) :: this
93 character(len=*), intent(in) :: name
94 integer, intent(in) :: design_size
95 character(len=*), intent(in), optional :: mask_name
96
97 this%name = name
98 this%value = 0.0_rp
99 call this%sensitivity%init(design_size)
100
101 this%has_mask = .false.
102 if (trim(mask_name) .ne. "") then
103 this%has_mask = .true.
104 this%mask => neko_point_zone_registry%get_point_zone(mask_name)
105 end if
106
107 end subroutine constraint_init_base
108
110 subroutine constraint_free_base(this)
111 class(constraint_t), target, intent(inout) :: this
112
113 this%value = 0.0_rp
114 call this%sensitivity%free()
115 this%has_mask = .false.
116 if (associated(this%mask)) nullify(this%mask)
117
118 end subroutine constraint_free_base
119
120 ! -------------------------------------------------------------------------- !
121 ! Implementations for the wrapper
122
124 subroutine constraint_wrapper_free(this)
125 class(constraint_wrapper_t), intent(inout) :: this
126 if (allocated(this%constraint)) then
127 call this%constraint%free()
128 deallocate(this%constraint)
129 end if
130 end subroutine constraint_wrapper_free
131
132end module constraint
133
Defines the abstract the base_functional_t type.
Implements the constraint_t type.
subroutine constraint_init_base(this, name, design_size, mask_name)
Factory function interface.
Implements the design_t.
Definition design.f90:34
Implements the steady_problem_t type.
The abstract constraint type.
Wrapper for constraints for use in lists.
An abstract design type.
Definition design.f90:50