
/*******************************************************************************
*
* File block.h
*
* Copyright (C) 2005 Martin Luescher
*
* This software is distributed under the terms of the GNU General Public
* License (GPL)
*
*******************************************************************************/

#ifndef BLOCK_H
#define BLOCK_H

#ifndef SU3_H
#include "su3.h"
#endif

#ifndef START_H
#include "start.h"
#endif

#ifndef FLAGS_H
#include "flags.h"
#endif

typedef struct
{
   int ifc,ibn,vol,ns,nsd;
   int *ipp,*imb;
   su3 *u;
   su3_dble *ud;
   weyl **s;
   weyl_dble **sd;
} bndry_t;


typedef struct
{
   int *bo,*bs,vol,volh,vbb,ns,nsd,shf;
   int *ipt,*imb,(*iup)[4],(*idn)[4];
   su3 (*u)[8];
   su3_dble (*ud)[8];
   pauli *sw;
   pauli_dble *swd,*swb;
   spinor **s;
   spinor_dble **sd;
   bndry_t *bb;
   int *uidx;
} block_t;


void alloc_blk(block_t *b,int *bo,int *bs,int iu,int iud,
                      int ns,int nsd);
void alloc_bnd(block_t *b,int ns,int nsd);
void free_blk(block_t *b);
int ipt_blk(block_t *b,int *x);
int dist_bndry(block_t *b,int ix);
void alloc_uidx(block_t *b);

//block grid

void alloc_bgr(blk_grid_t grid,int *bs);
void free_bgr(blk_grid_t grid);
block_t *blk_list(blk_grid_t grid,int *nb,int *isw);

//block umap

void assign_u2ubgr(blk_grid_t grid);
void assign_ud2ubgr(blk_grid_t grid);
void assign_ud2udbgr(blk_grid_t grid);
void swap_active(blk_grid_t grid);
void assign_udb2ub(blk_grid_t grid,int n);

//blk swmap
int assign_swd2swbgr(blk_grid_t grid,ptset_t set);
int assign_swd2swdbgr(blk_grid_t grid,ptset_t set);
int assign_swdb2swb(blk_grid_t grid,int n,ptset_t set);


//blk smap
void assign_s2sb(block_t *b,ptset_t set,int k,int l);
void assign_s2sb_ptr(block_t *b,ptset_t set,spinor *psk,int l);
void assign_sb2s(block_t *b,ptset_t set,int k,int l);
void assign_sd2sdb(block_t *b,ptset_t set,int k,int l);
void assign_sdb2sd(block_t *b,ptset_t set,int k,int l);


#endif
