38 use json_module,
only : json_file
48 type(
coef_t),
pointer :: coef => null()
50 real(kind=
rp) :: start_time = 0.0_rp
52 real(kind=
rp) :: end_time = huge(0.0_rp)
88 type(json_file),
intent(inout) :: json
90 type(
coef_t),
intent(in),
target :: coef
91 character(len=*),
intent(in) :: variable_name
122 module subroutine source_term_factory(object, json, fields, coef, &
124 class(source_term_t),
allocatable,
intent(inout) :: object
125 type(json_file),
intent(inout) :: json
127 type(
coef_t),
intent(inout) :: coef
128 character(len=*),
intent(in) :: variable_name
129 end subroutine source_term_factory
136 module subroutine source_term_allocator(object, type_name)
137 class(source_term_t),
allocatable,
intent(inout) :: object
138 character(len=:),
allocatable,
intent(in) :: type_name
139 end subroutine source_term_allocator
150 subroutine source_term_allocate(obj)
152 class(source_term_t),
allocatable,
intent(inout) :: obj
153 end subroutine source_term_allocate
158 module subroutine register_source_term(type_name, allocator)
159 character(len=*),
intent(in) :: type_name
160 procedure(source_term_allocate),
pointer,
intent(in) :: allocator
161 end subroutine register_source_term
167 character(len=20) :: type_name
168 procedure(source_term_allocate),
pointer,
nopass :: allocator
169 end type allocator_entry
172 type(allocator_entry),
allocatable :: source_term_registry(:)
175 integer :: source_term_registry_size = 0
177 public :: source_term_factory, source_term_allocator, register_source_term, &
188 subroutine source_term_init_base(this, fields, coef, start_time, end_time)
189 class(source_term_t),
intent(inout) :: this
191 type(
coef_t),
intent(in),
target :: coef
192 real(kind=
rp),
intent(in) :: start_time
193 real(kind=
rp),
intent(in) :: end_time
194 integer :: n_fields, i
197 this%start_time = start_time
198 this%end_time = end_time
199 n_fields = fields%size()
201 call this%fields%init(n_fields)
206 call this%fields%assign(i, fields%get(i))
208 end subroutine source_term_init_base
211 subroutine source_term_free_base(this)
212 class(source_term_t),
intent(inout) :: this
214 call this%fields%free()
216 end subroutine source_term_free_base
219 subroutine source_term_wrapper_free(this)
220 class(source_term_wrapper_t),
intent(inout) :: this
221 integer :: n_fields, i
223 if (
allocated(this%source_term))
then
224 call this%source_term%free()
225 deallocate(this%source_term)
227 end subroutine source_term_wrapper_free
231 subroutine source_term_compute_wrapper(this, time)
232 class(source_term_t),
intent(inout) :: this
235 if (time%t .ge. this%start_time .and. time%t .le. this%end_time)
then
236 call this%compute_(time)
239 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.
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.