1!! Copyright (C) 2020 M. Oliveira, Heiko Appel 2!! 3!! This program is free software; you can redistribute it and/or modify 4!! it under the terms of the GNU General Public License as published by 5!! the Free Software Foundation; either version 2, or (at your option) 6!! any later version. 7!! 8!! This program is distributed in the hope that it will be useful, 9!! but WITHOUT ANY WARRANTY; without even the implied warranty of 10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11!! GNU General Public License for more details. 12!! 13!! You should have received a copy of the GNU General Public License 14!! along with this program; if not, write to the Free Software 15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16!! 02110-1301, USA. 17!! 18#include "global.h" 19 20module interaction_abst_oct_m 21 use clock_oct_m 22 use global_oct_m 23 use linked_list_oct_m 24 use messages_oct_m 25 use profiling_oct_m 26 implicit none 27 28 private 29 public :: & 30 interaction_abst_t, & 31 interaction_abst_end, & 32 interaction_iterator_t 33 34 type, abstract :: interaction_abst_t 35 private 36 !> The interaction requires access to some quantities from a system to be evaluated. 37 integer, public :: n_system_quantities !< Number of quantities needed from the system 38 integer, allocatable, public :: system_quantities(:) !< Identifiers of the quantities needed from the system 39 type(clock_t), public :: clock !< Clock storing the time at which the interaction was last updated. 40 contains 41 procedure :: init_clock => interaction_init_clock 42 procedure(interaction_update), deferred :: update 43 procedure(interaction_calculate), deferred :: calculate 44 end type interaction_abst_t 45 46 !> This class extends the list iterator and adds one method to get the 47 !! interaction as a pointer of type class(interaction_abst_t). 48 type, extends(list_iterator_t) :: interaction_iterator_t 49 private 50 contains 51 procedure :: get_next_interaction => interaction_iterator_get_next 52 end type interaction_iterator_t 53 54 abstract interface 55 logical function interaction_update(this, requested_time) 56 import interaction_abst_t 57 import clock_t 58 class(interaction_abst_t), intent(inout) :: this 59 class(clock_t), intent(in) :: requested_time 60 end function interaction_update 61 62 subroutine interaction_calculate(this) 63 import interaction_abst_t 64 class(interaction_abst_t), intent(inout) :: this 65 end subroutine interaction_calculate 66 end interface 67 68contains 69 70 ! --------------------------------------------------------- 71 subroutine interaction_init_clock(this, label, dt, algo_dt) 72 class(interaction_abst_t), intent(inout) :: this 73 character(len=*), intent(in) :: label 74 FLOAT, intent(in) :: dt 75 FLOAT, intent(in) :: algo_dt 76 77 PUSH_SUB(interaction_init_clock) 78 79 this%clock = clock_t(label, dt, algo_dt, initial_tick=-1) 80 81 POP_SUB(interaction_init_clock) 82 end subroutine interaction_init_clock 83 84 ! --------------------------------------------------------- 85 subroutine interaction_abst_end(this) 86 class(interaction_abst_t), intent(inout) :: this 87 88 PUSH_SUB(interaction_abst_end) 89 90 SAFE_DEALLOCATE_A(this%system_quantities) 91 92 POP_SUB(interaction_abst_end) 93 94 end subroutine interaction_abst_end 95 96 ! --------------------------------------------------------- 97 function interaction_iterator_get_next(this) result(value) 98 class(interaction_iterator_t), intent(inout) :: this 99 class(interaction_abst_t), pointer :: value 100 101 class(*), pointer :: ptr 102 103 PUSH_SUB(interaction_iterator_get_next) 104 105 ptr => this%get_next() 106 select type (ptr) 107 class is (interaction_abst_t) 108 value => ptr 109 class default 110 ASSERT(.false.) 111 end select 112 113 POP_SUB(interaction_iterator_get_next) 114 end function interaction_iterator_get_next 115 116end module interaction_abst_oct_m 117 118!! Local Variables: 119!! mode: f90 120!! coding: utf-8 121!! End: 122