|
PSCF v1.4.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 set association with a Mesh and UnitCell object. | |
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 | |
| DeviceArray< int > const & | minImages_d () const |
| Get the array of minimum images on the device by reference. | |
| HostDArray< IntVec< D > > const & | minImages_h () const |
| Get minimum images as IntVec<D> objects on the host. | |
| RField< D > const & | kSq () const |
| Get the kSq array on the device by reference. | |
| RField< D > const & | dKSq (int i) const |
| Get derivatives of |k|^2 with respect to lattice parameter i. | |
| DeviceArray< 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 |
| Return the dimensions of the k-space mesh. | |
| int | kSize () const |
| Return the number of points in the k-space mesh. | |
| int | nBunch () const |
| Return 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 68 of file cuda/WaveList.h.
| Pscf::Prdc::Cuda::WaveList< D >::WaveList | ( | bool | isRealField = true | ) |
Constructor.
| isRealField | Will this object be used for real-valued fields? |
Definition at line 441 of file cuda/WaveList.tpp.
References isRealField().
| Pscf::Prdc::Cuda::WaveList< D >::~WaveList | ( | ) |
Destructor.
Definition at line 459 of file cuda/WaveList.tpp.
| void Pscf::Prdc::Cuda::WaveList< D >::allocate | ( | Mesh< D > const & | m, |
| UnitCell< D > const & | c ) |
Allocate memory and set association with a Mesh and UnitCell object.
| m | spatial discretization mesh (input) |
| c | crystallographic unit cell (input) |
Definition at line 492 of file cuda/WaveList.tpp.
References Pscf::MeshIterator< D >::atEnd(), Pscf::MeshIterator< D >::begin(), clearUnitCellData(), Pscf::Prdc::Cuda::FFT< D >::computeKMesh(), Pscf::Prdc::UnitCellBase< D >::nParameter(), Pscf::MeshIterator< D >::position(), Pscf::MeshIterator< D >::rank(), Pscf::Mesh< D >::size(), and UTIL_CHECK.
| void Pscf::Prdc::Cuda::WaveList< D >::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 552 of file cuda/WaveList.tpp.
References Pscf::Prdc::hasVariableAngle().
Referenced by allocate().
| void Pscf::Prdc::Cuda::WaveList< D >::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 571 of file cuda/WaveList.tpp.
References Pscf::MeshIterator< D >::atEnd(), Pscf::MeshIterator< D >::begin(), Pscf::DeviceArray< Data >::cArray(), Util::Log::file(), Pscf::MeshIterator< D >::position(), Pscf::MeshIterator< D >::rank(), Pscf::ThreadArray::setThreadsLogical(), Pscf::ThreadArray::setThreadsPerBlock(), and UTIL_CHECK.
Referenced by computedKSq(), and computeKSq().
| void Pscf::Prdc::Cuda::WaveList< D >::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 650 of file cuda/WaveList.tpp.
References Pscf::DeviceArray< Data >::cArray(), computeMinimumImages(), Pscf::ThreadArray::setThreadsLogical(), and UTIL_CHECK.
Referenced by sortWaves().
| void Pscf::Prdc::Cuda::WaveList< D >::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 699 of file cuda/WaveList.tpp.
References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), computeMinimumImages(), Pscf::ThreadArray::setThreadsLogical(), and UTIL_CHECK.
| void Pscf::Prdc::Cuda::WaveList< D >::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 759 of file cuda/WaveList.tpp.
References computeKSq(), Pscf::Sort::findBunches(), Pscf::Sort::sort(), and UTIL_CHECK.
|
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.
Definition at line 499 of file cuda/WaveList.h.
References UTIL_CHECK.
| HostDArray< IntVec< D > > const & Pscf::Prdc::Cuda::WaveList< D >::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.
Definition at line 827 of file cuda/WaveList.tpp.
References UTIL_CHECK.
|
inline |
Get the kSq array on the device by reference.
This method returns an RField<D> 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 507 of file cuda/WaveList.h.
References UTIL_CHECK.
Referenced by Pscf::Rpg::BinaryStructureFactor< D >::setup().
|
inline |
Get derivatives of |k|^2 with respect to lattice parameter i.
This method returns an RField<D> 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 515 of file cuda/WaveList.h.
References UTIL_CHECK.
|
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 523 of file cuda/WaveList.h.
References UTIL_CHECK.
Referenced by Pscf::Rpg::BinaryStructureFactor< D >::setup().
|
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 533 of file cuda/WaveList.h.
References UTIL_CHECK.
|
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 541 of file cuda/WaveList.h.
References UTIL_CHECK.
|
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 549 of file cuda/WaveList.h.
References UTIL_CHECK.
|
inline |
Return 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 266 of file cuda/WaveList.h.
|
inline |
Return 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 276 of file cuda/WaveList.h.
|
inline |
Return the number of bunches of sorted waves.
Definition at line 282 of file cuda/WaveList.h.
References UTIL_CHECK.
|
inline |
Has memory been allocated for arrays?
Definition at line 295 of file cuda/WaveList.h.
|
inline |
Have minimum images been computed?
Definition at line 301 of file cuda/WaveList.h.
|
inline |
Has the kSq array been computed?
Definition at line 307 of file cuda/WaveList.h.
|
inline |
Has the dKSq array been computed?
Definition at line 313 of file cuda/WaveList.h.
|
inline |
Have the waves been sorted by magnitude ?
Definition at line 319 of file cuda/WaveList.h.
|
inline |
Is this WaveList set up for use with real-valued fields?
Definition at line 325 of file cuda/WaveList.h.
Referenced by WaveList().