Neko 1.99.1
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 if (capacity <= 0) then
65 call neko_error('Field series list capacity must be positive')
66 end if
67
68 allocate(this%items(capacity))
69 this%n_items = 0
70
71 end subroutine field_series_list_init
72
74 subroutine field_series_list_free(this)
75 class(field_series_list_t), intent(inout) :: this
76
77 if (allocated(this%items)) then
78 deallocate(this%items)
79 end if
80 this%n_items = 0
81
82 end subroutine field_series_list_free
83
85 subroutine field_series_list_append(this, fld_series)
86 class(field_series_list_t), intent(inout) :: this
87 type(field_series_t), target, intent(in) :: fld_series
88 type(field_series_ptr_t), allocatable :: tmp(:)
89 integer :: len
90
91 if (.not. allocated(this%items)) then
92 allocate(this%items(1))
93 this%n_items = 0
94 end if
95
96 if (this%n_items >= size(this%items)) then
97 len = size(this%items)
98 allocate(tmp(len + 1))
99 tmp(1:len) = this%items
100 call move_alloc(tmp, this%items)
101 end if
102
103 this%n_items = this%n_items + 1
104 this%items(this%n_items)%ptr => fld_series
105
106 end subroutine field_series_list_append
107
109 function field_series_list_get(this, index) result(field_series_ptr)
110 class(field_series_list_t), intent(in) :: this
111 integer, intent(in) :: index
112 type(field_series_t), pointer :: field_series_ptr
113
114 if (index < 1 .or. index > this%n_items) then
115 call neko_error('Field series list index out of bounds')
116 end if
117
118 field_series_ptr => this%items(index)%ptr
119
120 end function field_series_list_get
121
123 pure function field_series_list_size(this) result(n)
124 class(field_series_list_t), intent(in) :: this
125 integer :: n
126
127 n = this%n_items
128
129 end function field_series_list_size
130
131end 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.