Skip to content

Commit

Permalink
dehydrate tester
Browse files Browse the repository at this point in the history
  • Loading branch information
szaghi committed May 26, 2017
1 parent f806e9d commit 1812d6e
Show file tree
Hide file tree
Showing 18 changed files with 213 additions and 411 deletions.
21 changes: 1 addition & 20 deletions src/lib/foodie_integrator_adams_bashforth.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ module foodie_integrator_adams_bashforth
contains
! deferred methods
procedure, pass(self) :: class_name !< Return the class name of schemes.
procedure, pass(self) :: description !< Return pretty-printed object description.
procedure, pass(self) :: has_fast_mode !< Return .true. if the integrator class has *fast mode* integrate.
procedure, pass(lhs) :: integr_assign_integr !< Operator `=`.
procedure, pass(self) :: integrate !< Integrate integrand field.
Expand All @@ -90,25 +89,6 @@ pure function class_name(self)
class_name = trim(adjustl(class_name_))
endfunction class_name

pure function description(self, prefix) result(desc)
!< Return a pretty-formatted object description.
class(integrator_adams_bashforth), intent(in) :: self !< Integrator.
character(*), intent(in), optional :: prefix !< Prefixing string.
character(len=:), allocatable :: desc !< Description.
character(len=:), allocatable :: prefix_ !< Prefixing string, local variable.
character(len=1), parameter :: NL=new_line('a') !< New line character.
integer(I_P) :: s !< Counter.

prefix_ = '' ; if (present(prefix)) prefix_ = prefix
desc = ''
desc = desc//prefix_//'Adams-Bashforth multi-step schemes class'//NL
desc = desc//prefix_//' Supported schemes:'//NL
do s=lbound(supported_schemes_, dim=1), ubound(supported_schemes_, dim=1) - 1
desc = desc//prefix_//' + '//supported_schemes_(s)//NL
enddo
desc = desc//prefix_//' + '//supported_schemes_(ubound(supported_schemes_, dim=1))
endfunction description

elemental function has_fast_mode(self)
!< Return .true. if the integrator class has *fast mode* integrate.
class(integrator_adams_bashforth), intent(in) :: self !< Integrator.
Expand Down Expand Up @@ -207,6 +187,7 @@ subroutine initialize(self, scheme, autoupdate, U, stop_on_fail)

if (self%is_supported(scheme=scheme)) then
call self%destroy
self%description_ = trim(adjustl(scheme))
select case(trim(adjustl(scheme)))
case('adams_bashforth_1')
self%steps = 1 ; allocate(self%b(1:self%steps)) ; self%b = 0.0_R_P
Expand Down
21 changes: 1 addition & 20 deletions src/lib/foodie_integrator_adams_bashforth_moulton.f90
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ module foodie_integrator_adams_bashforth_moulton
contains
! deferred methods
procedure, pass(self) :: class_name !< Return the class name of schemes.
procedure, pass(self) :: description !< Return pretty-printed object description.
procedure, pass(self) :: has_fast_mode !< Return .true. if the integrator class has *fast mode* integrate.
procedure, pass(lhs) :: integr_assign_integr !< Operator `=`.
procedure, pass(self) :: integrate !< Integrate integrand field.
Expand All @@ -144,25 +143,6 @@ pure function class_name(self)
class_name = trim(adjustl(class_name_))
endfunction class_name

pure function description(self, prefix) result(desc)
!< Return a pretty-formatted object description.
class(integrator_adams_bashforth_moulton), intent(in) :: self !< Integrator.
character(*), intent(in), optional :: prefix !< Prefixing string.
character(len=:), allocatable :: desc !< Description.
character(len=:), allocatable :: prefix_ !< Prefixing string, local variable.
character(len=1), parameter :: NL=new_line('a') !< New line character.
integer(I_P) :: s !< Counter.

prefix_ = '' ; if (present(prefix)) prefix_ = prefix
desc = ''
desc = desc//prefix_//'Adams-Bashforth-Moulton multi-step (predictor-corrector) schemes class'//NL
desc = desc//prefix_//' Supported schemes:'//NL
do s=lbound(supported_schemes_, dim=1), ubound(supported_schemes_, dim=1) - 1
desc = desc//prefix_//' + '//supported_schemes_(s)//NL
enddo
desc = desc//prefix_//' + '//supported_schemes_(ubound(supported_schemes_, dim=1))
endfunction description

