wenoof_optimal_weights.F90 Source File

Abstract optimal weights object.

This File Depends On

sourcefile~~wenoof_optimal_weights.f90~~EfferentGraph sourcefile~wenoof_optimal_weights.f90 wenoof_optimal_weights.F90 sourcefile~penf.f90 penf.F90 sourcefile~penf.f90->sourcefile~wenoof_optimal_weights.f90 sourcefile~wenoof_base_object.f90 wenoof_base_object.f90 sourcefile~wenoof_base_object.f90->sourcefile~wenoof_optimal_weights.f90 sourcefile~penf_b_size.f90 penf_b_size.F90 sourcefile~penf_b_size.f90->sourcefile~penf.f90 sourcefile~penf_stringify.f90 penf_stringify.F90 sourcefile~penf_b_size.f90->sourcefile~penf_stringify.f90 sourcefile~penf_global_parameters_variables.f90 penf_global_parameters_variables.F90 sourcefile~penf_global_parameters_variables.f90->sourcefile~penf.f90 sourcefile~penf_global_parameters_variables.f90->sourcefile~penf_b_size.f90 sourcefile~penf_global_parameters_variables.f90->sourcefile~penf_stringify.f90 sourcefile~penf_stringify.f90->sourcefile~penf.f90
Help

Files Dependent On This One

sourcefile~~wenoof_optimal_weights.f90~~AfferentGraph sourcefile~wenoof_optimal_weights.f90 wenoof_optimal_weights.F90 sourcefile~wenoof.f90 wenoof.f90 sourcefile~wenoof_optimal_weights.f90->sourcefile~wenoof.f90 sourcefile~wenoof_objects_factory.f90 wenoof_objects_factory.f90 sourcefile~wenoof_optimal_weights.f90->sourcefile~wenoof_objects_factory.f90 sourcefile~wenoof_interpolator_js.f90 wenoof_interpolator_js.f90 sourcefile~wenoof_optimal_weights.f90->sourcefile~wenoof_interpolator_js.f90 sourcefile~wenoof_interpolator.f90 wenoof_interpolator.F90 sourcefile~wenoof_optimal_weights.f90->sourcefile~wenoof_interpolator.f90 sourcefile~wenoof_optimal_weights_js.f90 wenoof_optimal_weights_js.f90 sourcefile~wenoof_optimal_weights.f90->sourcefile~wenoof_optimal_weights_js.f90 sourcefile~sin_reconstruction.f90 sin_reconstruction.f90 sourcefile~wenoof.f90->sourcefile~sin_reconstruction.f90 sourcefile~wenoof_objects_factory.f90->sourcefile~wenoof_interpolator.f90 sourcefile~wenoof_interpolator_js.f90->sourcefile~wenoof.f90 sourcefile~wenoof_interpolator.f90->sourcefile~wenoof.f90 sourcefile~wenoof_interpolator.f90->sourcefile~wenoof_interpolator_js.f90 sourcefile~wenoof_optimal_weights_js.f90->sourcefile~wenoof.f90 sourcefile~wenoof_optimal_weights_js.f90->sourcefile~wenoof_objects_factory.f90 sourcefile~wenoof_optimal_weights_js.f90->sourcefile~wenoof_interpolator_js.f90
Help


Source Code

!< Abstract optimal weights object.
module wenoof_optimal_weights
!< Abstract optimal weights object.

use penf, only : I_P, R_P
use wenoof_base_object

implicit none
private
public :: optimal_weights
public :: optimal_weights_constructor

type, extends(base_object_constructor) :: optimal_weights_constructor
  !< Abstract optimal weights object constructor.
  integer(I_P) :: S = 0 !< Stencils dimension.
endtype optimal_weights_constructor

type, extends(base_object) :: optimal_weights
  !< Optimal weights object.
  real(R_P), allocatable :: opt(:,:) !< Optimal weights [1:2,0:S-1].
  contains
    ! deferred public methods
    procedure, pass(self) :: compute     !< Compute weights.
    procedure, nopass     :: description !< Return weights string-description.
    ! public methods
    procedure, pass(self) :: create  !< Createte weights.
    procedure, pass(self) :: destroy !< Destroy weights.
endtype optimal_weights

contains
  ! deferred public methods
  pure subroutine compute(self, S)
  !< Compute weights.
  class(optimal_weights), intent(inout) :: self !< Optimal weights.
  integer(I_P),           intent(in)    :: S    !< Number of stencils used.

#ifndef DEBUG
  ! error stop in pure procedure is a F2015 feature not yet supported in debug mode
  error stop 'optimal_weights%compute to be implemented by your concrete optimal weights object'
#endif
  endsubroutine compute

  pure function description() result(string)
  !< Return weights string-description.
  character(len=:), allocatable  :: string !< String-description.

#ifndef DEBUG
  ! error stop in pure procedure is a F2015 feature not yet supported in debug mode
  error stop 'optimal_weights%description to be implemented by your concrete optimal weights object'
#endif
  endfunction description

  ! public methods
  pure subroutine create(self, constructor)
  !< Create weights.
  !<
  !< @note During creation the weights are also computed.
  class(optimal_weights),         intent(inout) :: self        !< Optimal weights.
  class(base_object_constructor), intent(in)    :: constructor !< Optimal weights constructor.

  call self%destroy
  select type(constructor)
  class is(optimal_weights_constructor)
    allocate(self%opt(1:2, 0:constructor%S - 1))
    call self%compute(S=constructor%S)
  class default
    ! @TODO add error handling
  endselect
  endsubroutine create

  elemental subroutine destroy(self)
  !< Destroy weights.
  class(optimal_weights), intent(inout) :: self !< Optimial weights.

  if (allocated(self%opt)) deallocate(self%opt)
  endsubroutine destroy
endmodule wenoof_optimal_weights