Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
mean_field.f90
Go to the documentation of this file.
1! Copyright (c) 2021-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!
37 use stats_quant, only : stats_quant_t
38 use num_types, only : rp
39 use registry, only: neko_registry
40 use field, only : field_t
42 implicit none
43 private
44
46 type, public, extends(stats_quant_t) :: mean_field_t
48 type(field_t), pointer :: f => null()
50 type(field_t), pointer :: mf => null()
52 real(kind=rp) :: time
53 contains
55 procedure, pass(this) :: init => mean_field_init
57 procedure, pass(this) :: free => mean_field_free
59 procedure, pass(this) :: update => mean_field_update
61 procedure, pass(this) :: reset => mean_field_reset
62 end type mean_field_t
63
64contains
65
70 subroutine mean_field_init(this, f, field_name)
71 class(mean_field_t), intent(inout) :: this
72 type(field_t), intent(in), target :: f
73 character(len=*), optional, intent(in) :: field_name
74 character(len=80) :: name
75
76 call this%free()
77
78 this%f => f
79 this%time = 0.0_rp
80
81 if (present(field_name)) then
82 name = field_name
83 else
84 write(name, '(A,A)') 'mean_', trim(f%name)
85 end if
86
87 call neko_registry%add_field(f%dof, trim(name))
88 this%mf => neko_registry%get_field(trim(name))
89
90 end subroutine mean_field_init
91
93 subroutine mean_field_free(this)
94 class(mean_field_t), intent(inout) :: this
95
96 if (associated(this%f)) then
97 nullify(this%f)
98 end if
99
100 if (associated(this%mf)) then
101 nullify(this%mf)
102 end if
103
104 end subroutine mean_field_free
105
107 subroutine mean_field_reset(this)
108 class(mean_field_t), intent(inout) :: this
109
110 this%time = 0.0
111 this%mf = 0.0_rp
112 end subroutine mean_field_reset
113
114
117 subroutine mean_field_update(this, k)
118 class(mean_field_t), intent(inout) :: this
119 real(kind=rp), intent(in) :: k
120
121 call field_cmult(this%mf, this%time, size(this%mf%x))
122 call field_add2s2(this%mf, this%f, k, size(this%mf%x))
123 this%time = this%time + k
124 call field_cmult(this%mf, 1.0_rp / this%time, size(this%mf%x))
125
126 end subroutine mean_field_update
127
128end module mean_field
129
subroutine, public field_add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
subroutine, public field_cmult(a, c, n)
Multiplication by constant c .
Defines a field.
Definition field.f90:34
Implements mean_field_t.
subroutine mean_field_update(this, k)
Update the mean field with a new sample.
subroutine mean_field_init(this, f, field_name)
Constructor.
subroutine mean_field_reset(this)
Resets a the mean field and the averaging time value to zero.
subroutine mean_field_free(this)
Destructor.
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:149
Defines a statistical quantity.
Computes the temporal mean of a field.
Abstract type defining a statistical quantity.