Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
adjoint_scalar_pnpn_bc_fctry.f90
1! Copyright (c) 2024, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
33!
38submodule(adjoint_scalar_pnpn) adjoint_scalar_pnpn_bc_fctry
39 use dirichlet, only : dirichlet_t
40 use neumann, only : neumann_t
41 use user_intf, only : user_t
42 use utils, only : neko_type_error
43 use field_dirichlet, only : field_dirichlet_t
44 implicit none
45
46 ! List of all possible types created by the boundary condition factories
47 character(len=25) :: ADJOINT_SCALAR_KNOWN_BCS(4) = [character(len=25) :: &
48 "dirichlet", &
49 "user_pointwise", &
50 "user", &
51 "neumann"]
52
53contains
54
62 module subroutine adjoint_bc_factory(object, scheme, json, coef, user)
63 class(bc_t), pointer, intent(inout) :: object
64 type(adjoint_scalar_pnpn_t), intent(in) :: scheme
65 type(json_file), intent(inout) :: json
66 type(coef_t), intent(in) :: coef
67 type(user_t), intent(in) :: user
68 character(len=:), allocatable :: type
69 integer :: i
70 integer, allocatable :: zone_indices(:)
71
72 call json_get(json, "type", type)
73
74 select case (trim(type))
75 case ("user")
76 allocate(field_dirichlet_t::object)
77 select type (obj => object)
78 type is (field_dirichlet_t)
79 obj%update => user%dirichlet_conditions
80 ! Add the name of the dummy field in the bc, matching the scalar
81 ! solved for.
82 call json%add("field_name", scheme%s_adj%name)
83 end select
84 case ("dirichlet")
85 allocate(dirichlet_t::object)
86 case ("neumann")
87 allocate(neumann_t::object)
88 case default
89 call neko_type_error("scalar_pnpn boundary conditions", type, &
90 ADJOINT_SCALAR_KNOWN_BCS)
91 end select
92
93 call json_get(json, "zone_indices", zone_indices)
94 call object%init(coef, json)
95 do i = 1, size(zone_indices)
96 call object%mark_zone(coef%msh%labeled_zones(zone_indices(i)))
97 end do
98 call object%finalize()
99
100 end subroutine adjoint_bc_factory
101
102
103end submodule adjoint_scalar_pnpn_bc_fctry
Contains the adjoint_scalar_pnpn_t type.