43 use json_module,
only: json_file
79 generic :: add => add_source_term, add_json_source_terms
81 procedure, pass(this) :: add_source_term => &
84 procedure, pass(this) :: add_json_source_terms => &
88 nopass,
deferred :: init_user_source
95 class(
source_term_t),
allocatable,
intent(inout) :: source_term
97 type(
coef_t),
intent(inout) :: coef
98 character(len=*) :: type
99 type(
user_t),
intent(in) :: user
109 type(
coef_t),
target,
intent(inout) :: coef
110 type(
user_t),
target,
intent(in) :: user
115 this%rhs_fields = rhs_fields
127 call this%rhs_fields%free()
129 if (
allocated(this%source_terms))
then
130 do i = 1,
size(this%source_terms)
131 call this%source_terms(i)%free()
133 deallocate(this%source_terms)
143 real(kind=
rp),
intent(in) :: t
144 integer,
intent(in) :: tstep
148 do i = 1, this%rhs_fields%size()
149 f => this%rhs_fields%get(i)
154 if (
allocated(this%source_terms))
then
155 do i = 1,
size(this%source_terms)
156 call this%source_terms(i)%source_term%compute(t, tstep)
165 type(json_file),
intent(inout) :: json
166 character(len=*),
intent(in) :: name
171 type(json_file) :: source_subdict
172 character(len=:),
allocatable :: type
173 integer :: n_sources, i, i0
175 if (json%valid_path(name))
then
177 call json%info(name, n_children=n_sources)
179 if (
allocated(this%source_terms))
then
180 i0 =
size(this%source_terms)
181 call move_alloc(this%source_terms, temp)
182 allocate(this%source_terms(i0 + n_sources))
183 if (
allocated(temp))
then
185 call move_alloc(temp(i)%source_term, this%source_terms(i)%source_term)
190 allocate(this%source_terms(n_sources))
196 call json_get(source_subdict,
"type", type)
199 if ((trim(type) .eq.
"user_vector") .or. &
200 (trim(type) .eq.
"user_pointwise"))
then
202 call this%init_user_source(this%source_terms(i+ i0)%source_term, &
203 this%rhs_fields, this%coef,
type, this%user)
206 this%source_terms(i + i0)%source_term%start_time, 0.0_rp)
208 this%source_terms(i + i0)%source_term%end_time, huge(0.0_rp))
211 call source_term_factory(this%source_terms(i + i0)%source_term, &
212 source_subdict, this%rhs_fields, this%coef)
226 integer :: n_sources, i
228 n_sources =
size(this%source_terms)
229 call move_alloc(this%source_terms, temp)
230 allocate(this%source_terms(n_sources + 1))
232 if (
allocated(temp))
then
234 call move_alloc(temp(i)%source_term, this%source_terms(i)%source_term)
238 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 field_rzero(a, n)
Zero a real vector.
Utilities for retrieving parameters from the case files.
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_compute(this, t, tstep)
Add all the source term to the passed right-hand side fields.
subroutine source_term_handler_init_base(this, rhs_fields, coef, user)
Constructor.
subroutine source_term_handler_free(this)
Destructor.
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.
Interfaces for user interaction with NEKO.
subroutine, public neko_warning(warning_msg)
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.