Skip to content

adam_flail_object ​

ADAM, FLAIL: the elliptic solver library (issue #84).

One entry point for the elliptic solves of every ADAM application. It is built on the two solvers verified in issues #81 and #87: the FFT solver poisson_fft_object (uniform grids, periodic or isolated, FFTW on the host; its FNL extension runs the transforms on cuFFT) and the multigrid-preconditioned conjugate-gradient solver poisson_mg_object (2:1 AMR grids, the symmetric composite operator, periodic or isolated through the James step, its coarsest level solved by the FFT solver). PRISM's t0 solves moved here in issue #84 E3, and its legacy smoothers (adam_flail_legacy_object, the [linear-algebra] section) were deleted in E4.

Phase E0 is a facade over the two solvers: setup chooses one for the current grid, as FLUME's self-gravity did, and solve/solve_packed forward to it with the call sequence unchanged, so a client gets bitwise the results it got from the solvers directly. The operator is the compact second-order Laplacian L_h phi = factor (f - mean f) (periodic) or L_h phi = factor f (isolated); further operators come in E2.

Boundary kinds (E1c). setup(..., bc) gives the kind of every face (adam_flail_parameters: periodic, Dirichlet or Neumann at the face, ghost-Dirichlet; mixed across axes and within one), forwarded to the solver chosen; the grid's periodicity must agree with it. Without a Dirichlet face the operator is singular and the mean of the source is removed, as on a periodic grid. Without bc the setup is the E0 one, unchanged: periodic or isolated. The values at the boundary are homogeneous on the FFT path; solve(..., ghost=) gives inhomogeneous ones (the multigrid's boundary-face list, mg%nbnd, mg%bnd_kind, mg%bnd_dir, mg%bnd_x) and needs the multigrid path (FLAIL_BACKEND_MULTIGRID: on a uniform grid one V-cycle is the exact FFT solve). FLAIL_BC_ZERO_GHOSTS (E2b, PRISM's Dirichlet face) is ghost-Dirichlet at zero for the compact operator; with the wide D(G) the FFT solver solves it by preconditioned CG. FLAIL_BC_FREE_GHOSTS (E3c, PRISM's exact/open face) holds the free-space potential of the source in the ghosts, on the same CG path. A vector whose components take different kinds (PRISM's vector potential at a PEC face: Neumann for the normal component, Dirichlet for the others) takes one FLAIL per set of kinds: the operators differ, and the instances coexist.

The wide operator (E2a). setup(..., dg_order=p) (2, 4, 6, 8) solves PRISM's D(G), the order-p centred first derivative composed with itself, instead of the compact Laplacian: on a uniform grid the FFT solver inverts it exactly (adam_poisson_fft_object). On AMR it is refused: a composite wide operator across 2:1 faces is not defined yet (#84 E7), and a compact multigrid preconditioner does not converge for it in a bounded number of iterations (the checkerboard branch; the #84 E2 prototype).

A backend's FFT solver is chosen by allocating the fft component before setup (the FNL backend allocates the cuFFT extension); otherwise setup allocates the host one. Its multigrid solver likewise by allocating the mg_mold component (the FNL backend allocates the device extension, #84 E6a); otherwise the host one.

Source: src/lib/common/adam_flail_object.F90

Dependencies

Contents ​

Variables ​

NameTypeAttributesDescription
FLAIL_BACKEND_AUTOinteger(kind=I4P)parameterFFT on a uniform grid, multigrid otherwise.
FLAIL_BACKEND_FFTinteger(kind=I4P)parameterThe FFT solver (uniform grids only).
FLAIL_BACKEND_MULTIGRIDinteger(kind=I4P)parameterThe multigrid solver, on any 2:1 grid.

Derived Types ​

flail_object ​

FLAIL: the elliptic solver of a realm.

Components ​

NameTypeAttributesDescription
fftclass(poisson_fft_object)allocatableFFT solver; on a multigrid setup, the mold of its coarsest level.
mgclass(poisson_mg_object)allocatableMultigrid solver, allocated only when the current setup uses it.
mg_moldclass(poisson_mg_object)allocatableThe backend's multigrid solver type (none: the host one).

Type-Bound Procedures ​

NameAttributesDescription
destroypass(self)Destroy the solvers.
is_multigridpass(self)True when the current setup uses the multigrid solver.
iterationspass(self)FCG iterations of the last multigrid solve (0 for the FFT solver).
setuppass(self)Choose and set up the solver for the current grid.
solvepass(self)Solve for phi from one variable of q.
solve_packedpass(self)Solve for phi from the packed interior source.

Subroutines ​

destroy ​

Destroy the solvers.

fortran
subroutine destroy(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(flail_object)inoutFLAIL.

Call graph

setup ​

Choose and set up the solver for the current grid: call it on the initial grid and after every regrid.

FLAIL_BACKEND_AUTO uses the FFT solver when every leaf is at one level and the multigrid solver otherwise; FLAIL_BACKEND_FFT on a grid with more than one level is fatal, the message naming option_name (the client's input key, default [flail].(backend)). The multigrid solver is rebuilt at every call, its coarsest level solved by a solver of the fft component's type. bc (E1c): the kind of every face, forwarded to the solver; isolated boundaries take none (fatal: the FFT solver would ignore it). dg_order (E2a): 0 the compact Laplacian (the default), 2, 4, 6 or 8 the wide D(G), on the FFT path only. root_cells (#84 E6): the multigrid's root at most this many cells (default: the root solver's root_cells_max); for measurements.

fortran
subroutine setup(self, grid, field, isolated, backend, option_name, bc, dg_order, root_cells)

Arguments

NameTypeIntentAttributesDescription
selfclass(flail_object)inoutFLAIL.
gridtype(grid_object)inThe grid.
fieldtype(field_object)inThe field (block coordinates).
isolatedlogicalinFree-space boundaries, else periodic.
backendinteger(kind=I4P)inFLAIL_BACKEND_AUTO, _FFT or _MULTIGRID.
option_namecharacter(len=*)inoptionalThe client's input key, for the messages.
bcinteger(kind=I4P)inoptionalKinds per face [lo/hi, axis] (adam_flail_parameters).
dg_orderinteger(kind=I4P)inoptional0 compact (default); 2, 4, 6, 8: the wide D(G).
root_cellsinteger(kind=I4P)inoptionalMost cells of the multigrid's root.

Call graph

solve ​

Solve for phi from the variable iv of q, every ghost layer of phi filled; optionally the energy sum_cells f phi dV (every rank). ghost (E1c): the boundary value of each of this rank's boundary faces (mg%nbnd, of its kind), multigrid path only.

fortran
subroutine solve(self, field, q, iv, factor, phi, energy, ghost)

Arguments

NameTypeIntentAttributesDescription
selfclass(flail_object)inoutFLAIL.
fieldtype(field_object)inThe field (coordinates).
qreal(kind=R8P)inConservative [nv,i,j,k,nb], ghosts included.
ivinteger(kind=I4P)inVariable of q, the source.
factorreal(kind=R8P)inSource factor (4 pi G for gravity).
phireal(kind=R8P)inoutPotential [i,j,k,nb], ghosts included.
energyreal(kind=R8P)outoptionalsum_cells f phi dV (all ranks).
ghostreal(kind=R8P)inoptionalBoundary values per boundary face (multigrid path).

Call graph

solve_packed ​

Solve for phi from the packed interior source of the active blocks (block-major, i fastest), every ghost layer of phi filled; optionally the energy sum_cells f phi dV (every rank); ghost as in solve.

fortran
subroutine solve_packed(self, field, buf, factor, phi, energy, ghost)

Arguments

NameTypeIntentAttributesDescription
selfclass(flail_object)inoutFLAIL.
fieldtype(field_object)inThe field (coordinates).
bufreal(kind=R8P)inPacked interior source.
factorreal(kind=R8P)inSource factor (4 pi G for gravity).
phireal(kind=R8P)inoutPotential [i,j,k,nb], ghosts included.
energyreal(kind=R8P)outoptionalsum_cells f phi dV (all ranks).
ghostreal(kind=R8P)inoptionalBoundary values per boundary face (multigrid path).

Call graph

refuse_ghost ​

Boundary values given on the FFT path, which solves the homogeneous problem: fatal.

fortran
subroutine refuse_ghost()

Call graph

Functions ​

is_multigrid ​

True when the current setup uses the multigrid solver.

Attributes: pure

Returns: logical

fortran
function is_multigrid(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(flail_object)inFLAIL.

Call graph

iterations ​

FCG iterations of the last multigrid solve (0 for the FFT solver).

Attributes: pure

Returns: integer(kind=I4P)

fortran
function iterations(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(flail_object)inFLAIL.

Call graph