extern void test_sagwrite_3x3_zero(void) { bbox_t bbox = BBOX(0, 3, 0, 3); polyline_t p; CU_ASSERT_EQUAL(polyline_rect(bbox, &p), 0); domain_t *dom = domain_insert(NULL, &p); CU_ASSERT_PTR_NOT_NULL(dom); const char path[] = "tmp/sagwrite-3x3.txt"; CU_ASSERT_EQUAL(sagwrite(path, dom, f0, NULL, 3, 3), 0); sagread_t sagread; CU_ASSERT_EQUAL(sagread_open(path, &sagread), 0); CU_ASSERT_EQUAL_FATAL(sagread.grid.dim, 2); CU_ASSERT_EQUAL_FATAL(sagread.vector.dim, 2); double eps = 1e-10; for (int i = 0 ; i < 2 ; i++) { CU_ASSERT_EQUAL_FATAL(sagread.grid.n[i], 3); CU_ASSERT_DOUBLE_EQUAL(sagread.grid.bnd[i].min, 0.5, eps); CU_ASSERT_DOUBLE_EQUAL(sagread.grid.bnd[i].max, 2.5, eps); } sagread_close(sagread); domain_destroy(dom); unlink(path); }
extern domain_t* cf_domain(double w, double h) { bbox_t b = {{-w/2, w/2}, {-h/2, h/2}}; vector_t v = {0, 0}; polyline_t p1, p2; double R = w/10.0; if ((polyline_rect(b, &p1) != 0) || (polyline_ngon(R, v, 32, &p2) != 0)) return NULL; domain_t* dom; dom = domain_insert(NULL, &p1); dom = domain_insert(dom, &p2); polyline_clear(&p1); polyline_clear(&p2); if (domain_orientate(dom) != 0) { domain_destroy(dom); return NULL; } return dom; }
extern domain_t* cylf_domain(cylf_t cylf) { bbox_t b = {{-1, 1}, {-1, 1}}; vector_t v = {cylf.x, cylf.y}; polyline_t p1, p2; if ((polyline_rect(b, &p1) != 0) || (polyline_ngon(cylf.radius, v, 32, &p2) != 0)) return NULL; domain_t* dom; dom = domain_insert(NULL, &p1); dom = domain_insert(dom, &p2); polyline_clear(&p1); polyline_clear(&p2); if (domain_orientate(dom) != 0) { domain_destroy(dom); return NULL; } return dom; }
dbus_bool_t dbus_notify_death (DBusMessage *msg, DBusMessage *reply) { DBusError err; dbus_bool_t ret; int32_t domid, sstate; struct domain *d; dbus_error_init (&err); ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &domid, DBUS_TYPE_INT32, &sstate, DBUS_TYPE_INVALID); if (!ret) { surfman_error ("Error getting message args: %s", err.message); return FALSE; } surfman_info ("notify_death(%d,%d)", domid, sstate); #if 1 surfman_warning ("THIS RPC IS DEPRECATED AND SHOULD NOT BE USED ANY MORE."); #else d = domain_by_domid (domid); if (!d) { surfman_error ("Domain %d not found", domid); return FALSE; } domain_destroy (d); #endif if (reply && ret) dbus_message_append_args (reply, DBUS_TYPE_INVALID); return ret; }
int main(int argc, char * argv[]) { MPI_Init(&argc, &argv); g_log_set_default_handler(log_handler, NULL); g_set_print_handler(print_handler); mpiu_init(); ROOTONLY { GError * error = NULL; GOptionContext * context = g_option_context_new("paramfile"); g_option_context_add_main_entries(context, entries, NULL); if(!g_option_context_parse(context, &argc, &argv, &error)) { g_print("Option parsing failed: %s", error->message); abort(); } if(g_strv_length(paramfilename) != 1) { g_print(g_option_context_get_help(context, FALSE, NULL)); abort(); } paramfile_read(paramfilename[0]); g_message("Reading param file %s", paramfilename[0]); g_option_context_free(context); } MPI_Barrier(MPI_COMM_WORLD); common_block_sync(); MPI_Barrier(MPI_COMM_WORLD); init_gadget(); g_message("MPI Task: %d of %d, datadir=%s", ThisTask, NTask, CB.datadir); MPI_Barrier(MPI_COMM_WORLD); domain_init(); for(CB.SnapNumMajor = CB.SnapNumMajorBegin; CB.SnapNumMajor < CB.SnapNumMajorEnd; CB.SnapNumMajor ++) { SnapHeader h; snapshot_read(&h); CB.a = h.a; domain_decompose(); domain_build_tree(); for(int color=0; color < NColor; color++) { TAKETURNS { inspect_par(color); inspect_tree(color); } } ROOTONLY { inspect_domain_table(); } domain_cleanup(); } domain_destroy(); MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); return 0; }
extern int plot(opt_t *opt) { int err = ERROR_BUG; #ifndef HAVE_GETRUSAGE /* simple timer */ clock_t c0, c1; c0 = clock(); #endif #ifdef HAVE_GETTIMEOFDAY /* high resolution elapsed time */ struct timeval tv0; gettimeofday(&tv0, NULL); #endif #ifdef HAVE_PTHREAD_H if (opt->v.verbose) { printf("using %i thread%s\n", opt->v.threads, (opt->v.threads == 1 ? "" : "s")); } #endif if (opt->test != test_none) { /* test field */ switch (opt->test) { case test_circular: TFMSG("circular"); err = plot_circular(opt); break; case test_electro2: TFMSG("two-point electrostatic"); err = plot_electro2(opt); break; case test_electro3: TFMSG("three-point electrostatic"); err = plot_electro3(opt); break; case test_cylinder: TFMSG("cylindrical flow"); err = plot_cylinder(opt); break; default: err = ERROR_BUG; } } else { /* data field */ if (opt->v.verbose) { int i; printf("reading field from\n"); for (i=0 ; i<opt->input.n ; i++) { printf(" %s\n", opt->input.file[i]); } } field_t *field = field_read(opt->input.format, opt->input.n, opt->input.file); if (!field) { fprintf(stderr, "failed to read field\n"); return ERROR_READ_OPEN; } /* this needs to be in libvfplot */ field_scale(field, opt->v.arrow.scale); domain_t* dom; if (opt->domain.file) dom = domain_read(opt->domain.file); else dom = field_domain(field); if (!dom) { fprintf(stderr, "no domain\n"); return ERROR_BUG; } err = plot_generic(dom, (vfun_t)fv_field, (cfun_t)fc_field, (void*)field, opt); field_destroy(field); domain_destroy(dom); } #ifdef HAVE_STAT /* if success then stat the output file */ if (err == ERROR_OK) { struct stat sb; if ((opt->v.file.output.path != NULL) && (stat(opt->v.file.output.path, &sb) != 0)) { fprintf(stderr, "problem with %s : %s\n", opt->v.file.output.path, strerror(errno)); } else { if (opt->v.verbose) printf("wrote %li bytes to %s\n", (long)sb.st_size, opt->v.file.output.path); } } #endif if (opt->v.verbose) { #ifdef HAVE_GETRUSAGE /* datailed stats on POSIX systems */ struct rusage usage; if (getrusage(RUSAGE_SELF, &usage) == 0) { double user = usage.ru_utime.tv_sec + (double)usage.ru_utime.tv_usec/1e6, sys = usage.ru_stime.tv_sec + (double)usage.ru_stime.tv_usec/1e6; printf("CPU time %.3f s (user) %.3f s (system)\n", user, sys); } else { fprintf(stderr, "no usage stats (not fatal) ; error %s\n", strerror(errno)); } #else /* simple stats on C89 systems */ c1 = clock(); double wall = ((double)(c1 - c0))/(double)CLOCKS_PER_SEC; printf("CPU time %.3f s\n", wall); #endif #ifdef HAVE_GETTIMEOFDAY struct timeval tv1, dtv; gettimeofday(&tv1, NULL); timeval_subtract(&dtv, &tv1, &tv0); printf("elapsed time %ld.%03ld s\n", dtv.tv_sec, dtv.tv_usec/1000); #endif } return err; }
int clickos_destroy(int domid, int force) { return domain_destroy(domid, force); }