Octopus
stencil_starplus.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
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
19#include "global.h"
20
27 use debug_oct_m
28 use global_oct_m
30
31 implicit none
32
33 private
34 public :: &
41
42contains
43
44 ! ---------------------------------------------------------
45 integer function stencil_starplus_size_lapl(dim, order) result(n)
46 integer, intent(in) :: dim
47 integer, intent(in) :: order
48
50
51 n = 2*dim*order + 1
52 if (dim == 2) n = n + 12
53 if (dim == 3) n = n + 44
54
57
58
59 ! ---------------------------------------------------------
60 integer function stencil_starplus_size_grad(dim, order) result(n)
61 integer, intent(in) :: dim
62 integer, intent(in) :: order
63
65
66 n = 2*order + 1
67 if (dim == 2) n = n + 2
68 if (dim == 3) n = n + 4
69
72
73
74 ! ---------------------------------------------------------
75 subroutine stencil_starplus_get_lapl(this, dim, order)
76 type(stencil_t), intent(inout) :: this
77 integer, intent(in) :: dim
78 integer, intent(in) :: order
79
80 integer :: i, j, n
81
83
84 call stencil_allocate(this, dim, stencil_starplus_size_lapl(dim, order))
85
86 n = 1
87 select case (dim)
88 case (1)
89 n = 1
90 do i = 1, dim
91 do j = -order, order
92 if (j == 0) cycle
93 n = n + 1
94 this%points(i, n) = j
95 end do
96 end do
97 case (2)
98 n = 1
99 do i = 1, dim
100 do j = -order, order
101 if (j == 0) cycle
102 n = n + 1
103 this%points(i, n) = j
104 end do
105 end do
106 n = n + 1; this%points(1:2, n) = (/ -2, 1 /)
107 n = n + 1; this%points(1:2, n) = (/ -2, -1 /)
108 n = n + 1; this%points(1:2, n) = (/ -1, 2 /)
109 n = n + 1; this%points(1:2, n) = (/ -1, 1 /)
110 n = n + 1; this%points(1:2, n) = (/ -1, -1 /)
111 n = n + 1; this%points(1:2, n) = (/ -1, -2 /)
112 n = n + 1; this%points(1:2, n) = (/ 1, 2 /)
113 n = n + 1; this%points(1:2, n) = (/ 1, 1 /)
114 n = n + 1; this%points(1:2, n) = (/ 1, -1 /)
115 n = n + 1; this%points(1:2, n) = (/ 1, -2 /)
116 n = n + 1; this%points(1:2, n) = (/ 2, 1 /)
117 n = n + 1; this%points(1:2, n) = (/ 2, -1 /)
118 case (3)
119 n = 1
120 do i = 1, dim
121 do j = -order, order
122 if (j == 0) cycle
123 n = n + 1
124 this%points(i, n) = j
125 end do
126 end do
127 n = n + 1; this%points(1:3, n) = (/ -2, 1, 0 /)
128 n = n + 1; this%points(1:3, n) = (/ -2, -1, 0 /)
129 n = n + 1; this%points(1:3, n) = (/ -1, 2, 0 /)
130 n = n + 1; this%points(1:3, n) = (/ -1, 1, 0 /)
131 n = n + 1; this%points(1:3, n) = (/ -1, -1, 0 /)
132 n = n + 1; this%points(1:3, n) = (/ -1, -2, 0 /)
133 n = n + 1; this%points(1:3, n) = (/ 1, 2, 0 /)
134 n = n + 1; this%points(1:3, n) = (/ 1, 1, 0 /)
135 n = n + 1; this%points(1:3, n) = (/ 1, -1, 0 /)
136 n = n + 1; this%points(1:3, n) = (/ 1, -2, 0 /)
137 n = n + 1; this%points(1:3, n) = (/ 2, 1, 0 /)
138 n = n + 1; this%points(1:3, n) = (/ 2, -1, 0 /)
139
140 n = n + 1; this%points(1:3, n) = (/ -2, 0, 1 /)
141 n = n + 1; this%points(1:3, n) = (/ -2, 0, -1 /)
142 n = n + 1; this%points(1:3, n) = (/ -1, 0, 2 /)
143 n = n + 1; this%points(1:3, n) = (/ -1, 0, 1 /)
144 n = n + 1; this%points(1:3, n) = (/ -1, 0, -1 /)
145 n = n + 1; this%points(1:3, n) = (/ -1, 0, -2 /)
146 n = n + 1; this%points(1:3, n) = (/ 1, 0, 2 /)
147 n = n + 1; this%points(1:3, n) = (/ 1, 0, 1 /)
148 n = n + 1; this%points(1:3, n) = (/ 1, 0, -1 /)
149 n = n + 1; this%points(1:3, n) = (/ 1, 0, -2 /)
150 n = n + 1; this%points(1:3, n) = (/ 2, 0, 1 /)
151 n = n + 1; this%points(1:3, n) = (/ 2, 0, -1 /)
152
153 n = n + 1; this%points(1:3, n) = (/ 0, -2, 1 /)
154 n = n + 1; this%points(1:3, n) = (/ 0, -2, -1 /)
155 n = n + 1; this%points(1:3, n) = (/ 0, -1, 2 /)
156 n = n + 1; this%points(1:3, n) = (/ 0, -1, 1 /)
157 n = n + 1; this%points(1:3, n) = (/ 0, -1, -1 /)
158 n = n + 1; this%points(1:3, n) = (/ 0, -1, -2 /)
159 n = n + 1; this%points(1:3, n) = (/ 0, 1, 2 /)
160 n = n + 1; this%points(1:3, n) = (/ 0, 1, 1 /)
161 n = n + 1; this%points(1:3, n) = (/ 0, 1, -1 /)
162 n = n + 1; this%points(1:3, n) = (/ 0, 1, -2 /)
163 n = n + 1; this%points(1:3, n) = (/ 0, 2, 1 /)
164 n = n + 1; this%points(1:3, n) = (/ 0, 2, -1 /)
165
166 n = n + 1; this%points(1:3, n) = (/ -1, -1, -1 /)
167 n = n + 1; this%points(1:3, n) = (/ -1, -1, 1 /)
168 n = n + 1; this%points(1:3, n) = (/ -1, 1, -1 /)
169 n = n + 1; this%points(1:3, n) = (/ -1, 1, 1 /)
170 n = n + 1; this%points(1:3, n) = (/ 1, -1, -1 /)
171 n = n + 1; this%points(1:3, n) = (/ 1, -1, 1 /)
172 n = n + 1; this%points(1:3, n) = (/ 1, 1, -1 /)
173 n = n + 1; this%points(1:3, n) = (/ 1, 1, 1 /)
174
175 end select
176
177 call stencil_init_center(this)
178
180 end subroutine stencil_starplus_get_lapl
181
182
183 ! ---------------------------------------------------------
184 subroutine stencil_starplus_get_grad(this, dim, dir, order)
185 type(stencil_t), intent(inout) :: this
186 integer, intent(in) :: dim
187 integer, intent(in) :: dir
188 integer, intent(in) :: order
189
190 integer :: i, n, j
191
193
194 call stencil_allocate(this, dim, stencil_starplus_size_grad(dim, order))
195
196 n = 1
197 do i = -order, order
198 this%points(dir, n) = i
199 n = n + 1
200 end do
201 do j = 1, dim
202 if (j == dir) cycle
203 this%points(j, n) = -1
204 n = n + 1
205 this%points(j, n) = 1
206 n = n + 1
207 end do
208
209 call stencil_init_center(this)
210
212 end subroutine stencil_starplus_get_grad
213
214
215 ! ---------------------------------------------------------
216 subroutine stencil_starplus_pol_lapl(dim, order, pol)
217 integer, intent(in) :: dim
218 integer, intent(in) :: order
219 integer, intent(out) :: pol(:,:)
220
221 integer :: i, j, n
222
224
225 n = 1
226 select case (dim)
227 case (1)
228 n = 1
229 pol(:,:) = 0
230 do i = 1, dim
231 do j = 1, 2*order
232 n = n + 1
233 pol(i, n) = j
234 end do
235 end do
236 case (2)
237 n = 1
238 pol(:,:) = 0
239 do i = 1, dim
240 do j = 1, 2*order
241 n = n + 1
242 pol(i, n) = j
243 end do
244 end do
245 n = n + 1; pol(1:2, n) = (/ 1, 1 /)
246 n = n + 1; pol(1:2, n) = (/ 1, 2 /)
247 n = n + 1; pol(1:2, n) = (/ 1, 3 /)
248 n = n + 1; pol(1:2, n) = (/ 1, 4 /)
249 n = n + 1; pol(1:2, n) = (/ 2, 1 /)
250 n = n + 1; pol(1:2, n) = (/ 2, 2 /)
251 n = n + 1; pol(1:2, n) = (/ 2, 3 /)
252 n = n + 1; pol(1:2, n) = (/ 2, 4 /)
253 n = n + 1; pol(1:2, n) = (/ 3, 1 /)
254 n = n + 1; pol(1:2, n) = (/ 3, 2 /)
255 n = n + 1; pol(1:2, n) = (/ 4, 1 /)
256 n = n + 1; pol(1:2, n) = (/ 4, 2 /)
257 case (3)
258 n = 1
259 pol(:,:) = 0
260 do i = 1, dim
261 do j = 1, 2*order
262 n = n + 1
263 pol(i, n) = j
264 end do
265 end do
266
267 n = n + 1; pol(1:3, n) = (/ 1, 1, 0 /)
268 n = n + 1; pol(1:3, n) = (/ 1, 2, 0 /)
269 n = n + 1; pol(1:3, n) = (/ 1, 3, 0 /)
270 n = n + 1; pol(1:3, n) = (/ 1, 4, 0 /)
271 n = n + 1; pol(1:3, n) = (/ 2, 1, 0 /)
272 n = n + 1; pol(1:3, n) = (/ 2, 2, 0 /)
273 n = n + 1; pol(1:3, n) = (/ 2, 3, 0 /)
274 n = n + 1; pol(1:3, n) = (/ 2, 4, 0 /)
275 n = n + 1; pol(1:3, n) = (/ 3, 1, 0 /)
276 n = n + 1; pol(1:3, n) = (/ 3, 2, 0 /)
277 n = n + 1; pol(1:3, n) = (/ 4, 1, 0 /)
278 n = n + 1; pol(1:3, n) = (/ 4, 2, 0 /)
279
280 n = n + 1; pol(1:3, n) = (/ 1, 0, 1 /)
281 n = n + 1; pol(1:3, n) = (/ 1, 0, 2 /)
282 n = n + 1; pol(1:3, n) = (/ 1, 0, 3 /)
283 n = n + 1; pol(1:3, n) = (/ 1, 0, 4 /)
284 n = n + 1; pol(1:3, n) = (/ 2, 0, 1 /)
285 n = n + 1; pol(1:3, n) = (/ 2, 0, 2 /)
286 n = n + 1; pol(1:3, n) = (/ 2, 0, 3 /)
287 n = n + 1; pol(1:3, n) = (/ 2, 0, 4 /)
288 n = n + 1; pol(1:3, n) = (/ 3, 0, 1 /)
289 n = n + 1; pol(1:3, n) = (/ 3, 0, 2 /)
290 n = n + 1; pol(1:3, n) = (/ 4, 0, 1 /)
291 n = n + 1; pol(1:3, n) = (/ 4, 0, 2 /)
292
293 n = n + 1; pol(1:3, n) = (/ 0, 1, 1 /)
294 n = n + 1; pol(1:3, n) = (/ 0, 1, 2 /)
295 n = n + 1; pol(1:3, n) = (/ 0, 1, 3 /)
296 n = n + 1; pol(1:3, n) = (/ 0, 1, 4 /)
297 n = n + 1; pol(1:3, n) = (/ 0, 2, 1 /)
298 n = n + 1; pol(1:3, n) = (/ 0, 2, 2 /)
299 n = n + 1; pol(1:3, n) = (/ 0, 2, 3 /)
300 n = n + 1; pol(1:3, n) = (/ 0, 2, 4 /)
301 n = n + 1; pol(1:3, n) = (/ 0, 3, 1 /)
302 n = n + 1; pol(1:3, n) = (/ 0, 3, 2 /)
303 n = n + 1; pol(1:3, n) = (/ 0, 4, 1 /)
304 n = n + 1; pol(1:3, n) = (/ 0, 4, 2 /)
305
306 n = n + 1; pol(1:3, n) = (/ 1, 1, 1 /)
307 n = n + 1; pol(1:3, n) = (/ 1, 1, 2 /)
308 n = n + 1; pol(1:3, n) = (/ 1, 2, 1 /)
309 n = n + 1; pol(1:3, n) = (/ 1, 2, 2 /)
310 n = n + 1; pol(1:3, n) = (/ 2, 1, 1 /)
311 n = n + 1; pol(1:3, n) = (/ 2, 1, 2 /)
312 n = n + 1; pol(1:3, n) = (/ 2, 2, 1 /)
313 n = n + 1; pol(1:3, n) = (/ 2, 2, 2 /)
314
315 end select
316
318 end subroutine stencil_starplus_pol_lapl
319
320
321 ! ---------------------------------------------------------
322 subroutine stencil_starplus_pol_grad(dim, dir, order, pol)
323 integer, intent(in) :: dim
324 integer, intent(in) :: dir
325 integer, intent(in) :: order
326 integer, intent(out) :: pol(:,:)
327
328 integer :: j, n
329
331
332 pol(:,:) = 0
333 do j = 0, 2*order
334 pol(dir, j+1) = j
335 end do
336 n = 2*order + 1
337
338 select case (dim)
339 case (2)
340 select case (dir)
341 case (1)
342 n = n + 1; pol(1:2, n) = (/ 0, 1 /)
343 n = n + 1; pol(1:2, n) = (/ 0, 2 /)
344 case (2)
345 n = n + 1; pol(1:2, n) = (/ 1, 0 /)
346 n = n + 1; pol(1:2, n) = (/ 2, 0 /)
347 end select
348 case (3)
349 select case (dir)
350 case (1)
351 n = n + 1; pol(1:3, n) = (/ 0, 1, 0 /)
352 n = n + 1; pol(1:3, n) = (/ 0, 2, 0 /)
353 n = n + 1; pol(1:3, n) = (/ 0, 0, 1 /)
354 n = n + 1; pol(1:3, n) = (/ 0, 0, 2 /)
355 case (2)
356 n = n + 1; pol(1:3, n) = (/ 1, 0, 0 /)
357 n = n + 1; pol(1:3, n) = (/ 2, 0, 0 /)
358 n = n + 1; pol(1:3, n) = (/ 0, 0, 1 /)
359 n = n + 1; pol(1:3, n) = (/ 0, 0, 2 /)
360 case (3)
361 n = n + 1; pol(1:3, n) = (/ 1, 0, 0 /)
362 n = n + 1; pol(1:3, n) = (/ 2, 0, 0 /)
363 n = n + 1; pol(1:3, n) = (/ 0, 1, 0 /)
364 n = n + 1; pol(1:3, n) = (/ 0, 2, 0 /)
365 end select
366 end select
367
369 end subroutine stencil_starplus_pol_grad
370
371end module stencil_starplus_oct_m
372
373!! Local Variables:
374!! mode: f90
375!! coding: utf-8
376!! End:
This module defines stencils used in Octopus.
Definition: stencil.F90:135
subroutine, public stencil_allocate(this, dim, size)
Definition: stencil.F90:178
subroutine, public stencil_init_center(this)
Definition: stencil.F90:275
This module defines routines, generating operators for a stencil consisting of a star and a cross....
subroutine, public stencil_starplus_pol_grad(dim, dir, order, pol)
subroutine, public stencil_starplus_pol_lapl(dim, order, pol)
subroutine, public stencil_starplus_get_lapl(this, dim, order)
subroutine, public stencil_starplus_get_grad(this, dim, dir, order)
integer function, public stencil_starplus_size_lapl(dim, order)
integer function, public stencil_starplus_size_grad(dim, order)
The class representing the stencil, which is used for non-local mesh operations.
Definition: stencil.F90:163