Neko 1.99.9
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
38 use field_math, only : field_cmult
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), pointer :: nut
52 type(field_t), pointer :: u
53 type(field_t), pointer :: v
54 type(field_t), pointer :: w
55
56 type(mean_field_t) :: nut_mean
57
58 type(mean_field_t) :: uu_sgs
59 type(mean_field_t) :: vv_sgs
60 type(mean_field_t) :: ww_sgs
61 type(mean_field_t) :: uv_sgs
62 type(mean_field_t) :: uw_sgs
63 type(mean_field_t) :: vw_sgs
64
66 type(coef_t), pointer :: coef
67
69 integer :: n_stats = 7
70
73 type(field_list_t) :: stat_fields
74 contains
76 procedure, pass(this) :: init => fluid_sgs_stats_init
78 procedure, pass(this) :: free => fluid_sgs_stats_free
80 procedure, pass(this) :: update => fluid_sgs_stats_update
82 procedure, pass(this) :: reset => fluid_sgs_stats_reset
83 end type fluid_sgs_stats_t
84
85contains
86
94 subroutine fluid_sgs_stats_init(this, coef, u, v, w, nut_field)
95 class(fluid_sgs_stats_t), intent(inout), target:: this
96 type(coef_t), target :: coef
97 type(field_t), target, intent(in) :: u, v, w
98 character(*), intent(in), optional :: nut_field
99
100 call this%free()
101 this%coef => coef
102
103 this%u => u
104 this%v => v
105 this%w => w
106
107 if (present(nut_field)) then
108 this%nut => neko_registry%get_field_by_name(trim(nut_field))
109 else
110 this%nut => neko_registry%get_field_by_name('nut')
111 end if
112
113
114 ! Initialize mean fields. The SGS stresses are means of products, updated
115 ! with update_col3. The field passed to init only provides the dofmap.
116 call this%nut_mean%init(this%nut)
117
118 call this%uu_sgs%init(this%nut, 'uu_sgs')
119 call this%vv_sgs%init(this%nut, 'vv_sgs')
120 call this%ww_sgs%init(this%nut, 'ww_sgs')
121 call this%uv_sgs%init(this%nut, 'uv_sgs')
122 call this%uw_sgs%init(this%nut, 'uw_sgs')
123 call this%vw_sgs%init(this%nut, 'vw_sgs')
124
125 allocate(this%stat_fields%items(this%n_stats))
126
127 call this%stat_fields%assign_to_field(1, this%nut_mean%mf)
128
129 call this%stat_fields%assign_to_field(2, this%uu_sgs%mf)
130 call this%stat_fields%assign_to_field(3, this%vv_sgs%mf)
131 call this%stat_fields%assign_to_field(4, this%ww_sgs%mf)
132 call this%stat_fields%assign_to_field(5, this%uv_sgs%mf)
133 call this%stat_fields%assign_to_field(6, this%uw_sgs%mf)
134 call this%stat_fields%assign_to_field(7, this%vw_sgs%mf)
135
136 end subroutine fluid_sgs_stats_init
137
140 subroutine fluid_sgs_stats_update(this, k)
141 class(fluid_sgs_stats_t), intent(inout) :: this
142 real(kind=rp), intent(in) :: k
143 type(field_t), pointer :: s11, s22, s33
144 type(field_t), pointer :: s12, s13, s23
145 integer :: temp_indices(6)
146
147 call neko_scratch_registry%request(s11, temp_indices(1), .false.)
148 call neko_scratch_registry%request(s22, temp_indices(2), .false.)
149 call neko_scratch_registry%request(s33, temp_indices(3), .false.)
150 call neko_scratch_registry%request(s12, temp_indices(4), .false.)
151 call neko_scratch_registry%request(s13, temp_indices(5), .false.)
152 call neko_scratch_registry%request(s23, temp_indices(6), .false.)
153
154 call this%nut_mean%update(k)
155
156 call strain_rate(s11, s22, s33, s12, s13, s23, &
157 this%u, this%v, this%w, this%coef)
158
159 ! form the double sij tensor
160 call field_cmult(s11, 2.0_rp)
161 call field_cmult(s22, 2.0_rp)
162 call field_cmult(s33, 2.0_rp)
163 call field_cmult(s12, 2.0_rp)
164 call field_cmult(s13, 2.0_rp)
165 call field_cmult(s23, 2.0_rp)
166
167 call this%uu_sgs%update_col3(k, this%nut, s11)
168 call this%vv_sgs%update_col3(k, this%nut, s22)
169 call this%ww_sgs%update_col3(k, this%nut, s33)
170 call this%uv_sgs%update_col3(k, this%nut, s12)
171 call this%uw_sgs%update_col3(k, this%nut, s13)
172 call this%vw_sgs%update_col3(k, this%nut, s23)
173
174 call neko_scratch_registry%relinquish_field(temp_indices)
175 end subroutine fluid_sgs_stats_update
176
177
179 subroutine fluid_sgs_stats_free(this)
180 class(fluid_sgs_stats_t), intent(inout) :: this
181
182 call this%nut_mean%free()
183
184 call this%uu_sgs%free()
185 call this%vv_sgs%free()
186 call this%ww_sgs%free()
187 call this%uv_sgs%free()
188 call this%uw_sgs%free()
189 call this%vw_sgs%free()
190
191 nullify(this%coef)
192 nullify(this%u)
193 nullify(this%v)
194 nullify(this%w)
195 nullify(this%nut)
196
197 call this%stat_fields%free()
198
199 end subroutine fluid_sgs_stats_free
200
202 subroutine fluid_sgs_stats_reset(this)
203 class(fluid_sgs_stats_t), intent(inout), target:: this
204
205 call this%nut_mean%reset()
206
207 call this%uu_sgs%reset()
208 call this%vv_sgs%reset()
209 call this%ww_sgs%reset()
210 call this%uv_sgs%reset()
211 call this%uw_sgs%reset()
212 call this%vw_sgs%reset()
213
214 end subroutine fluid_sgs_stats_reset
215
216end module fluid_sgs_stats
Compute the strain rate tensor of a vector field.
Coefficients.
Definition coef.f90:34
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:14
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:158
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:136
field_list_t, To be able to group fields together
Computes the temporal mean of a field.
Abstract type defining a statistical quantity.