Source file boundary.F90
The source file boundary.F90 contains all routines related to boundary
conditions and most of the communication between different processors.
This includes the communication with remote processors to load the ghost
cells and the special treatment of the domain boundaries in the y
direction if non-periodic boundary conditions are applied. Note, that the
exchange of particles according to their position in space is handled by
the routine redistribute in the source file particles.F90.
Communication related to the determination of the charge and the current
density (subroutine calc_rho and calc_j, source file particles.F90)
is performed in the subroutine bound_rho_j in the source file particles.F90.
The file boundary.F90 consists of the main subroutines that act
as entry points to be called from other source code files and internal
support routines. The external entry points are:
-
Subroutines bound_e, bound_b, bound_phi, bound_j,
bound_rho,
bound_pe, bound_pi, bound_n:
These subroutines load the ghost cells for the electric field (bound_e),
the magnetic field (bound_b), the potential phi (bound_phi),
the current density (bound_j), the charge density (bound_rho),
electron and ion pressure (bound_pe, bound_pi), and the density
(bound_n).
First the ghost cells are exchanged between neighboring processors (=subdomains)
assuming that the computational domain is periodically closed in all three
spatial directions (call to the internal subroutine
boundary, see
below). If periodic boundary conditions are applied nothing else needs to
be done. For non-periodic boundary conditions the ghost cells at the domain
boundary in y need to be altered appropriately according to the
special type of boundary conditions. In this case either Dirichlet
(f=0)
or von Neumann (df/dy=0) boundary conditions are supported.
For the full-particle version three types of boundary conditions are
available:
-
periodic in all three directions
-
2-D GEM boundary conditions: These boundary conditions can be translated
to a larger periodic system. For this purpose the original domain [0...Lx,
0...Ly] is doubled by rotating the real domain around the x
axis and attaching it as a virtual domain at [0...Lx,Ly...2*Ly].
Thus, scalar data at the coordinates (x,y) and (x,2*Ly-y)
are
identical whereas the sign of vector quantities changes accordingly.
-
3-D GEM boundary conditions: or the 3-D case a conducting wall is introduced
at y=0 and y=Ly.
For the hybrid and the two-fluid version only periodic boundary conditions
are available at present. In case other boundary conditions are implemented
the source files hybrid.M and twofluid.M
need to be checked carefully, if the calls to the bound_... routines
always lead to the expected boundary conditions. This is of particular
importance for the potential phi, i.e. the solution to the Helmholtz
equation and the artificial viscosities.
-
Subroutines virtual_charge, virtual_current:
For non-periodic boundary conditions virtual particles beyond the boundary
of the domain may be necessary (compare subroutines calc_rho and
calc_j
in source file particles.F90). If for example
a conducting wall is located at y=0 each particle at position (x,y)
corresponds to a virtual particle at (x,-y). The subroutine
virtual_charge determines the sign of the virtual charge: The virtual
charge is given by the charge of the real particle multiplied by the value
returned by the subroutine. Analogously the components of the virtual current
are controlled by the subroutine virtual_current. The two subroutines
are called by calc_rho and calc_j in the source file particles.F90.
-
Function non_periodic:
The function non_periodic returns the values .true. or
.false. depending on whether the boundary conditions are periodic or not.
It is called by subroutines in the source file particles.F90.
In bound_rho_j it is used to determine whether charge/current that
was collected in the ghost cells at the domain boundary in y is
to be transferred periodically. In subroutine stepx the result of
function non_periodic is used to decide how particles are treated
that leave the domain in y: Should they be periodically transferred
or should they be reflected?
-
Subroutine bound_particle:
The subroutine bound_particle specifies which velocity components
of a particle that hits the boundary should be inverted (in case there
is a wall).
-
Subroutines smooth_e, smooth_j, smooth_rho:
These subroutines are called to average the current density, the charge
and the electric field that acts on the particles over the closets grid
cells to reduce the noise level.
To perform the tasks of the subroutines described above several internal
support routines are used:
-
Subroutine boundary:
The subroutine boundary loads the ghost cell layers by exchanging
data between adjacent processors. It contains the calls to the MPI routines
which perform the communication.
-
Subroutines dirichlet, von_neumann:
These two subroutines alter the ghost cells along the domain boundary
in y such the Dirichlet or von Neumann boundary conditions are satisfied.
-
Subroutine smooth:
This routine performs the smoothing of the electric field, the current
and the charge density after the boundary conditions have been set appropriately
by the calling routine.
Switches:
-
boundary_condition:
This switch determines which type of boundary conditions is used. Possible
values are
-
#define boundary_condition periodic
-
#define boundary_condition gem_reconnection (full particle version
only)
-
#define boundary_condition gem_3d (full particle version only)
Make sure that the initial data set used for start-up satisfies the chosen
boundary conditions.