Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
mixed_bc.f90
Go to the documentation of this file.
1! Copyright (c) 2026, 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 copyright
12! notice, this list of conditions and the following disclaimer in the
13! documentation and/or other materials provided with the distribution.
14!
15! * Neither the name of the authors nor the names of its contributors may be
16! used to endorse or promote products derived from this software without
17! specific prior written permission.
18!
19! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
23! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29!
32 use bc, only : bc_t
34 use num_types, only : rp
35 use device, only : device_to_host
36 use mask, only : mask_t
37 use matrix, only : matrix_t
38 use field, only : field_t
39 use field_list, only : field_list_t
40 use fld_file, only : fld_file_t
44 use field_math, only : field_rzero
45 implicit none
46 private
47
50 type, public, abstract, extends(bc_t) :: mixed_bc_t
57 type(mask_t) :: resolved_msk
59 type(matrix_t) :: n
60 type(matrix_t) :: t1
61 type(matrix_t) :: t2
62 contains
64 procedure, pass(this) :: free_mixed => mixed_bc_free
66 procedure, pass(this) :: debug_output => mixed_bc_debug_output
67 end type mixed_bc_t
68
69contains
70
72 subroutine mixed_bc_free(this)
73 class(mixed_bc_t), intent(inout) :: this
74
75 call this%free_base()
76 call this%resolved_msk%free()
77 call this%n%free()
78 call this%t1%free()
79 call this%t2%free()
80 end subroutine mixed_bc_free
81
86 subroutine mixed_bc_debug_output(this, field_name)
87 class(mixed_bc_t), intent(inout) :: this
88 character(len=*), intent(in), optional :: field_name
89 type(field_t), pointer :: mask_field, nx_field, ny_field, nz_field
90 type(field_list_t) :: debug_fields
91 type(fld_file_t) :: dump_file
92 integer :: scratch_idx(4)
93 character(len=:), allocatable :: field_name_
94
95 if (present(field_name)) then
96 field_name_ = trim(field_name)
97 else if (allocated(this%name) .and. len_trim(this%name) .gt. 0) then
98 field_name_ = trim(this%name)
99 else
100 field_name_ = 'mixed_bc'
101 end if
102
103 call neko_scratch_registry%request_field(mask_field, scratch_idx(1), .true.)
104 call neko_scratch_registry%request_field(nx_field, scratch_idx(2), .true.)
105 call neko_scratch_registry%request_field(ny_field, scratch_idx(3), .true.)
106 call neko_scratch_registry%request_field(nz_field, scratch_idx(4), .true.)
107
108 call field_rzero(mask_field)
109 call field_rzero(nx_field)
110 call field_rzero(ny_field)
111 call field_rzero(nz_field)
112
113 if (this%resolved_msk%is_set()) then
114 if (neko_bcknd_device .eq. 1) then
115 call device_cfill_mask(mask_field%x_d, 1.0_rp, mask_field%size(), &
116 this%resolved_msk%get_d(), this%resolved_msk%size())
117 call mask_field%copy_from(device_to_host, .true.)
118 else
119 call cfill_mask(mask_field%x, 1.0_rp, mask_field%size(), &
120 this%resolved_msk%get(), this%resolved_msk%size())
121 end if
122
123 if (this%n%size() .gt. 0) then
124 call this%n%copy_from(device_to_host, .true.)
125
126 call masked_scatter_copy(nx_field%x(:,1,1,1), this%n%x(1,:), &
127 this%resolved_msk%get(), nx_field%size(), &
128 this%resolved_msk%size())
129 call masked_scatter_copy(ny_field%x(:,1,1,1), this%n%x(2,:), &
130 this%resolved_msk%get(), ny_field%size(), &
131 this%resolved_msk%size())
132 call masked_scatter_copy(nz_field%x(:,1,1,1), this%n%x(3,:), &
133 this%resolved_msk%get(), nz_field%size(), &
134 this%resolved_msk%size())
135 end if
136 end if
137
138 call debug_fields%init(4)
139 call debug_fields%assign(1, mask_field)
140 call debug_fields%assign(2, nx_field)
141 call debug_fields%assign(3, ny_field)
142 call debug_fields%assign(4, nz_field)
143
144 call dump_file%init(field_name_ // '.fld')
145 call dump_file%write(debug_fields)
146 call debug_fields%free()
147
148 call neko_scratch_registry%relinquish_field(scratch_idx)
149 end subroutine mixed_bc_debug_output
150end module mixed_bc
Defines a boundary condition.
Definition bc.f90:34
subroutine, public device_cfill_mask(a_d, c, n, mask_d, n_mask, strm)
Fill a constant to a masked vector. .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
integer, parameter, public device_to_host
Definition device.F90:48
subroutine, public field_rzero(a, n)
Zero a real vector.
Defines a field.
Definition field.f90:34
NEKTON fld file format.
Definition fld_file.f90:35
Object for handling masks in Neko.
Definition mask.f90:34
Definition math.f90:60
subroutine, public masked_scatter_copy(a, b, mask, n, n_mask)
Scatter a contigous vector to masked positions in a target array .
Definition math.f90:473
subroutine, public cfill_mask(a, c, n, mask, n_mask)
Fill a constant to a masked vector. .
Definition math.f90:491
Defines a matrix.
Definition matrix.f90:34
Implements mixed_bc_t.
Definition mixed_bc.f90:31
subroutine mixed_bc_debug_output(this, field_name)
Write debug fields for a mixed bc.
Definition mixed_bc.f90:87
subroutine mixed_bc_free(this)
Destructor for the mixed-bc extension state.
Definition mixed_bc.f90:73
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Defines a registry for storing and requesting temporary objects This can be used when you have a func...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Base type for a boundary condition.
Definition bc.f90:72
field_list_t, To be able to group fields together
Interface for NEKTON fld files.
Definition fld_file.f90:66
Type for consistently handling masks in Neko. This type encapsulates the mask array and its associate...
Definition mask.f90:51
Base type for mixed boundary conditions that need projector-provided local-basis data on the physical...
Definition mixed_bc.f90:50