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 num_types, only : rp
37 use case, only : case_t
38 use field, only : field_t
39 use json_module, only : json_file
40 use registry, only : neko_registry
41 use coefs, only : coef_t
42 use dofmap, only : dofmap_t
43 use time_state, only : time_state_t
44 implicit none
45 private
46
48 type, abstract, public :: avm_t
50 type(field_t), pointer :: reg_coeff => null()
52 type(coef_t), pointer :: coef => null()
54 type(dofmap_t), pointer :: dof => null()
56 integer :: les_model_registry_size = 0
57 contains
59 procedure, pass(this) :: init_base => avm_init_base
61 procedure, pass(this) :: free_base => avm_free_base
63 procedure(avm_init), pass(this), deferred :: init
65 procedure(avm_free), pass(this), deferred :: free
67 procedure(avm_preprocess), pass(this), deferred :: preprocess
69 procedure(avm_compute), pass(this), deferred :: compute
71 procedure, pass(this) :: restart => avm_restart
72 end type avm_t
73
74 abstract interface
75
78 subroutine avm_preprocess(this, time)
79 import avm_t, time_state_t
80 class(avm_t), intent(inout) :: this
81 type(time_state_t), intent(in) :: time
82 end subroutine avm_preprocess
83 end interface
84
85 abstract interface
86
89 subroutine avm_compute(this, time)
90 import avm_t, time_state_t
91 class(avm_t), intent(inout) :: this
92 type(time_state_t), intent(in) :: time
93 end subroutine avm_compute
94 end interface
95
96 abstract interface
97
101 subroutine avm_init(this, case, json)
102 import avm_t, json_file, case_t
103 class(avm_t), intent(inout) :: this
104 class(case_t), intent(inout), target :: case
105 type(json_file), intent(inout) :: json
106 end subroutine avm_init
107 end interface
108
109 abstract interface
110
112 subroutine avm_free(this)
113 import avm_t
114 class(avm_t), intent(inout) :: this
115 end subroutine avm_free
116 end interface
117
118 interface
119
122 module subroutine avm_allocator(object, type_name)
123 class(avm_t), allocatable, intent(inout) :: object
124 character(len=*), intent(in) :: type_name
125 end subroutine avm_allocator
126 end interface
127
128 !
129 ! Machinery for injecting user-defined types
130 !
131
135 abstract interface
136
138 subroutine avm_allocate(obj)
139 import avm_t
140 class(avm_t), allocatable, intent(inout) :: obj
141 end subroutine avm_allocate
142 end interface
143
144 interface
145
148 module subroutine register_avm(type_name, allocator)
149 character(len=*), intent(in) :: type_name
150 procedure(avm_allocate), pointer, intent(in) :: allocator
151 end subroutine register_avm
152 end interface
153
156 type allocator_entry
158 character(len=20) :: type_name
160 procedure(avm_allocate), pointer, nopass :: allocator
161 end type allocator_entry
162
164 type(allocator_entry), allocatable :: avm_registry(:)
165
167 integer :: avm_registry_size = 0
168
169
170
171 interface
172
178 module subroutine avm_factory(object, type_name, case, json)
179 class(avm_t), allocatable, intent(inout) :: object
180 character(len=*), intent(in) :: type_name
181 class(case_t), intent(inout), target :: case
182 type(json_file), intent(inout) :: json
183 end subroutine avm_factory
184 end interface
185
186 public :: avm_factory, avm_allocator, register_avm, &
187 avm_allocate
188
189
190contains
196 subroutine avm_init_base(this, dof, coef, reg_coeff_name)
197 class(avm_t), intent(inout) :: this
198 class(dofmap_t), intent(in), target :: dof
199 class(coef_t), intent(in), target :: coef
200 character(len=*), intent(in) :: reg_coeff_name
201
202 call this%free_base()
203
204 call neko_registry%add_field(dof, trim(reg_coeff_name), .true.)
205
206 this%reg_coeff => neko_registry%get_field(trim(reg_coeff_name))
207 this%coef => coef
208 this%dof => dof
209
210 end subroutine avm_init_base
211
216 subroutine avm_restart(this, time)
217 class(avm_t), intent(inout) :: this
218 type(time_state_t), intent(in) :: time
219
220 call this%compute(time)
221
222 end subroutine avm_restart
223
226 subroutine avm_free_base(this)
227 class(avm_t), intent(inout) :: this
228
229 nullify(this%reg_coeff)
230 nullify(this%coef)
231 nullify(this%dof)
232
233 end subroutine avm_free_base
234
Perform artificial viscosity related computations after the time step.
Definition avm.f90:89
Perform artificial viscosity related computations before the time step.
Definition avm.f90:78
Implements avm_t.
Definition avm.f90:35
subroutine avm_free_base(this)
Destructor for the avm_t (base) class.
Definition avm.f90:227
subroutine avm_restart(this, time)
Restore model state after loading a checkpoint. Models with additional history should override this m...
Definition avm.f90:217
subroutine avm_init_base(this, dof, coef, reg_coeff_name)
Artificial viscosity model factory. Both allocates and initializes the object.
Definition avm.f90:197
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.
Base abstract type for artificial viscosity models.
Definition avm.f90:48
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:135
A struct that contains all info about the time, expand as needed.