MACSio  0.9
Multi-purpose, Application-Centric, Scalable I/O Proxy App
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
macsio_data.c
Go to the documentation of this file.
1 /*
2 Copyright (c) 2015, Lawrence Livermore National Security, LLC.
3 Produced at the Lawrence Livermore National Laboratory.
4 Written by Mark C. Miller
5 
6 LLNL-CODE-676051. All rights reserved.
7 
8 This file is part of MACSio
9 
10 Please also read the LICENSE file at the top of the source code directory or
11 folder hierarchy.
12 
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License (as published by the Free Software
15 Foundation) version 2, dated June 1991.
16 
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the terms and conditions of the GNU General
20 Public License for more details.
21 
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
24 Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26 
27 #include <json-c/json.h>
28 
29 #include <macsio_data.h>
30 #include <macsio_utils.h>
31 
32 #include <math.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 
37 
42 static double fade(double t) { return t * t * t * (t * (t * 6 - 15) + 10); }
43 static double lerp(double t, double a, double b) { return a + t * (b - a); }
44 static double grad(int hash, double x, double y, double z) {
45  int h = hash & 15;
46  double u = h<8 ? x : y;
47  double v = h<4 ? y : h==12||h==14 ? x : z;
48  return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v);
49 }
59 static double noise(
60  double _x,
61  double _y,
62  double _z,
63  double const *bounds
64 )
65 {
66  static int p[512], permutation[256] = {151,160,137,91,90,15,
67  131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
68  190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
69  88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
70  77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
71  102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
72  135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
73  5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
74  223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
75  129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
76  251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
77  49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
78  138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180};
79  static int p_initialized = 0;
80 
81  int X, Y, Z, A, AA, AB, B, BA, BB;
82  double u, v, w;
83  double x = 0, y = 0, z = 0;
84 
85  if (!p_initialized)
86  {
87  int i;
88  for (i=0; i < 256 ; i++)
89  p[256+i] = p[i] = permutation[i];
90  p_initialized = 1;
91  }
92 
93  /* Map point in bounds to point in unit cube */
94  x = _x / (bounds[3] - bounds[0]);
95  if (bounds[4] != bounds[1])
96  y = _y / (bounds[4] - bounds[1]);
97  if (bounds[5] != bounds[2])
98  z = _z / (bounds[5] - bounds[2]);
99 
100  /* Unit cube that contains the point */
101  X = (int)floor(x) & 255;
102  Y = (int)floor(y) & 255;
103  Z = (int)floor(z) & 255;
104 
105  /* Find relative X, Y, Z of point in cube */
106  x -= floor(x);
107  y -= floor(y);
108  z -= floor(z);
109 
110  /* Compute fade curves */
111  u = fade(x);
112  v = fade(y);
113  w = fade(z);
114 
115  /* Hash coords of 8 cube corners */
116  A = p[X ]+Y; AA = p[A]+Z; AB = p[A+1]+Z;
117  B = p[X+1]+Y; BA = p[B]+Z; BB = p[B+1]+Z;
118 
119  return lerp(w, lerp(v, lerp(u, grad(p[AA ], x , y , z ),
120  grad(p[BA ], x-1, y , z )),
121  lerp(u, grad(p[AB ], x , y-1, z ),
122  grad(p[BB ], x-1, y-1, z ))),
123  lerp(v, lerp(u, grad(p[AA+1], x , y , z-1 ),
124  grad(p[BA+1], x-1, y , z-1 )),
125  lerp(u, grad(p[AB+1], x , y-1, z-1 ),
126  grad(p[BB+1], x-1, y-1, z-1 ))));
127 }
128 
129 static json_object *
131 {
132  return json_object_new_int(random() % 100000);
133 }
134 
135 static json_object *
137 {
138  return json_object_new_double(
139  (double) (random() % 100000) / (random() % 100000 + 1));
140 }
141 
142 static json_object *
144 {
145  int rval = random() % 100;
146  if (rval < 33) /* favor doubles over ints 2:1 */
147  return make_random_int();
148  else
149  return make_random_double();
150 }
151 
152 static json_object *
153 make_random_string(int nthings)
154 {
155  int i;
156  char *rval = (char *) malloc(nthings);
157  json_object *retval;
158 
159  for (i = 0; i < nthings-1; i++)
160  rval[i] = 'A' + (random() % 61);
161  rval[nthings-1] = '\0';
162  retval = json_object_new_string(rval);
163  free(rval);
164 
165  return retval;
166 }
167 
168 static json_object *
169 make_random_array(int nthings)
170 {
171  int i, rval = random() % 100;
173  for (i = 0; i < nthings; i++)
174  {
175  if (rval < 33) /* favor double arrays over int arrays 2:1 */
177  else
179  }
180  return retval;
181 }
182 
183 static json_object *
184 make_random_extarr(int nthings)
185 {
186 
187  int dims[2], ndims = random() % 2 + 1;
188  int rval = random() % 100;
189  json_extarr_type dtype;
190  void *data;
191 
192  dims[0] = nthings;
193  if (ndims == 2)
194  MACSIO_UTILS_Best2DFactors(nthings, &dims[0], &dims[1]);
195 
196  if (rval < 33) /* favor double arrays over int arrays 2:1 */
197  {
198  int i, *vals = (int *) malloc(nthings * sizeof(int));
199  for (i = 0; i < nthings; i++)
200  vals[i] = i % 11 ? i : random() % nthings;
201  dtype = json_extarr_type_int32;
202  data = vals;
203  }
204  else
205  {
206  int i;
207  double *vals = (double *) malloc(nthings * sizeof(double));
208  for (i = 0; i < nthings; i++)
209  vals[i] = (double) (random() % 100000) / (random() % 100000 + 1);
210  dtype = json_extarr_type_flt64;
211  data = vals;
212  }
213 
214  return json_object_new_extarr(data, dtype, ndims, dims);
215 }
216 
217 static json_object *
218 make_random_object_recurse(int nthings, int depth)
219 {
220  int rval = random() % 100;
221  int prim_cutoff, string_cutoff, array_cutoff, extarr_cutoff;
222 
223  /* adjust cutoffs to affect odds of different kinds of objects depending on total size */
224  if (depth == 0 && nthings > 1)
225  {
226  prim_cutoff = 0; string_cutoff = 0; array_cutoff = 0; extarr_cutoff = 0;
227  }
228  else if (nthings > 10000)
229  {
230  prim_cutoff = 0; string_cutoff = 5; array_cutoff = 10; extarr_cutoff = 30;
231  }
232  else if (nthings > 1000)
233  {
234  prim_cutoff = 0; string_cutoff = 10; array_cutoff = 20; extarr_cutoff = 60;
235  }
236  else if (nthings > 100)
237  {
238  prim_cutoff = 0; string_cutoff = 25; array_cutoff = 55; extarr_cutoff = 85;
239  }
240  else if (nthings > 10)
241  {
242  prim_cutoff = 0; string_cutoff = 40; array_cutoff = 80; extarr_cutoff = 92;
243  }
244  else if (nthings > 1)
245  {
246  prim_cutoff = 0; string_cutoff = 40; array_cutoff = 85; extarr_cutoff = 96;
247  }
248  else
249  {
250  prim_cutoff = 100;
251  }
252 
253  if (rval < prim_cutoff)
254  return make_random_primitive();
255  else if (rval < string_cutoff)
256  return make_random_string(nthings);
257  else if (rval < array_cutoff)
258  return make_random_array(nthings);
259  else if (rval < extarr_cutoff)
260  return make_random_extarr(nthings);
261  else
262  {
263  int i;
264  int nmembers = random() % (nthings > 100000 ? 500:
265  (nthings > 10000 ? 100:
266  (nthings > 1000 ? 25:
267  (nthings > 100 ? 10:
268  (nthings > 10 ? 3:
269  nthings)))));
271 
272  nthings -= nmembers;
273  depth++;
274  for (i = 0; i < nmembers; i++)
275  {
276  char name[32];
277  int nthings_member = random() % nthings;
278  snprintf(name, sizeof(name), "member%04d", i++);
279  json_object_object_add(obj, name, make_random_object_recurse(nthings_member, depth));
280  nthings -= nthings_member;
281  if (nthings <= 0) break;
282  }
283  return obj;
284  }
285 }
286 
287 json_object *
289 {
290  return make_random_object_recurse(nthings, 0);
291 }
292 
293 #warning NEED TO REPLACE STRINGS WITH KEYS FOR MESH PARAMETERS
294 static json_object *
295 make_uniform_mesh_coords(int ndims, int const *dims, double const *bounds)
296 {
298 
299  json_object_object_add(coords, "CoordBasis", json_object_new_string("X,Y,Z"));
303  json_object_object_add(coords, "DeltaX", json_object_new_double(MACSIO_UTILS_XDelta(dims, bounds)));
304  json_object_object_add(coords, "DeltaY", json_object_new_double(MACSIO_UTILS_YDelta(dims, bounds)));
305  json_object_object_add(coords, "DeltaZ", json_object_new_double(MACSIO_UTILS_ZDelta(dims, bounds)));
309 
310  return coords;
311 }
312 
313 #warning PACKAGE EXTARR METHOD WITH CHECKSUM STUFF
314 
315 static json_object *
316 make_rect_mesh_coords(int ndims, int const *dims, double const *bounds)
317 {
319  double *vals, delta;
320  int i;
321 
322 #warning SUPPORT DIFFERENT DATATYPES HERE
323 
324  json_object_object_add(coords, "CoordBasis", json_object_new_string("X,Y,Z"));
325 
326  /* build X coordinate array */
327  delta = MACSIO_UTILS_XDelta(dims, bounds);
328  vals = (double *) malloc(MACSIO_UTILS_XDim(dims) * sizeof(double));
329  for (i = 0; i < MACSIO_UTILS_XDim(dims); i++)
330  vals[i] = MACSIO_UTILS_XMin(bounds) + i * delta;
331  json_object_object_add(coords, "XAxisCoords", json_object_new_extarr(vals, json_extarr_type_flt64, 1, &dims[0]));
332 
333  if (ndims > 1)
334  {
335  /* build Y coordinate array */
336  delta = MACSIO_UTILS_YDelta(dims, bounds);
337  vals = (double *) malloc(MACSIO_UTILS_YDim(dims) * sizeof(double));
338  for (i = 0; i < MACSIO_UTILS_YDim(dims); i++)
339  vals[i] = MACSIO_UTILS_YMin(bounds) + i * delta;
340  json_object_object_add(coords, "YAxisCoords", json_object_new_extarr(vals, json_extarr_type_flt64, 1, &dims[1]));
341  }
342 
343  if (ndims > 2)
344  {
345  /* build Z coordinate array */
346  delta = MACSIO_UTILS_ZDelta(dims, bounds);
347  vals = (double *) malloc(MACSIO_UTILS_ZDim(dims) * sizeof(double));
348  for (i = 0; i < MACSIO_UTILS_ZDim(dims); i++)
349  vals[i] = MACSIO_UTILS_ZMin(bounds) + i * delta;
350  json_object_object_add(coords, "ZAxisCoords", json_object_new_extarr(vals, json_extarr_type_flt64, 1, &dims[2]));
351  }
352 
353  return coords;
354 }
355 
356 static json_object *
357 make_curv_mesh_coords(int ndims, int const *dims, double const *bounds)
358 {
360  double *x = 0, *y = 0, *z = 0;
361  double dx = MACSIO_UTILS_XDelta(dims, bounds);
362  double dy = MACSIO_UTILS_YDelta(dims, bounds);
363  double dz = MACSIO_UTILS_ZDelta(dims, bounds);
364  int nx = MACSIO_UTILS_XDim(dims), ny = MU_MAX(MACSIO_UTILS_YDim(dims),1), nz = MU_MAX(MACSIO_UTILS_ZDim(dims),1);
365  int i, j, k;
366 
367  json_object_object_add(coords, "CoordBasis", json_object_new_string("X,Y,Z")); /* "R,Theta,Phi" */
368 
369  x = (double *) malloc(nx * ny * nz * sizeof(double));
370  if (ndims > 1)
371  y = (double *) malloc(nx * ny * nz * sizeof(double));
372  if (ndims > 2)
373  z = (double *) malloc(nx * ny * nz * sizeof(double));
374  for (i = 0; i < nx; i++)
375  {
376  for (j = 0; j < ny; j++)
377  {
378  for (k = 0; k < nz; k++)
379  {
380  int idx = k * ny * nx + j * nx + i;
381  x[idx] = MACSIO_UTILS_XMin(bounds) + i * dx;
382  if (y) y[idx] = MACSIO_UTILS_YMin(bounds) + j * dy;
383  if (z) z[idx] = MACSIO_UTILS_ZMin(bounds) + k * dz;
384  }
385  }
386  }
387  json_object_object_add(coords, "XCoords", json_object_new_extarr(x, json_extarr_type_flt64, ndims, dims));
388  if (ndims > 1)
389  json_object_object_add(coords, "YCoords", json_object_new_extarr(y, json_extarr_type_flt64, ndims, dims));
390  if (ndims > 2)
391  json_object_object_add(coords, "ZCoords", json_object_new_extarr(z, json_extarr_type_flt64, ndims, dims));
392 
393  return coords;
394 }
395 
396 static json_object *
397 make_ucdzoo_mesh_coords(int ndims, int const *dims, double const *bounds)
398 {
399  /* same case as curvilinear mesh */
400  return make_curv_mesh_coords(ndims, dims, bounds);
401 }
402 
403 static json_object *
404 make_arb_mesh_coords(int ndims, int const *dims, double const *bounds)
405 {
406  /* same case as curvilinear mesh */
407  return make_curv_mesh_coords(ndims, dims, bounds);
408 }
409 
410 static json_object *
411 make_structured_mesh_topology(int ndims, int const *dims)
412 {
413  json_object *topology = json_object_new_object();
414  int nx = MACSIO_UTILS_XDim(dims);
415  int ny = MACSIO_UTILS_YDim(dims);
416  int nz = MACSIO_UTILS_ZDim(dims);
417 
418  json_object_object_add(topology, "Type", json_object_new_string("Templated"));
419  json_object_object_add(topology, "DomainDim", json_object_new_int(ndims));
420  json_object_object_add(topology, "RangeDim", json_object_new_int(0)); /* node refs */
421 
422  /* would be better for elem types to be enum or int */
423  /* We can use a bonified json array here because the template is small. But,
424  should we? */
425 
426  if (ndims == 1)
427  {
428  json_object *topo_template = json_object_new_array();
429 
430  /* For domain entity (zone i), here are the nodal offsets in
431  linear address space, left node followed by right node */
434 
435  json_object_object_add(topology, "ElemType", json_object_new_string("Beam2"));
436  json_object_object_add(topology, "Template", topo_template);
437  }
438  else if (ndims == 2)
439  {
440  json_object *topo_template = json_object_new_array();
441 
442  /* For domain entity (zone i,j), here are the nodal offsets in
443  linear address space, right-hand-rule starting from lower-left corner */
444  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx2(0,0,nx)));
445  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx2(1,0,nx)));
446  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx2(1,1,nx)));
447  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx2(0,1,nx)));
448 
449  json_object_object_add(topology, "ElemType", json_object_new_string("Quad4"));
450  json_object_object_add(topology, "Template", topo_template);
451  }
452  else if (ndims == 3)
453  {
454  json_object *topo_template = json_object_new_array();
455 
456  /* For domain entity (zone i,j,k), here are the nodal offsets
457  in linear address space, starting from lower-left-back corner,
458  back-face first with inward normal using rhr then front face with
459  outward normal using rhr. */
460  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx3(0,0,0,nx,ny)));
461  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx3(1,0,0,nx,ny)));
462  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx3(1,1,0,nx,ny)));
463  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx3(0,1,0,nx,ny)));
464  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx3(0,0,1,nx,ny)));
465  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx3(1,0,1,nx,ny)));
466  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx3(1,1,1,nx,ny)));
467  json_object_array_add(topo_template, json_object_new_int(MU_SeqIdx3(0,1,1,nx,ny)));
468 
469  json_object_object_add(topology, "ElemType", json_object_new_string("Hex8"));
470  json_object_object_add(topology, "Template", topo_template);
471  }
472 
473  return topology;
474 }
475 
476 static json_object *
477 make_uniform_mesh_topology(int ndims, int const *dims)
478 {
479  return make_structured_mesh_topology(ndims, dims);
480 }
481 
482 static json_object *
483 make_rect_mesh_topology(int ndims, int const *dims)
484 {
485  return make_structured_mesh_topology(ndims, dims);
486 }
487 
488 static json_object *
489 make_curv_mesh_topology(int ndims, int const *dims)
490 {
491  return make_structured_mesh_topology(ndims, dims);
492 }
493 
494 static json_object *
495 make_ucdzoo_mesh_topology(int ndims, int const *dims)
496 {
497  json_object *topology = json_object_new_object();
498  int i,j,k,n=0;
499  int nx = MACSIO_UTILS_XDim(dims), ny = MU_MAX(MACSIO_UTILS_YDim(dims),1), nz = MU_MAX(MACSIO_UTILS_ZDim(dims),1);
500  int ncells = nx * ny * nz;
501  int cellsize = 2 * ndims;
502  int *nodelist = (int *) malloc(ncells * cellsize * sizeof(int));
503  int nl_dims[2] = {ncells, cellsize};
504 
505  json_object_object_add(topology, "Type", json_object_new_string("Explicit"));
506  json_object_object_add(topology, "DomainDim", json_object_new_int(ndims));
507  json_object_object_add(topology, "RangeDim", json_object_new_int(0)); /* node refs */
508 
509  if (ndims == 1)
510  {
511  for (i = 0; i < nx; i++)
512  {
513  nodelist[n++] = MU_SeqIdx1(i+0);
514  nodelist[n++] = MU_SeqIdx1(i+1);
515  }
516  json_object_object_add(topology, "ElemType", json_object_new_string("Beam2"));
517  }
518  else if (ndims == 2)
519  {
520  for (i = 0; i < nx; i++)
521  {
522  for (j = 0; j < ny; j++)
523  {
524  nodelist[n++] = MU_SeqIdx2(i+0,j+0,nx);
525  nodelist[n++] = MU_SeqIdx2(i+1,j+0,nx);
526  nodelist[n++] = MU_SeqIdx2(i+1,j+1,nx);
527  nodelist[n++] = MU_SeqIdx2(i+0,j+1,nx);
528  }
529  }
530  json_object_object_add(topology, "ElemType", json_object_new_string("Quad4"));
531  }
532  else if (ndims == 3)
533  {
534  for (i = 0; i < nx; i++)
535  {
536  for (j = 0; j < ny; j++)
537  {
538  for (k = 0; k < nz; k++)
539  {
540  nodelist[n++] = MU_SeqIdx3(i+0,j+0,k+0,nx,ny);
541  nodelist[n++] = MU_SeqIdx3(i+1,j+0,k+0,nx,ny);
542  nodelist[n++] = MU_SeqIdx3(i+1,j+1,k+0,nx,ny);
543  nodelist[n++] = MU_SeqIdx3(i+0,j+1,k+0,nx,ny);
544  nodelist[n++] = MU_SeqIdx3(i+0,j+0,k+1,nx,ny);
545  nodelist[n++] = MU_SeqIdx3(i+1,j+0,k+1,nx,ny);
546  nodelist[n++] = MU_SeqIdx3(i+1,j+1,k+1,nx,ny);
547  nodelist[n++] = MU_SeqIdx3(i+0,j+1,k+1,nx,ny);
548  }
549  }
550  }
551  json_object_object_add(topology, "ElemType", json_object_new_string("Hex8"));
552  }
553  json_object_object_add(topology, "ElemSize", json_object_new_int(cellsize));
554  json_object_object_add(topology, "Nodelist", json_object_new_extarr(nodelist, json_extarr_type_int32, 2, nl_dims));
555 
556  return topology;
557 }
558 
559 #warning WE SHOULD ENABLE ABILITY TO CHANGE TOPOLOGY WITH TIME
560 
561 #warning REPLACE STRINGS FOR CENTERING AND DTYPE WITH ENUMS
562 static json_object *
563 make_scalar_var(int ndims, int const *dims, double const *bounds,
564  char const *centering, char const *dtype, char const *kind)
565 {
566  json_object *var_obj = json_object_new_object();
567  int i,j,k,n;
568  int dims2[3] = {1,1,1};
569  double dims_diameter2 = 1;
570  int minus_one = strcmp(centering, "zone")?0:-1;
571  json_object *data_obj;
572  double *valdp;
573  int *valip;
574 
575  for (i = 0; i < ndims; i++)
576  {
577  dims2[i] = dims[i] + minus_one;
578  dims_diameter2 += dims[i]*dims[i];
579  }
580 
581 #warning NEED EXPLICIT NAME FOR VARIABLE
582  json_object_object_add(var_obj, "name", json_object_new_string(kind));
583  json_object_object_add(var_obj, "centering", json_object_new_string(centering));
584  if (!strcmp(dtype, "double"))
585  data_obj = json_object_new_extarr_alloc(json_extarr_type_flt64, ndims, dims2);
586  else if (!strcmp(dtype, "int"))
587  data_obj = json_object_new_extarr_alloc(json_extarr_type_int32, ndims, dims2);
588  json_object_object_add(var_obj, "data", data_obj);
589  valdp = (double *) json_object_extarr_data(data_obj);
590  valip = (int *) json_object_extarr_data(data_obj);
591 
592  n = 0;
593 #warning PASS RANK OR RANDOM SEED IN HERE TO ENSURE DIFF PROCESSORS HAVE DIFF RANDOM DATA
594  srandom(0xBabeFace);
595  for (k = 0; k < dims2[2]; k++)
596  {
597  for (j = 0; j < dims2[1]; j++)
598  {
599  for (i = 0; i < dims2[0]; i++)
600  {
601 #warning PUT THESE INTO A GENERATOR FUNCTION
602 #warning ACCOUNT FOR HALF ZONE OFFSETS
603  if (!strcmp(kind, "constant"))
604  valdp[n++] = 1.0;
605  else if (!strcmp(kind, "random"))
606  valdp[n++] = (double) (random() % 1000) / 1000;
607  else if (!strcmp(kind, "xramp"))
608  valdp[n++] = bounds[0] + i * MACSIO_UTILS_XDelta(dims, bounds);
609  else if (!strcmp(kind, "spherical"))
610  {
611  double x = bounds[0] + i * MACSIO_UTILS_XDelta(dims, bounds);
612  double y = bounds[1] + j * MACSIO_UTILS_YDelta(dims, bounds);
613  double z = bounds[2] + k * MACSIO_UTILS_ZDelta(dims, bounds);
614  valdp[n++] = sqrt(x*x+y*y+z*z);
615  }
616  else if (!strcmp(kind, "noise"))
617  {
618  double x = bounds[0] + i * MACSIO_UTILS_XDelta(dims, bounds);
619  double y = bounds[1] + j * MACSIO_UTILS_YDelta(dims, bounds);
620  double z = bounds[2] + k * MACSIO_UTILS_ZDelta(dims, bounds);
621  valdp[n++] = noise(x,y,z,bounds);
622  }
623  else if (!strcmp(kind, "noise_sum"))
624  {
625 #warning SHOULD USE GLOBAL DIMS DIAMETER HERE
626  int q, nlevels = (int) log2(sqrt(dims_diameter2))+1;
627  double x = bounds[0] + i * MACSIO_UTILS_XDelta(dims, bounds);
628  double y = bounds[1] + j * MACSIO_UTILS_YDelta(dims, bounds);
629  double z = bounds[2] + k * MACSIO_UTILS_ZDelta(dims, bounds);
630  double mult = 1;
631  valdp[n++] = 0;
632  for (q = 0; q < nlevels; q++)
633  {
634  valdp[n-1] += 1/mult * fabs(noise(mult*x,mult*y,mult*z,bounds));
635  mult *= 2;
636  }
637  }
638  else if (!strcmp(kind, "ysin"))
639  {
640  double y = bounds[1] + j * MACSIO_UTILS_YDelta(dims, bounds);
641  valdp[n++] = sin(y*3.1415266);
642  }
643  else if (!strcmp(kind, "xlayers"))
644  {
645  valip[n++] = (i / 20) % 3;
646  }
647  }
648  }
649  }
650 #warning ADD CHECKSUM TO JSON OBJECT
651 
652  return var_obj;
653 
654 }
655 
656 static json_object *
657 make_vector_var(int ndims, int const *dims, double const *bounds)
658 {
659  return 0;
660 }
661 
662 static json_object *
663 make_tensor_var(int ndims, int const *dims, double const *bounds)
664 {
665  return 0;
666 }
667 
668 static json_object *
669 make_subset_var(int ndims, int const *dims, double const *bounds)
670 {
671  return 0;
672 }
673 
674 static json_object *
675 make_mesh_vars(int ndims, int const *dims, double const *bounds, int nvars)
676 {
677  json_object *vars_array = json_object_new_array();
678  char const *centering_names[2] = {"zone", "node"};
679  char const *type_names[2] = {"double", "int"};
680  int const centerings[] = {0,0,0,1,1,1,1,0};
681  int const types[] = {0,0,0,0,0,0,0,1};
682  char const *var_names[] = {"constant","random","spherical","xramp","ysin","noise","noise_sum","xlayers"};
683  int i;
684 
685  /* for now, just hack and cycle through possible combinations */
686  for (i = 0; i < nvars; i++)
687  {
688  int mod8 = i % 8;
689  char const *centering = centering_names[centerings[mod8]];
690  char const *type = type_names[types[mod8]];
691  char const *name = var_names[mod8];
692  char tmpname[32];
693 
694  if (i < 8)
695  snprintf(tmpname, sizeof(tmpname), "%s", name);
696  else
697  snprintf(tmpname, sizeof(tmpname), "%s_%03d", name, (i-8)/8);
698 
699  json_object_array_add(vars_array, make_scalar_var(ndims, dims, bounds, centering, type, tmpname));
700  }
701  return vars_array;
702 }
703 
704 static json_object *
705 make_arb_mesh_topology(int ndims, int const *dims)
706 {
707  return 0;
708 }
709 
710 #warning UNIFY PART CHUNK TERMINOLOGY THEY ARE THE SAME
711 #warning SHOULD NAME CHUNK/PART NUMBER HERE TO INDICATE IT IS A GLOBAL NUMBER
712 static json_object *make_uniform_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds, int nvars)
713 {
714  json_object *mesh_chunk = json_object_new_object();
715  json_object_object_add(mesh_chunk, "MeshType", json_object_new_string("uniform"));
716  json_object_object_add(mesh_chunk, "ChunkID", json_object_new_int(chunkId));
717  json_object_object_add(mesh_chunk, "GeomDim", json_object_new_int(ndims));
718  json_object_object_add(mesh_chunk, "TopoDim", json_object_new_int(ndims));
719  json_object_object_add(mesh_chunk, "LogDims", MACSIO_UTILS_MakeDimsJsonArray(ndims, dims));
720  json_object_object_add(mesh_chunk, "Bounds", MACSIO_UTILS_MakeBoundsJsonArray(bounds));
721  json_object_object_add(mesh_chunk, "Coords", make_uniform_mesh_coords(ndims, dims, bounds));
722  json_object_object_add(mesh_chunk, "Topology", make_uniform_mesh_topology(ndims, dims));
723  return mesh_chunk;
724 }
725 
726 #warning ADD CALLS TO VARGEN FOR OTHER MESH TYPES
727 static json_object *make_rect_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds, int nvars)
728 {
729  json_object *chunk_obj = json_object_new_object();
730  json_object *mesh_obj = json_object_new_object();
731  json_object_object_add(mesh_obj, "MeshType", json_object_new_string("rectilinear"));
732  json_object_object_add(mesh_obj, "ChunkID", json_object_new_int(chunkId));
733  json_object_object_add(mesh_obj, "GeomDim", json_object_new_int(ndims));
734  json_object_object_add(mesh_obj, "TopoDim", json_object_new_int(ndims));
735  json_object_object_add(mesh_obj, "LogDims", MACSIO_UTILS_MakeDimsJsonArray(ndims, dims));
736  json_object_object_add(mesh_obj, "Bounds", MACSIO_UTILS_MakeBoundsJsonArray(bounds));
737  json_object_object_add(mesh_obj, "Coords", make_rect_mesh_coords(ndims, dims, bounds));
738  json_object_object_add(mesh_obj, "Topology", make_rect_mesh_topology(ndims, dims));
739  json_object_object_add(chunk_obj, "Mesh", mesh_obj);
740 #warning ADD NVARS AND VARMAPS ARGS HERE
741  json_object_object_add(chunk_obj, "Vars", make_mesh_vars(ndims, dims, bounds, nvars));
742  return chunk_obj;
743 }
744 
745 json_object *MACSIO_DATA_BuildRectMeshChunk(int chunkId, int ndims, int const *dims, void const **coords,
746  json_extarr_type dtype)
747 {
748 
749 }
750 
751 static json_object *make_curv_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds)
752 {
753  json_object *mesh_chunk = json_object_new_object();
754  json_object_object_add(mesh_chunk, "MeshType", json_object_new_string("curvilinear"));
755  json_object_object_add(mesh_chunk, "ChunkID", json_object_new_int(chunkId));
756  json_object_object_add(mesh_chunk, "GeomDim", json_object_new_int(ndims));
757  json_object_object_add(mesh_chunk, "TopoDim", json_object_new_int(ndims));
758  json_object_object_add(mesh_chunk, "LogDims", MACSIO_UTILS_MakeDimsJsonArray(ndims, dims));
759  json_object_object_add(mesh_chunk, "Bounds", MACSIO_UTILS_MakeBoundsJsonArray(bounds));
760  json_object_object_add(mesh_chunk, "Coords", make_curv_mesh_coords(ndims, dims, bounds));
761  json_object_object_add(mesh_chunk, "Topology", make_curv_mesh_topology(ndims, dims));
762  return mesh_chunk;
763 }
764 
765 static json_object *make_ucdzoo_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds, int nvars)
766 {
767  json_object *mesh_chunk = json_object_new_object();
768  json_object_object_add(mesh_chunk, "MeshType", json_object_new_string("ucdzoo"));
769  json_object_object_add(mesh_chunk, "ChunkID", json_object_new_int(chunkId));
770  json_object_object_add(mesh_chunk, "GeomDim", json_object_new_int(ndims));
771  json_object_object_add(mesh_chunk, "TopoDim", json_object_new_int(ndims));
772  json_object_object_add(mesh_chunk, "LogDims", MACSIO_UTILS_MakeDimsJsonArray(ndims, dims));
773  json_object_object_add(mesh_chunk, "Bounds", MACSIO_UTILS_MakeBoundsJsonArray(bounds));
774  json_object_object_add(mesh_chunk, "Coords", make_ucdzoo_mesh_coords(ndims, dims, bounds));
775  json_object_object_add(mesh_chunk, "Topology", make_ucdzoo_mesh_topology(ndims, dims));
776  return mesh_chunk;
777 }
778 
779 /* dims are # nodes in x, y and z,
780  bounds are xmin,ymin,zmin,xmax,ymax,zmax */
781 static json_object *
782 make_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds, char const *type, int nvars)
783 {
784  if (!strncasecmp(type, "uniform", sizeof("uniform")))
785  return make_uniform_mesh_chunk(chunkId, ndims, dims, bounds, nvars);
786  else if (!strncasecmp(type, "rectilinear", sizeof("rectilinear")))
787  return make_rect_mesh_chunk(chunkId, ndims, dims, bounds, nvars);
788  else if (!strncasecmp(type, "curvilinear", sizeof("curvilinear")))
789  return 0;
790  else if (!strncasecmp(type, "unstructured", sizeof("unstructured")))
791  return make_ucdzoo_mesh_chunk(chunkId, ndims, dims, bounds, nvars);
792  else if (!strncasecmp(type, "arbitrary", sizeof("arbitrary")))
793  return 0;
794  return 0;
795 }
796 
797 static int choose_part_count(int K, int mod, int *R, int *Q)
798 {
799  /* We have either K or K+1 parts so randomly select that for each rank */
800  int retval = K + random() % mod;
801  if (retval == K)
802  {
803  if (*R > 0)
804  {
805  *R--;
806  }
807  else if (*Q > 0)
808  {
809  retval = K+1;
810  *Q--;
811  }
812  }
813  else
814  {
815  if (*Q > 0)
816  {
817  *Q--;
818  }
819  else if (*R > 0)
820  {
821  retval = K;
822  *R--;
823  }
824  }
825  return retval;
826 }
827 
828 #warning ADD ABILITY TO VARY MESH TOPOLOGY WITH TIME AND ADD KEY TO INDICATE IF ITS BEEN CHANGED
829 #warning GET FUNTION NAMING CONSISTENT THROUGHOUT SOURCE FILES
830 #warning MAYBE PASS IN SEED HERE OR ADD TO MAIN_OBJ
831 #warning COULD IMPROVE DESIGN A BIT BY SEPARATING ALGORITHM FOR GEN WITH A CALLBACK
832 /* Just a very simple spatial partitioning. We use the same exact algorithm
833  to determine which rank owns a chunk. So, we overload this method and
834  for that purpose as well even though in that case, it doesn generate
835  anything. */
836 json_object *
837 MACSIO_DATA_GenerateTimeZeroDumpObject(json_object *main_obj, int *rank_owning_chunkId)
838 {
839 #warning FIX LEAK OF OBJECTS FOR QUERY CASE
840  json_object *mesh_obj = rank_owning_chunkId?0:json_object_new_object();
841  json_object *global_obj = rank_owning_chunkId?0:json_object_new_object();
842  json_object *part_array = rank_owning_chunkId?0:json_object_new_array();
843  int size = json_object_path_get_int(main_obj, "parallel/mpi_size");
844  int part_size = json_object_path_get_int(main_obj, "clargs/part_size") / sizeof(double);
845  double avg_num_parts = json_object_path_get_double(main_obj, "clargs/avg_num_parts");
846  int dim = json_object_path_get_int(main_obj, "clargs/part_dim");
847  int vars_per_part = json_object_path_get_int(main_obj, "clargs/vars_per_part");
848  double total_num_parts_d = size * avg_num_parts;
849  int total_num_parts = (int) lround(total_num_parts_d);
850  int myrank = json_object_path_get_int(main_obj, "parallel/mpi_rank");
851 
852  int K = floor(avg_num_parts); /* some ranks get K parts */
853  int K1 = K+1; /* some ranks get K+1 parts */
854  int Q = total_num_parts - size * K; /* # ranks with K+1 parts */
855  int R = size - Q; /* # ranks with K parts */
856  int mod = ((double)K == avg_num_parts)?1:2;
857  int nx_parts = total_num_parts, ny_parts = 1, nz_parts = 1;
858  int nx = part_size, ny = 1, nz = 1;
859  int ipart_width = 1, jpart_width = 0, kpart_width = 0;
860  int ipart, jpart, kpart, chunk, rank, parts_on_this_rank;
861  int part_dims[3], part_block_dims[3], global_log_dims[3], global_indices[3];
862  double part_bounds[6], global_bounds[6];
863 
864  /* Determine spatial size and arrangement of parts */
865  if (dim == 1)
866  {
867  ; /* no-op */
868  }
869  else if (dim == 2)
870  {
871  MACSIO_UTILS_Best2DFactors(total_num_parts, &nx_parts, &ny_parts);
872  MACSIO_UTILS_Best2DFactors(part_size, &nx, &ny);
873  jpart_width = 1;
874  }
875  else if (dim == 3)
876  {
877  MACSIO_UTILS_Best3DFactors(total_num_parts, &nx_parts, &ny_parts, &nz_parts);
878  MACSIO_UTILS_Best3DFactors(part_size, &nx, &ny, &nz);
879  kpart_width = 1;
880  }
881  MACSIO_UTILS_SetDims(part_dims, nx, ny, nz);
882  MACSIO_UTILS_SetDims(part_block_dims, nx_parts, ny_parts, nz_parts);
883  MACSIO_UTILS_SetDims(global_log_dims, nx * nx_parts, ny * ny_parts, nz * nz_parts);
884  MACSIO_UTILS_SetBounds(global_bounds, 0, 0, 0,
885  nx_parts * ipart_width, ny_parts * jpart_width, nz_parts * kpart_width);
886  if (!rank_owning_chunkId)
887  {
888  json_object_object_add(global_obj, "TotalParts", json_object_new_int(total_num_parts));
889 #warning NOT SURE PartsLogDims IS USEFUL IN GENERAL CASE
890  json_object_object_add(global_obj, "PartsLogDims", MACSIO_UTILS_MakeDimsJsonArray(dim, part_block_dims));
891  json_object_object_add(global_obj, "LogDims", MACSIO_UTILS_MakeDimsJsonArray(dim, global_log_dims));
892  json_object_object_add(global_obj, "Bounds", MACSIO_UTILS_MakeBoundsJsonArray(global_bounds));
893  json_object_object_add(mesh_obj, "global", global_obj);
894  }
895 
896  rank = 0;
897  chunk = 0;
898  srandom(0xDeadBeef); /* initialize for choose_part_count */
899  parts_on_this_rank = choose_part_count(K,mod,&R,&Q);
900  for (ipart = 0; ipart < nx_parts; ipart++)
901  {
902  for (jpart = 0; jpart < ny_parts; jpart++)
903  {
904  for (kpart = 0; kpart < nz_parts; kpart++)
905  {
906  if (!rank_owning_chunkId && rank == myrank)
907  {
908  int global_log_origin[3];
909 
910  /* build mesh part on this rank */
911  MACSIO_UTILS_SetBounds(part_bounds, (double) ipart, (double) jpart, (double) kpart,
912  (double) ipart+ipart_width, (double) jpart+jpart_width, (double) kpart+kpart_width);
913  json_object *part_obj = make_mesh_chunk(chunk, dim, part_dims, part_bounds,
914  json_object_path_get_string(main_obj, "clargs/part_type"), vars_per_part);
915  MACSIO_UTILS_SetDims(global_indices, ipart, jpart, kpart);
916 #warning MAYBE MOVE GLOBAL LOG INDICES TO make_mesh_chunk
917 #warning GlogalLogIndices MAY NOT BE NEEDED
918  json_object_object_add(part_obj, "GlobalLogIndices",
919  MACSIO_UTILS_MakeDimsJsonArray(dim, global_indices));
920  MACSIO_UTILS_SetDims(global_log_origin, ipart * nx, jpart * ny, kpart * nz);
921  json_object_object_add(part_obj, "GlobalLogOrigin",
922  MACSIO_UTILS_MakeDimsJsonArray(dim, global_log_origin));
923  json_object_array_add(part_array, part_obj);
924  }
925  else if (rank_owning_chunkId && *rank_owning_chunkId == chunk)
926  {
927  *rank_owning_chunkId = rank;
928  return 0;
929  }
930  chunk++;
931  parts_on_this_rank--;
932  if (parts_on_this_rank == 0)
933  {
934  rank++;
935  parts_on_this_rank = choose_part_count(K,mod,&R,&Q);
936  }
937  }
938  }
939  }
940  json_object_object_add(mesh_obj, "parts", part_array);
941 
942  return mesh_obj;
943 
944 }
945 
946 int MACSIO_DATA_GetRankOwningPart(json_object *main_obj, int chunkId)
947 {
948  int tmp = chunkId;
949  /* doesn't really generate anything; just goes through the motions
950  necessary to compute which ranks own which parts. */
952  return tmp;
953 }
954 
956 {
957 #warning IMPLEMENT THE DATA READ VALIDATION
958  return 0;
959 }
960 
961 int MACSIO_DATA_SimpleAssignKPartsToNProcs(int k, int n, int my_rank, int *my_part_cnt, int **my_part_ids)
962 {
963  return 0;
964 }
int MACSIO_DATA_ValidateDataRead(json_object *main_obj)
Definition: macsio_data.c:955
static json_object * make_uniform_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds, int nvars)
Definition: macsio_data.c:712
static json_object * make_curv_mesh_coords(int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:357
struct json_object * json_object_new_extarr_alloc(enum json_extarr_type etype, int ndims, int const *dims)
Definition: json_object.c:1115
static json_object * make_curv_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:751
struct json_object * json_object_new_string(const char *s)
Definition: json_object.c:727
static json_object * make_scalar_var(int ndims, int const *dims, double const *bounds, char const *centering, char const *dtype, char const *kind)
Definition: macsio_data.c:563
static json_object * make_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds, char const *type, int nvars)
Definition: macsio_data.c:782
json_object * MACSIO_UTILS_MakeDimsJsonArray(int ndims, const int *dims)
Definition: macsio_utils.c:248
static json_object * make_curv_mesh_topology(int ndims, int const *dims)
Definition: macsio_data.c:489
double MACSIO_UTILS_XMin(double const *bounds)
Definition: macsio_utils.c:225
struct json_object * json_object_new_object(void)
Definition: json_object.c:369
void MACSIO_UTILS_SetDims(int *dims, int nx, int ny, int nz)
Definition: macsio_utils.c:200
#define MU_SeqIdx2(i, j, Ni)
Definition: macsio_utils.h:39
int MACSIO_UTILS_Best2DFactors(int val, int *x, int *y)
Definition: macsio_utils.c:101
void const * json_object_extarr_data(struct json_object *jso)
Definition: json_object.c:1206
int MACSIO_UTILS_XDim(int const *dims)
Definition: macsio_utils.c:206
static json_object * make_uniform_mesh_coords(int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:295
static int choose_part_count(int K, int mod, int *R, int *Q)
Definition: macsio_data.c:797
static double lerp(double t, double a, double b)
Definition: macsio_data.c:43
static json_object * make_random_object_recurse(int nthings, int depth)
Definition: macsio_data.c:218
static double fade(double t)
Support functions for Perlin noise.
Definition: macsio_data.c:42
static json_object * make_random_int()
Definition: macsio_data.c:130
#define MU_MAX(A, B)
Definition: macsio_utils.h:35
static json_object * make_tensor_var(int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:663
#define MU_SeqIdx1(i)
Definition: macsio_utils.h:40
double MACSIO_UTILS_YMin(double const *bounds)
Definition: macsio_utils.c:226
struct json_object * json_object_new_int(int32_t i)
Definition: json_object.c:495
int json_object_array_add(struct json_object *obj, struct json_object *val)
Definition: json_object.c:859
static json_object * make_random_string(int nthings)
Definition: macsio_data.c:153
static json_object * make_vector_var(int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:657
json_extarr_type
Definition: json_object.h:120
json_object * MACSIO_DATA_MakeRandomObject(int nthings)
Definition: macsio_data.c:288
static json_object * make_random_array(int nthings)
Definition: macsio_data.c:169
static double noise(double _x, double _y, double _z, double const *bounds)
Ken Perlin's Improved Noise.
Definition: macsio_data.c:59
static json_object * make_uniform_mesh_topology(int ndims, int const *dims)
Definition: macsio_data.c:477
int MACSIO_UTILS_Best3DFactors(int val, int *x, int *y, int *z)
Definition: macsio_utils.c:121
static json_object * make_ucdzoo_mesh_coords(int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:397
double MACSIO_UTILS_YDelta(int const *dims, double const *bounds)
Definition: macsio_utils.c:236
struct json_object * json_object_new_array(void)
Definition: json_object.c:828
static json_object * make_ucdzoo_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds, int nvars)
Definition: macsio_data.c:765
static json_object * make_rect_mesh_coords(int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:316
double MACSIO_UTILS_ZDelta(int const *dims, double const *bounds)
Definition: macsio_utils.c:241
static json_object * make_random_extarr(int nthings)
Definition: macsio_data.c:184
double json_object_path_get_double(struct json_object *src, char const *key_path)
Get a double value for the object at specified path.
Definition: json_object.c:2140
json_object * MACSIO_DATA_BuildRectMeshChunk(int chunkId, int ndims, int const *dims, void const **coords, json_extarr_type dtype)
Definition: macsio_data.c:745
struct json_object * json_object_new_double(double d)
Definition: json_object.c:622
int MACSIO_UTILS_YDim(int const *dims)
Definition: macsio_utils.c:207
static json_object * make_subset_var(int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:669
char const * json_object_path_get_string(struct json_object *src, char const *key_path)
Get a string value for the object at specified path.
Definition: json_object.c:2198
static json_object * make_structured_mesh_topology(int ndims, int const *dims)
Definition: macsio_data.c:411
json_object * MACSIO_DATA_GenerateTimeZeroDumpObject(json_object *main_obj, int *rank_owning_chunkId)
Definition: macsio_data.c:837
static json_object * make_rect_mesh_topology(int ndims, int const *dims)
Definition: macsio_data.c:483
int MACSIO_DATA_GetRankOwningPart(json_object *main_obj, int chunkId)
Definition: macsio_data.c:946
static json_object * make_rect_mesh_chunk(int chunkId, int ndims, int const *dims, double const *bounds, int nvars)
Definition: macsio_data.c:727
struct json_object * json_object_new_extarr(void const *data, enum json_extarr_type type, int ndims, int const *dims)
Definition: json_object.c:1086
json_object * MACSIO_UTILS_MakeBoundsJsonArray(double const *bounds)
Definition: macsio_utils.c:261
static json_object * make_ucdzoo_mesh_topology(int ndims, int const *dims)
Definition: macsio_data.c:495
static json_object * make_random_double()
Definition: macsio_data.c:136
static json_object * make_arb_mesh_coords(int ndims, int const *dims, double const *bounds)
Definition: macsio_data.c:404
static json_object * make_arb_mesh_topology(int ndims, int const *dims)
Definition: macsio_data.c:705
#define MU_SeqIdx3(i, j, k, Ni, Nj)
Definition: macsio_utils.h:38
static json_object * make_mesh_vars(int ndims, int const *dims, double const *bounds, int nvars)
Definition: macsio_data.c:675
int32_t json_object_path_get_int(struct json_object *src, char const *key_path)
Get integer value for object at specified path.
Definition: json_object.c:2103
void MACSIO_UTILS_SetBounds(double *bounds, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
Definition: macsio_utils.c:210
double MACSIO_UTILS_XDelta(int const *dims, double const *bounds)
Definition: macsio_utils.c:231
int MACSIO_UTILS_ZDim(int const *dims)
Definition: macsio_utils.c:208
static double grad(int hash, double x, double y, double z)
Definition: macsio_data.c:44
void json_object_object_add(struct json_object *obj, const char *key, struct json_object *val)
Definition: json_object.c:391
int MACSIO_DATA_SimpleAssignKPartsToNProcs(int k, int n, int my_rank, int *my_part_cnt, int **my_part_ids)
Definition: macsio_data.c:961
double MACSIO_UTILS_ZMin(double const *bounds)
Definition: macsio_utils.c:227
static json_object * make_random_primitive()
Definition: macsio_data.c:143