Octopus
mesh_cube_map.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!! Copyright (C) 2021 S. Ohlmann
3!!
4!! This program is free software; you can redistribute it and/or modify
5!! it under the terms of the GNU General Public License as published by
6!! the Free Software Foundation; either version 2, or (at your option)
7!! any later version.
8!!
9!! This program is distributed in the hope that it will be useful,
10!! but WITHOUT ANY WARRANTY; without even the implied warranty of
11!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!! GNU General Public License for more details.
13!!
14!! You should have received a copy of the GNU General Public License
15!! along with this program; if not, write to the Free Software
16!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17!! 02110-1301, USA.
18!!
19
20#include "global.h"
21
23 use accel_oct_m
24 use debug_oct_m
25 use global_oct_m
26 use index_oct_m
27 use mesh_oct_m
30 use types_oct_m
31
32 implicit none
33
34 private
35 public :: &
39
41 ! Components are public by default
42 integer :: nmap
43 integer, allocatable :: map(:, :)
44 type(accel_mem_t) :: map_buffer
45 end type mesh_cube_map_t
46
47 integer, public, parameter :: MCM_POINT = 4, mcm_count = 5
48
49contains
50
51 ! ---------------------------------------------------------
52
53 subroutine mesh_cube_map_init(this, mesh, np)
54 type(mesh_cube_map_t), intent(out) :: this
55 class(mesh_t), intent(in) :: mesh
56 integer, intent(in) :: np
57
58 integer :: i1(1:3), i2(1:3)
59 integer :: step
60 integer :: ip
61
62 push_sub(mesh_cube_map_init)
63
64 if (mesh%idx%dim <= 3) then
65 do step = 1, 2
66 if (step == 2) then
67 safe_allocate(this%map(1:5, 1:this%nmap))
68 end if
69
70 this%nmap = 0
71 i2 = 0
72 do ip = 1, np
73
74 i1 = 0
75 call mesh_local_index_to_coords(mesh, ip, i1)
76
77 if (any(i1(2:3) /= i2(2:3)) .or. i1(1) /= i2(1) + 1 .or. ip == 1) then
78 this%nmap = this%nmap + 1
79 if (step == 2) then
80 this%map(1:3, this%nmap) = i1(1:3)
81 this%map(mesh%idx%dim + 1:3, this%nmap) = 0
82 this%map(mcm_point, this%nmap) = ip
83 this%map(mcm_count, this%nmap) = 1
84 end if
85 else
86 if (step == 2) this%map(mcm_count, this%nmap) = this%map(mcm_count, this%nmap) + 1
87 end if
88 i2 = i1
89 end do
90 end do
91
92 if (accel_is_enabled()) then
93 call accel_create_buffer(this%map_buffer, accel_mem_read_only, type_integer, this%nmap*5)
94 call accel_write_buffer(this%map_buffer, this%nmap*5, this%map)
95 end if
96
97 end if
98
99 pop_sub(mesh_cube_map_init)
100 end subroutine mesh_cube_map_init
101
102 ! ---------------------------------------------------------
103
104 subroutine mesh_cube_map_end(this)
105 type(mesh_cube_map_t), intent(inout) :: this
106
107 push_sub(mesh_cube_map_end)
108
109 if (allocated(this%map)) then
110
111 safe_deallocate_a(this%map)
112
113 if (accel_is_enabled()) call accel_release_buffer(this%map_buffer)
114
115 end if
116
117 pop_sub(mesh_cube_map_end)
118 end subroutine mesh_cube_map_end
119
120 ! ---------------------------------------------------------
121
122end module mesh_cube_map_oct_m
123
124!! Local Variables:
125!! mode: f90
126!! coding: utf-8
127!! End:
subroutine, public accel_release_buffer(this)
Definition: accel.F90:1246
pure logical function, public accel_is_enabled()
Definition: accel.F90:400
integer, parameter, public accel_mem_read_only
Definition: accel.F90:183
This module implements the index, used for the mesh points.
Definition: index.F90:122
subroutine, public mesh_cube_map_end(this)
integer, parameter, public mcm_count
subroutine, public mesh_cube_map_init(this, mesh, np)
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118
subroutine, public mesh_local_index_to_coords(mesh, ip, ix)
Given a local point index, this function returns the set of integer coordinates of the point.
Definition: mesh.F90:947
type(type_t), public type_integer
Definition: types.F90:135