elemental function has_fast_mode(self)
!< Return .true. if the integrator class has *fast mode* integrate.
class(integrator_adams_bashforth_moulton), intent(in) :: self !< Integrator.
Expand Down Expand Up @@ -282,6 +262,7 @@ subroutine initialize(self, scheme, iterations, autoupdate, U, stop_on_fail)

if (self%is_supported(scheme=scheme)) then
call self%destroy
self%description_ = trim(adjustl(scheme))
scheme_number_ = self%scheme_number(scheme=scheme)
schemes_ab = self%predictor%supported_schemes()
schemes_am = self%corrector%supported_schemes()
Expand Down
23 changes: 2 additions & 21 deletions src/lib/foodie_integrator_adams_moulton.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ module foodie_integrator_adams_moulton
contains
! deferred methods
procedure, pass(self) :: class_name !< Return the class name of schemes.
procedure, pass(self) :: description !< Return pretty-printed object description.
procedure, pass(lhs) :: integr_assign_integr !< Operator `=`.
procedure, pass(self) :: has_fast_mode !< Return .true. if the integrator class has *fast mode* integrate.
procedure, pass(self) :: integrate !< Integrate integrand field.
Expand All @@ -91,25 +90,6 @@ pure function class_name(self)
class_name = trim(adjustl(class_name_))
endfunction class_name

pure function description(self, prefix) result(desc)
!< Return a pretty-formatted object description.
class(integrator_adams_moulton), intent(in) :: self !< Integrator.
character(*), intent(in), optional :: prefix !< Prefixing string.
character(len=:), allocatable :: desc !< Description.
character(len=:), allocatable :: prefix_ !< Prefixing string, local variable.
character(len=1), parameter :: NL=new_line('a') !< New line character.
integer(I_P) :: s !< Counter.

prefix_ = '' ; if (present(prefix)) prefix_ = prefix
desc = ''
desc = desc//prefix_//'Adams-Moulton multi-step schemes class'//NL
desc = desc//prefix_//' Supported schemes:'//NL
do s=lbound(supported_schemes_, dim=1), ubound(supported_schemes_, dim=1) - 1
desc = desc//prefix_//' + '//supported_schemes_(s)//NL
enddo
desc = desc//prefix_//' + '//supported_schemes_(ubound(supported_schemes_, dim=1))
endfunction description

elemental function has_fast_mode(self)
!< Return .true. if the integrator class has *fast mode* integrate.
class(integrator_adams_moulton), intent(in) :: self !< Integrator.
Expand Down Expand Up @@ -252,7 +232,8 @@ subroutine initialize(self, scheme, iterations, autoupdate, U, stop_on_fail)
logical, intent(in), optional :: stop_on_fail !< Stop execution if initialization fail.

if (self%is_supported(scheme=scheme)) then
call self%destroy
call self%destroy
self%description_ = trim(adjustl(scheme))
select case(trim(adjustl(scheme)))
case('adams_moulton_0')
self%steps = 0 ; allocate(self%b(0:self%steps)) ; self%b = 0.0_R_P
Expand Down
23 changes: 2 additions & 21 deletions src/lib/foodie_integrator_backward_differentiation_formula.f90
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ module foodie_integrator_backward_differentiation_formula
contains
! deferred methods
procedure, pass(self) :: class_name !< Return the class name of schemes.
procedure, pass(self) :: description !< Return pretty-printed object description.
procedure, pass(self) :: has_fast_mode !< Return .true. if the integrator class has *fast mode* integrate.
procedure, pass(lhs) :: integr_assign_integr !< Operator `=`.
procedure, pass(self) :: integrate !< Integrate integrand field.
Expand All @@ -89,25 +88,6 @@ pure function class_name(self)
class_name = trim(adjustl(class_name_))
endfunction class_name

