Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
avm.f90
Go to the documentation of this file.
1! Copyright (c) 2026, 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!
33!
36 use utils, only : neko_typename_len
37 use num_types, only : rp
38 use case, only : case_t
39 use field, only : field_t
40 use json_module, only : json_file
41 use registry, only : neko_registry
42 use coefs, only : coef_t
43 use dofmap, only : dofmap_t
44 use time_state, only : time_state_t
45 implicit none
46 private
47
49 type, abstract, public :: avm_t
51 type(field_t), pointer :: reg_coeff => null()
53 type(coef_t), pointer :: coef => null()
55 type(dofmap_t), pointer :: dof => null()
57 integer :: les_model_registry_size = 0
58 contains
60 procedure, pass(this) :: init_base => avm_init_base
62 procedure, pass(this) :: free_base => avm_free_base
64 procedure(avm_init), pass(this), deferred :: init
66 procedure(avm_free), pass(this), deferred :: free
68 procedure(avm_preprocess), pass(this), deferred :: preprocess
70 procedure(avm_compute), pass(this), deferred :: compute
72 procedure, pass(this) :: restart => avm_restart
73 end type avm_t
74
75 abstract interface
76
79 subroutine avm_preprocess(this, time)
80 import avm_t, time_state_t
81 class(avm_t), intent(inout) :: this
82 type(time_state_t), intent(in) :: time
83 end subroutine avm_preprocess
84 end interface
85
86 abstract interface
87
90 subroutine avm_compute(this, time)
91 import avm_t, time_state_t
92 class(avm_t), intent(inout) :: this
93 type(time_state_t), intent(in) :: time
94 end subroutine avm_compute
95 end interface
96
97 abstract interface
98
102 subroutine avm_init(this, case, json)
103 import avm_t, json_file, case_t
104 class(avm_t), intent(inout) :: this
105 class(case_t), intent(inout), target :: case
106 type(json_file), intent(inout) :: json
107 end subroutine avm_init
108 end interface
109
110 abstract interface
111
113 subroutine avm_free(this)
114 import avm_t
115 class(avm_t), intent(inout) :: this
116 end subroutine avm_free
117 end interface
118
119 interface
120
123 module subroutine avm_allocator(object, type_name)
124 class(avm_t), allocatable, intent(inout) :: object
125 character(len=*), intent(in) :: type_name
126 end subroutine avm_allocator
127 end interface
128
129 !
130 ! Machinery for injecting user-defined types
131 !
132
136 abstract interface
137
139 subroutine avm_allocate(obj)
140 import avm_t
141 class(avm_t), allocatable, intent(inout) :: obj
142 end subroutine avm_allocate
143 end interface
144
145 interface
146
149 module subroutine register_avm(type_name, allocator)
150 character(len=*), intent(in) :: type_name
151 procedure(avm_allocate), pointer, intent(in) :: allocator
152 end subroutine register_avm
153 end interface
154
157 type allocator_entry
159 character(len=NEKO_TYPENAME_LEN) :: type_name
161 procedure(avm_allocate), pointer, nopass :: allocator
162 end type allocator_entry
163
165 type(allocator_entry), allocatable :: avm_registry(:)
166
168 integer :: avm_registry_size = 0
169
170
171
172 interface
173
179 module subroutine avm_factory(object, type_name, case, json)
180 class(avm_t), allocatable, intent(inout) :: object
181 character(len=*), intent(in) :: type_name
182 class(case_t), intent(inout), target :: case
183 type(json_file), intent(inout) :: json
184 end subroutine avm_factory
185 end interface
186
187 public :: avm_factory, avm_allocator, register_avm, &
188 avm_allocate
189
190
191contains
197 subroutine avm_init_base(this, dof, coef, reg_coeff_name)
198 class(avm_t), intent(inout) :: this
199 class(dofmap_t), intent(in), target :: dof
200 class(coef_t), intent(in), target :: coef
201 character(len=*), intent(in) :: reg_coeff_name
202
203 call this%free_base()
204
205 call neko_registry%add_field(dof, trim(reg_coeff_name), .true.)
206
207 this%reg_coeff => neko_registry%get_field(trim(reg_coeff_name))
208 this%coef => coef
209 this%dof => dof
210
211 end subroutine avm_init_base
212
217 subroutine avm_restart(this, time)
218 class(avm_t), intent(inout) :: this
219 type(time_state_t), intent(in) :: time
220
221 call this%compute(time)
222
223 end subroutine avm_restart
224
227 subroutine avm_free_base(this)
228 class(avm_t), intent(inout) :: this
229
230 nullify(this%reg_coeff)
231 nullify(this%coef)
232 nullify(this%dof)
233
234 end subroutine avm_free_base
235
Perform artificial viscosity related computations after the time step.
Definition avm.f90:90
Perform artificial viscosity related computations before the time step.
Definition avm.f90:79
Implements avm_t.
Definition avm.f90:35
subroutine avm_free_base(this)
Destructor for the avm_t (base) class.
Definition avm.f90:228
subroutine avm_restart(this, time)
Restore model state after loading a checkpoint. Models with additional history should override this m...
Definition avm.f90:218
subroutine avm_init_base(this, dof, coef, reg_coeff_name)
Artificial viscosity model factory. Both allocates and initializes the object.
Definition avm.f90:198
Defines a simulation case.
Definition case.f90:34
Coefficients.
Definition coef.f90:34
Defines a mapping of the degrees of freedom.
Definition dofmap.f90:35
Defines a field.
Definition field.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:158
Module with things related to the simulation time.
Utilities.
Definition utils.f90:35
integer, parameter, public neko_typename_len
Definition utils.f90:44
Base abstract type for artificial viscosity models.
Definition avm.f90:49
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:136
A struct that contains all info about the time, expand as needed.