Octopus
stencil_variational.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! ---------------------------------------------------------
41! ---------------------------------------------------------
43 use debug_oct_m
44 use global_oct_m
45 use, intrinsic :: iso_fortran_env
49
50 implicit none
51
52 private
53 public :: &
55
56contains
57
58 ! ---------------------------------------------------------
59 subroutine stencil_variational_coeff_lapl(dim, order, h, lapl, alpha)
60 integer, intent(in) :: dim
61 integer, intent(in) :: order
62 real(real64), intent(in) :: h(:)
63 type(nl_operator_t), intent(inout) :: lapl
64 real(real64), optional, intent(in) :: alpha
65
66 integer :: i, j, k
67 real(real64) :: alpha_, kmax
68 real(real64), allocatable :: fp(:)
69
71
72 alpha_ = m_one
73 if (present(alpha)) alpha_ = alpha
74 kmax = m_pi**2 * alpha_
75
76 safe_allocate(fp(1:order+1))
77 select case (order)
78 case (1)
79 fp(1) = -kmax/m_two
80 fp(2) = kmax/m_four
81 case (2)
82 fp(1) = -m_half-m_three*kmax/8.0_real64
83 fp(2) = kmax/m_four
84 fp(3) = m_one/m_four - kmax/16.0_real64
85 case (3)
86 fp(1) = -m_five/6.0_real64 - m_five*kmax/16.0_real64
87 fp(2) = m_one/12.0_real64 + 15.0_real64*kmax/64.0_real64
88 fp(3) = m_five/12.0_real64 - m_three*kmax/32.0_real64
89 fp(4) = -m_one/12.0_real64 + kmax/64.0_real64
90 case (4)
91 fp(1) = -77.0_real64/72.0_real64 - 35.0_real64*kmax/128.0_real64
92 fp(2) = 8.0_real64/45.0_real64 + 7.0_real64*kmax/32.0_real64
93 fp(3) = 23.0_real64/45.0_real64 - 7.0_real64*kmax/64.0_real64
94 fp(4) = -8.0_real64/45.0_real64 + kmax/32.0_real64
95 fp(5) = 17.0_real64/720.0_real64 - kmax/256.0_real64
96 case (5)
97 fp(1) = -449.0_real64/360.0_real64 - 63.0_real64*kmax/256.0_real64
98 fp(2) = m_four/15.0_real64 + 105.0_real64*kmax/512.0_real64
99 fp(3) = 59.0_real64/105.0_real64 - 15.0_real64*kmax/128.0_real64
100 fp(4) = -82.0_real64/315.0_real64 + 45.0_real64*kmax/1024.0_real64
101 fp(5) = 311.0_real64/5040.0_real64 - m_five*kmax/512.0_real64
102 fp(6) = -m_two/315.0_real64 + kmax/1024.0_real64
103 case (6)
104 fp(1) = -2497.0_real64/1800.0_real64 - 231.0_real64*kmax/1024.0_real64
105 fp(2) = 26.0_real64/75.0_real64 + 99.0_real64*kmax/512.0_real64
106 fp(3) = 493.0_real64/840.0_real64 - 495.0_real64*kmax/4096.0_real64
107 fp(4) = -103.0_real64/315.0_real64 + 55.0_real64*kmax/1024.0_real64
108 fp(5) = 2647.0_real64/25200.0_real64 - 33.0_real64*kmax/2048.0_real64
109 fp(6) = -31.0_real64/1575.0_real64 + m_three*kmax/1024.0_real64
110 fp(7) = m_one/600.0_real64 - kmax/4096.0_real64
111 end select
112
113 lapl%w(1,:) = fp(1)*sum(1/h(1:dim)**2)
114
115 k = 1
116 do i = 1, dim
117 do j = -order, -1
118 k = k + 1
119 lapl%w(k,:) = fp(-j+1) / h(i)**2
120 end do
121
122 do j = 1, order
123 k = k + 1
124 lapl%w(k,:) = fp( j+1) / h(i)**2
125 end do
126 end do
127
128 safe_deallocate_a(fp)
129
131 end subroutine stencil_variational_coeff_lapl
132
133
136!! Local Variables:
137!! mode: f90
138!! coding: utf-8
139!! End:
real(real64), parameter, public m_two
Definition: global.F90:189
real(real64), parameter, public m_four
Definition: global.F90:191
real(real64), parameter, public m_pi
some mathematical constants
Definition: global.F90:185
real(real64), parameter, public m_half
Definition: global.F90:193
real(real64), parameter, public m_one
Definition: global.F90:188
real(real64), parameter, public m_three
Definition: global.F90:190
real(real64), parameter, public m_five
Definition: global.F90:192
This module defines non-local operators.
Implements the variational discretization of the Laplacian as proposed by P. Maragakis,...
subroutine, public stencil_variational_coeff_lapl(dim, order, h, lapl, alpha)