mdcore  0.1.5
/home/pedro/work/mdcore/src/cell.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of mdcore.
00003  * Coypright (c) 2010 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
00004  * 
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU Lesser General Public License as published
00007  * by the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU Lesser General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  * 
00018  ******************************************************************************/
00019 
00020 
00021 /* cell error codes */
00022 #define cell_err_ok                     0
00023 #define cell_err_null                   -1
00024 #define cell_err_malloc                 -2
00025 #define cell_err_pthread                -3
00026 
00027 
00028 /* some constants */
00029 #define cell_default_size               64
00030 #define cell_incr                       10
00031 
00033 #ifdef CELL
00034     #define cell_partalign                  128
00035 #else
00036     #define cell_partalign                  64
00037 #endif
00038 
00040 #define cell_flag_none                  0
00041 #define cell_flag_ghost                 1
00042 #define cell_flag_wait                  2
00043 #define cell_flag_waited                4
00044 #define cell_flag_marked                8
00045 
00046 
00047 /* Map shift vector to sortlist. */
00048 extern const char cell_sortlistID[27];
00049 extern const FPTYPE cell_shift[13*3];
00050 extern const char cell_flip[27]; 
00051 
00052 
00053 /* the last error */
00054 extern int cell_err;
00055 
00056 
00057 /* the cell structure */
00058 struct cell {
00059 
00060     /* some flags */
00061     unsigned int flags;
00062     
00063     /* The ID of this cell. */
00064     int id;
00065 
00066     /* relative cell location */
00067     int loc[3];
00068     
00069     /* absolute cell origin */
00070     double origin[3];
00071     
00072     /* cell dimensions */
00073     double dim[3];
00074     
00075     /* size and count of particle buffer */
00076     int size, count;
00077     
00078     /* the particle buffer */
00079     struct part *parts;
00080     
00081     /* buffer to store the potential energy */
00082     double epot;
00083     
00084     /* a buffer to store incomming parts. */
00085     struct part *incomming;
00086     int incomming_size, incomming_count;
00087     
00088     /* Mutex for synchronized cell access. */
00089     pthread_mutex_t cell_mutex;
00090         pthread_cond_t cell_cond;
00091     
00092     /* Old particle positions for the verlet lists. */
00093     FPTYPE *oldx;
00094     int oldx_size;
00095     
00096     /* ID of the node this cell belongs to. */
00097     int nodeID;
00098     
00099     /* Pointer to sorted cell data for pseudo-Verlet lists. */
00100     unsigned int *sortlist;
00101     char sorted[13];
00102     
00103     };
00104     
00105 
00106 /* associated functions */
00107 int cell_init ( struct cell *c , int *loc , double *origin , double *dim );
00108 struct part *cell_add ( struct cell *c , struct part *p , struct part **partlist );
00109 struct part *cell_add_incomming ( struct cell *c , struct part *p );
00110 int cell_add_incomming_multiple ( struct cell *c , struct part *p , int count );
00111 int cell_welcome ( struct cell *c , struct part **partlist );
00112 int cell_load ( struct cell *c , struct part *parts , int nr_parts , struct part **partlist , struct cell **celllist );
00113 int cell_flush ( struct cell *c , struct part **partlist , struct cell **celllist );
 All Data Structures Files Functions Variables Typedefs Enumerator Defines