43 use json_module,
only: json_file
74 character(len=:),
allocatable :: scheme_name
77 integer :: n_unextrapolated = 0
87 generic :: add => add_source_term, add_json_source_terms
89 procedure, pass(this) :: add_source_term => &
92 procedure, pass(this) :: add_json_source_terms => &
96 nopass,
deferred :: init_user_source
101 coef, user, scheme_name)
103 class(
source_term_t),
allocatable,
intent(inout) :: source_term
105 type(
coef_t),
intent(in) :: coef
106 type(
user_t),
intent(in) :: user
107 character(len=*),
intent(in) :: scheme_name
118 type(
coef_t),
target,
intent(in) :: coef
119 type(
user_t),
target,
intent(in) :: user
120 character(len=*),
intent(in) :: scheme_name
125 this%rhs_fields = rhs_fields
128 this%scheme_name = trim(scheme_name)
138 call this%rhs_fields%free()
140 if (
allocated(this%source_terms))
then
141 do i = 1,
size(this%source_terms)
142 call this%source_terms(i)%free()
144 deallocate(this%source_terms)
146 this%n_unextrapolated = 0
151 if (
allocated(this%scheme_name))
then
152 deallocate(this%scheme_name)
171 logical,
intent(in) :: extrapolate
172 type(
field_t),
intent(in),
optional :: scale
175 integer,
allocatable :: stash_idx(:)
178 n_rhs = this%rhs_fields%size()
182 if (.not. extrapolate)
then
183 if (this%n_unextrapolated .eq. 0)
return
184 call stash%init(n_rhs)
185 allocate(stash_idx(n_rhs))
187 f => this%rhs_fields%get(i)
190 call stash%assign(i, s)
195 f => this%rhs_fields%get(i)
200 if (
allocated(this%source_terms))
then
202 do i = 1,
size(this%source_terms)
203 if (this%source_terms(i)%source_term%extrapolate .neqv. &
205 call this%source_terms(i)%source_term%compute(time)
210 f => this%rhs_fields%get(i)
214 call col2(f%x, this%coef%B, f%size())
222 if (.not. extrapolate)
then
224 f => this%rhs_fields%get(i)
230 deallocate(stash_idx)
240 this%n_unextrapolated = 0
241 if (.not.
allocated(this%source_terms))
return
243 do i = 1,
size(this%source_terms)
244 if (.not. this%source_terms(i)%source_term%extrapolate)
then
245 this%n_unextrapolated = this%n_unextrapolated + 1
254 type(json_file),
intent(inout) :: json
255 character(len=*),
intent(in) :: name
260 type(json_file) :: source_subdict
261 character(len=:),
allocatable :: type
262 integer :: n_sources, i, i0
264 if (json%valid_path(name))
then
266 call json%info(name, n_children = n_sources)
268 if (
allocated(this%source_terms))
then
269 i0 =
size(this%source_terms)
270 call move_alloc(this%source_terms, temp)
271 allocate(this%source_terms(i0 + n_sources))
272 if (
allocated(temp))
then
274 call move_alloc(temp(i)%source_term, &
275 this%source_terms(i)%source_term)
280 allocate(this%source_terms(n_sources))
286 call json_get(source_subdict,
"type", type)
289 if (trim(type) .eq.
"user")
then
291 call this%init_user_source(this%source_terms(i+ i0)%source_term, &
292 this%rhs_fields, this%coef, this%user, this%scheme_name)
295 this%source_terms(i + i0)%source_term%start_time, 0.0_rp)
297 this%source_terms(i + i0)%source_term%end_time, huge(0.0_rp))
299 call source_term_factory(this%source_terms(i + i0)%source_term, &
300 source_subdict, this%rhs_fields, this%coef, &
317 integer :: n_sources, i
319 if (
allocated(this%source_terms))
then
320 n_sources =
size(this%source_terms)
325 call move_alloc(this%source_terms, temp)
326 allocate(this%source_terms(n_sources + 1))
328 if (
allocated(temp))
then
330 call move_alloc(temp(i)%source_term, &
331 this%source_terms(i)%source_term)
335 this%source_terms(n_sources + 1)%source_term =
source_term
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
subroutine, public field_col2(a, b, n)
Vector multiplication .
subroutine, public field_rzero(a, n)
Zero a real vector.
subroutine, public field_add2(a, b, n)
Vector addition .
subroutine, public field_copy(a, b, n)
Copy a vector .
Utilities for retrieving parameters from the case files.
subroutine, public col2(a, b, n)
Vector multiplication .
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Defines a registry for storing and requesting temporary objects This can be used when you have a func...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Implements the source_term_handler_t type.
subroutine source_term_handler_free(this)
Destructor.
subroutine source_term_handler_init_base(this, rhs_fields, coef, user, scheme_name)
Constructor.
subroutine source_term_handler_compute(this, time, extrapolate, scale)
Add source terms to the right-hand side fields.
subroutine source_term_handler_add_json_source_terms(this, json, name)
Read from the json file and initialize the source terms.
subroutine source_term_handler_count_unextrapolated(this)
Count the source terms that are not extrapolated in time.
subroutine source_term_handler_add_source_term(this, source_term)
Add new source term to the list.
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Module with things related to the simulation time.
Interfaces for user interaction with NEKO.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
field_list_t, To be able to group fields together
Base abstract type for source terms.
A helper type that is needed to have an array of polymorphic objects.
Abstract class for handling source terms.
A struct that contains all info about the time, expand as needed.
A type collecting all the overridable user routines and flag to suppress type injection from custom m...