pure function description(self, prefix) result(desc)
!< Return a pretty-formatted object description.
class(integrator_back_df), intent(in) :: self !< Integrator.
character(*), intent(in), optional :: prefix !< Prefixing string.
character(len=:), allocatable :: desc !< Description.
character(len=:), allocatable :: prefix_ !< Prefixing string, local variable.
character(len=1), parameter :: NL=new_line('a') !< New line character.
integer(I_P) :: s !< Counter.

prefix_ = '' ; if (present(prefix)) prefix_ = prefix
desc = ''
desc = desc//prefix_//'Backward-Differentiation-Formula multi-step schemes class'//NL
desc = desc//prefix_//' Supported schemes:'//NL
do s=lbound(supported_schemes_, dim=1), ubound(supported_schemes_, dim=1) - 1
desc = desc//prefix_//' + '//supported_schemes_(s)//NL
enddo
desc = desc//prefix_//' + '//supported_schemes_(ubound(supported_schemes_, dim=1))
endfunction description

elemental function has_fast_mode(self)
!< Return .true. if the integrator class has *fast mode* integrate.
class(integrator_back_df), intent(in) :: self !< Integrator.
Expand Down Expand Up @@ -219,7 +199,8 @@ subroutine initialize(self, scheme, iterations, autoupdate, U, stop_on_fail)
logical, intent(in), optional :: stop_on_fail !< Stop execution if initialization fail.

if (self%is_supported(scheme=scheme)) then
call self%destroy
call self%destroy
self%description_ = trim(adjustl(scheme))
select case(trim(adjustl(scheme)))
case('back_df_1')
self%steps = 1 ; allocate(self%a(1:self%steps)) ; self%a = 0.0_R_P
Expand Down
49 changes: 19 additions & 30 deletions src/lib/foodie_integrator_euler_explicit.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module foodie_integrator_euler_explicit
contains
! deferred methods
procedure, pass(self) :: class_name !< Return the class name of schemes.
procedure, pass(self) :: description !< Return pretty-printed object description.
procedure, pass(self) :: has_fast_mode !< Return .true. if the integrator class has *fast mode* integrate.
procedure, pass(lhs) :: integr_assign_integr !< Operator `=`.
procedure, pass(self) :: integrate !< Integrate integrand field.
Expand All @@ -55,17 +54,6 @@ pure function class_name(self)
class_name = trim(adjustl(class_name_))
endfunction class_name

pure function description(self, prefix) result(desc)
!< Return a pretty-formatted object description.
class(integrator_euler_explicit), intent(in) :: self !< Integrator.
character(*), intent(in), optional :: prefix !< Prefixing string.
character(len=:), allocatable :: desc !< Description.
character(len=:), allocatable :: prefix_ !< Prefixing string, local variable.

prefix_ = '' ; if (present(prefix)) prefix_ = prefix
desc = prefix_//'Euler, Explicit (1 step/stage) 1st order scheme'
endfunction description

elemental function has_fast_mode(self)
!< Return .true. if the integrator class has *fast mode* integrate.
class(integrator_euler_explicit), intent(in) :: self !< Integrator.
Expand Down Expand Up @@ -142,22 +130,23 @@ elemental subroutine destroy(self)
call self%destroy_multistage
endsubroutine destroy

subroutine initialize(self, scheme, U, stop_on_fail)
!< Create the actual RK integrator: initialize the Butcher' table coefficients.
class(integrator_euler_explicit), intent(inout) :: self !< Integrator.
character(*), intent(in) :: scheme !< Selected scheme.
class(integrand_object), intent(in), optional :: U !< Integrand molding prototype.
logical, intent(in), optional :: stop_on_fail !< Stop execution if initialization fail.

if (self%is_supported(scheme=scheme)) then
call self%destroy
self%stages = 0
self%registers = self%stages
if (present(U)) call self%allocate_integrand_members(U=U)
else
call self%trigger_error(error=ERROR_UNSUPPORTED_SCHEME, &
error_message='"'//trim(adjustl(scheme))//'" unsupported scheme', &
is_severe=stop_on_fail)
endif
endsubroutine initialize
subroutine initialize(self, scheme, U, stop_on_fail)
!< Create the actual RK integrator: initialize the Butcher' table coefficients.
class(integrator_euler_explicit), intent(inout) :: self !< Integrator.
character(*), intent(in) :: scheme !< Selected scheme.
class(integrand_object), intent(in), optional :: U !< Integrand molding prototype.
logical, intent(in), optional :: stop_on_fail !< Stop execution if initialization fail.

