28 P.get_local_data(&nloc, &inds, &loc_parts);
32 for (int64_t i=0; i<nloc; i++){
38 loc_parts[i].
dx = drand48();
39 loc_parts[i].
dy = drand48();
41 loc_parts[i].
coeff = .001*drand48();
42 loc_parts[i].
id = 777;
44 P.write(nloc, inds, loc_parts);
48 std::vector< Pair<force> > my_forces;
49 P.read_all(&nall, &all_parts);
50 for (
int i=0; i<nloc; i++){
51 for (
int j=0; j<nall; j++){
62 F.
write(my_forces.size(), &my_forces[0]);
70 uacc(F2[
"ij"],P[
"i"]);
73 P.read(nloc, inds, loc_parts_new);
78 for (int64_t i=0; i<nloc; i++){
79 if (fabs(loc_parts[i].dx - loc_parts_new[i].dx)>1.E-6 ||
80 fabs(loc_parts[i].dy - loc_parts_new[i].dy)>1.E-6) pass = 1;
82 MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
83 if (!pass && dw.
rank == 0){
84 printf(
"Test incorrect: application of uacc did not modify some value.\n");
92 P.read(nloc, inds, loc_parts_new);
96 for (int64_t i=0; i<nloc; i++){
97 if (fabs(loc_parts[i].dx - loc_parts_new[i].dx)>1.E-6 ||
98 fabs(loc_parts[i].dy - loc_parts_new[i].dy)>1.E-6) pass = 0;
102 delete [] loc_parts_new;
103 MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
107 printf(
"{ P[\"i\"] = uacc(F[\"ij\"]) } passed\n");
109 printf(
"{ P[\"i\"] = uacc(F[\"ij\"]) } failed\n");
123 char ** itr = std::find(begin, end, option);
124 if (itr != end && ++itr != end){
131 int main(
int argc,
char ** argv){
133 int const in_num = argc;
134 char ** input_str = argv;
136 MPI_Init(&argc, &argv);
137 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
138 MPI_Comm_size(MPI_COMM_WORLD, &np);
141 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
147 World dw(MPI_COMM_WORLD, argc, argv);
150 printf(
"Computing force_integration_sparse P_i = f(F_ij)\n");
Set class defined by a datatype and a min/max function (if it is partially ordered i...
Matrix class which encapsulates a 2D tensor.
Vector class which encapsulates a 1D tensor.
int force_integration_sparse(int n, World &dw)
an instance of the CTF library (world) on a MPI communicator
char * getCmdOption(char **begin, char **end, const std::string &option)
index-value pair used for tensor data input
void acc_force(force f, particle &p)
int rank
rank of local processor
double get_distance(particle const &p, particle const &q)
Group is a Monoid with operator '-' defined special case (parent) of a ring.
force get_force(particle const p, particle const q)
int main(int argc, char **argv)
void write(int64_t npair, int64_t const *global_idx, dtype const *data)
writes in values associated with any set of indices The sparse data is defined in coordinate format...