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)
153 do i = 1, this%rhs_fields%size()
154 f => this%rhs_fields%get(i)
159 if (
allocated(this%source_terms))
then
161 do i = 1,
size(this%source_terms)
162 call this%source_terms(i)%source_term%compute(time)
166 do i = 1, this%rhs_fields%size()
167 f => this%rhs_fields%get(i)
171 call col2(f%x, this%coef%B, f%size())
182 type(json_file),
intent(inout) :: json
183 character(len=*),
intent(in) :: name
188 type(json_file) :: source_subdict
189 character(len=:),
allocatable :: type
190 integer :: n_sources, i, i0
192 if (json%valid_path(name))
then
194 call json%info(name, n_children = n_sources)
196 if (
allocated(this%source_terms))
then
197 i0 =
size(this%source_terms)
198 call move_alloc(this%source_terms, temp)
199 allocate(this%source_terms(i0 + n_sources))
200 if (
allocated(temp))
then
202 call move_alloc(temp(i)%source_term, &
203 this%source_terms(i)%source_term)
208 allocate(this%source_terms(n_sources))
214 call json_get(source_subdict,
"type", type)
217 if (trim(type) .eq.
"user")
then
219 call this%init_user_source(this%source_terms(i+ i0)%source_term, &
220 this%rhs_fields, this%coef, this%user, this%scheme_name)
223 this%source_terms(i + i0)%source_term%start_time, 0.0_rp)
225 this%source_terms(i + i0)%source_term%end_time, huge(0.0_rp))
227 call source_term_factory(this%source_terms(i + i0)%source_term, &
228 source_subdict, this%rhs_fields, this%coef, &
243 integer :: n_sources, i
245 if (
allocated(this%source_terms))
then
246 n_sources =
size(this%source_terms)
251 call move_alloc(this%source_terms, temp)
252 allocate(this%source_terms(n_sources + 1))
254 if (
allocated(temp))
then
256 call move_alloc(temp(i)%source_term, &
257 this%source_terms(i)%source_term)
261 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...