LCOV - code coverage report
Current view: top level - src/pw - dirichlet_bc_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:d1f8d1b) Lines: 72 81 88.9 %
Date: 2024-11-29 06:42:44 Functions: 3 8 37.5 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief  Dirichlet boundary condition data types
      10             : !> \par History
      11             : !>       08.2014 created [Hossein Bani-Hashemian]
      12             : !>       10.2015 completely revised [Hossein Bani-Hashemian]
      13             : !> \author Mohammad Hossein Bani-Hashemian
      14             : ! **************************************************************************************************
      15             : MODULE dirichlet_bc_types
      16             : 
      17             :    USE kinds,                           ONLY: dp
      18             :    USE pw_pool_types,                   ONLY: pw_pool_type
      19             :    USE pw_types,                        ONLY: pw_r3d_rs_type
      20             : #include "../base/base_uses.f90"
      21             : 
      22             :    IMPLICIT NONE
      23             :    PRIVATE
      24             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'dirichlet_bc_types'
      25             : 
      26             : ! main types
      27             :    TYPE :: dirichlet_bc_parameters
      28             :       LOGICAL                                  :: verbose_output = .FALSE.
      29             :       LOGICAL                                  :: do_dbc_cube = .FALSE.
      30             :       REAL(KIND=dp)                            :: time = 0.0_dp
      31             : 
      32             :       INTEGER                                  :: n_aa_planar = 0
      33             :       INTEGER, DIMENSION(:, :), POINTER         :: aa_planar_nprtn => NULL()
      34             :       INTEGER, DIMENSION(:), POINTER           :: aa_planar_pplane => NULL()
      35             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: aa_planar_xxtnt => NULL()
      36             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: aa_planar_yxtnt => NULL()
      37             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: aa_planar_zxtnt => NULL()
      38             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_planar_vD => NULL()
      39             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_planar_osc_frac => NULL()
      40             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_planar_frequency => NULL()
      41             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_planar_phase => NULL()
      42             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_planar_sigma => NULL()
      43             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_planar_thickness => NULL()
      44             :       LOGICAL, DIMENSION(:), POINTER           :: aa_planar_is_periodic => NULL()
      45             : 
      46             :       INTEGER                                  :: n_planar = 0
      47             :       INTEGER, DIMENSION(:, :), POINTER         :: planar_nprtn => NULL()
      48             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: planar_Avtx => NULL()
      49             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: planar_Bvtx => NULL()
      50             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: planar_Cvtx => NULL()
      51             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: planar_Dvtx => NULL()
      52             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: planar_vD => NULL()
      53             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: planar_osc_frac => NULL()
      54             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: planar_frequency => NULL()
      55             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: planar_phase => NULL()
      56             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: planar_sigma => NULL()
      57             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: planar_thickness => NULL()
      58             :       LOGICAL, DIMENSION(:), POINTER           :: planar_is_periodic => NULL()
      59             : 
      60             :       INTEGER                                  :: n_aa_cylindrical = 0
      61             :       INTEGER, DIMENSION(:, :), POINTER         :: aa_cylindrical_nprtn => NULL()
      62             :       INTEGER, DIMENSION(:), POINTER           :: aa_cylindrical_paxis => NULL()
      63             :       INTEGER, DIMENSION(:), POINTER           :: aa_cylindrical_nsides => NULL()
      64             :       INTEGER, DIMENSION(:), POINTER           :: aa_cylindrical_apxtyp => NULL()
      65             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: aa_cylindrical_xtnt => NULL()
      66             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: aa_cylindrical_bctr => NULL()
      67             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cylindrical_brad => NULL()
      68             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cylindrical_vD => NULL()
      69             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cylindrical_osc_frac => NULL()
      70             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cylindrical_frequency => NULL()
      71             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cylindrical_phase => NULL()
      72             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cylindrical_sigma => NULL()
      73             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cylindrical_thickness => NULL()
      74             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cylindrical_sgap => NULL()
      75             :       LOGICAL, DIMENSION(:), POINTER           :: aa_cylindrical_is_periodic => NULL()
      76             : 
      77             :       INTEGER                                  :: n_aa_cuboidal = 0
      78             :       INTEGER, DIMENSION(:, :), POINTER         :: aa_cuboidal_nprtn => NULL()
      79             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: aa_cuboidal_xxtnt => NULL()
      80             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: aa_cuboidal_yxtnt => NULL()
      81             :       REAL(KIND=dp), DIMENSION(:, :), POINTER   :: aa_cuboidal_zxtnt => NULL()
      82             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cuboidal_vD => NULL()
      83             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cuboidal_osc_frac => NULL()
      84             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cuboidal_frequency => NULL()
      85             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cuboidal_phase => NULL()
      86             :       REAL(KIND=dp), DIMENSION(:), POINTER     :: aa_cuboidal_sigma => NULL()
      87             :       LOGICAL, DIMENSION(:), POINTER           :: aa_cuboidal_is_periodic => NULL()
      88             :    END TYPE dirichlet_bc_parameters
      89             : 
      90             :    TYPE :: dirichlet_bc_type
      91             :       REAL(dp)                          :: v_D = 0.0_dp
      92             :       REAL(dp)                          :: osc_frac = 0.0_dp
      93             :       REAL(dp)                          :: frequency = 0.0_dp
      94             :       REAL(dp)                          :: phase = 0.0_dp
      95             :       INTEGER                           :: dbc_id = 0
      96             :       INTEGER                           :: dbc_geom = 0
      97             :       REAL(dp), DIMENSION(3, 8)          :: vertices = 0
      98             :       TYPE(tile_p_type), &
      99             :          DIMENSION(:), POINTER           :: tiles => NULL()
     100             :       INTEGER                           :: n_tiles = 0
     101             :       REAL(dp)                          :: smoothing_width = 0.0_dp
     102             :    END TYPE dirichlet_bc_type
     103             : 
     104             :    TYPE :: dirichlet_bc_p_type
     105             :       TYPE(dirichlet_bc_type), POINTER  :: dirichlet_bc => NULL()
     106             :    END TYPE dirichlet_bc_p_type
     107             : 
     108             :    TYPE :: tile_type
     109             :       INTEGER                           :: tile_id = 0
     110             :       REAL(dp), DIMENSION(3, 8)          :: vertices = 0
     111             :       TYPE(pw_r3d_rs_type), POINTER            :: tile_pw => NULL()
     112             :       REAL(dp)                          :: volume = 0.0_dp
     113             :    END TYPE tile_type
     114             : 
     115             :    TYPE :: tile_p_type
     116             :       TYPE(tile_type), POINTER          :: tile => NULL()
     117             :    END TYPE tile_p_type
     118             : 
     119             : ! publicly accessible entities
     120             :    PUBLIC dirichlet_bc_type, dirichlet_bc_p_type, tile_type, tile_p_type
     121             :    PUBLIC dirichlet_bc_parameters
     122             : 
     123             :    PUBLIC dbc_release, &
     124             :       dbc_tile_release, &
     125             :       dbc_parameters_dealloc
     126             : 
     127             : ! parameters
     128             :    INTEGER, PARAMETER, PUBLIC           :: AA_PLANAR = 10, &
     129             :                                            PLANAR = 11, &
     130             :                                            CYLINDRICAL = 20, &
     131             :                                            AA_CUBOIDAL = 30
     132             : 
     133             :    INTEGER, PARAMETER, PUBLIC           :: CIRCUMSCRIBED = 1, &
     134             :                                            INSCRIBED = 2
     135             : 
     136             :    INTEGER, PARAMETER, PUBLIC           :: xy_plane = 110, &
     137             :                                            xz_plane = 101, &
     138             :                                            yz_plane = 011
     139             : 
     140             :    INTEGER, PARAMETER, PUBLIC           :: x_axis = 100, &
     141             :                                            y_axis = 010, &
     142             :                                            z_axis = 001
     143             : CONTAINS
     144             : 
     145             : ! **************************************************************************************************
     146             : !> \brief   releases the defined Dirichlet boundary region
     147             : !> \param contacts the DBC region to be released
     148             : !> \param do_dbc_cube ...
     149             : !> \param pw_pool pool of the plane wave grid
     150             : !> \par History
     151             : !>       08.2014 created [Hossein Bani-Hashemian]
     152             : !> \author Mohammad Hossein Bani-Hashemian
     153             : ! **************************************************************************************************
     154          54 :    SUBROUTINE dbc_release(contacts, do_dbc_cube, pw_pool)
     155             : 
     156             :       TYPE(dirichlet_bc_p_type), ALLOCATABLE, &
     157             :          DIMENSION(:), INTENT(INOUT)                     :: contacts
     158             :       LOGICAL, INTENT(IN)                                :: do_dbc_cube
     159             :       TYPE(pw_pool_type), INTENT(IN), OPTIONAL, POINTER  :: pw_pool
     160             : 
     161             :       CHARACTER(LEN=*), PARAMETER                        :: routineN = 'dbc_release'
     162             : 
     163             :       INTEGER                                            :: handle, i, n_contacts
     164             : 
     165          54 :       CALL timeset(routineN, handle)
     166             : 
     167          54 :       IF (ALLOCATED(contacts)) THEN
     168          38 :          n_contacts = SIZE(contacts)
     169          38 :          IF (do_dbc_cube) THEN
     170           0 :             DO i = 1, n_contacts
     171           0 :                CALL dbc_tile_release(contacts(i)%dirichlet_bc, pw_pool)
     172           0 :                DEALLOCATE (contacts(i)%dirichlet_bc)
     173             :             END DO
     174             :          ELSE
     175         166 :             DO i = 1, n_contacts
     176         166 :                DEALLOCATE (contacts(i)%dirichlet_bc)
     177             :             END DO
     178             :          END IF
     179          38 :          DEALLOCATE (contacts)
     180             :       END IF
     181             : 
     182          54 :       CALL timestop(handle)
     183             : 
     184          54 :    END SUBROUTINE dbc_release
     185             : 
     186             : ! **************************************************************************************************
     187             : !> \brief   releases tiles
     188             : !> \param dbc ...
     189             : !> \param pw_pool pool of the plane wave grid
     190             : !> \par History
     191             : !>       11.2015 created [Hossein Bani-Hashemian]
     192             : !> \author Mohammad Hossein Bani-Hashemian
     193             : ! **************************************************************************************************
     194         128 :    SUBROUTINE dbc_tile_release(dbc, pw_pool)
     195             : 
     196             :       TYPE(dirichlet_bc_type), INTENT(INOUT), POINTER    :: dbc
     197             :       TYPE(pw_pool_type), INTENT(IN), OPTIONAL, POINTER  :: pw_pool
     198             : 
     199             :       CHARACTER(LEN=*), PARAMETER                        :: routineN = 'dbc_tile_release'
     200             : 
     201             :       INTEGER                                            :: handle, k, n_tiles
     202             : 
     203         128 :       CALL timeset(routineN, handle)
     204             : 
     205         128 :       n_tiles = dbc%n_tiles
     206         128 :       IF (PRESENT(pw_pool)) THEN
     207         352 :          DO k = 1, n_tiles
     208         224 :             CALL pw_pool%give_back_pw(dbc%tiles(k)%tile%tile_pw)
     209         224 :             DEALLOCATE (dbc%tiles(k)%tile%tile_pw)
     210         352 :             DEALLOCATE (dbc%tiles(k)%tile)
     211             :          END DO
     212         128 :          DEALLOCATE (dbc%tiles)
     213             :       ELSE
     214           0 :          DO k = 1, n_tiles
     215           0 :             CALL dbc%tiles(k)%tile%tile_pw%release()
     216           0 :             DEALLOCATE (dbc%tiles(k)%tile%tile_pw)
     217           0 :             DEALLOCATE (dbc%tiles(k)%tile)
     218             :          END DO
     219           0 :          DEALLOCATE (dbc%tiles)
     220             :       END IF
     221             : 
     222         128 :       CALL timestop(handle)
     223             : 
     224         128 :    END SUBROUTINE dbc_tile_release
     225             : 
     226             : ! **************************************************************************************************
     227             : !> \brief   deallocates dirichlet_bc_parameters type
     228             : !> \param dbc_params dbc parameters
     229             : !> \par History
     230             : !>       08.2014 created [Hossein Bani-Hashemian]
     231             : !> \author Mohammad Hossein Bani-Hashemian
     232             : ! **************************************************************************************************
     233          54 :    SUBROUTINE dbc_parameters_dealloc(dbc_params)
     234             : 
     235             :       TYPE(dirichlet_bc_parameters), INTENT(INOUT)       :: dbc_params
     236             : 
     237          54 :       IF (ASSOCIATED(dbc_params%aa_planar_nprtn)) DEALLOCATE (dbc_params%aa_planar_nprtn)
     238          54 :       IF (ASSOCIATED(dbc_params%aa_planar_pplane)) DEALLOCATE (dbc_params%aa_planar_pplane)
     239          54 :       IF (ASSOCIATED(dbc_params%aa_planar_xxtnt)) DEALLOCATE (dbc_params%aa_planar_xxtnt)
     240          54 :       IF (ASSOCIATED(dbc_params%aa_planar_yxtnt)) DEALLOCATE (dbc_params%aa_planar_yxtnt)
     241          54 :       IF (ASSOCIATED(dbc_params%aa_planar_zxtnt)) DEALLOCATE (dbc_params%aa_planar_zxtnt)
     242          54 :       IF (ASSOCIATED(dbc_params%aa_planar_vD)) DEALLOCATE (dbc_params%aa_planar_vD)
     243          54 :       IF (ASSOCIATED(dbc_params%aa_planar_frequency)) DEALLOCATE (dbc_params%aa_planar_frequency)
     244          54 :       IF (ASSOCIATED(dbc_params%aa_planar_osc_frac)) DEALLOCATE (dbc_params%aa_planar_osc_frac)
     245          54 :       IF (ASSOCIATED(dbc_params%aa_planar_phase)) DEALLOCATE (dbc_params%aa_planar_phase)
     246          54 :       IF (ASSOCIATED(dbc_params%aa_planar_sigma)) DEALLOCATE (dbc_params%aa_planar_sigma)
     247          54 :       IF (ASSOCIATED(dbc_params%aa_planar_thickness)) DEALLOCATE (dbc_params%aa_planar_thickness)
     248          54 :       IF (ASSOCIATED(dbc_params%aa_planar_is_periodic)) DEALLOCATE (dbc_params%aa_planar_is_periodic)
     249             : 
     250          54 :       IF (ASSOCIATED(dbc_params%planar_nprtn)) DEALLOCATE (dbc_params%planar_nprtn)
     251          54 :       IF (ASSOCIATED(dbc_params%planar_Avtx)) DEALLOCATE (dbc_params%planar_Avtx)
     252          54 :       IF (ASSOCIATED(dbc_params%planar_Bvtx)) DEALLOCATE (dbc_params%planar_Bvtx)
     253          54 :       IF (ASSOCIATED(dbc_params%planar_Cvtx)) DEALLOCATE (dbc_params%planar_Cvtx)
     254          54 :       IF (ASSOCIATED(dbc_params%planar_Dvtx)) DEALLOCATE (dbc_params%planar_Dvtx)
     255          54 :       IF (ASSOCIATED(dbc_params%planar_vD)) DEALLOCATE (dbc_params%planar_vD)
     256          54 :       IF (ASSOCIATED(dbc_params%planar_frequency)) DEALLOCATE (dbc_params%planar_frequency)
     257          54 :       IF (ASSOCIATED(dbc_params%planar_osc_frac)) DEALLOCATE (dbc_params%planar_osc_frac)
     258          54 :       IF (ASSOCIATED(dbc_params%planar_phase)) DEALLOCATE (dbc_params%planar_phase)
     259          54 :       IF (ASSOCIATED(dbc_params%planar_sigma)) DEALLOCATE (dbc_params%planar_sigma)
     260          54 :       IF (ASSOCIATED(dbc_params%planar_thickness)) DEALLOCATE (dbc_params%planar_thickness)
     261          54 :       IF (ASSOCIATED(dbc_params%planar_is_periodic)) DEALLOCATE (dbc_params%planar_is_periodic)
     262             : 
     263          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_paxis)) DEALLOCATE (dbc_params%aa_cylindrical_paxis)
     264          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_nprtn)) DEALLOCATE (dbc_params%aa_cylindrical_nprtn)
     265          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_nsides)) DEALLOCATE (dbc_params%aa_cylindrical_nsides)
     266          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_apxtyp)) DEALLOCATE (dbc_params%aa_cylindrical_apxtyp)
     267          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_xtnt)) DEALLOCATE (dbc_params%aa_cylindrical_xtnt)
     268          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_bctr)) DEALLOCATE (dbc_params%aa_cylindrical_bctr)
     269          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_brad)) DEALLOCATE (dbc_params%aa_cylindrical_brad)
     270          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_vD)) DEALLOCATE (dbc_params%aa_cylindrical_vD)
     271          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_frequency)) DEALLOCATE (dbc_params%aa_cylindrical_frequency)
     272          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_osc_frac)) DEALLOCATE (dbc_params%aa_cylindrical_osc_frac)
     273          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_phase)) DEALLOCATE (dbc_params%aa_cylindrical_phase)
     274          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_sigma)) DEALLOCATE (dbc_params%aa_cylindrical_sigma)
     275          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_thickness)) DEALLOCATE (dbc_params%aa_cylindrical_thickness)
     276          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_sgap)) DEALLOCATE (dbc_params%aa_cylindrical_sgap)
     277          54 :       IF (ASSOCIATED(dbc_params%aa_cylindrical_is_periodic)) DEALLOCATE (dbc_params%aa_cylindrical_is_periodic)
     278             : 
     279          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_nprtn)) DEALLOCATE (dbc_params%aa_cuboidal_nprtn)
     280          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_xxtnt)) DEALLOCATE (dbc_params%aa_cuboidal_xxtnt)
     281          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_yxtnt)) DEALLOCATE (dbc_params%aa_cuboidal_yxtnt)
     282          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_zxtnt)) DEALLOCATE (dbc_params%aa_cuboidal_zxtnt)
     283          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_vD)) DEALLOCATE (dbc_params%aa_cuboidal_vD)
     284          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_frequency)) DEALLOCATE (dbc_params%aa_cuboidal_frequency)
     285          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_osc_frac)) DEALLOCATE (dbc_params%aa_cuboidal_osc_frac)
     286          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_phase)) DEALLOCATE (dbc_params%aa_cuboidal_phase)
     287          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_sigma)) DEALLOCATE (dbc_params%aa_cuboidal_sigma)
     288          54 :       IF (ASSOCIATED(dbc_params%aa_cuboidal_is_periodic)) DEALLOCATE (dbc_params%aa_cuboidal_is_periodic)
     289             : 
     290          54 :    END SUBROUTINE dbc_parameters_dealloc
     291             : 
     292           0 : END MODULE dirichlet_bc_types

Generated by: LCOV version 1.15