Commit 58547ce8 by Francois Gygi

Add basis_fits_in_grid function

parent e66b7c0d
......@@ -136,6 +136,14 @@ bool Basis::factorizable(int n) const
int Basis::np(int i) const { return np_[i]; }
////////////////////////////////////////////////////////////////////////////////
bool Basis::fits_in_grid(int np0, int np1, int np2) const
{ return
( idxmax_[0] < np0/2 ) && ( idxmin_[0] >= -np0/2 ) &&
( idxmax_[1] < np1/2 ) && ( idxmin_[1] >= -np1/2 ) &&
( idxmax_[2] < np2/2 ) && ( idxmin_[2] >= -np2/2 );
}
////////////////////////////////////////////////////////////////////////////////
const D3vector Basis::kpoint(void) const { return kpoint_; }
////////////////////////////////////////////////////////////////////////////////
......
......@@ -80,6 +80,7 @@ class Basis
const UnitCell& refcell() const;// reference cell dimensions
const D3vector kpoint() const; // k-point in units of b0,b1,b2
int np(int i) const; // good size of FFT grid in direction i
bool fits_in_grid(int np0, int np1, int np2) const;
bool factorizable(int n) const;// check if n is factorizable with low factors
int idxmin(int i) const; // smallest index in direction i
int idxmax(int i) const; // largest index in direction i
......
......@@ -248,6 +248,10 @@ FourierTransform::FourierTransform (const Basis &basis,
rdispl[iproc] = rdispl[iproc-1] + rcounts[iproc-1];
}
// check if the basis_ fits in the grid np0, np1, np2
basis_fits_in_grid_ = basis_.fits_in_grid(np0,np1,np2);
assert(basis_fits_in_grid_);
if ( basis_.real() )
{
// compute index arrays ifftp_ and ifftm_ for mapping vector->zvec
......
......@@ -65,6 +65,7 @@ class FourierTransform
int ntrans0_,ntrans1_,ntrans2_;
int nvec_;
bool basis_fits_in_grid_;
std::vector<int> np2_loc_; // np2_loc_[iproc], iproc=0, nprocs_-1
std::vector<int> np2_first_; // np2_first_[iproc], iproc=0, nprocs_-1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment