Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
field_series.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!
35 use field, only : field_t
36 implicit none
37 private
38
39 type, public :: field_series_t
40 type(field_t), pointer :: f => null()
41 type(field_t), allocatable :: lf(:)
42 integer, private :: len = 0
43 contains
44 procedure, pass(this) :: init => field_series_init
45 procedure, pass(this) :: free => field_series_free
46 procedure, pass(this) :: update => field_series_update
47 procedure, pass(this) :: set => field_series_set
48 procedure, pass(this) :: size => field_series_size
49 end type field_series_t
50
52 type, public :: field_series_ptr_t
53 type(field_series_t), pointer :: ptr => null()
54 end type field_series_ptr_t
55
56contains
57
59 subroutine field_series_init(this, f, len)
60 class(field_series_t), intent(inout) :: this
61 type(field_t), intent(inout), target :: f
62 integer :: len
63 character(len=80) :: name
64 character(len=5) :: id_str
65 integer :: i
66
67 call this%free()
68
69 this%f => f
70 this%len = len
71
72 allocate(this%lf(len))
73
74 do i = 1, this%len
75 write(id_str, '(I0)') i
76 name = trim(f%name)//'_lag'//id_str
77 call this%lf(i)%init(this%f%dof, name)
78 end do
79
80 end subroutine field_series_init
81
83 subroutine field_series_free(this)
84 class(field_series_t), intent(inout) :: this
85 integer :: i
86
87 if (associated(this%f)) then
88 nullify(this%f)
89 end if
90
91 do i = 1, this%len
92 call this%lf(i)%free()
93 end do
94
95 end subroutine field_series_free
96
98 function field_series_size(this) result(len)
99 class(field_series_t), intent(in) :: this
100 integer :: len
101 len = this%len
102 end function field_series_size
103
105 subroutine field_series_update(this)
106 class(field_series_t), intent(inout) :: this
107 integer :: i
108
109 do i = this%len, 2, -1
110 this%lf(i) = this%lf(i-1)
111 end do
112
113 this%lf(1) = this%f
114
115 end subroutine field_series_update
116
118 subroutine field_series_set(this, g)
119 class(field_series_t), intent(inout) :: this
120 type(field_t), intent(in) :: g
121 integer :: i
122
123 do i = 1, this%len
124 this%lf(i) = g
125 end do
126
127 end subroutine field_series_set
128
129end module field_series
Stores a series fields.
subroutine field_series_set(this, g)
Set all fields in a series to g.
subroutine field_series_update(this)
Update a field series (evict oldest entry)
integer function field_series_size(this)
Return the size of the field series.
subroutine field_series_free(this)
Deallocates a field series.
subroutine field_series_init(this, f, len)
Initialize a field series of length len for a field f.
Defines a field.
Definition field.f90:34
field_series_ptr_t, To easily obtain a pointer to a field series