43 use json_module,
only: json_file
73 character(len=:),
allocatable :: scheme_name
83 generic :: add => add_source_term, add_json_source_terms
85 procedure, pass(this) :: add_source_term => &
88 procedure, pass(this) :: add_json_source_terms => &
92 nopass,
deferred :: init_user_source
97 coef, user, scheme_name)
99 class(
source_term_t),
allocatable,
intent(inout) :: source_term
101 type(
coef_t),
intent(in) :: coef
102 type(
user_t),
intent(in) :: user
103 character(len=*),
intent(in) :: scheme_name
114 type(
coef_t),
target,
intent(in) :: coef
115 type(
user_t),
target,
intent(in) :: user
116 character(len=*),
intent(in) :: scheme_name
121 this%rhs_fields = rhs_fields
124 this%scheme_name = trim(scheme_name)
134 call this%rhs_fields%free()
136 if (
allocated(this%source_terms))
then
137 do i = 1,
size(this%source_terms)
138 call this%source_terms(i)%free()
140 deallocate(this%source_terms)
146 if (
allocated(this%scheme_name))
then
147 deallocate(this%scheme_name)
160 do i = 1, this%rhs_fields%size()
161 f => this%rhs_fields%get(i)
166 if (
allocated(this%source_terms))
then
168 do i = 1,
size(this%source_terms)
169 call this%source_terms(i)%source_term%compute(time)
173 do i = 1, this%rhs_fields%size()
174 f => this%rhs_fields%get(i)
178 call col2(f%x, this%coef%B, f%size())
189 type(json_file),
intent(inout) :: json
190 character(len=*),
intent(in) :: name
195 type(json_file) :: source_subdict
196 character(len=:),
allocatable :: type
197 integer :: n_sources, i, i0
199 if (json%valid_path(name))
then
201 call json%info(name, n_children = n_sources)
203 if (
allocated(this%source_terms))
then
204 i0 =
size(this%source_terms)
205 call move_alloc(this%source_terms, temp)
206 allocate(this%source_terms(i0 + n_sources))
207 if (
allocated(temp))
then
209 call move_alloc(temp(i)%source_term, &
210 this%source_terms(i)%source_term)
215 allocate(this%source_terms(n_sources))
221 call json_get(source_subdict,
"type", type)
224 if (trim(type) .eq.
"user")
then
226 call this%init_user_source(this%source_terms(i+ i0)%source_term, &
227 this%rhs_fields, this%coef, this%user, this%scheme_name)
230 this%source_terms(i + i0)%source_term%start_time, 0.0_rp)
232 this%source_terms(i + i0)%source_term%end_time, huge(0.0_rp))
234 call source_term_factory(this%source_terms(i + i0)%source_term, &
235 source_subdict, this%rhs_fields, this%coef, &
250 integer :: n_sources, i
252 if (
allocated(this%source_terms))
then
253 n_sources =
size(this%source_terms)
258 call move_alloc(this%source_terms, temp)
259 allocate(this%source_terms(n_sources + 1))
261 if (
allocated(temp))
then
263 call move_alloc(temp(i)%source_term, &
264 this%source_terms(i)%source_term)
268 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_rzero(a, n)
Zero a real 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.
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)
Add all the source term to the passed 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_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...