SUSUKITA, Ryutaro1
The M2 library is used to access and manipulate the MDGRAPE-2 boards from C programs. The library can be linked with the parameters "-L/usr/local/lib -lm2"
Units
m2_allocate_unit
m2_allocate_periodic_unit
m2_free_unit
m2_get_num_pipelines
m2_set_host_function
m2_set_positions
m2_set_rscale
m2_set_rscales
m2_set_rscale_matrix
m2_set_charge
m2_set_charges
m2_set_charge_matrix
m2_set_types
m2_set_pipeline_types
m2_set_softening
m2_set_softenings
m2_set_softening_matrix
m2_set_pipeline_softenings
m2_set_particle_offset
m2_set_cells
m2_set_neighbor_radius
m2_set_neighbor_radii
m2_set_neighbor_radius_matrix
m2_set_pipeline_neighbor_radii
m2_calculate_forces
m2_calculate_potentials
m2_start_force_calculation
m2_start_potential_calculation
m2_wait_calculation
m2_get_neighbors
Groups
m2_allocate_group
m2_allocate_member
m2_allocate_periodic_member
m2_free_group
m2_get_num_group_pipelines
m2_set_member_positions
m2_wait_member_calculation
A unit is a logical unit resources of one or more MDGRAPE-2 boards are allocated for. Units have all data necessary to use MDGRAPE-2. For units, M2 library provides the following functions. The functions and identifiers used for the functions are declared in "m2_unit.h".
m2_allocate_unit allocates a unit. Resources which are not currently allocated for other units and groups (see section 2) are allocated.
function specifies the function table which corresponds a force function or a potential function calculated by the unit. M2 library includes the function tables listed in Table 1.
mode must be M2_FORCE or M2_POTENTIAL if the function represents a force or a potential, respectively.
lower and upper specify the range which includes coordinates of positions of particles which appear in the calculation of force or potential. lower and upper must be less and greater than all the coordinates, respectively. If the specified range is wider than it must be, the accuracy of the calculation may not be optimized.
num_pipelines specifies the number of pipelines allocated for the unit.
The environment variable M2_ON specifies a list of boards. The
pipelines on only the boards are allowed to be allocated for the unit.
M2_ON must be a list of board numbers or ranges of board
numbers. The numbers or the ranges must be separated by ,. A
range of
-
is equivalent to
,...,
. If M2_ON is not set, all boards are allowed to be
allocated.
The environment variable M2_SIZE specifies the number of boards if num_pipelines is NULL_INT. The pipelines on boards of the number are allocated for the unit. If M2_SIZE is not set, pipelines on all boards are allocated.
The particle offset of the unit is set to 0.
m2_allocate_unit returns a pointer to the unit on success. It returns NULL on failure.
m2_allocate_periodic_unit is similar to m2_allocate_unit except that period specifies the period of the unit.
m2_free_unit frees the unit mu.
m2_get_num_pipelines returns the number of pipelines allocated for the unit mu.
m2_set_host_function sets the C-langauge function which corresponds to a force function or a potential function calculated by the unit mu to f. M2 library includes the C-langauge functions listed in Table 1.
m2_set_positions sets the positions of particle
, ...,
particle
of the unit mu to the 2-dimensional
array rj, where
is the particle offset of the unit. rj[j][0], rj[j][1] and rj[j][2] specify the x, y and z
coordinates of the position of particle
, respectively.
If m2_set_cells was not called and the particle offset of the
unit is 0, m2_set_positions sets the number of the cells of
the unit to 1 and the base and sets the number of the particles of
cell 0 to 0 and n, respectively.
m2_set_rscale set the rscale of the unit mu to a. a must be 0 or positive.
m2_set_rscales sets the rscale of particle
, ..., the
rscale of particle
of the unit mu to aj[0], ..., aj[n - 1], respectively, where
is the
particle offset of the unit. aj[0], ..., aj[n - 1] must be
0 or positive. If any two of the charge, the softening and the
neighbor radius of each particle of the unit were set, m2_set_rscales fails.
m2_set_rscale_matrix sets the rscale matrix of the unit mu to an
matrix whose component (i, j) is specified by acicj[i * ncj + j]. acicj[0],
..., acicj[nci * ncj - 1] must be 0 or positive. If any two of
charge matrix, softening matrix and neighbor radius matrix of the unit
were set, m2_set_rscale_matrix fails.
m2_set_charge set the charge of the unit mu to b.
m2_set_charges sets the charge of particle
, ..., the
charge of particle
of the unit mu to bj[0], ..., bj[n - 1], respectively, where
is the
particle offset of the unit. If any two of the rscale, the softening
and the neighbor radius of each particle of the unit were set, m2_set_charges fails.
m2_set_charge_matrix sets the charge matrix of the unit mu to an
matrix whose component (i, j) is specified by bcicj[i * ncj + j]. If any two of
rscale matrix, softening matrix and neighbor radius matrix of the
unit were set, m2_set_charge_matrix fails.
m2_set_types sets the types of particle
, ..., the
type of particle
of the unit mu to cj[0], ..., cj[n - 1], respectively, where
is the particle
offset of the unit.
m2_set_pipeline_types sets the types of the particles on which
forces are calculated by m2_calculate_forces or whose
potentials are calculated by m2_calculate_potential
afterwards. mu specifies the unit. ci[0], ..., ci[n -
1] specify the type of particle 0, ..., the type of particle
, respectively.
m2_set_softening sets the softening of the unit mu to e.
m2_set_softenings sets the softening of particle
, ..., the
softening of particle
of the unit mu to ej[0], ..., ej[n - 1], respectively, where
is the particle
offset of the unit. If any two of the rscale, the charge and the
neighbor radius of each particle of the unit were set, m2_set_softenings fails.
m2_set_softening_matrix sets the softening matrix of the unit mu to an
matrix whose component (i, j) is specified by ecicj[i * ncj + j]. If any two of
rscale matrix, charge matrix and neighbor radius matrix of the unit
were set, m2_set_softening_matrix fails.
m2_set_pipeline_softenings sets the softenings of the
particles on which forces are calculated by m2_calculate_forces or whose potentials are calculated by m2_calculate_potential afterwards. mu specifies the
unit. ei[0], ..., ei[n - 1] specify the softening of
particle 0, ..., the softening of particle
,
respectively.
m2_set_particle_offset sets the particle offset of the unit mu to offset.
m2_set_cells sets cell 0, ..., cell
of the unit
mu to cells[0], ..., cells[n - 1], respectively. The
M2_CELL structure contains the following members
m2_set_neighbor_radius sets the neighbor radius of the unit mu to h. h must be 0 or positive.
m2_set_neighbor_radii sets the neighbor radius of particle
, ..., the neighbor radius of particle
of the
unit mu to hj[0], ..., hj[n - 1], respectively,
where
is the particle offset of the unit. hj[0], ..., hj[n - 1] must be 0 or positive. If any two of the rscale, the charge
and the softening of each particle of the unit were set, m2_set_neighbor_radii fails.
m2_set_neighbor_radius_matrix sets the neighbor radius
matrix of the unit mu to an
matrix
whose component (i, j) is specified by hcicj[i * ncj
+ j]. hcicj[0], ..., hcicj[nci * ncj - 1] must be 0 or
positive. If any two of rscale matrix, charge matrix and softening
matrix of the unit were set, m2_set_neighbor_radius_matrix
fails.
m2_set_pipeline_neighbor_radii sets the neighbor radii of the
particles on which forces are calculated by m2_calculate_forces or whose potentials are calculated by m2_calculate_potential afterwards. mu specifies the
unit. hi[0], ..., hi[n - 1] specify the neighbor radius of
particle 0, ..., the neighbor radius of particle
,
respectively. hi[0], ..., hi[n - 1] must be 0 or positive.
m2_calculate_forces calculates the force exerted on each given particle and searches for neighbors of the particle.
mu specifies the unit which calculates and searches.
The 2-dimensional array ri specifies the positions of particle
0, ..., particle
. ri[i][0], ri[i][1] and ri[i][2] specify the x, y and z coordinates of the position of
particle i, respectively.
The force exerted on the given particle
is calculated as
| the number of the cells | |
| the base of cell |
|
| the number of the particles of cell |
|
| the force function |
As neighbors of the given particle
, particles of the unit which
satisfy
are searched for, where the
coefficient
is determined in a similar way to
except that
is determined from neighbor radius.
The 2-dimensional array fi returns
, ...,
. fi[i][0], fi[i][1] and fi[i][2] returns the x, y and z coordinate of
,
respectively.
m2_calculate_potentials is similar to m2_calculate_forces except that the potential of each given
particle is calculated. The potential of the given particle
is
calculated as
m2_start_force_calculation is similar to m2_calculate_forces except that the array fi return the forces after m2_wait_calculation is called for the unit mu and the array fi may not return the forces if any element of the array ri is changed before m2_wait_calculation is called for the unit mu.
m2_start_potential_calculation is similar to m2_calculate_potentials except that the array pi returns the potentials after m2_wait_calculation is called for the unit mu and the array pi may not return the potentials if any element of the array ri is changed before m2_wait_calculation is called for the unit mu.
See m2_start_force_calculation and m2_start_potential_calculation.
m2_get_neighbors is called to get the neighbors which were found by m2_calculate_forces or m2_calculate_potentials.
mu specifies the unit which found the neighbors.
m2_get_neighbors allocates memory to contain the particle
number of the neighbors. nli[0], ..., nli[n - 1] returns
offsets in the memory to be referred to as follows: l[0], ...,
l[nli[0] - 1] return the particle numbers of the neighbors of
particle 0, respectively, where l is a pointer to the memory and
the type is long *. ... l[nli[n - 2]], ..., l[nli[n -
1] - 1] return the particle numbers of the neighbors of particle
, respectively.
m2_get_neighbors returns a pointer to the memory. The memory is freed by free.
A group is a group of units resources of one or more MDGRAPE-2 boards are allocated for. For groups, M2 library provides the following functions. The functions and identifiers for the functions are declared in "m2_group.h".
m2_allocate_group allocates a group which has no units. Resources which are not currently allocated for other unit groups and units are allocated. The number of allocated pipelines is determined in a similar way to m2_allocate_unit. m2_allocate_group returns a pointer to the group on success. It returns NULL on failure.
m2_allocate_member is similar to m2_allocate_unit except that the allocated unit becomes a member of the unit group mg and quantities of the unit private does not specify may be shared. If a quantity is shared, a library function called to set the quantity of the unit also sets the same quantities of other member units of the group. If a quantity is not shared, it is private. private must be 0, NULL_UNSIGNED or the bitwise inclusive OR of one or more of the following flags:
| flag | quantity of unit |
| M2_POSITIONS | positions of particles |
| M2_RSCALE | rscale |
| M2_RSCALES | rscales of particles |
| M2_RSCALE_MATRIX | rscale matrix |
| M2_CHARGE | charge |
| M2_CHARGES | charges of particles |
| M2_CHARGE_MATRIX | charge matrix |
| M2_NEIGHBOR_RADIUS | neighbor radius |
| M2_NEIGHBOR_RADII | neighbor radii of particles |
| M2_NEIGHBOR_RADIUS_MATRIX | neighbor radius matrix |
| M2_SOFTENING | softening |
| M2_SOFTENINGS | softenings of particles |
| M2_SOFTENING_MATRIX | softening matrix |
| M2_TYPES | types of particles |
| M2_CELLS | cells |
| M2_PARTICLE_OFFSET | particle offset |
m2_allocate_periodic_member is similar to m2_allocate_member except that period specifies the period of the unit.
m2_free_group frees all member units of the group mg and the group.
m2_get_num_group_pipelines returns the number of pipelines allocated for the group mg.
m2_set_member_positions is equivalent to calling m2_set_positions for each member unit of the group mg.
m2_wait_member_calculation is equivalent to calling m2_wait_calculation for each member unit of the group mg.
This document was generated using the LaTeX2HTML translator Version 99.2beta6 (1.42)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 0 document
The translation was initiated by on 2001-05-10