Commit 71ad6870 authored by Francois Gygi's avatar Francois Gygi
Browse files

remove dependency on Context

git-svn-id: http://qboxcode.org/svn/qb/trunk@1338 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 6b59e0d3
...@@ -15,13 +15,9 @@ ...@@ -15,13 +15,9 @@
// FourierTransform.C // FourierTransform.C
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// $Id: FourierTransform.C,v 1.22 2010-04-16 22:42:27 fgygi Exp $
// The following macros must be defined: USE_FFTW, USE_ESSL, USE_ESSL_2DFFT
#include "FourierTransform.h" #include "FourierTransform.h"
#include "Basis.h" #include "Basis.h"
#include "Context.h"
#include "blas.h" #include "blas.h"
#include <complex> #include <complex>
...@@ -93,15 +89,11 @@ FourierTransform::~FourierTransform() ...@@ -93,15 +89,11 @@ FourierTransform::~FourierTransform()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
FourierTransform::FourierTransform (const Basis &basis, FourierTransform::FourierTransform (const Basis &basis,
int np0, int np1, int np2) : ctxt_(basis.context()), basis_(basis), int np0, int np1, int np2) : comm_(basis.comm()), basis_(basis),
np0_(np0), np1_(np1), np2_(np2) np0_(np0), np1_(np1), np2_(np2)
{ {
assert(ctxt_.npcol() == 1); MPI_Comm_size(comm_,&nprocs_);
nprocs_ = ctxt_.size(); MPI_Comm_rank(comm_,&myproc_);
myproc_ = ctxt_.myproc();
//if ( ctxt_.onpe0() )
// cout << " FourierTransform: " << np0 << " " << np1 << " " << np2 << endl;
np2_loc_.resize(nprocs_); np2_loc_.resize(nprocs_);
np2_first_.resize(nprocs_); np2_first_.resize(nprocs_);
...@@ -624,11 +616,11 @@ void FourierTransform::bwd(complex<double>* val) ...@@ -624,11 +616,11 @@ void FourierTransform::bwd(complex<double>* val)
#if USE_MPI #if USE_MPI
int status = MPI_Alltoallv((double*)&sbuf[0],&scounts[0],&sdispl[0], int status = MPI_Alltoallv((double*)&sbuf[0],&scounts[0],&sdispl[0],
MPI_DOUBLE,(double*)&rbuf[0],&rcounts[0],&rdispl[0],MPI_DOUBLE, MPI_DOUBLE,(double*)&rbuf[0],&rcounts[0],&rdispl[0],MPI_DOUBLE,
ctxt_.comm()); comm_);
if ( status != 0 ) if ( status != 0 )
{ {
cout << " FourierTransform: status = " << status << endl; cout << " FourierTransform: status = " << status << endl;
ctxt_.abort(2); MPI_Abort(MPI_COMM_WORLD,2);
} }
#else #else
assert(sbuf.size()==rbuf.size()); assert(sbuf.size()==rbuf.size());
...@@ -1016,7 +1008,7 @@ void FourierTransform::fwd(complex<double>* val) ...@@ -1016,7 +1008,7 @@ void FourierTransform::fwd(complex<double>* val)
#if USE_MPI #if USE_MPI
int status = MPI_Alltoallv((double*)&rbuf[0],&rcounts[0],&rdispl[0], int status = MPI_Alltoallv((double*)&rbuf[0],&rcounts[0],&rdispl[0],
MPI_DOUBLE,(double*)&sbuf[0],&scounts[0],&sdispl[0],MPI_DOUBLE, MPI_DOUBLE,(double*)&sbuf[0],&scounts[0],&sdispl[0],MPI_DOUBLE,
ctxt_.comm()); comm_);
assert ( status == 0 ); assert ( status == 0 );
#else #else
assert(sbuf.size()==rbuf.size()); assert(sbuf.size()==rbuf.size());
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
// FourierTransform.h // FourierTransform.h
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// $Id: FourierTransform.h,v 1.13 2008-09-08 15:56:18 fgygi Exp $
#ifndef FOURIERTRANSFORM_H #ifndef FOURIERTRANSFORM_H
#define FOURIERTRANSFORM_H #define FOURIERTRANSFORM_H
...@@ -31,16 +30,19 @@ ...@@ -31,16 +30,19 @@
#endif #endif
#endif #endif
#if USE_MPI
#include <mpi.h>
#endif
#include "Timer.h" #include "Timer.h"
class Basis; class Basis;
class Context;
class FourierTransform class FourierTransform
{ {
private: private:
const Context& ctxt_; MPI_Comm comm_;
const Basis& basis_; const Basis& basis_;
int nprocs_, myproc_; int nprocs_, myproc_;
...@@ -90,7 +92,7 @@ class FourierTransform ...@@ -90,7 +92,7 @@ class FourierTransform
FourierTransform (const Basis &basis, int np0, int np1, int np2); FourierTransform (const Basis &basis, int np0, int np1, int np2);
~FourierTransform (); ~FourierTransform ();
const Context& context(void) const { return ctxt_; } MPI_Comm comm(void) const { return comm_; }
// backward: Fourier synthesis, compute real-space function // backward: Fourier synthesis, compute real-space function
// forward: Fourier analysis, compute Fourier coefficients // forward: Fourier analysis, compute Fourier coefficients
......
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