Neko 1.99.5
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
field_series_list.f90
Go to the documentation of this file.
1! Copyright (c) 2025, 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 utils, only : neko_error
37 implicit none
38 private
39
42 type, public :: field_series_list_t
43 type(field_series_ptr_t), allocatable :: items(:)
44 integer, private :: n_items = 0
45 contains
47 procedure, pass(this) :: init => field_series_list_init
49 procedure, pass(this) :: free => field_series_list_free
51 procedure, pass(this) :: append => field_series_list_append
53 procedure, pass(this) :: get => field_series_list_get
55 procedure, pass(this) :: size => field_series_list_size
56 end type field_series_list_t
57
58contains
59
61 subroutine field_series_list_init(this, capacity)
62 class(field_series_list_t), intent(inout) :: this
63 integer, intent(in) :: capacity
64
65 call this%free()
66
67 if (capacity <= 0) then
68 call neko_error('Field series list capacity must be positive')
69 end if
70
71 allocate(this%items(capacity))
72 this%n_items = 0
73
74 end subroutine field_series_list_init
75
77 subroutine field_series_list_free(this)
78 class(field_series_list_t), intent(inout) :: this
79 integer :: i
80
81 if (allocated(this%items)) then
82 do i = 1, size(this%items)
83 if (associated(this%items(i)%ptr)) then
84 nullify(this%items(i)%ptr)
85 end if
86 end do
87 deallocate(this%items)
88 end if
89 this%n_items = 0
90
91 end subroutine field_series_list_free
92
94 subroutine field_series_list_append(this, fld_series)
95 class(field_series_list_t), intent(inout) :: this
96 type(field_series_t), target, intent(in) :: fld_series
97 type(field_series_ptr_t), allocatable :: tmp(:)
98 integer :: len
99
100 if (.not. allocated(this%items)) then
101 allocate(this%items(1))
102 this%n_items = 0
103 end if
104
105 if (this%n_items >= size(this%items)) then
106 len = size(this%items)
107 allocate(tmp(len + 1))
108 tmp(1:len) = this%items
109 call move_alloc(tmp, this%items)
110 end if
111
112 this%n_items = this%n_items + 1
113 this%items(this%n_items)%ptr => fld_series
114
115 end subroutine field_series_list_append
116
118 function field_series_list_get(this, index) result(field_series_ptr)
119 class(field_series_list_t), intent(in) :: this
120 integer, intent(in) :: index
121 type(field_series_t), pointer :: field_series_ptr
122
123 if (index < 1 .or. index > this%n_items) then
124 call neko_error('Field series list index out of bounds')
125 end if
126
127 field_series_ptr => this%items(index)%ptr
128
129 end function field_series_list_get
130
132 pure function field_series_list_size(this) result(n)
133 class(field_series_list_t), intent(in) :: this
134 integer :: n
135
136 n = this%n_items
137
138 end function field_series_list_size
139
140end module field_series_list
Contains the field_series_list_t type for managing multiple field series.
pure integer function field_series_list_size(this)
Get the number of items in the list.
subroutine field_series_list_init(this, capacity)
Initialize a field series list with a given capacity.
type(field_series_t) function, pointer field_series_list_get(this, index)
Get a field series by index.
subroutine field_series_list_free(this)
Free the field series list.
subroutine field_series_list_append(this, fld_series)
Add a field series to the list.
Contains the field_serties_t type.
Utilities.
Definition utils.f90:35
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 ...
A list of field series pointers, used for managing multiple scalar lag fields.