
/* ===purpose=== */

/**********************************************************************************************************************************/
/*****************************************************  Computational cells  ******************************************************/
/*****************************  Definitions of wide range variables, arrays, functions and parameters  ****************************/
/**********************************************************************************************************************************/

/* Developer: Sylvain Nintcheu Fata */
/* Version:   V.1.1                 */
/* Released:  Jun 14, 2012          */


#ifndef _GBEM_CELL_UTIL_H_
#define _GBEM_CELL_UTIL_H_

#include "gbem_util.h"


/* A computational box containing the boundary mesh is subdivided into parallelepipeds called cells */
/* cellinfo_t == Structure to store information about a computational cell */
 typedef struct { int nnc;           /* nnc == Number of boundary nodes in the current cell */
 		  int *nd_id;        /* nd_id[k] == Global index of the k-th boundary node in the current computational cell */
		                     /* Length of array nd_id is nnc */
		  ilst_t *ptr_list;  /* ptr_list == Linked list */
		  double bbox[3][2]; /* Bounding Box of the current cell */
		  int nnnc;          /* nnnc = Number of Near-Neighboring cells to the current cell including itself */
		  int *nbor;         /* nbor[k] == Global index of the k-th near-neighboring cell to the current cell including itself */
		                     /* Length of array nbor is nnnc */
		  int nnbsprs;       /* nnbsprs == Number of Near-Neighboring cells to the current cell used */
                                     /*            in the Sparse approximation of the Discretized BIE        */
                                     /* nnbsprs <= nnnc */
		} cellinfo_t;


/* Cell Arrays and Parameters
 * A computational box containing the boundary mesh is subdivided into parallelepipeds called cells
 *---cell[k]---= Structure containing information about the k-th cell
 *-----note----= cell is allocated and partially initialized in function "gbem_cell_init" (see gbem_cell_util.c)

 *----ncwnd----= Number of computional Cells containing boundary nodes
 *----cwnd-----= Array containing index of Computational Cells with boundary nodes
 *-----note----= Array cwelt is allocated and initialized in subroutine "gbem_cell_init" (see gbem_cell_util.c)

 *-----ncx-----= Total number of cells in the computational box in the x-coordinate direction
 *-----ncy-----= Total number of cells in the computational box in the y-coordinate direction
 *-----ncz-----= Total number of cells in the computational box in the z-coordinate direction
 *----ncell----= Total number of cells in the homogeneous computational box: ncell = ncx*ncy*ncz
 *----nbfac----= Factor characterizing the near-neighboring region of a giving cell
 */
int ncwnd,ncell;
int ncx,ncy,ncz;
double nbfac;
int *cwnd; /* cwnd == Computational Cells with boundary nodes */
cellinfo_t *cell;


void gbem_cell_init(void); /* Construct the computational box and distribute without repetition boundary nodes into cells */
void gbem_cell_neighbor(void); /* For all non-empty cell, find "Near-neighboring" cells */

#endif /* _GBEM_CELL_UTIL_H_ */
