mdcore  0.1.5
Defines | Functions | Variables
/home/pedro/work/mdcore/src/cell.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <math.h>
#include "errs.h"
#include "fptype.h"
#include "part.h"
#include "cell.h"

Defines

#define align_ceil(v)   (((v) + (cell_partalign-1) ) & ~(cell_partalign-1))
#define error(id)   ( cell_err = errs_register( id , cell_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) )

Functions

int cell_flush (struct cell *c, struct part **partlist, struct cell **celllist)
 Flush all the parts from a cell.
int cell_load (struct cell *c, struct part *parts, int nr_parts, struct part **partlist, struct cell **celllist)
 Load a block of particles to the cell.
int cell_welcome (struct cell *c, struct part **partlist)
 Move particles from the incomming buffer to the cell.
struct partcell_add_incomming (struct cell *c, struct part *p)
 Add a particle to the incomming array of a cell.
int cell_add_incomming_multiple (struct cell *c, struct part *p, int count)
 Add one or more particles to the incomming array of a cell.
struct partcell_add (struct cell *c, struct part *p, struct part **partlist)
 Add a particle to a cell.
int cell_init (struct cell *c, int *loc, double *origin, double *dim)
 Initialize the given cell.

Variables

char * cell_err_msg []
const char cell_sortlistID [27]
const FPTYPE cell_shift [13 *3]
const char cell_flip [27]
int cell_err = cell_err_ok

Define Documentation

#define align_ceil (   v)    (((v) + (cell_partalign-1) ) & ~(cell_partalign-1))
#define error (   id)    ( cell_err = errs_register( id , cell_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) )

Function Documentation

struct part* cell_add ( struct cell c,
struct part p,
struct part **  partlist 
) [read]

Add a particle to a cell.

Parameters:
cThe cell to which the particle should be added.
pThe #particle to add to the cell
Returns:
A pointer to the particle data in the cell.

This routine assumes the particle position has already been adjusted to the cell c.

struct part* cell_add_incomming ( struct cell c,
struct part p 
) [read]

Add a particle to the incomming array of a cell.

Parameters:
cThe cell to which the particle should be added.
pThe #particle to add to the cell
Returns:
A pointer to the particle data in the incomming array of the cell.

This routine assumes the particle position has already been adjusted to the cell c.

int cell_add_incomming_multiple ( struct cell c,
struct part p,
int  count 
)

Add one or more particles to the incomming array of a cell.

Parameters:
cThe cell to which the particle should be added.
pThe #particle to add to the cell
Returns:
The number of incomming parts or < 0 on error (see cell_err).

This routine assumes the particle position have already been adjusted to the cell c.

int cell_flush ( struct cell c,
struct part **  partlist,
struct cell **  celllist 
)

Flush all the parts from a cell.

Parameters:
cThe cell to flush.
partlistA pointer to the partlist to set the part indices.
celllistA pointer to the celllist to set the part indices.
Returns:
cell_err_ok or < 0 on error (see cell_err).
int cell_init ( struct cell c,
int *  loc,
double *  origin,
double *  dim 
)

Initialize the given cell.

Parameters:
cThe cell to initialize.
locArray containing the location of this cell in the space.
originThe origin of the cell in global coordinates
dimThe cell dimensions.
Returns:
cell_err_ok or < 0 on error (see cell_err).
int cell_load ( struct cell c,
struct part parts,
int  nr_parts,
struct part **  partlist,
struct cell **  celllist 
)

Load a block of particles to the cell.

Parameters:
cThe cell.
partsPointer to a block of part.
nr_partsThe number of parts to load.
partlistA pointer to the partlist to set the part indices.
celllistA pointer to the celllist to set the part indices.
Returns:
cell_err_ok or < 0 on error (see cell_err).
int cell_welcome ( struct cell c,
struct part **  partlist 
)

Move particles from the incomming buffer to the cell.

Parameters:
cThe cell.
partlistA pointer to the partlist to set the part indices.
Returns:
cell_err_ok or < 0 on error (see cell_err).

Variable Documentation

char* cell_err_msg[]
Initial value:
 {
        "Nothing bad happened.",
    "An unexpected NULL pointer was encountered.",
    "A call to malloc failed, probably due to insufficient memory.",
    "A call to a pthread routine failed."
        }
const char cell_flip[27]
Initial value:
 { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 ,
                             0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
const FPTYPE cell_shift[13 *3]
Initial value:
 {
     5.773502691896258e-01 ,  5.773502691896258e-01 ,  5.773502691896258e-01 ,
     7.071067811865475e-01 ,  7.071067811865475e-01 ,  0.0                   ,
     5.773502691896258e-01 ,  5.773502691896258e-01 , -5.773502691896258e-01 ,
     7.071067811865475e-01 ,  0.0                   ,  7.071067811865475e-01 ,
     1.0                   ,  0.0                   ,  0.0                   ,
     7.071067811865475e-01 ,  0.0                   , -7.071067811865475e-01 ,
     5.773502691896258e-01 , -5.773502691896258e-01 ,  5.773502691896258e-01 ,
     7.071067811865475e-01 , -7.071067811865475e-01 ,  0.0                   ,
     5.773502691896258e-01 , -5.773502691896258e-01 , -5.773502691896258e-01 ,
     0.0                   ,  7.071067811865475e-01 ,  7.071067811865475e-01 ,
     0.0                   ,  1.0                   ,  0.0                   ,
     0.0                   ,  7.071067811865475e-01 , -7.071067811865475e-01 ,
     0.0                   ,  0.0                   ,  1.0                   ,
    }
const char cell_sortlistID[27]
Initial value:
 {
       0 ,
       1 , 
       2 ,
       3 ,
       4 , 
       5 ,
       6 ,
       7 , 
       8 ,
       9 ,
       10 , 
       11 ,
       12 ,
       0 , 
       12 ,
       11 ,
       10 , 
       9 ,
       8 ,
       7 , 
       6 ,
       5 ,
       4 , 
       3 ,
       2 ,
       1 , 
       0 
    }
 All Data Structures Files Functions Variables Typedefs Enumerator Defines