38 use json_module,
only : json_file
47 type(
coef_t),
pointer :: coef => null()
49 real(kind=
rp) :: start_time = 0.0_rp
51 real(kind=
rp) :: end_time = huge(0.0_rp)
85 type(json_file),
intent(inout) :: json
87 type(
coef_t),
intent(in),
target :: coef
106 real(kind=
rp),
intent(in) :: t
107 integer,
intent(in) :: tstep
117 module subroutine source_term_factory(object, json, fields, coef)
118 class(source_term_t),
allocatable,
intent(inout) :: object
119 type(json_file),
intent(inout) :: json
121 type(
coef_t),
intent(inout) :: coef
122 end subroutine source_term_factory
129 module subroutine source_term_allocator(object, type_name)
130 class(source_term_t),
allocatable,
intent(inout) :: object
131 character(len=:),
allocatable,
intent(in) :: type_name
132 end subroutine source_term_allocator
143 subroutine source_term_allocate(obj)
145 class(source_term_t),
allocatable,
intent(inout) :: obj
143 subroutine source_term_allocate(obj)
…
146 end subroutine source_term_allocate
151 module subroutine register_source_term(type_name, allocator)
152 character(len=*),
intent(in) :: type_name
153 procedure(source_term_allocate),
pointer,
intent(in) :: allocator
154 end subroutine register_source_term
160 character(len=20) :: type_name
161 procedure(source_term_allocate),
pointer,
nopass :: allocator
162 end type allocator_entry
159 type allocator_entry
…
165 type(allocator_entry),
allocatable :: source_term_registry(:)
168 integer :: source_term_registry_size = 0
170 public :: source_term_factory, source_term_allocator, register_source_term, &
181 subroutine source_term_init_base(this, fields, coef, start_time, end_time)
182 class(source_term_t),
intent(inout) :: this
184 type(
coef_t),
intent(in),
target :: coef
185 real(kind=
rp),
intent(in) :: start_time
186 real(kind=
rp),
intent(in) :: end_time
187 integer :: n_fields, i
190 this%start_time = start_time
191 this%end_time = end_time
192 n_fields = fields%size()
194 call this%fields%init(n_fields)
199 call this%fields%assign(i, fields%get(i))
181 subroutine source_term_init_base(this, fields, coef, start_time, end_time)
…
201 end subroutine source_term_init_base
204 subroutine source_term_free_base(this)
205 class(source_term_t),
intent(inout) :: this
207 call this%fields%free()
204 subroutine source_term_free_base(this)
…
209 end subroutine source_term_free_base
212 subroutine source_term_wrapper_free(this)
213 class(source_term_wrapper_t),
intent(inout) :: this
214 integer :: n_fields, i
216 if (
allocated(this%source_term))
then
217 call this%source_term%free()
218 deallocate(this%source_term)
212 subroutine source_term_wrapper_free(this)
…
220 end subroutine source_term_wrapper_free
225 subroutine source_term_compute_wrapper(this, t, tstep)
226 class(source_term_t),
intent(inout) :: this
227 real(kind=
rp),
intent(in) :: t
228 integer,
intent(in) :: tstep
230 if (t .ge. this%start_time .and. t .le. this%end_time)
then
231 call this%compute_(t, tstep)
225 subroutine source_term_compute_wrapper(this, t, tstep)
…
234 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, t, tstep)
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.
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.