Neko 1.99.2
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
41 type, public :: field_series_list_t
42 type(field_series_ptr_t), allocatable :: items(:)
43 integer, private :: n_items = 0
44 contains
46 procedure, pass(this) :: init => field_series_list_init
48 procedure, pass(this) :: free => field_series_list_free
50 procedure, pass(this) :: append => field_series_list_append
52 procedure, pass(this) :: get => field_series_list_get
54 procedure, pass(this) :: size => field_series_list_size
55 end type field_series_list_t
56
57contains
58
60 subroutine field_series_list_init(this, capacity)
61 class(field_series_list_t), intent(inout) :: this
62 integer, intent(in) :: capacity
63
64 call this%free()
65
66 if (capacity <= 0) then
67 call neko_error('Field series list capacity must be positive')
68 end if
69
70 allocate(this%items(capacity))
71 this%n_items = 0
72
73 end subroutine field_series_list_init
74
76 subroutine field_series_list_free(this)
77 class(field_series_list_t), intent(inout) :: this
78 integer :: i
79
80 if (allocated(this%items)) then
81 do i = 1, size(this%items)
82 if (associated(this%items(i)%ptr)) then
83 nullify(this%items(i)%ptr)
84 end if
85 end do
86 deallocate(this%items)
87 end if
88 this%n_items = 0
89
90 end subroutine field_series_list_free
91
93 subroutine field_series_list_append(this, fld_series)
94 class(field_series_list_t), intent(inout) :: this
95 type(field_series_t), target, intent(in) :: fld_series
96 type(field_series_ptr_t), allocatable :: tmp(:)
97 integer :: len
98
99 if (.not. allocated(this%items)) then
100 allocate(this%items(1))
101 this%n_items = 0
102 end if
103
104 if (this%n_items >= size(this%items)) then
105 len = size(this%items)
106 allocate(tmp(len + 1))
107 tmp(1:len) = this%items
108 call move_alloc(tmp, this%items)
109 end if
110
111 this%n_items = this%n_items + 1
112 this%items(this%n_items)%ptr => fld_series
113
114 end subroutine field_series_list_append
115
117 function field_series_list_get(this, index) result(field_series_ptr)
118 class(field_series_list_t), intent(in) :: this
119 integer, intent(in) :: index
120 type(field_series_t), pointer :: field_series_ptr
121
122 if (index < 1 .or. index > this%n_items) then
123 call neko_error('Field series list index out of bounds')
124 end if
125
126 field_series_ptr => this%items(index)%ptr
127
128 end function field_series_list_get
129
131 pure function field_series_list_size(this) result(n)
132 class(field_series_list_t), intent(in) :: this
133 integer :: n
134
135 n = this%n_items
136
137 end function field_series_list_size
138
139end 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.