25 use,
intrinsic :: iso_c_binding, only: c_ptr
26 use,
intrinsic :: iso_fortran_env
44 real(real64),
public :: threshold
45 integer,
public :: maxiter
52 integer,
intent(in) :: itr
53 real(real64),
intent(in) :: thr
69 subroutine poisson_cg1(namespace, der, corrector, pot, rho)
70 type(namespace_t),
intent(in) :: namespace
71 type(derivatives_t),
target,
intent(in) :: der
72 type(poisson_corr_t),
intent(in) :: corrector
73 real(real64),
intent(inout) :: pot(:)
74 real(real64),
intent(in) :: rho(:)
78 real(real64),
allocatable :: wk(:), lwk(:), zk(:), pk(:)
79 type(c_ptr) :: userdata(0)
83 safe_allocate( wk(1:der%mesh%np_part))
84 safe_allocate(lwk(1:der%mesh%np_part))
85 safe_allocate( zk(1:der%mesh%np_part))
86 safe_allocate( pk(1:der%mesh%np_part))
89 wk(1:der%mesh%np) = pot(1:der%mesh%np)
93 zk(1:der%mesh%np) = -
m_four*
m_pi*rho(1:der%mesh%np) - lwk(1:der%mesh%np)
95 safe_deallocate_a(lwk)
100 pk(der%mesh%np + 1:) =
m_zero
103 if (res >= threshold)
then
104 message(1) =
'Conjugate-gradients Poisson solver did not converge.'
105 write(
message(2),
'(a,i8)')
' Iter = ',iter
106 write(
message(3),
'(a,e14.6)')
' Res = ', res
110 pot(1:der%mesh%np) = pot(1:der%mesh%np) + pk(1:der%mesh%np)
112 safe_deallocate_a(zk)
113 safe_deallocate_a(pk)
120 type(namespace_t),
intent(in) :: namespace
121 type(derivatives_t),
target,
intent(in) :: der
122 real(real64),
contiguous,
intent(inout) :: pot(:)
123 real(real64),
intent(in) :: rho(:)
126 real(real64),
allocatable :: potc(:), rhs(:)
128 type(c_ptr) :: userdata(0)
136 safe_allocate(rhs(1:der%mesh%np))
137 safe_allocate(potc(1:der%mesh%np_part))
139 do ip = 1, der%mesh%np
140 rhs(ip) = -4.0_real64*
m_pi*rho(ip)
146 if (res >= threshold)
then
147 message(1) =
'Conjugate-gradients Poisson solver did not converge.'
148 write(
message(2),
'(a,i8)')
' Iter = ', iter
149 write(
message(3),
'(a,e14.6)')
' Res = ', res
157 safe_deallocate_a(rhs)
158 safe_deallocate_a(potc)
Copies a vector x, to a vector y.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public dderivatives_lapl(der, ff, op_ff, ghost_update, set_bc, factor)
apply the Laplacian to a mesh function
real(real64), parameter, public m_zero
real(real64), parameter, public m_four
real(real64), parameter, public m_pi
some mathematical constants
This module defines the meshes, which are used in Octopus.
subroutine, public messages_warning(no_lines, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public poisson_cg2(namespace, der, pot, rho)
subroutine, public poisson_cg1(namespace, der, corrector, pot, rho)
subroutine, public poisson_cg_init(thr, itr)
subroutine, public poisson_cg_end
subroutine, public internal_laplacian_op(xx, yy, userdata)
real(real64) function, public internal_dotp(xx, yy)
subroutine, public poisson_boundary_conditions(this, mesh, rho, pot)
type(mesh_t), pointer, public mesh_pointer
type(derivatives_t), pointer, public der_pointer
This module is intended to contain "only mathematical" functions and procedures.