|
PSCF v1.5.0
|
Class to compute and store properties associated with wavevectors. More...
#include <WaveList.h>
Public Member Functions | |
Construction, Destruction and Initialization | |
| WaveList (bool isRealField=true) | |
| Constructor. | |
| ~WaveList () | |
| Destructor. | |
| void | allocate (Mesh< D > const &m, UnitCell< D > const &c) |
| Allocate memory and associate with Mesh and UnitCell objects. | |
Computation | |
| void | clearUnitCellData () |
| Clear all internal data that depends on lattice parameters. | |
| void | computeMinimumImages () |
| Compute minimum images of wavevectors, and also calculate kSq. | |
| void | computeKSq () |
| Compute square norm |k|^2 for all wavevectors. | |
| void | computedKSq () |
| Compute derivatives of |k|^2 w/ respect to unit cell parameters. | |
| void | sortWaves () |
| Sort waves in order of ascending wavevector norm. | |
Data Access | |
| BackendArray< int, CUT > const & | minImages_d () const |
| Get the array of minimum images on the device by reference. | |
| DArray< IntVec< D > > const & | minImages_h () const |
| Get minimum images as IntVec<D> objects on the host. | |
| RField< D, CUT > const & | kSq () const |
| Get the kSq array on the device by reference. | |
| RField< D, CUT > const & | dKSq (int i) const |
| Get derivatives of |k|^2 with respect to lattice parameter i. | |
| DArray< bool > const & | implicitInverse () const |
| Get the implicitInverse array by reference. | |
| DArray< int > const & | sortedIds () const |
| Get the sortedIds array by reference. | |
| GArray< Pair< int > > const & | sortedBunches () const |
| Get the sortedBunches array by reference. | |
| DArray< int > const & | bunchIds () const |
| Get the bunchIds array by reference. | |
| IntVec< D > const & | kMeshDimensions () const |
| Get the dimensions of the k-space mesh. | |
| int | kSize () const |
| Get the number of points in the k-space mesh. | |
| int | nBunch () const |
| Get the number of bunches of sorted waves. | |
Boolean Queries | |
| bool | isAllocated () const |
| Has memory been allocated for arrays? | |
| bool | hasMinImages () const |
| Have minimum images been computed? | |
| bool | hasKSq () const |
| Has the kSq array been computed? | |
| bool | hasdKSq () const |
| Has the dKSq array been computed? | |
| bool | isSorted () const |
| Have the waves been sorted by magnitude ? | |
| bool | isRealField () const |
| Is this WaveList set up for use with real-valued fields? | |
Class to compute and store properties associated with wavevectors.
A WaveList computes and stores minimum images of wavevectors, square norms of wavevectors (kSq), and derivatives of the square norms with respect to the unit cell parameters (dKSq). A WaveList can also be used to sort wavevectors in order of increasing wavevector norm.
A WaveList computes these properties for a mesh of grid points in k-space. Different dimensions are used for this mesh depending on the value of the parameter isRealField that is passed to constructor. This parameter specifies whether this class will use a k-space mesh designed for real or complex fields throughout the lifetime of this WaveList object. If isRealField == true, this class uses the k-space mesh used by FFTW for the result of a real-to-complex discrete Fourier transform, which is contains slightly more than half the number of grid points as the corresponding real-space mesh. If isRealField == true, this class uses a k-space mesh with dimensions that are the same as those of the associated real-space mesh. The dimensions of this k-space mesh are returned as an IntVec<D> by member function kMeshDimensions().
In most of the arrays constructed by this class, each element corresponds to a wavevector in the associated k-space mesh, and the index of each element correspond to the rank of the associated wavevector within that mesh. This applies to the arrays returned by the functions minImages(), kSq(), dkSq(int i), and bunchIds().
Any time the lattice parameters change, the clearUnitCellData() method should be called. This function sets internal flags that mark some properties as being outdated, indicating that they are outdated and thus must be recalculated before the next use.
Definition at line 70 of file cuda/WaveList.h.
| Pscf::WaveList< D, CUT >::WaveList | ( | bool | isRealField = true | ) |
Constructor.
| isRealField | Will this object be used for real-valued fields? |
Definition at line 442 of file cuda/WaveList.tpp.
References isRealField(), and WaveList().
Referenced by allocate(), bunchIds(), clearUnitCellData(), computedKSq(), computeKSq(), computeMinimumImages(), dKSq(), implicitInverse(), kSq(), minImages_d(), minImages_h(), sortedBunches(), sortedIds(), sortWaves(), WaveList(), and ~WaveList().
| Pscf::WaveList< D, CUT >::~WaveList | ( | ) |
| void Pscf::WaveList< D, CUT >::allocate | ( | Mesh< D > const & | m, |
| UnitCell< D > const & | c ) |
Allocate memory and associate with Mesh and UnitCell objects.
| m | spatial discretization mesh (input) |
| c | crystallographic unit cell (input) |
Definition at line 493 of file cuda/WaveList.tpp.
References Pscf::MeshIterator< D >::atEnd(), Pscf::MeshIterator< D >::begin(), clearUnitCellData(), Pscf::UnitCellBase< D >::nParameter(), Pscf::MeshIterator< D >::position(), Pscf::MeshIterator< D >::rank(), Pscf::Mesh< D >::size(), UTIL_CHECK, and WaveList().
| void Pscf::WaveList< D, CUT >::clearUnitCellData | ( | ) |
Clear all internal data that depends on lattice parameters.
Sets hasKSq_ and hasdKSq_ to false, and sets hasMinImages_ to false only if the unit cell type has variable angles.
Definition at line 550 of file cuda/WaveList.tpp.
References Pscf::hasVariableAngle(), and WaveList().
Referenced by allocate().
| void Pscf::WaveList< D, CUT >::computeMinimumImages | ( | ) |
Compute minimum images of wavevectors, and also calculate kSq.
This function recomputes the minimum images of all wavevectors if necessary (i.e., if hasMinImages() == false), but does nothing if the minimum images are up to date (if hasMinImages() == true).
The minimum images may change if a lattice angle in the unit cell is changed, so this method should be called whenever such changes occur.
In the process of computing the minimum images, the square norm |k|^2 for all wavevectors is also calculated and stored, so it is not necessary to call computeKSq after calling this method. computeKSq is provided to allow calculation of kSq without recalculating minimum images.
Definition at line 569 of file cuda/WaveList.tpp.
References Pscf::MeshIterator< D >::atEnd(), Pscf::MeshIterator< D >::begin(), Util::Log::file(), Pscf::MeshIterator< D >::position(), Pscf::MeshIterator< D >::rank(), Pscf::ThreadArray::setThreadsLogical(), Pscf::ThreadArray::setThreadsPerBlock(), UTIL_CHECK, and WaveList().
Referenced by computedKSq(), and computeKSq().
| void Pscf::WaveList< D, CUT >::computeKSq | ( | ) |
Compute square norm |k|^2 for all wavevectors.
This function recomputes values of the square norm for all wavevectors if necessary (i.e., if hasKSq() == false), and does nothing if these values are up to date (if hasKSq() == true). Mininum image values are updated if necessary.
Definition at line 649 of file cuda/WaveList.tpp.
References computeMinimumImages(), Pscf::ThreadArray::setThreadsLogical(), UTIL_CHECK, and WaveList().
Referenced by sortWaves().
| void Pscf::WaveList< D, CUT >::computedKSq | ( | ) |
Compute derivatives of |k|^2 w/ respect to unit cell parameters.
This function computes values of the derivatives of wavevector square norms with respect to unit cell parameters if necessary (i.e., if hasdKSq() == false), and does nothing if these values are up to date. Minimum images are updated if necessary.
Definition at line 698 of file cuda/WaveList.tpp.
References computeMinimumImages(), Pscf::ThreadArray::setThreadsLogical(), UTIL_CHECK, and WaveList().
| void Pscf::WaveList< D, CUT >::sortWaves | ( | ) |
Sort waves in order of ascending wavevector norm.
This function computes the sortedIds, sortedBunches, and bunchIds arrays. Values of kSq are updated before sorting waves if hasKSq() is false on entry.
Definition at line 758 of file cuda/WaveList.tpp.
References computeKSq(), Pscf::Sort::findBunches(), Pscf::Sort::sort(), UTIL_CHECK, and WaveList().
|
inline |
Get the array of minimum images on the device by reference.
The array has size kSize * D, where kSize is the number of grid points in the FFT k-space mesh. The array is unwrapped into a linear array in an index-by-index manner, in which the first kSize elements of the array contain the first index of each minimum image, and so on. If isRealField is true, kSize is smaller than the size of the real-space mesh. Otherwise, it is equal.
| Exception | if hasMinImages() == false |
Definition at line 522 of file cuda/WaveList.h.
References UTIL_CHECK, and WaveList().
| DArray< IntVec< D > > const & Pscf::WaveList< D, CUT >::minImages_h | ( | ) | const |
Get minimum images as IntVec<D> objects on the host.
This function returns an array of kSize elements in which each element is an IntVec<D> containing the integer coordinates of the minimum image of one wavevector in the k-space mesh used for discrete Fourier transforms.
| Exception | if hasMinImages() == false |
Definition at line 825 of file cuda/WaveList.tpp.
References UTIL_CHECK, and WaveList().
|
inline |
Get the kSq array on the device by reference.
This method returns an RField<D,CUT> in which each element is the square magnitude |k|^2 of a wavevector k in the k-space mesh used for a DFT. If isRealField is true, this k-space mesh is smaller than the real-space mesh. Otherwise, it is the same size.
Definition at line 530 of file cuda/WaveList.h.
References UTIL_CHECK, and WaveList().
|
inline |
Get derivatives of |k|^2 with respect to lattice parameter i.
This method returns an RField<D,CUT> in which each element is the derivative of the square-wavevector with respect to unit cell parameter i, multiplied by a prefactor. The prefactor is 2.0 for waves that have an implicit inverse and 1.0 otherwise. The choice of prefactor is designed to simplify use of the array to compute stress.
Each element corresponds to one wavevector k in the k-space mesh used for the DFT. If isRealField is true, this k-space mesh is smaller than the real-space mesh. Otherwise, it is the same size. In the latter case, there are no implicit waves, so the prefactor is always 1.0.
| i | index of lattice parameter |
Definition at line 538 of file cuda/WaveList.h.
References UTIL_CHECK, and WaveList().
|
inline |
Get the implicitInverse array by reference.
This array is defined on a k-grid mesh, with a boolean value for each wavevector. The boolean represents whether the inverse of the wave at the given gridpoint is an implicit wave. Implicit here is used to mean any wave that is outside the bounds of the k-grid.
This method will throw an error if isRealField == false, because there are no implicit inverses in such a case.
Definition at line 546 of file cuda/WaveList.h.
References UTIL_CHECK, and WaveList().
|
inline |
Get the sortedIds array by reference.
The array returned by this function contains k-grid rank indices of wavevectors sorted in order of increasing wavevector magnitude.
This method throws an Exception if isSorted == false.
Definition at line 556 of file cuda/WaveList.h.
References UTIL_CHECK, and WaveList().
|
inline |
Get the sortedBunches array by reference.
Each element in this array contains a Pair<int> of two integers that give upper and lower index bounds of a contiguous slice (a "bunch") that contains ids of wavevectors of equal magnitude. The first value in such a pair is the array index in sortIds_ of the first element of such bunch, and the second is one greater than the index of the last element in that bunch.
This method throws an Exception if isSorted == false.
Definition at line 564 of file cuda/WaveList.h.
References UTIL_CHECK, and WaveList().
|
inline |
Get the bunchIds array by reference.
This function returns an array, indexed by wave rank, in which the value is the integer identifier of a bunch to which the wave belongs. Each such value corresponds to an array index of the corresponding bunch in the sortedBunches array.
This method throws an Exception if isSorted == false.
Definition at line 572 of file cuda/WaveList.h.
References UTIL_CHECK, and WaveList().
|
inline |
Get the dimensions of the k-space mesh.
If isRealField() == true, the reciprocal-space grid is smaller than the real-space grid. Otherwise, the two grids are identical.
Definition at line 280 of file cuda/WaveList.h.
|
inline |
Get the number of points in the k-space mesh.
If isRealField() == true, kSize is approximately half the size of the real-space grid. Otherwise, the two grids are identical.
Definition at line 290 of file cuda/WaveList.h.
|
inline |
Get the number of bunches of sorted waves.
Definition at line 296 of file cuda/WaveList.h.
References UTIL_CHECK.
|
inline |
Has memory been allocated for arrays?
Definition at line 309 of file cuda/WaveList.h.
|
inline |
Have minimum images been computed?
Definition at line 315 of file cuda/WaveList.h.
|
inline |
Has the kSq array been computed?
Definition at line 321 of file cuda/WaveList.h.
|
inline |
Has the dKSq array been computed?
Definition at line 327 of file cuda/WaveList.h.
|
inline |
Have the waves been sorted by magnitude ?
Definition at line 333 of file cuda/WaveList.h.
|
inline |
Is this WaveList set up for use with real-valued fields?
Definition at line 339 of file cuda/WaveList.h.
Referenced by WaveList().