Commit 43309d78 by Francois Gygi

define vcontext_ same as sd(0,0) basis context.


git-svn-id: http://qboxcode.org/svn/qb/trunk@290 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 0ab43f7b
......@@ -3,7 +3,7 @@
// ChargeDensity.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: ChargeDensity.C,v 1.10 2004-10-28 16:48:15 fgygi Exp $
// $Id: ChargeDensity.C,v 1.11 2004-11-10 22:30:53 fgygi Exp $
#include "ChargeDensity.h"
#include "Basis.h"
......@@ -16,42 +16,11 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////
ChargeDensity::ChargeDensity(const Wavefunction& wf) : ctxt_(wf.context()),
wf_(wf)
wf_(wf), vcontext_(wf.sd(0,0)->basis().context())
{
// determine which k points are stored on the sd context to which
// this pe belongs
int myspin = -1;
int ikplast = -1;
for ( int ispin = 0; ispin < wf.nspin(); ispin++ )
{
for ( int ikp = 0; ikp < wf.nkp(); ikp++ )
{
if ( wf.sd(ispin,ikp) != 0 )
{
myspin = ispin;
ikplast = ikp;
}
}
}
// the last kpoint on this process is ikplast
// create a vbasis
// Note: avoid creating more than one vcontext if there are
// more than one kpoint per process
if ( wf.sd(myspin,ikplast) != 0 )
{
// Note: Basis defined on columns of vcontext
vcontext_ = new Context(*wf_.spincontext(myspin),'c',
wf_.spincontext(myspin)->mycol());
vbasis_ = new Basis(*vcontext_, D3vector(0,0,0));
vbasis_->resize(wf.cell(),wf.refcell(),4.0*wf.ecut());
//cout << vcontext_->mype() << ": vcontext = " << *vcontext_ << endl;
}
else
{
vcontext_ = 0;
vbasis_ = 0;
}
vbasis_ = new Basis(vcontext_, D3vector(0,0,0));
vbasis_->resize(wf.cell(),wf.refcell(),4.0*wf.ecut());
// define vft_, FT on vbasis context for transforming the density
......@@ -87,7 +56,6 @@ wf_(wf)
////////////////////////////////////////////////////////////////////////////////
ChargeDensity::~ChargeDensity(void)
{
delete const_cast<Context*>(vcontext_);
delete vbasis_;
delete vft_;
for ( int ikp = 0; ikp < ft_.size(); ikp++ )
......@@ -165,9 +133,9 @@ void ChargeDensity::update_density(void)
<< " -->" << endl;
}
tmap["charge_ft"].start();
tmap["charge_vft"].start();
vft_->forward(&rhotmp[0],&rhog[ispin][0]);
tmap["charge_ft"].stop();
tmap["charge_vft"].stop();
}
}
}
......
......@@ -3,7 +3,7 @@
// ChargeDensity.h
//
////////////////////////////////////////////////////////////////////////////////
// $Id: ChargeDensity.h,v 1.3 2004-10-28 16:55:47 fgygi Exp $
// $Id: ChargeDensity.h,v 1.4 2004-11-10 22:31:43 fgygi Exp $
#ifndef CHARGEDENSITY_H
#define CHARGEDENSITY_H
......@@ -27,8 +27,8 @@ class ChargeDensity
private:
const Context& ctxt_;
const Context& vcontext_;
const Wavefunction& wf_;
const Context* vcontext_;
Basis* vbasis_;
FourierTransform* vft_;
vector<FourierTransform*> ft_; // ft_[ikp];
......@@ -45,7 +45,7 @@ class ChargeDensity
void update_rhor(void);
Basis* vbasis(void) const { return vbasis_; }
const Context* vcontext(void) const { return vcontext_; }
const Context& vcontext(void) const { return vcontext_; }
FourierTransform* vft(void) const { return vft_; }
FourierTransform* ft(int ikp) const { return ft_[ikp]; }
......
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