if (self%is_supported(scheme=scheme)) then
call self%destroy
self%description_ = trim(adjustl(scheme))
self%stages = 0
self%registers = self%stages
if (present(U)) call self%allocate_integrand_members(U=U)
else
call self%trigger_error(error=ERROR_UNSUPPORTED_SCHEME, &
error_message='"'//trim(adjustl(scheme))//'" unsupported scheme', &
is_severe=stop_on_fail)
endif
endsubroutine initialize
endmodule foodie_integrator_euler_explicit
41 changes: 15 additions & 26 deletions src/lib/foodie_integrator_leapfrog.f90
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ module foodie_integrator_leapfrog
contains
! deferred methods
procedure, pass(self) :: class_name !< Return the class name of schemes.
procedure, pass(self) :: description !< Return pretty-printed object description.
procedure, pass(self) :: has_fast_mode !< Return .true. if the integrator class has *fast mode* integrate.
procedure, pass(lhs) :: integr_assign_integr !< Operator `=`.
procedure, pass(self) :: integrate !< Integrate integrand field.
Expand All @@ -91,17 +90,6 @@ pure function class_name(self)
class_name = trim(adjustl(class_name_))
endfunction class_name

pure function description(self, prefix) result(desc)
!< Return a pretty-formatted object description.
class(integrator_leapfrog), intent(in) :: self !< Integrator.
character(*), intent(in), optional :: prefix !< Prefixing string.
character(len=:), allocatable :: desc !< Description.
character(len=:), allocatable :: prefix_ !< Prefixing string, local variable.

prefix_ = '' ; if (present(prefix)) prefix_ = prefix
desc = desc//prefix_//'Explicit leapfrog multi-step 2nd order scheme'
endfunction description

elemental function has_fast_mode(self)
!< Return .true. if the integrator class has *fast mode* integrate.
class(integrator_leapfrog), intent(in) :: self !< Integrator.
Expand Down Expand Up @@ -219,21 +207,22 @@ subroutine initialize(self, scheme, nu, alpha, autoupdate, U, stop_on_fail)
logical, intent(in), optional :: stop_on_fail !< Stop execution if initialization fail.

if (self%is_supported(scheme=scheme)) then
call self%destroy
select case(trim(adjustl(scheme)))
case('leapfrog_raw')
self%nu = 0.01_R_P ; if (present(nu)) self%nu = nu
self%alpha = 0.53_R_P ; if (present(alpha)) self%alpha = alpha
self%is_filtered = .true.
endselect
self%autoupdate = .true. ; if (present(autoupdate)) self%autoupdate = autoupdate
self%steps = 2
self%registers = self%steps
if (present(U)) call self%allocate_integrand_members(U=U)
call self%destroy
self%description_ = trim(adjustl(scheme))
select case(trim(adjustl(scheme)))
case('leapfrog_raw')
self%nu = 0.01_R_P ; if (present(nu)) self%nu = nu
self%alpha = 0.53_R_P ; if (present(alpha)) self%alpha = alpha
self%is_filtered = .true.
endselect
self%autoupdate = .true. ; if (present(autoupdate)) self%autoupdate = autoupdate
self%steps = 2
self%registers = self%steps
if (present(U)) call self%allocate_integrand_members(U=U)
else
call self%trigger_error(error=ERROR_UNSUPPORTED_SCHEME, &
error_message='"'//trim(adjustl(scheme))//'" unsupported scheme', &
is_severe=stop_on_fail)
call self%trigger_error(error=ERROR_UNSUPPORTED_SCHEME, &
error_message='"'//trim(adjustl(scheme))//'" unsupported scheme', &
is_severe=stop_on_fail)
endif
endsubroutine initialize

Expand Down
Loading

0 comments on commit 1812d6e

Please sign in to comment.