39 use json_module,
only : json_file
49 type(
coef_t),
pointer :: coef => null()
51 real(kind=
rp) :: start_time = 0.0_rp
53 real(kind=
rp) :: end_time = huge(0.0_rp)
56 logical :: extrapolate = .true.
92 type(json_file),
intent(inout) :: json
94 type(
coef_t),
intent(in),
target :: coef
95 character(len=*),
intent(in) :: variable_name
126 module subroutine source_term_factory(object, json, fields, coef, &
128 class(source_term_t),
allocatable,
intent(inout) :: object
129 type(json_file),
intent(inout) :: json
131 type(
coef_t),
intent(inout) :: coef
132 character(len=*),
intent(in) :: variable_name
133 end subroutine source_term_factory
140 module subroutine source_term_allocator(object, type_name)
141 class(source_term_t),
allocatable,
intent(inout) :: object
142 character(len=:),
allocatable,
intent(in) :: type_name
143 end subroutine source_term_allocator
154 subroutine source_term_allocate(obj)
156 class(source_term_t),
allocatable,
intent(inout) :: obj
157 end subroutine source_term_allocate
162 module subroutine register_source_term(type_name, allocator)
163 character(len=*),
intent(in) :: type_name
164 procedure(source_term_allocate),
pointer,
intent(in) :: allocator
165 end subroutine register_source_term
171 character(len=NEKO_TYPENAME_LEN) :: type_name
172 procedure(source_term_allocate),
pointer,
nopass :: allocator
173 end type allocator_entry
176 type(allocator_entry),
allocatable :: source_term_registry(:)
179 integer :: source_term_registry_size = 0
181 public :: source_term_factory, source_term_allocator, register_source_term, &
192 subroutine source_term_init_base(this, fields, coef, start_time, end_time)
193 class(source_term_t),
intent(inout) :: this
195 type(
coef_t),
intent(in),
target :: coef
196 real(kind=
rp),
intent(in) :: start_time
197 real(kind=
rp),
intent(in) :: end_time
198 integer :: n_fields, i
201 this%start_time = start_time
202 this%end_time = end_time
203 n_fields = fields%size()
205 call this%fields%init(n_fields)
210 call this%fields%assign(i, fields%get(i))
212 end subroutine source_term_init_base
215 subroutine source_term_free_base(this)
216 class(source_term_t),
intent(inout) :: this
218 call this%fields%free()
220 this%extrapolate = .true.
221 end subroutine source_term_free_base
224 subroutine source_term_wrapper_free(this)
225 class(source_term_wrapper_t),
intent(inout) :: this
226 integer :: n_fields, i
228 if (
allocated(this%source_term))
then
229 call this%source_term%free()
230 deallocate(this%source_term)
232 end subroutine source_term_wrapper_free
236 subroutine source_term_compute_wrapper(this, time)
237 class(source_term_t),
intent(inout) :: this
240 if (time%t .ge. this%start_time .and. time%t .le. this%end_time)
then
241 call this%compute_(time)
244 end subroutine source_term_compute_wrapper
Computes the source term and adds the result to fields.
The common constructor using a JSON object.
integer, parameter, public rp
Global precision used in computations.
Implements the source_term_t type and a wrapper source_term_wrapper_t.
subroutine source_term_wrapper_free(this)
Destructor for the source_term_wrapper_t type.
subroutine source_term_compute_wrapper(this, time)
Executes compute_ based on time conditions.
subroutine source_term_free_base(this)
Destructor for the source_term_t (base) type.
subroutine source_term_init_base(this, fields, coef, start_time, end_time)
Constructor for the source_term_t (base) type.
Module with things related to the simulation time.
integer, parameter, public neko_typename_len
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.
A struct that contains all info about the time, expand as needed.