Skip to content

Commit ef89f34

Browse files
committed
Merge branch 'release/0.3.0'
2 parents ef18b26 + 88f6a02 commit ef89f34

18 files changed

+377
-328
lines changed

src/lib/foodie.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ module foodie
6262
!<```
6363

6464
use, intrinsic :: iso_fortran_env, only : stderr=>error_unit
65-
use foodie_adt_integrand, only : integrand
6665
use foodie_error_codes, only : ERROR_UNSUPPORTED_SCHEME
66+
use foodie_integrand_object, only : integrand_object
6767
use foodie_integrator_object, only : integrator_object
6868
use foodie_integrator_adams_bashforth, only : integrator_adams_bashforth
6969
use foodie_integrator_adams_bashforth_moulton, only : integrator_adams_bashforth_moulton
@@ -85,7 +85,7 @@ module foodie
8585
public :: foodie_integrator
8686
public :: foodie_integrator_class_names
8787
public :: foodie_integrator_schemes
88-
public :: integrand
88+
public :: integrand_object
8989
public :: integrator_object
9090
public :: integrator_adams_bashforth
9191
public :: integrator_adams_bashforth_moulton

src/lib/foodie_adt_integrand.f90

Lines changed: 0 additions & 92 deletions
This file was deleted.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
!< Define the abstract type *integrand* for building FOODIE ODE integrators.
2+
3+
module foodie_integrand_object
4+
!< Define the abstract type *integrand* for building FOODIE ODE integrators.
5+
6+
use penf, only : I_P, R_P
7+
8+
implicit none
9+
private
10+
public :: integrand_object
11+
12+
type, abstract :: integrand_object
13+
!< Abstract type for building FOODIE ODE integrators.
14+
#ifdef CAF
15+
class(*), allocatable :: dummy_to_allow_extensions[:] !< Dummy member to allow concrete extensions with coarray members.
16+
#endif
17+
contains
18+
! public deferred procedures that concrete integrand-field must implement
19+
procedure(time_derivative), pass(self), deferred, public :: t !< Time derivative, residuals.
20+
! operators
21+
procedure(local_error_operator), pass(lhs), deferred, public :: local_error !< `||integrand - integrand||` operator.
22+
generic, public :: operator(.lterror.) => local_error !< Estimate local truncation error.
23+
! +
24+
procedure(symmetric_operator), pass(lhs), deferred, public :: integrand_add_integrand !< `+` operator.
25+
procedure(integrand_op_real), pass(lhs), deferred, public :: integrand_add_real !< `+ real` operator.
26+
procedure(real_op_integrand), pass(rhs), deferred, public :: real_add_integrand !< `real +` operator.
27+
generic, public :: operator(+) => integrand_add_integrand, &
28+
integrand_add_real, &
29+
real_add_integrand !< Overloading `+` operator.
30+
! *
31+
procedure(symmetric_operator), pass(lhs), deferred, public :: integrand_multiply_integrand !< `*` operator.
32+
procedure(integrand_op_real), pass(lhs), deferred, public :: integrand_multiply_real !< `* real` operator.
33+
procedure(real_op_integrand), pass(rhs), deferred, public :: real_multiply_integrand !< `real *` operator.
34+
procedure(integrand_op_real_scalar), pass(lhs), deferred, public :: integrand_multiply_real_scalar !< `* real_scalar` operator.
35+
procedure(real_scalar_op_integrand), pass(rhs), deferred, public :: real_scalar_multiply_integrand !< `real_scalar *` operator.
36+
generic, public :: operator(*) => integrand_multiply_integrand, &
37+
integrand_multiply_real, &
38+
real_multiply_integrand, &
39+
integrand_multiply_real_scalar, &
40+
real_scalar_multiply_integrand !< Overloading `*` operator.
41+
! -
42+
procedure(symmetric_operator), pass(lhs), deferred, public :: integrand_sub_integrand !< `-` operator.
43+
procedure(integrand_op_real), pass(lhs), deferred, public :: integrand_sub_real !< `- real` operator.
44+
procedure(real_op_integrand), pass(rhs), deferred, public :: real_sub_integrand !< `real -` operator.
45+
generic, public :: operator(-) => integrand_sub_integrand, &
46+
integrand_sub_real, &
47+
real_sub_integrand !< Overloading `-` operator.
48+
! =
49+
procedure(assignment_integrand), pass(lhs), deferred, public :: assign_integrand !< `=` operator.
50+
procedure(assignment_real), pass(lhs), deferred, public :: assign_real !< `= real` operator.
51+
generic, public :: assignment(=) => assign_integrand, assign_real !< Overloading `=` assignament.
52+
endtype integrand_object
53+
54+
abstract interface
55+
!< Abstract type bound procedures necessary for implementing a concrete extension of [[integrand_object]].
56+
57+
function time_derivative(self, t) result(dState_dt)
58+
!< Time derivative function of integrand class, i.e. the residuals function.
59+
import :: integrand_object, R_P
60+
class(integrand_object), intent(in) :: self !< Integrand field.
61+
real(R_P), optional, intent(in) :: t !< Time.
62+
real(R_P), allocatable :: dState_dt(:) !< Result of the time derivative function of integrand field.
63+
endfunction time_derivative
64+
65+
! operators
66+
function local_error_operator(lhs, rhs) result(error)
67+
!< Estimate local truncation error between 2 solution approximations.
68+
import :: integrand_object, R_P
69+
class(integrand_object), intent(in) :: lhs !< Left hand side.
70+
class(integrand_object), intent(in) :: rhs !< Right hand side.
71+
real(R_P) :: error !< Error estimation.
72+
endfunction local_error_operator
73+
74+
pure function integrand_op_real(lhs, rhs) result(operator_result)
75+
!< Asymmetric type operator `integrand.op.real`.
76+
import :: integrand_object, R_P
77+
class(integrand_object), intent(in) :: lhs !< Left hand side.
78+
real(R_P), intent(in) :: rhs(1:) !< Right hand side.
79+
real(R_P), allocatable :: operator_result(:) !< Operator result.
80+
endfunction integrand_op_real
81+
82+
pure function real_op_integrand(lhs, rhs) result(operator_result)
83+
!< Asymmetric type operator `real.op.integrand`.
84+
import :: integrand_object, R_P
85+
class(integrand_object), intent(in) :: rhs !< Right hand side.
86+
real(R_P), intent(in) :: lhs(1:) !< Left hand side.
87+
real(R_P), allocatable :: operator_result(:) !< Operator result.
88+
endfunction real_op_integrand
89+
90+
pure function integrand_op_real_scalar(lhs, rhs) result(operator_result)
91+
!< Asymmetric type operator `integrand.op.real`.
92+
import :: integrand_object, R_P
93+
class(integrand_object), intent(in) :: lhs !< Left hand side.
94+
real(R_P), intent(in) :: rhs !< Right hand side.
95+
real(R_P), allocatable :: operator_result(:) !< Operator result.
96+
endfunction integrand_op_real_scalar
97+
98+
pure function real_scalar_op_integrand(lhs, rhs) result(operator_result)
99+
!< Asymmetric type operator `real.op.integrand`.
100+
import :: integrand_object, R_P
101+
real(R_P), intent(in) :: lhs !< Left hand side.
102+
class(integrand_object), intent(in) :: rhs !< Right hand side.
103+
real(R_P), allocatable :: operator_result(:) !< Operator result.
104+
endfunction real_scalar_op_integrand
105+
106+
pure function symmetric_operator(lhs, rhs) result(operator_result)
107+
!< Symmetric type operator integrand.op.integrand.
108+
import :: integrand_object, R_P
109+
class(integrand_object), intent(in) :: lhs !< Left hand side.
110+
class(integrand_object), intent(in) :: rhs !< Right hand side.
111+
real(R_P), allocatable :: operator_result(:) !< Operator result.
112+
endfunction symmetric_operator
113+
114+
pure subroutine assignment_integrand(lhs, rhs)
115+
!< Symmetric assignment integrand = integrand.
116+
import :: integrand_object
117+
class(integrand_object), intent(inout) :: lhs !< Left hand side.
118+
class(integrand_object), intent(in) :: rhs !< Right hand side.
119+
endsubroutine assignment_integrand
120+
121+
pure subroutine assignment_real(lhs, rhs)
122+
!< Symmetric assignment integrand = integrand.
123+
import :: integrand_object, R_P
124+
class(integrand_object), intent(inout) :: lhs !< Left hand side.
125+
real(R_P), intent(in) :: rhs(1:) !< Right hand side.
126+
endsubroutine assignment_real
127+
endinterface
128+
endmodule foodie_integrand_object

src/lib/foodie_integrator_adams_bashforth.f90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ module foodie_integrator_adams_bashforth
2626
!<
2727
!< [2] *Linear multistep method*, [wikipedia article](https://en.wikipedia.org/wiki/Linear_multistep_method).
2828

29-
use foodie_adt_integrand, only : integrand
3029
use foodie_error_codes, only : ERROR_UNSUPPORTED_SCHEME
30+
use foodie_integrand_object, only : integrand_object
3131
use foodie_integrator_object, only : integrator_object
3232
use penf, only : I_P, R_P
3333

@@ -341,8 +341,8 @@ subroutine initialize(self, scheme)
341341
subroutine integrate(self, U, previous, Dt, t, autoupdate)
342342
!< Integrate field with Adams-Bashforth class scheme.
343343
class(integrator_adams_bashforth), intent(in) :: self !< Integrator.
344-
class(integrand), intent(inout) :: U !< Field to be integrated.
345-
class(integrand), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand field.
344+
class(integrand_object), intent(inout) :: U !< Field to be integrated.
345+
class(integrand_object), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand field.
346346
real(R_P), intent(in) :: Dt !< Time steps.
347347
real(R_P), intent(in) :: t(:) !< Times.
348348
logical, optional, intent(in) :: autoupdate !< Perform cyclic autoupdate of previous time steps.
@@ -359,8 +359,8 @@ subroutine integrate(self, U, previous, Dt, t, autoupdate)
359359
subroutine update_previous(self, U, previous)
360360
!< Cyclic update previous time steps.
361361
class(integrator_adams_bashforth), intent(in) :: self !< Integrator.
362-
class(integrand), intent(in) :: U !< Field to be integrated.
363-
class(integrand), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand field.
362+
class(integrand_object), intent(in) :: U !< Field to be integrated.
363+
class(integrand_object), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand field.
364364
integer(I_P) :: s !< Steps counter.
365365

366366
do s=1, self%steps - 1

src/lib/foodie_integrator_adams_bashforth_moulton.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ module foodie_integrator_adams_bashforth_moulton
7676
!<#### Bibliography
7777
!<
7878

79-
use foodie_adt_integrand, only : integrand
8079
use foodie_error_codes, only : ERROR_UNSUPPORTED_SCHEME
80+
use foodie_integrand_object, only : integrand_object
8181
use foodie_integrator_adams_bashforth, only : integrator_adams_bashforth
8282
use foodie_integrator_adams_moulton, only : integrator_adams_moulton
8383
use foodie_integrator_object, only : integrator_object
@@ -232,8 +232,8 @@ subroutine initialize(self, scheme)
232232
subroutine integrate(self, U, previous, Dt, t, iterations)
233233
!< Integrate field with Adams-Bashforth-Moulton class scheme.
234234
class(integrator_adams_bashforth_moulton), intent(in) :: self !< Integrator.
235-
class(integrand), intent(inout) :: U !< Field to be integrated.
236-
class(integrand), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand.
235+
class(integrand_object), intent(inout) :: U !< Field to be integrated.
236+
class(integrand_object), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand.
237237
real(R_P), intent(in) :: Dt !< Time steps.
238238
real(R_P), intent(in) :: t(:) !< Times.
239239
integer(I_P), intent(in), optional :: iterations !< Fixed point iterations of AM scheme.

src/lib/foodie_integrator_adams_moulton.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ module foodie_integrator_adams_moulton
2727
!<
2828
!< [2] *Linear multistep method*, [wikipedia article](https://en.wikipedia.org/wiki/Linear_multistep_method).
2929

30-
use foodie_adt_integrand, only : integrand
3130
use foodie_error_codes, only : ERROR_UNSUPPORTED_SCHEME
31+
use foodie_integrand_object, only : integrand_object
3232
use foodie_integrator_object, only : integrator_object
3333
use penf, only : I_P, R_P
3434

@@ -339,14 +339,14 @@ subroutine initialize(self, scheme)
339339
subroutine integrate(self, U, previous, Dt, t, iterations, autoupdate)
340340
!< Integrate field with Adams-Moulton class scheme.
341341
class(integrator_adams_moulton), intent(in) :: self !< Integrator.
342-
class(integrand), intent(inout) :: U !< Field to be integrated.
343-
class(integrand), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand field.
342+
class(integrand_object), intent(inout) :: U !< Field to be integrated.
343+
class(integrand_object), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand field.
344344
real(R_P), intent(in) :: Dt !< Time steps.
345345
real(R_P), intent(in) :: t(:) !< Times.
346346
integer(I_P), intent(in), optional :: iterations !< Fixed point iterations.
347347
logical, intent(in), optional :: autoupdate !< Cyclic autoupdate of previous time steps flag.
348348
logical :: autoupdate_ !< Cyclic autoupdate of previous time steps flag, dummy var.
349-
class(integrand), allocatable :: delta !< Delta RHS for fixed point iterations.
349+
class(integrand_object), allocatable :: delta !< Delta RHS for fixed point iterations.
350350
integer(I_P) :: s !< Steps counter.
351351

352352
autoupdate_ = .true. ; if (present(autoupdate)) autoupdate_ = autoupdate
@@ -375,8 +375,8 @@ subroutine integrate(self, U, previous, Dt, t, iterations, autoupdate)
375375
subroutine update_previous(self, U, previous)
376376
!< Cyclic update previous time steps.
377377
class(integrator_adams_moulton), intent(in) :: self !< Integrator.
378-
class(integrand), intent(in) :: U !< Field to be integrated.
379-
class(integrand), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand field.
378+
class(integrand_object), intent(in) :: U !< Field to be integrated.
379+
class(integrand_object), intent(inout) :: previous(1:) !< Previous time steps solutions of integrand field.
380380
integer(I_P) :: s !< Steps counter.
381381

382382
if (self%steps>0) then

0 commit comments

Comments
 (0)