Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
adjoint_fluid_pnpn_bc_fctry.f90
1
34!
36submodule(adjoint_fluid_pnpn) adjoint_fluid_pnpn_bc_fctry
37 use user_intf, only: user_t
38 use utils, only: neko_type_error
39 use field_dirichlet, only: field_dirichlet_t
40 use inflow, only: inflow_t
41 use blasius, only: blasius_t
42 use dirichlet, only: dirichlet_t
43 use dong_outflow, only: dong_outflow_t
44 use symmetry_aligned, only: symmetry_aligned_t
45 use non_normal_aligned, only: non_normal_aligned_t
46 use zero_dirichlet, only: zero_dirichlet_t
47 use shear_stress, only: shear_stress_t
48 use wall_model_bc, only: wall_model_bc_t
49 use field_dirichlet_vector, only: field_dirichlet_vector_t
50 implicit none
51
52 ! List of all possible types created by the boundary condition factories
53 character(len=25) :: ADJOINT_FLUID_PNPN_KNOWN_BCS(13) = &
54 [character(len=25) :: &
55 "symmetry", &
56 "velocity_value", &
57 "no_slip", &
58 "outflow", &
59 "normal_outflow", &
60 "outflow+dong", &
61 "normal_outflow+dong", &
62 "shear_stress", &
63 "user_velocity", &
64 "user_pressure", &
65 "blasius_profile", &
66 "user_velocity_pointwise", &
67 "wall_model"]
68
69contains
70
77 module subroutine pressure_bc_factory(object, scheme, json, coef, user)
78 class(bc_t), pointer, intent(inout) :: object
79 type(adjoint_fluid_pnpn_t), intent(in) :: scheme
80 type(json_file), intent(inout) :: json
81 type(coef_t), target, intent(in) :: coef
82 type(user_t), target, intent(in) :: user
83 character(len=:), allocatable :: type
84 integer :: i, j, k
85 integer, allocatable :: zone_indices(:)
86
87 call json_get(json, "type", type)
88
89 select case (trim(type))
90 case ("outflow", "normal_outflow")
91 allocate(zero_dirichlet_t::object)
92
93 case ("outflow+dong", "normal_outflow+dong")
94 allocate(dong_outflow_t::object)
95
96 case ("user_pressure")
97 allocate(field_dirichlet_t::object)
98 select type (obj => object)
99 type is (field_dirichlet_t)
100 obj%update => user%dirichlet_conditions
101 call json%add("field_name", scheme%p_adj%name)
102 end select
103
104 case default
105 do i = 1, size(adjoint_fluid_pnpn_known_bcs)
106 if (trim(type) .eq. trim(adjoint_fluid_pnpn_known_bcs(i))) return
107 end do
108 call neko_type_error("adjoint_fluid_pnpn boundary conditions", type, &
109 ADJOINT_FLUID_PNPN_KNOWN_BCS)
110 end select
111
112 call json_get(json, "zone_indices", zone_indices)
113 call object%init(coef, json)
114
115 do i = 1, size(zone_indices)
116 call object%mark_labeled_zone(zone_indices(i))
117 end do
118 call object%finalize()
119
120 ! All pressure bcs are currently strong, so for all of them we
121 ! mark with value 1 in the mesh
122 do i = 1, size(zone_indices)
123 do j = 1, scheme%msh%nelv
124 do k = 1, 2 * scheme%msh%gdim
125 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
126 scheme%msh%facet_type(k, j) = 1
127 end if
128 end do
129 end do
130 end do
131 end subroutine pressure_bc_factory
132
139 module subroutine velocity_bc_factory(object, scheme, json, coef, user)
140 class(bc_t), pointer, intent(inout) :: object
141 type(adjoint_fluid_pnpn_t), intent(in) :: scheme
142 type(json_file), intent(inout) :: json
143 type(coef_t), target, intent(in) :: coef
144 type(user_t), target, intent(in) :: user
145 character(len=:), allocatable :: type
146 integer :: i, j, k
147 integer, allocatable :: zone_indices(:)
148
149 call json_get(json, "type", type)
150
151 select case (trim(type))
152 case ("symmetry")
153 allocate(symmetry_aligned_t::object)
154 case ("velocity_value")
155 allocate(inflow_t::object)
156 case ("no_slip")
157 allocate(zero_dirichlet_t::object)
158 case ("normal_outflow", "normal_outflow+dong")
159 allocate(non_normal_aligned_t::object)
160 case ("blasius_profile")
161 allocate(blasius_t::object)
162 case ("shear_stress")
163 allocate(shear_stress_t::object)
164 case ("wall_model")
165 allocate(wall_model_bc_t::object)
166 ! Kind of hack, but maybe OK? The thing is, we need the nu for
167 ! initing the wall model, and forcing the user duplicate that there
168 ! would be a nightmare.
169 ! call json%add("nu", scheme%mu / scheme%rho)
170
171 case ("user_velocity")
172 allocate(field_dirichlet_vector_t::object)
173 select type (obj => object)
174 type is (field_dirichlet_vector_t)
175 obj%update => user%dirichlet_conditions
176 end select
177
178 ! case ("user_velocity_pointwise")
179 ! allocate(usr_inflow_t::object)
180 ! select type (obj => object)
181 ! type is (usr_inflow_t)
182 ! call obj%set_eval(user%adjoint_user_if)
183 ! call obj%validate()
184 ! end select
185
186 case default
187 do i = 1, size(adjoint_fluid_pnpn_known_bcs)
188 if (trim(type) .eq. trim(adjoint_fluid_pnpn_known_bcs(i))) return
189 end do
190 call neko_type_error("adjoint_fluid_pnpn boundary conditions", type, &
191 ADJOINT_FLUID_PNPN_KNOWN_BCS)
192 end select
193
194 call json_get(json, "zone_indices", zone_indices)
195 call object%init(coef, json)
196 do i = 1, size(zone_indices)
197 call object%mark_labeled_zone(zone_indices(i))
198 end do
199 call object%finalize()
200
201 ! Exclude these two because they are bcs for the residual, not velocity
202 if (trim(type) .ne. "normal_outflow" .and. &
203 trim(type) .ne. "normal_outflow+dong") then
204 do i = 1, size(zone_indices)
205 do j = 1, scheme%msh%nelv
206 do k = 1, 2 * scheme%msh%gdim
207 if (scheme%msh%facet_type(k,j) .eq. -zone_indices(i)) then
208 scheme%msh%facet_type(k, j) = 2
209 end if
210 end do
211 end do
212 end do
213 end if
214 end subroutine velocity_bc_factory
215
216end submodule adjoint_fluid_pnpn_bc_fctry
Adjoint Pn/Pn formulation.