Commit a0bb6c79 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'powergrid' into better_params

parents 8994990f 55fde95a
......@@ -499,6 +499,8 @@ template<typename T> class Helper
{
private:
const GridderConfig<T> &gconf;
int nu, nv, nsafe, w;
T beta;
complex<T> *grid;
bool write;
int su;
......@@ -512,9 +514,7 @@ template<typename T> class Helper
void dump() const
{
if (bu0<-int(gconf.Nsafe())) return; // nothing written into buffer yet
auto nu = int(gconf.Nu());
auto nv = int(gconf.Nv());
if (bu0<-nsafe) return; // nothing written into buffer yet
#pragma omp critical
{
......@@ -535,8 +535,6 @@ template<typename T> class Helper
void load()
{
auto nu = int(gconf.Nu());
auto nv = int(gconf.Nv());
int idxu = (bu0+nu)%nu;
int idxv0 = (bv0+nv)%nv;
for (int iu=0; iu<su; ++iu)
......@@ -556,21 +554,21 @@ template<typename T> class Helper
vector<T> kernel;
Helper(const GridderConfig<T> &gconf_, const complex<T> *grid_, bool write_)
: gconf(gconf_), grid(const_cast<complex<T> *>(grid_)), write(write_),
su(2*gconf.Nsafe()+(1<<logsquare)), sv(2*gconf.Nsafe()+(1<<logsquare)),
bu0(-1000000), bv0(-1000000), data(su*sv,T(0)), kernel(2*gconf.W())
: gconf(gconf_), nu(gconf.Nu()), nv(gconf.Nv()), nsafe(gconf.Nsafe()), w(gconf.W()),
beta(gconf.Beta()),
grid(const_cast<complex<T> *>(grid_)), write(write_),
su(2*nsafe+(1<<logsquare)), sv(2*nsafe+(1<<logsquare)),
bu0(-1000000), bv0(-1000000), data(su*sv,T(0)), kernel(2*w)
{}
~Helper() { if (write) dump(); }
void prep(T u_in, T v_in)
{
T u, v;
int w = gconf.W();
gconf.getpix(u_in, v_in, u, v, iu0, iv0);
T xw=T(2)/w;
auto x0 = xw*(iu0-u);
auto y0 = xw*(iv0-v);
T beta = gconf.Beta();
for (int i=0; i<w; ++i)
{
auto x = x0+i*xw;
......@@ -584,8 +582,8 @@ template<typename T> class Helper
if ((iu0<bu0) || (iv0<bv0) || (iu0+w>bu0+su) || (iv0+w>bv0+sv))
{
if (write) { dump(); fill(data.begin(), data.end(), T(0)); }
bu0=((((iu0+gconf.Nsafe())>>logsquare)<<logsquare))-gconf.Nsafe();
bv0=((((iv0+gconf.Nsafe())>>logsquare)<<logsquare))-gconf.Nsafe();
bu0=((((iu0+nsafe)>>logsquare)<<logsquare))-nsafe;
bv0=((((iv0+nsafe)>>logsquare)<<logsquare))-nsafe;
if (!write) load();
}
p0 = data.data() + sv*(iu0-bu0) + iv0-bv0;
......
Supports Markdown
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