Neko 1.99.1
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
42 type, public :: field_series_t
43 type(field_t), pointer :: f => null()
44 type(field_t), allocatable :: lf(:)
45 integer, private :: len = 0
46 contains
48 procedure, pass(this) :: init => field_series_init
50 procedure, pass(this) :: free => field_series_free
51 procedure, pass(this) :: update => field_series_update
52 procedure, pass(this) :: set => field_series_set
54 procedure, pass(this) :: size => field_series_size
55 end type field_series_t
56
58 type, public :: field_series_ptr_t
59 type(field_series_t), pointer :: ptr => null()
60 end type field_series_ptr_t
61
62contains
63
65 subroutine field_series_init(this, f, len)
66 class(field_series_t), intent(inout) :: this
67 type(field_t), intent(inout), target :: f
68 integer :: len
69 character(len=80) :: name
70 character(len=5) :: id_str
71 integer :: i
72
73 call this%free()
74
75 this%f => f
76 this%len = len
77
78 allocate(this%lf(len))
79
80 do i = 1, this%len
81 write(id_str, '(I0)') i
82 name = trim(f%name)//'_lag'//id_str
83 call this%lf(i)%init(this%f%dof, name)
84 end do
85
86 end subroutine field_series_init
87
89 subroutine field_series_free(this)
90 class(field_series_t), intent(inout) :: this
91 integer :: i
92
93 if (associated(this%f)) then
94 nullify(this%f)
95 end if
96
97 do i = 1, this%len
98 call this%lf(i)%free()
99 end do
100
101 end subroutine field_series_free
102
104 function field_series_size(this) result(len)
105 class(field_series_t), intent(in) :: this
106 integer :: len
107 len = this%len
108 end function field_series_size
109
111 subroutine field_series_update(this)
112 class(field_series_t), intent(inout) :: this
113 integer :: i
114
115 do i = this%len, 2, -1
116 this%lf(i) = this%lf(i-1)
117 end do
118
119 this%lf(1) = this%f
120
121 end subroutine field_series_update
122
124 subroutine field_series_set(this, g)
125 class(field_series_t), intent(inout) :: this
126 type(field_t), intent(in) :: g
127 integer :: i
128
129 do i = 1, this%len
130 this%lf(i) = g
131 end do
132
133 end subroutine field_series_set
134
135end module field_series
Contains the field_serties_t type.
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
A wrapper for a pointer to a field_series_t.
Stores a series (sequence) of fields, logically connected to a base field, and arranged according to ...