Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
simple_brinkman_source_term.f90
1! Copyright (c) 2023, 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!
34! a term in the form $\chi \mathbf{u}$
36 use num_types, only: rp
37 use field_list, only: field_list_t
38 use json_module, only: json_file
39 use json_utils, only: json_get, json_get_or_default
40 use source_term, only: source_term_t
41 use coefs, only: coef_t
42 use neko_config, only: neko_bcknd_device
43 use utils, only: neko_error
44 use field, only: field_t
45 use field_math, only: field_subcol3
46 implicit none
47 private
48
50 ! We have a source term of the form $\chi \mathbf{u}$
51 type, public, extends(source_term_t) :: simple_brinkman_source_term_t
53 type(field_t), pointer :: chi => null()
55 type(field_t), pointer :: u => null()
57 type(field_t), pointer :: v => null()
59 type(field_t), pointer :: w => null()
60
61 contains
63 procedure, pass(this) :: init => &
64 simple_brinkman_source_term_init_from_json
66 procedure, pass(this) :: init_from_components => &
67 simple_brinkman_source_term_init_from_components
69 procedure, pass(this) :: free => simple_brinkman_source_term_free
71 procedure, pass(this) :: compute_ => simple_brinkman_source_term_compute
73
74contains
81 subroutine simple_brinkman_source_term_init_from_json(this, json, fields, &
82 coef, variable_name)
83 class(simple_brinkman_source_term_t), intent(inout) :: this
84 type(json_file), intent(inout) :: json
85 type(field_list_t), intent(in), target :: fields
86 type(coef_t), intent(in), target :: coef
87 character(len=*), intent(in) :: variable_name
88
89
90 ! we shouldn't be initializing this from JSON
91 ! maybe throw an error?
92
93
94 end subroutine simple_brinkman_source_term_init_from_json
95
102 subroutine simple_brinkman_source_term_init_from_components(this, &
103 f_x, f_y, f_z, chi, u, v, w, coef)
104 class(simple_brinkman_source_term_t), intent(inout) :: this
105 type(field_t), pointer, intent(in) :: f_x, f_y, f_z
106 type(field_list_t) :: fields
107 type(coef_t) :: coef
108 real(kind=rp) :: start_time
109 real(kind=rp) :: end_time
110 type(field_t), intent(in), target :: u, v, w
111 type(field_t), intent(in), target :: chi
112
113 ! I wish you didn't need a start time and end time...
114 ! but I'm just going to set a super big number...
115 start_time = 0.0_rp
116 end_time = 100000000.0_rp
117
118 call this%free()
119
120 ! this is copying the fluid source term init
121 ! We package the fields for the source term to operate on in a field list.
122 call fields%init(3)
123 call fields%assign(1, f_x)
124 call fields%assign(2, f_y)
125 call fields%assign(3, f_z)
126
127 call this%init_base(fields, coef, start_time, end_time)
128
129 ! point everything in the correct places
130 this%u => u
131 this%v => v
132 this%w => w
133 ! and get chi out of the design
134 this%chi => chi
135
136 end subroutine simple_brinkman_source_term_init_from_components
137
139 subroutine simple_brinkman_source_term_free(this)
140 class(simple_brinkman_source_term_t), intent(inout) :: this
141
142 call this%free_base()
143 end subroutine simple_brinkman_source_term_free
144
149 subroutine simple_brinkman_source_term_compute(this, t, tstep)
150 class(simple_brinkman_source_term_t), intent(inout) :: this
151 real(kind=rp), intent(in) :: t
152 integer, intent(in) :: tstep
153 type(field_t), pointer :: fu, fv, fw
154
155 fu => this%fields%get_by_index(1)
156 fv => this%fields%get_by_index(2)
157 fw => this%fields%get_by_index(3)
158
159 call field_subcol3(fu, this%u, this%chi)
160 call field_subcol3(fv, this%v, this%chi)
161 call field_subcol3(fw, this%w, this%chi)
162
163 end subroutine simple_brinkman_source_term_compute
164
Implements the simple_brinkman_source_term_t type.