26 use,
intrinsic :: iso_fortran_env
53 type(poisson_corr_t) :: corrector
54 type(multigrid_t) :: mgrid
55 type(mg_solver_t) :: mg_solver
56 logical :: periodic = .false.
58 integer :: multigrid_cycle
66 type(poisson_mg_solver_t),
intent(out) :: this
67 type(namespace_t),
intent(in) :: namespace
68 class(space_t),
intent(in) :: space
69 type(mesh_t),
intent(inout) :: mesh
70 type(derivatives_t),
intent(in) :: der
71 type(stencil_t),
intent(in) :: stencil
72 type(multicomm_t),
intent(in) :: mc
73 integer,
intent(in) :: ml
74 real(real64),
intent(in) :: thr
80 this%periodic = space%is_periodic()
81 if (.not. this%periodic)
then
85 call multigrid_init(this%mgrid, namespace, space, mesh, der, stencil, mc)
89 do i = 1, this%mgrid%n_levels
90 this%mgrid%level(i - 1)%der%lapl%coarser => this%mgrid%level(i)%der%lapl
115 type(poisson_mg_solver_t),
intent(inout) :: this
130 type(poisson_mg_solver_t),
intent(in) :: this
131 type(namespace_t),
intent(in) :: namespace
132 type(derivatives_t),
intent(in) :: der
133 real(real64),
intent(out) :: pot(:)
134 real(real64),
contiguous,
intent(in) :: rho(:)
137 real(real64),
allocatable :: vh_correction(:), res(:), cor(:)
141 safe_allocate(res(1:der%mesh%np_part))
142 safe_allocate(cor(1:der%mesh%np_part))
145 if (this%periodic)
then
146 res(1:der%mesh%np) = rho(1:der%mesh%np)
151 safe_allocate(vh_correction(1:der%mesh%np_part))
152 call correct_rho(this%corrector, der, rho, res, vh_correction)
156 select case (this%multigrid_cycle)
159 cor, res, this%multigrid_cycle)
161 call multigrid_fmg_solver(this%mg_solver, namespace, this%mgrid%level(0)%der, this%mgrid%level(0)%der%lapl, cor, res)
166 if (this%periodic)
then
168 pot(1:der%mesh%np) = cor(1:der%mesh%np)
170 do ip = 1, der%mesh%np
171 pot(ip) = cor(ip) + vh_correction(ip)
173 safe_deallocate_a(vh_correction)
175 safe_deallocate_a(res)
176 safe_deallocate_a(cor)
scales a vector by a constant
Module implementing boundary conditions in Octopus.
This module calculates the derivatives (gradients, Laplacians, etc.) of a 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 various routines, operating on mesh functions.
subroutine, public dmf_remove_average(mesh, ff, reduce)
Remove the average value of a mesh function.
This module defines the meshes, which are used in Octopus.
This module handles the communicators for the various parallelization strategies.
subroutine, public multigrid_end(mgrid)
subroutine, public multigrid_init(mgrid, namespace, space, mesh, der, stencil, mc, nlevels)
This modules provides the routines for solving Ax=b using the V-shaped multigrid method.
recursive subroutine, public multigrid_fmg_solver(this, namespace, der, op, sol, rhs)
Full multigrid (FMG) solver.
subroutine, public multigrid_solver_init(this, namespace, mesh, thr)
subroutine, public multigrid_iterative_solver(this, namespace, der, op, sol, rhs, multigrid_shape)
An iterative multigrid solver.
integer, parameter, public mg_fmg
integer, parameter, public mg_v_shape
integer, parameter, public mg_w_shape
subroutine, public poisson_corrections_end(this)
subroutine, public poisson_corrections_init(this, namespace, space, ml, mesh)
subroutine, public correct_rho(this, der, rho, rho_corrected, vh_correction)
subroutine, public poisson_multigrid_solver(this, namespace, der, pot, rho)
A multigrid Poisson solver with corrections at the boundaries.
subroutine, public poisson_multigrid_end(this)
subroutine, public poisson_multigrid_init(this, namespace, space, mesh, der, stencil, mc, ml, thr)
This module defines stencils used in Octopus.