25 use iso_c_binding,
only: c_loc
26 use,
intrinsic :: iso_fortran_env
46 real(real64),
public :: threshold
47 integer,
public :: maxiter
54 integer,
intent(in) :: itr
55 real(real64),
intent(in) :: thr
71 subroutine poisson_cg1(namespace, der, corrector, pot, rho)
72 type(namespace_t),
intent(in) :: namespace
73 type(derivatives_t),
target,
intent(in) :: der
74 type(poisson_corr_t),
intent(in) :: corrector
75 real(real64),
contiguous,
intent(inout) :: pot(:)
76 real(real64),
intent(in) :: rho(:)
80 real(real64),
allocatable :: wk(:), lwk(:), rhs(:), sol(:)
84 safe_allocate( wk(1:der%mesh%np_part))
85 safe_allocate(lwk(1:der%mesh%np_part))
86 safe_allocate(rhs(1:der%mesh%np_part))
87 safe_allocate(sol(1:der%mesh%np_part))
90 wk(1:der%mesh%np) = pot(1:der%mesh%np)
91 if (der%periodic_dim > 0)
then
99 rhs(1:der%mesh%np) = (
m_four*
m_pi*rho(1:der%mesh%np) + lwk(1:der%mesh%np))
101 safe_deallocate_a(wk)
102 safe_deallocate_a(lwk)
109 if (der%periodic_dim > 0)
then
115 if (res >= threshold)
then
116 message(1) =
'Conjugate-gradients Poisson solver did not converge.'
117 write(
message(2),
'(a,i8)')
' Iter = ',iter
118 write(
message(3),
'(a,e14.6)')
' Res = ', res
122 pot(1:der%mesh%np) = pot(1:der%mesh%np) + sol(1:der%mesh%np)
124 safe_deallocate_a(rhs)
125 safe_deallocate_a(sol)
132 type(namespace_t),
intent(in) :: namespace
133 type(derivatives_t),
target,
intent(in) :: der
134 real(real64),
contiguous,
intent(inout) :: pot(:)
135 real(real64),
intent(in) :: rho(:)
138 real(real64),
allocatable :: potc(:), rhs(:)
147 safe_allocate(rhs(1:der%mesh%np))
148 safe_allocate(potc(1:der%mesh%np_part))
151 do ip = 1, der%mesh%np
152 rhs(ip) = 4.0_real64*
m_pi*rho(ip)
158 if (res >= threshold)
then
159 message(1) =
'Conjugate-gradients Poisson solver did not converge.'
161 write(
message(3),
'(a,e14.6)')
' Res = ', res
169 safe_deallocate_a(rhs)
170 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_four
real(real64), parameter, public m_pi
some mathematical constants
Computes and , suitable as an operator callback for iterative solvers (CG, QMR, etc....
subroutine, public dlaplacian_op(x, hx, userdata)
Computes the negative Laplacian operator action: .
This module defines various routines, operating on mesh functions.
class(mesh_t), pointer, public mesh_aux
Globally-scoped pointer to the mesh instance.
subroutine, public dmf_remove_average(mesh, ff, reduce)
Remove the average value of a mesh function.
subroutine, public dmf_remove_average_aux(f)
Interface for nullspace removal in linear solvers.
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
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.