|
MADNESS 0.10.1
|
Holds displacements for applying operators to avoid replicating for all operators. More...
#include <displacements.h>

Classes | |
| struct | DispEntry |
| struct | PeriodicLists |
| the displacements for kernels lattice-summed along one set of axes, per level, in the two orders consumers use More... | |
Public Member Functions | |
| Displacements () | |
| const std::vector< Key< NDIM > > & | get_disp () |
| return the standard displacements appropriate for operators w/o lattice summation | |
| const std::vector< Key< NDIM > > & | get_disp (Level n, const array_of_bools< NDIM > &kernel_lattice_sum_axes) |
| const std::vector< Key< NDIM > > & | get_disp_images (Level n, const array_of_bools< NDIM > &kernel_lattice_sum_axes) |
Static Public Member Functions | |
| static std::array< int, NDIM > | bmax_axes () |
| The bound on |l_d| for the displacements l that do_apply visits at level n, per axis. | |
| static std::array< int, NDIM > | bmax_current () |
| the per-axis reach (in boxes) of the standard displacement lists, see bmax_axes() | |
| static int | bmax_default () |
| static void | make_disp (const std::array< int, NDIM > &bmax) |
| static void | make_disp_images (PeriodicLists &lists) |
| fills lists.by_image_distance (requires the lock) | |
| static void | make_disp_periodic (const std::array< int, NDIM > &bmax_in, Level n, PeriodicLists &lists) |
| fills lists.by_distance[n] for lists.axes | |
| static PeriodicLists & | periodic (const array_of_bools< NDIM > &axes) |
the lists for kernels lattice-summed along axes, built on the first request | |
| static void | reset_periodic_axes (const array_of_bools< NDIM > &periodic_axes) |
builds the displacements for kernels lattice-summed along periodic_axes if they do not exist yet | |
| static void | set_width (const Tensor< double > &width) |
| static void | sort_displacements (std::vector< Key< NDIM > > &d, const Tensor< double > &w) |
| static void | sort_displacements_images (std::vector< Key< NDIM > > &d, const array_of_bools< NDIM > &paxes, const Tensor< double > &w) |
| static void | sort_displacements_periodic (std::vector< Key< NDIM > > &d, const array_of_bools< NDIM > &paxes, const Tensor< double > &w) |
Static Private Member Functions | |
| static std::size_t | axes_mask (const array_of_bools< NDIM > &axes) |
Static Private Attributes | |
| static std::array< int, NDIM > | bmax_used {} |
| the per-axis reach the current lists were built with (see bmax_axes) | |
| static std::vector< Key< NDIM > > | disp = {} |
| standard displacements to be used with standard kernels (range-unrestricted, no lattice sum) | |
| static constexpr Level | nlevels = 8 * sizeof(Translation) - 2 |
| levels for which lists are built | |
| static std::array< std::atomic< PeriodicLists * >,(std::size_t(1)<< NDIM)> | periodic_lists {} |
| static Mutex | periodic_lists_mutex {} |
| serializes building the lists and set_width() | |
| static std::vector< std::unique_ptr< PeriodicLists > > | periodic_lists_owner {} |
| owns what periodic_lists points to | |
| static Tensor< double > | widths {NDIM} |
| cell width, used to order displacements from least to most real space distance | |
Holds displacements for applying operators to avoid replicating for all operators.
|
inline |
The first call generates the standard displacements and, if the default boundary conditions have periodic axes, the displacements for kernels lattice-summed along those axes. Lists for any other set of lattice-summed axes are built on their first request (get_disp, get_disp_images), which SeparatedConvolution makes when it is constructed.
References bmax_axes(), bmax_used, disp, e(), madness::FunctionDefaults< NDIM >::get_bc(), MADNESS_PRAGMA_CLANG, make_disp(), NDIM, periodic(), madness::pop(), and widths.
|
inlinestaticprivate |
References d, madness::mask(), and NDIM.
Referenced by periodic().
|
inlinestatic |
The bound on |l_d| for the displacements l that do_apply visits at level n, per axis.
The blocks of the non-standard form decay with the real-space distance l_d h_d, so a narrow axis needs more boxes to reach the same decay as a wide one: a fit term unresolved on the long axis (which is what makes the operator act on it at level n) is smooth across the boxes of a short axis, where its block falls off only as exp(-a (l h)^2). Hence bmax_d = ceil(bmax_default * w_max / w_d): bmax_default on every axis of a cube, (4, 4, 23) in a 100x100x18 cell, where an isotropic 4 leaves the Coulomb potential of a neutral chain 1.3e-4 off the analytic result at eps 1e-6 (1e-5 with the per-axis bound). The extra displacements are only norm-checked: for a decaying kernel the shell-wise stop in do_apply ends the loop at the same real distance as before.
Cost: the lists hold prod_d (2 bmax_d + 1) keys (up to 2x more per lattice-summed axis), the periodic ones for every level, so they grow with the aspect ratio along every short axis. Measured in 3D with two short periodic axes and a 100-bohr free one: 18x18x100 -> 4.4e6 keys, 170 MB, 0.9 s to build; 5x5x100 -> 5.1e7 keys, 1.9 GB, 13 s, paid on every set_cell that changes the shape. Nothing limits the reach beyond the overflow guard below: the boxes past the shell stop are never visited, but how to drop them safely is not known (a Dirac solver resolving the nuclei refines to level ~30 where the kernel is local on every axis). In 6D the standard list alone would hold (2 bmax_d + 1)^6 keys, 7e7 for a 5.6:1 cell, so non-cubic cells are not practical there (and 6D is not used in periodic settings).
References b, bmax_default(), d, e(), MADNESS_CHECK_THROW, MADNESS_PRAGMA_CLANG, NDIM, madness::pop(), w(), and widths.
Referenced by Displacements(), bmax_current(), periodic(), and set_width().
|
inlinestatic |
the per-axis reach (in boxes) of the standard displacement lists, see bmax_axes()
the reach the lists were built with; if none was built yet, the reach they will be built with
References bmax_axes(), bmax_used, and disp.
Referenced by madness::BoxSurfaceDisplacementRange< NDIM >::compute_probing_displacement(), and madness::BoxSurfaceDisplacementValidator< NDIM >::operator()().
|
inlinestatic |
References NDIM.
Referenced by bmax_axes(), and main().
|
inline |
return the standard displacements appropriate for operators w/o lattice summation
References disp, MADNESS_PRAGMA_CLANG, and madness::pop().
|
inline |
the displacements for a kernel lattice-summed along kernel_lattice_sum_axes (the standard displacements if none), ordered by the real-space distance to the source modulo the lattice (Key::real_distsq_bc), as FunctionImpl::do_apply screens a kernel that decays away from the source
References madness::array_of_bools< N >::any(), madness::Displacements< NDIM >::PeriodicLists::by_distance, disp, MADNESS_CHECK, MADNESS_PRAGMA_CLANG, nlevels, periodic(), and madness::pop().
Referenced by madness::FunctionImpl< T, LDIM >::do_apply_directed_screening(), and madness::SeparatedConvolution< double, 3 >::get_disp().
|
inline |
the displacements of get_disp(n, kernel_lattice_sum_axes) ordered by the distance to the nearest lattice image other than the home cell (Key::real_distsq_images), for kernels that sum only those images (OperatorInfo::images_only); built on the first request for these axes
References madness::Displacements< NDIM >::PeriodicLists::by_image_distance, madness::Displacements< NDIM >::PeriodicLists::images_built, MADNESS_CHECK, MADNESS_PRAGMA_CLANG, make_disp_images(), nlevels, periodic(), periodic_lists_mutex, and madness::pop().
Referenced by madness::SeparatedConvolution< double, 3 >::get_disp().
|
inlinestatic |
References d, disp, NDIM, sort_displacements(), and widths.
Referenced by Displacements(), periodic(), and set_width().
|
inlinestatic |
fills lists.by_image_distance (requires the lock)
References madness::Displacements< NDIM >::PeriodicLists::axes, madness::Displacements< NDIM >::PeriodicLists::by_distance, madness::Displacements< NDIM >::PeriodicLists::by_image_distance, nlevels, sort_displacements_images(), and widths.
Referenced by get_disp_images(), and set_width().
|
inlinestatic |
fills lists.by_distance[n] for lists.axes
References madness::array_of_bools< N >::any(), madness::Displacements< NDIM >::PeriodicLists::axes, madness::Displacements< NDIM >::PeriodicLists::by_distance, d, MADNESS_ASSERT, MADNESS_PRAGMA_CLANG, NDIM, madness::pop(), sort_displacements_periodic(), and widths.
Referenced by periodic(), and set_width().
|
inlinestatic |
the lists for kernels lattice-summed along axes, built on the first request
References madness::array_of_bools< N >::any(), axes_mask(), bmax_axes(), bmax_used, disp, MADNESS_CHECK_THROW, MADNESS_PRAGMA_CLANG, make_disp(), make_disp_periodic(), NDIM, nlevels, p(), periodic_lists, periodic_lists_mutex, periodic_lists_owner, and madness::pop().
Referenced by Displacements(), get_disp(), get_disp_images(), and reset_periodic_axes().
|
inlinestatic |
builds the displacements for kernels lattice-summed along periodic_axes if they do not exist yet
Lists are built per set of lattice-summed axes on first request, so this is not needed for correctness; it moves the build (all levels, a few tens of milliseconds) out of the first apply.
| periodic_axes | the lattice-summed axes |
References madness::array_of_bools< N >::any(), MADNESS_ASSERT, and periodic().
Referenced by main().
|
inlinestatic |
Sets the cell widths used to order the displacements by real-space distance, and reorders them if the widths changed. Called by FunctionDefaults::recompute_cell_info whenever the cell is set.
References bmax_axes(), bmax_used, madness::copy(), disp, MADNESS_ASSERT, MADNESS_PRAGMA_CLANG, make_disp(), make_disp_images(), make_disp_periodic(), NDIM, madness::BaseTensor::ndim(), nlevels, periodic_lists_mutex, periodic_lists_owner, madness::pop(), madness::BaseTensor::size(), sort_displacements(), sort_displacements_periodic(), and widths.
Referenced by madness::FunctionDefaults< 1 >::recompute_cell_info(), test_opdir(), and testgradG().
|
inlinestatic |
References d, madness::FunctionDefaults< NDIM >::k, and w().
Referenced by make_disp(), and set_width().
|
inlinestatic |
orders by the distance to the nearest non-home image: least distance between the boxes, then boxes, then the distance between the box centers. The last breaks the tie among the displacements one box from an image, which are all at least distance 0: the narrowest summed axis comes first, and its block is the operator's largest (SeparatedConvolution::norm_bound visits the leading image-adjacent run).
References d, madness::FunctionDefaults< NDIM >::k, and w().
Referenced by make_disp_images().
|
inlinestatic |
References d, madness::FunctionDefaults< NDIM >::k, and w().
Referenced by make_disp_periodic(), and set_width().
|
inlinestaticprivate |
the per-axis reach the current lists were built with (see bmax_axes)
Referenced by Displacements(), bmax_current(), periodic(), and set_width().
|
inlinestaticprivate |
standard displacements to be used with standard kernels (range-unrestricted, no lattice sum)
Referenced by Displacements(), bmax_current(), get_disp(), get_disp(), make_disp(), periodic(), and set_width().
|
staticconstexprprivate |
levels for which lists are built
Referenced by get_disp(), get_disp_images(), make_disp_images(), periodic(), and set_width().
|
inlinestaticprivate |
the lists for each set of lattice-summed axes, indexed by the axes' bitmask; a slot is filled on the first request for its axes (see periodic()) and published through the atomic once complete, so lookups take no lock. Sorting the lists with the metric of the axes they are requested for is what makes the shell-wise screening of FunctionImpl::do_apply sound: a list sorted for a superset of the kernel's axes would place a displacement wrapped along an axis the kernel does not sum next to the source, where for that kernel it is a cell away. A set holds every level's list in each order it was asked for (for NDIM = 3 up to (4 bmax + 1)^3 keys per level, some ten MB per order), so a process that uses operators summed along several different axis sets pays that per set; before, one set served them all.
Referenced by periodic().
|
inlinestaticprivate |
serializes building the lists and set_width()
Referenced by get_disp_images(), periodic(), and set_width().
|
inlinestaticprivate |
owns what periodic_lists points to
Referenced by periodic(), and set_width().
|
inlinestaticprivate |
cell width, used to order displacements from least to most real space distance
Referenced by Displacements(), bmax_axes(), make_disp(), make_disp_images(), make_disp_periodic(), and set_width().