mdcore
0.1.5
|
Go to the source code of this file.
Data Structures | |
struct | space |
struct | cellpair |
struct | celltuple |
struct | verlet_entry |
Defines | |
#define | space_err_ok 0 |
#define | space_err_null -1 |
#define | space_err_malloc -2 |
#define | space_err_cell -3 |
#define | space_err_pthread -4 |
#define | space_err_range -5 |
#define | space_err_maxpairs -6 |
#define | space_periodic_none 0 |
#define | space_periodic_x 1 |
#define | space_periodic_y 2 |
#define | space_periodic_z 4 |
#define | space_periodic_full 7 |
#define | space_periodic_ghost_x 8 |
#define | space_periodic_ghost_y 16 |
#define | space_periodic_ghost_z 32 |
#define | space_periodic_ghost_full 56 |
#define | space_partlist_incr 100 |
#define | space_maxtuples 4 |
#define | space_verlet_maxpairs 800 |
#define | space_cellid(s, i, j, k) ( ((i)*(s)->cdim[1] + (j)) * (s)->cdim[2] + (k) ) |
#define | space_pairind(i, j) ( space_maxtuples*(i) - (i)*((i)+1)/2 + (j) ) |
Functions | |
int | space_init (struct space *s, const double *origin, const double *dim, double *L, double cutoff, unsigned int period) |
Initialize the space with the given dimensions. | |
struct cellpair * | space_getpair (struct space *s, int owner, int count, struct cellpair *old, int *err, int wait) |
Get a set of cellpair from the space. | |
struct cellpair * | space_getpair_spin (struct space *s, int owner, int count, struct cellpair *old, int *err, int wait) |
int | space_releasepair (struct space *s, int ci, int cj) |
Free the cells involved in the current pair. | |
int | space_releasepair_spin (struct space *s, int ci, int cj) |
Free the cells involved in the current pair. | |
int | space_shuffle (struct space *s) |
Run through the cells of a space and make sure every particle is in its place. | |
int | space_shuffle_local (struct space *s) |
Run through the non-ghost cells of a space and make sure every particle is in its place. | |
int | space_addpart (struct space *s, struct part *p, double *x) |
Add a part to a space at the given coordinates. | |
int | space_pairs_sort (struct space *s) |
Sort the cell pairs in a space according to their direction. | |
int | space_prepare (struct space *s) |
Prepare the space before a time step. | |
int | space_maketuples (struct space *s) |
Generate the list of celltuple. | |
int | space_gettuple (struct space *s, struct celltuple **out, int wait) |
Get the next free celltuple from the space. | |
int | space_gettuple_spin (struct space *s, struct celltuple **out, int wait) |
Get the next free celltuple from the space. | |
int | space_getpos (struct space *s, int id, double *x) |
Get the absolute position of a particle. | |
int | space_setpos (struct space *s, int id, double *x) |
int | space_flush (struct space *s) |
Clear all particles from this space. | |
int | space_verlet_init (struct space *s, int list_global) |
Initialize the Verlet-list data structures. | |
int | space_verlet_get (struct space *s, int maxcount, int *from) |
Get a chunk of Verlet list entries. | |
int | space_verlet_force (struct space *s, FPTYPE *f, double epot) |
Collect forces and potential energies. | |
int | space_flush_ghosts (struct space *s) |
Clear all particles from the ghost cells in this space. | |
int | space_getcell (struct space *s, struct cell **out) |
Get the next unprocessed cell from the spaece. | |
Variables | |
int | space_err |
#define space_cellid | ( | s, | |
i, | |||
j, | |||
k | |||
) | ( ((i)*(s)->cdim[1] + (j)) * (s)->cdim[2] + (k) ) |
Converts the index triplet (i
, j
, k
) to the cell id in the space s
.
#define space_err_cell -3 |
#define space_err_malloc -2 |
#define space_err_maxpairs -6 |
#define space_err_null -1 |
#define space_err_ok 0 |
#define space_err_pthread -4 |
#define space_err_range -5 |
#define space_maxtuples 4 |
Maximum number of cells per tuple.
#define space_pairind | ( | i, | |
j | |||
) | ( space_maxtuples*(i) - (i)*((i)+1)/2 + (j) ) |
Convert tuple ids into the pairid index.
#define space_partlist_incr 100 |
#define space_periodic_full 7 |
#define space_periodic_ghost_full 56 |
#define space_periodic_ghost_x 8 |
#define space_periodic_ghost_y 16 |
#define space_periodic_ghost_z 32 |
#define space_periodic_none 0 |
#define space_periodic_x 1 |
#define space_periodic_y 2 |
#define space_periodic_z 4 |
#define space_verlet_maxpairs 800 |
Maximum number of interactions per particle in the Verlet list.
int space_addpart | ( | struct space * | s, |
struct part * | p, | ||
double * | x | ||
) |
Add a part to a space at the given coordinates.
s | The space to which p should be added. |
p | The part to be added. |
x | A pointer to an array of three doubles containing the particle position. |
Inserts a part p
into the space s
at the position x
. Note that since particle positions in part are relative to the cell, that data in p
is overwritten and x
is used.
int space_flush | ( | struct space * | s | ) |
Clear all particles from this space.
s | The space to flush. |
int space_flush_ghosts | ( | struct space * | s | ) |
Clear all particles from the ghost cells in this space.
s | The space to flush. |
int space_getcell | ( | struct space * | s, |
struct cell ** | out | ||
) |
Get the next unprocessed cell from the spaece.
1
if a cell was found, space_err_ok if the list is empty or < 0 on error (see space_err). struct cellpair* space_getpair | ( | struct space * | s, |
int | owner, | ||
int | count, | ||
struct cellpair * | old, | ||
int * | err, | ||
int | wait | ||
) | [read] |
Get a set of cellpair from the space.
s | The space from which to get pairs. |
owner | The id of the calling runner. |
count | The maximum number of cellpair to return. |
old | A list of cellpair that have been processed and may be released, can also be NULL . |
err | A pointer to an integer in which to store the error code. |
wait | A boolean integer specifying if to wait or not if no pairs are available. |
NULL
is returned. If an error occurs, NULL
is returned and err
is set to the respective error code.The returned cellpair are linked through the field next
. The value of next
in the last cellpair is NULL
.
The routine starts by blocking the cellpair_mutex
of the space s
and searches for available pairs in the space pair-list until either count
pairs have been found or the list has been exhausted.
For each pair found, the space s
counters in cells_taboo
are incremented.
If no pairs are available and wait
is not 0
, the routines waits for a signal on the space s
condition variable cellpairs_avail
. If wait
is 0
and no cellpair have been found, the routine returns NULL
and sets err
to 0
.
If the last cellpair has been taken, the routine broadcasts a signal on the space s
condition variable cellpairs_avail
to release any other runners
waiting for pairs.
struct cellpair* space_getpair_spin | ( | struct space * | s, |
int | owner, | ||
int | count, | ||
struct cellpair * | old, | ||
int * | err, | ||
int | wait | ||
) | [read] |
int space_getpos | ( | struct space * | s, |
int | id, | ||
double * | x | ||
) |
int space_gettuple | ( | struct space * | s, |
struct celltuple ** | out, | ||
int | wait | ||
) |
int space_gettuple_spin | ( | struct space * | s, |
struct celltuple ** | out, | ||
int | wait | ||
) |
int space_init | ( | struct space * | s, |
const double * | origin, | ||
const double * | dim, | ||
double * | L, | ||
double | cutoff, | ||
unsigned int | period | ||
) |
Initialize the space with the given dimensions.
s | The space to initialize. |
origin | Pointer to an array of three doubles specifying the origin of the rectangular domain. |
dim | Pointer to an array of three doubles specifying the length of the rectangular domain along each dimension. |
L | The minimum cell edge length, in each dimension. |
cutoff | A double-precision value containing the maximum cutoff lenght that will be used in the potentials. |
period | Unsigned integer containing the flags space_periodic_x, space_periodic_y and/or space_periodic_z or space_periodic_full. |
This routine initializes the fields of the space s
, creates the cells and generates the cell-pair list.
int space_maketuples | ( | struct space * | s | ) |
Generate the list of celltuple.
s | Pointer to the space to make tuples for. |
int space_pairs_sort | ( | struct space * | s | ) |
Sort the cell pairs in a space according to their direction.
s | The space. |
int space_prepare | ( | struct space * | s | ) |
Prepare the space before a time step.
s | A pointer to the space to prepare. |
Initializes a space for a single time step. This routine runs through the particles and sets their forces to zero.
int space_releasepair | ( | struct space * | s, |
int | ci, | ||
int | cj | ||
) |
Free the cells involved in the current pair.
s | The space to operate on. |
ci | ID of the first cell. |
cj | ID of the second cell. |
Decreases the taboo-counter of the cells involved in the pair and signals any runner that might be waiting. Note that only a single waiting runner is released per released cell and therefore, if two different cells become free, the condition cellpairs_avail
is signaled twice.
int space_releasepair_spin | ( | struct space * | s, |
int | ci, | ||
int | cj | ||
) |
Free the cells involved in the current pair.
s | The space to operate on. |
ci | ID of the first cell. |
cj | ID of the second cell. |
Decreases the taboo-counter of the cells involved in the pair and signals any runner that might be waiting. Note that only a single waiting runner is released per released cell and therefore, if two different cells become free, the condition cellpairs_avail
is signaled twice.
int space_setpos | ( | struct space * | s, |
int | id, | ||
double * | x | ||
) |
int space_shuffle | ( | struct space * | s | ) |
Run through the cells of a space and make sure every particle is in its place.
s | The space on which to operate. |
Runs through the cells of s
and if a particle has stepped outside the cell bounds, moves it to the correct cell.
int space_shuffle_local | ( | struct space * | s | ) |
Run through the non-ghost cells of a space and make sure every particle is in its place.
s | The space on which to operate. |
Runs through the cells of s
and if a particle has stepped outside the cell bounds, moves it to the correct cell.
int space_verlet_force | ( | struct space * | s, |
FPTYPE * | f, | ||
double | epot | ||
) |
Collect forces and potential energies.
s | The space. |
maxcount | The maximum number of entries. |
from | Pointer to an integer which will contain the index to the first entry on success. |
to | Pointer to an integer which will contain the index to the last entry on success. |
int space_verlet_get | ( | struct space * | s, |
int | maxcount, | ||
int * | from | ||
) |
Get a chunk of Verlet list entries.
s | The space. |
maxcount | The maximum number of entries. |
from | Pointer to an integer which will contain the index to the first entry on success. |
to | Pointer to an integer which will contain the index to the last entry on success. |
int space_verlet_init | ( | struct space * | s, |
int | list_global | ||
) |
Initialize the Verlet-list data structures.
s | The space. |
int space_err |
ID of the last error