Neko 1.99.2
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
98 if (allocated(this%lf)) then
99 do i = 1, this%len
100 call this%lf(i)%free()
101 end do
102
103 deallocate(this%lf)
104 end if
105
106 end subroutine field_series_free
107
109 function field_series_size(this) result(len)
110 class(field_series_t), intent(in) :: this
111 integer :: len
112 len = this%len
113 end function field_series_size
114
116 subroutine field_series_update(this)
117 class(field_series_t), intent(inout) :: this
118 integer :: i
119
120 do i = this%len, 2, -1
121 this%lf(i) = this%lf(i-1)
122 end do
123
124 this%lf(1) = this%f
125
126 end subroutine field_series_update
127
129 subroutine field_series_set(this, g)
130 class(field_series_t), intent(inout) :: this
131 type(field_t), intent(in) :: g
132 integer :: i
133
134 do i = 1, this%len
135 this%lf(i) = g
136 end do
137
138 end subroutine field_series_set
139
140end 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 ...