Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
fluid_sgs_stats.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
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!
36 use mean_field, only : mean_field_t
37 use num_types, only : rp
39 use operators, only : strain_rate
40 use coefs, only : coef_t
41 use field, only : field_t
42 use field_list, only : field_list_t
43 use stats_quant, only : stats_quant_t
44 use registry, only : neko_registry
46 implicit none
47 private
48
49 type, public, extends(stats_quant_t) :: fluid_sgs_stats_t
51 type(field_t) :: stats_work
52
54 type(field_t), pointer :: nut
55 type(field_t), pointer :: u
56 type(field_t), pointer :: v
57 type(field_t), pointer :: w
58
59 type(mean_field_t) :: nut_mean
60
61 type(mean_field_t) :: uu_sgs
62 type(mean_field_t) :: vv_sgs
63 type(mean_field_t) :: ww_sgs
64 type(mean_field_t) :: uv_sgs
65 type(mean_field_t) :: uw_sgs
66 type(mean_field_t) :: vw_sgs
67
69 type(coef_t), pointer :: coef
70
72 integer :: n_stats = 7
73
76 type(field_list_t) :: stat_fields
77 contains
79 procedure, pass(this) :: init => fluid_sgs_stats_init
81 procedure, pass(this) :: free => fluid_sgs_stats_free
83 procedure, pass(this) :: update => fluid_sgs_stats_update
85 procedure, pass(this) :: reset => fluid_sgs_stats_reset
86 end type fluid_sgs_stats_t
87
88contains
89
97 subroutine fluid_sgs_stats_init(this, coef, u, v, w, nut_field)
98 class(fluid_sgs_stats_t), intent(inout), target:: this
99 type(coef_t), target :: coef
100 type(field_t), target, intent(in) :: u, v, w
101 character(*), intent(in), optional :: nut_field
102
103 call this%free()
104 this%coef => coef
105
106 this%u => u
107 this%v => v
108 this%w => w
109
110 if (present(nut_field)) then
111 this%nut => neko_registry%get_field_by_name(trim(nut_field))
112 else
113 this%nut => neko_registry%get_field_by_name('nut')
114 end if
115
116
117 ! Initialize work fields
118 call this%stats_work%init(this%u%dof, 'stats')
119
120 ! Initialize mean fields
121 call this%nut_mean%init(this%nut)
122
123 call this%uu_sgs%init(this%stats_work, 'uu_sgs')
124 call this%vv_sgs%init(this%stats_work, 'vv_sgs')
125 call this%ww_sgs%init(this%stats_work, 'ww_sgs')
126 call this%uv_sgs%init(this%stats_work, 'uv_sgs')
127 call this%uw_sgs%init(this%stats_work, 'uw_sgs')
128 call this%vw_sgs%init(this%stats_work, 'vw_sgs')
129
130 allocate(this%stat_fields%items(this%n_stats))
131
132 call this%stat_fields%assign_to_field(1, this%nut_mean%mf)
133
134 call this%stat_fields%assign_to_field(2, this%uu_sgs%mf)
135 call this%stat_fields%assign_to_field(3, this%vv_sgs%mf)
136 call this%stat_fields%assign_to_field(4, this%ww_sgs%mf)
137 call this%stat_fields%assign_to_field(5, this%uv_sgs%mf)
138 call this%stat_fields%assign_to_field(6, this%uw_sgs%mf)
139 call this%stat_fields%assign_to_field(7, this%vw_sgs%mf)
140
141 end subroutine fluid_sgs_stats_init
142
145 subroutine fluid_sgs_stats_update(this, k)
146 class(fluid_sgs_stats_t), intent(inout) :: this
147 real(kind=rp), intent(in) :: k
148 type(field_t), pointer :: s11, s22, s33
149 type(field_t), pointer :: s12, s13, s23
150 integer :: temp_indices(6)
151
152 call neko_scratch_registry%request(s11, temp_indices(1), .false.)
153 call neko_scratch_registry%request(s22, temp_indices(2), .false.)
154 call neko_scratch_registry%request(s33, temp_indices(3), .false.)
155 call neko_scratch_registry%request(s12, temp_indices(4), .false.)
156 call neko_scratch_registry%request(s13, temp_indices(5), .false.)
157 call neko_scratch_registry%request(s23, temp_indices(6), .false.)
158
159 call this%nut_mean%update(k)
160
161 call strain_rate(s11, s22, s33, s12, s13, s23, &
162 this%u, this%v, this%w, this%coef)
163
164 ! form the double sij tensor
165 call field_cmult(s11, 2.0_rp)
166 call field_cmult(s22, 2.0_rp)
167 call field_cmult(s33, 2.0_rp)
168 call field_cmult(s12, 2.0_rp)
169 call field_cmult(s13, 2.0_rp)
170 call field_cmult(s23, 2.0_rp)
171
172 associate(stats_work => this%stats_work)
173 call field_col3(stats_work, this%nut, s11)
174 call this%uu_sgs%update(k)
175 call field_col3(stats_work, this%nut, s22)
176 call this%vv_sgs%update(k)
177 call field_col3(stats_work, this%nut, s33)
178 call this%ww_sgs%update(k)
179 call field_col3(stats_work, this%nut, s12)
180 call this%uv_sgs%update(k)
181 call field_col3(stats_work, this%nut, s13)
182 call this%uw_sgs%update(k)
183 call field_col3(stats_work, this%nut, s23)
184 call this%vw_sgs%update(k)
185
186 end associate
187
188 call neko_scratch_registry%relinquish_field(temp_indices)
189 end subroutine fluid_sgs_stats_update
190
191
193 subroutine fluid_sgs_stats_free(this)
194 class(fluid_sgs_stats_t), intent(inout) :: this
195
196 call this%stats_work%free()
197
198 call this%nut_mean%free()
199
200 call this%uu_sgs%free()
201 call this%vv_sgs%free()
202 call this%ww_sgs%free()
203 call this%uv_sgs%free()
204 call this%uw_sgs%free()
205 call this%vw_sgs%free()
206
207 nullify(this%coef)
208 nullify(this%u)
209 nullify(this%v)
210 nullify(this%w)
211 nullify(this%nut)
212
213 call this%stat_fields%free()
214
215 end subroutine fluid_sgs_stats_free
216
218 subroutine fluid_sgs_stats_reset(this)
219 class(fluid_sgs_stats_t), intent(inout), target:: this
220
221 call this%nut_mean%reset()
222
223 call this%uu_sgs%reset()
224 call this%vv_sgs%reset()
225 call this%ww_sgs%reset()
226 call this%uv_sgs%reset()
227 call this%uw_sgs%reset()
228 call this%vw_sgs%reset()
229
230 end subroutine fluid_sgs_stats_reset
231
232end module fluid_sgs_stats
Compute the strain rate tensor of a vector field.
Coefficients.
Definition coef.f90:34
subroutine, public field_col3(a, b, c, n)
Vector multiplication with 3 vectors .
subroutine, public field_cmult(a, c, n)
Multiplication by constant c .
Defines a field.
Definition field.f90:34
Computes the subgrid-scale contributions for Reynolds stresses. We use the Reynolds decomposition for...
subroutine fluid_sgs_stats_update(this, k)
Updates all fields with a new sample.
subroutine fluid_sgs_stats_free(this)
Destructor.
subroutine fluid_sgs_stats_init(this, coef, u, v, w, nut_field)
Constructor. Initialize the fields associated with fluid_sgs_stats.
subroutine fluid_sgs_stats_reset(this)
Resets all the computed means values and sampling times to zero.
Implements mean_field_t.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Operators.
Definition operators.f90:34
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:144
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.
Defines a statistical quantity.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:63
field_list_t, To be able to group fields together
Computes the temporal mean of a field.
Abstract type defining a statistical quantity.