|
mdcore
0.1.5
|
#include <stdlib.h>#include <stdio.h>#include <string.h>#include <strings.h>#include <alloca.h>#include <pthread.h>#include <math.h>#include "../config.h"#include <omp.h>#include "errs.h"#include "fptype.h"#include "lock.h"#include "part.h"#include "cell.h"#include "fifo.h"#include "space.h"Defines | |
| #define | error(id) ( space_err = errs_register( id , space_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) ) |
Functions | |
| int | space_pairs_sort (struct space *s) |
| Sort the cell pairs in a space according to their direction. | |
| int | space_verlet_force (struct space *s, FPTYPE *f, double epot) |
| Collect forces and potential energies. | |
| int | space_verlet_get (struct space *s, int maxcount, int *from) |
| Get a chunk of Verlet list entries. | |
| int | space_verlet_init (struct space *s, int list_global) |
| Initialize the Verlet-list data structures. | |
| int | space_flush_ghosts (struct space *s) |
| Clear all particles from the ghost cells in this space. | |
| int | space_flush (struct space *s) |
| Clear all particles from this space. | |
| int | space_getcell (struct space *s, struct cell **out) |
| Get the next unprocessed cell from the spaece. | |
| 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_maketuples (struct space *s) |
| Generate the list of celltuple. | |
| int | space_prepare (struct space *s) |
| Prepare the space before a time step. | |
| 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_getpos (struct space *s, int id, double *x) |
| Get the absolute position of a particle. | |
| 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. | |
| 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_init (struct space *s, const double *origin, const double *dim, double *L, double cutoff, unsigned int period) |
| Initialize the space with the given dimensions. | |
Variables | |
| int | space_err = space_err_ok |
| char * | space_err_msg [7] |
| #define error | ( | id | ) | ( space_err = errs_register( id , space_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) ) |
| 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_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 = space_err_ok |
ID of the last error
| char* space_err_msg[7] |
{
"Nothing bad happened.",
"An unexpected NULL pointer was encountered.",
"A call to malloc failed, probably due to insufficient memory.",
"An error occured when calling a cell function.",
"A call to a pthread routine failed.",
"One or more values were outside of the allowed range.",
"Too many pairs associated with a single particle in Verlet list.",
}
1.7.6.1