| 1 | ! DOUG - Domain decomposition On Unstructured Grids |
|---|
| 2 | ! Copyright (C) 1998-2006 Faculty of Computer Science, University of Tartu and |
|---|
| 3 | ! Department of Mathematics, University of Bath |
|---|
| 4 | ! |
|---|
| 5 | ! This library is free software; you can redistribute it and/or |
|---|
| 6 | ! modify it under the terms of the GNU Lesser General Public |
|---|
| 7 | ! License as published by the Free Software Foundation; either |
|---|
| 8 | ! version 2.1 of the License, or (at your option) any later version. |
|---|
| 9 | ! |
|---|
| 10 | ! This library is distributed in the hope that it will be useful, |
|---|
| 11 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 13 | ! Lesser General Public License for more details. |
|---|
| 14 | ! |
|---|
| 15 | ! You should have received a copy of the GNU Lesser General Public |
|---|
| 16 | ! License along with this library; if not, write to the Free Software |
|---|
| 17 | ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 18 | ! or contact the authors (University of Tartu, Faculty of Computer Science, Chair |
|---|
| 19 | ! of Distributed Systems, Liivi 2, 50409 Tartu, Estonia, http://dougdevel.org, |
|---|
| 20 | ! mailto:info(at)dougdevel.org) |
|---|
| 21 | |
|---|
| 22 | !> Base component for data distribution. |
|---|
| 23 | module Distribution_mod |
|---|
| 24 | use Mesh_class |
|---|
| 25 | use SpMtx_class |
|---|
| 26 | |
|---|
| 27 | implicit none |
|---|
| 28 | |
|---|
| 29 | #include<doug_config.h> |
|---|
| 30 | |
|---|
| 31 | !> Component that reads in and distributes data. |
|---|
| 32 | type Distribution |
|---|
| 33 | type(Mesh) :: mesh !< Information about mesh and neighbours |
|---|
| 34 | type(SpMtx) :: A !< Distributed system matrix |
|---|
| 35 | type(SpMtx) :: A_ghost !< Matrix elements needed for ghost values |
|---|
| 36 | real(kind=rk),pointer :: rhs(:) !< Distributed RHS |
|---|
| 37 | end type Distribution |
|---|
| 38 | |
|---|
| 39 | private |
|---|
| 40 | public :: Distribution, Distribution_New, Distribution_NewInit |
|---|
| 41 | |
|---|
| 42 | contains |
|---|
| 43 | |
|---|
| 44 | function Distribution_New() result (D) |
|---|
| 45 | type(Distribution) :: D |
|---|
| 46 | D%mesh = Mesh_New() |
|---|
| 47 | D%A = SpMtx_New() |
|---|
| 48 | D%A_ghost = SpMtx_New() |
|---|
| 49 | D%rhs => NULL() |
|---|
| 50 | end function Distribution_New |
|---|
| 51 | |
|---|
| 52 | !---------------------------------------------------------------- |
|---|
| 53 | !> Distributes data, chooses algorithm based on input type |
|---|
| 54 | !---------------------------------------------------------------- |
|---|
| 55 | function Distribution_NewInit(input_type, nparts, part_opts) result(D) |
|---|
| 56 | use Distribution_elem_mod |
|---|
| 57 | use Distribution_assm_mod |
|---|
| 58 | implicit none |
|---|
| 59 | |
|---|
| 60 | integer, intent(in) :: input_type !< Input Type |
|---|
| 61 | type(Distribution) :: D |
|---|
| 62 | ! Partitioning |
|---|
| 63 | integer, intent(in) :: nparts !< number of parts to partition a mesh |
|---|
| 64 | integer, dimension(6), intent(in) :: part_opts !< partition options (see METIS manual) |
|---|
| 65 | |
|---|
| 66 | D = Distribution_New() |
|---|
| 67 | |
|---|
| 68 | select case (input_type) |
|---|
| 69 | case (DCTL_INPUT_TYPE_ELEMENTAL) |
|---|
| 70 | ! ELEMENTAL |
|---|
| 71 | call parallelAssembleFromElemInput(D%mesh,D%A,D%rhs,nparts,part_opts,D%A_ghost) |
|---|
| 72 | case (DCTL_INPUT_TYPE_ASSEMBLED) |
|---|
| 73 | ! ASSEMBLED |
|---|
| 74 | call parallelDistributeAssembledInput(D%mesh,D%A,D%rhs,D%A_ghost) |
|---|
| 75 | case default |
|---|
| 76 | call DOUG_abort('[DOUG main] : Unrecognised input type.', -1) |
|---|
| 77 | end select |
|---|
| 78 | end function Distribution_NewInit |
|---|
| 79 | |
|---|
| 80 | end module Distribution_mod |
|---|