Basis.h 3.66 KB
Newer Older
Francois Gygi committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
//
//  Basis.h
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
6
// $Id: Basis.h,v 1.8 2007-10-19 17:10:58 fgygi Exp $
Francois Gygi committed
7 8 9 10 11 12 13 14 15 16 17 18

#ifndef BASIS_H
#define BASIS_H

#include "D3vector.h"
#include "UnitCell.h"

class Context;

class Basis
{
  private:
19

Francois Gygi committed
20
  struct BasisImpl* pimpl_;
21

Francois Gygi committed
22
  public:
23

Francois Gygi committed
24 25 26 27 28 29 30 31 32 33
  const Context& context(void) const; // context on which Basis is defined

  const UnitCell& cell() const;   // cell dimensions
  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
  int idxmin(int i) const;       // smallest index in direction i
  int idxmax(int i) const;       // largest index in direction i
  double ecut() const;           // energy cutoff in Hartree
  bool real() const;             // return true if kpoint == (0,0,0)
34

Francois Gygi committed
35 36 37 38 39
  int size() const;              // total number of g vectors
  int localsize() const;         // local number of g vectors on current process
  int localsize(int ipe) const;  // local number of g vectors on process ipe
  int maxlocalsize() const;      // largest local size
  int minlocalsize() const;      // smallest local size
40

Francois Gygi committed
41 42 43
  int nrods() const;             // total number of rods
  int nrod_loc() const;          // local number of rods on current process
  int nrod_loc(int ipe) const;   // local number of rods on process ipe
44

Francois Gygi committed
45 46 47 48 49 50 51 52 53 54
  int rod_h(int irod) const;     // h-position of rod irod on current process
  int rod_h(int ipe, int irod) const; // h-position of rod irod on process ipe

  int rod_k(int irod) const;     // k-position of rod irod on current process
  int rod_k(int ipe, int irod) const; // k-position of rod irod on process ipe

  int rod_lmin(int irod) const;  // lmin-position of rod irod on current process
  int rod_lmin(int ipe, int irod) const; // lmin-pos. of rod irod on process ipe

  // size of rod irod
55
  int rod_size(int irod) const;
Francois Gygi committed
56 57
  int rod_size(int ipe, int irod) const;

58 59
  // local position of first elem. of rod irod
  int rod_first(int irod) const;
Francois Gygi committed
60
  int rod_first(int ipe, int irod) const;
61

Francois Gygi committed
62 63 64 65
  int    idx(int i) const;   // integer indices of vectors idx[i*3+j]
  double g(int i) const;     // norm of g vectors g[i]
  double kpg(int i) const;   // norm of k+g vectors kpg[i]
  double gi(int i) const;    // inverse norm of g vectors gi[i]
Francois Gygi committed
66
  double kpgi(int i) const;  // inverse norm of k+g vectors kpgi[i]
Francois Gygi committed
67 68 69
  double g2(int i) const;    // 2-norm of g vectors g2[i]
  double kpg2(int i) const;  // 2-norm of k+g vectors kpg[i]
  double g2i(int i) const;   // inverse square norm of g g2i[i]
Francois Gygi committed
70
  double kpg2i(int i) const; // inverse square norm of k+g kpg2i[i]
Francois Gygi committed
71
  double gx(int i) const;    // g vectors gx[i+localsize*j],j=0,1,2
Francois Gygi committed
72
  double kpgx(int i) const;  // k+g vectors kpgx[i+localsize*j],j=0,1,2
73

Francois Gygi committed
74
  int isort(int i) const;    // index of vectors locally sorted by norm
75

Francois Gygi committed
76 77 78 79
  const int*    idx_ptr(void) const;
  const double* g_ptr(void) const;
  const double* kpg_ptr(void) const;
  const double* gi_ptr(void) const;
Francois Gygi committed
80
  const double* kpgi_ptr(void) const;
Francois Gygi committed
81 82 83
  const double* g2_ptr(void) const;
  const double* kpg2_ptr(void) const;
  const double* g2i_ptr(void) const;
Francois Gygi committed
84
  const double* kpg2i_ptr(void) const;
Francois Gygi committed
85
  const double* gx_ptr(int j) const;
Francois Gygi committed
86
  const double* kpgx_ptr(int j) const;
87

Francois Gygi committed
88 89 90 91 92 93
  double memsize(void) const;
  double localmemsize(void) const;

  Basis(const Context &ctxt, D3vector kpoint);
  Basis(const Basis &b);
  ~Basis(void);
94

Francois Gygi committed
95
  bool resize(const UnitCell& cell, const UnitCell& refcell, double ecut);
96
  void print(std::ostream& os);
Francois Gygi committed
97
};
98
std::ostream& operator << ( std::ostream& os, Basis& b );
Francois Gygi committed
99
#endif