static PyObject * yami4py_agent_add_listener(PyObject *self, PyObject *args) { unsigned long long pa; const char * listener; if (!PyArg_ParseTuple(args, "Ks", &pa, &listener)) { return NULL; } void * res = yami4_agent_add_listener(ull2ptr(pa), listener); return Py_BuildValue("K", ptr2ull(res)); }
static PyObject * yami4py_incoming_message_get_message_name( PyObject *self, PyObject *args) { unsigned long long pmsg; if (!PyArg_ParseTuple(args, "K", &pmsg)) { return NULL; } void * res = yami4_incoming_message_get_message_name(ull2ptr(pmsg)); return Py_BuildValue("K", ptr2ull(res)); }
static PyObject * yami4py_create_agent(PyObject *self, PyObject *args) { const char * serialized_options; int dummy; int buffer_len; if (!PyArg_ParseTuple(args, "t#i", &serialized_options, &dummy, &buffer_len)) { return NULL; } void * res = yami4_create_agent(serialized_options, buffer_len); return Py_BuildValue("K", ptr2ull(res)); }
static PyObject * yami4py_agent_open_connection( PyObject *self, PyObject *args) { unsigned long long pa; const char * target; if (!PyArg_ParseTuple(args, "Ks", &pa, &target)) { return NULL; } void * res = yami4_agent_open_connection(ull2ptr(pa), target); return Py_BuildValue("K", ptr2ull(res)); }
static PyObject * yami4py_agent_get_next_connection_event( PyObject *self, PyObject *args) { unsigned long long pa; if (!PyArg_ParseTuple(args, "K", &pa)) { return NULL; } void * res; Py_BEGIN_ALLOW_THREADS res = yami4_agent_get_next_connection_event(ull2ptr(pa)); Py_END_ALLOW_THREADS return Py_BuildValue("K", ptr2ull(res)); }
static PyObject * yami4py_get_pointer(PyObject *self, PyObject *args) { unsigned long long pr; if (!PyArg_ParseTuple(args, "K", &pr)) { return NULL; } void * res = yami4_get_pointer(ull2ptr(pr)); if (res != NULL) { return Py_BuildValue("K", ptr2ull(res)); } else { Py_RETURN_NONE; } }
static PyObject * yami4py_outgoing_message_wait_for_completion( PyObject *self, PyObject *args) { unsigned long long pmsg; int timeout; if (!PyArg_ParseTuple(args, "Ki", &pmsg, &timeout)) { return NULL; } void * res; Py_BEGIN_ALLOW_THREADS res = yami4_outgoing_message_wait_for_completion( ull2ptr(pmsg), timeout); Py_END_ALLOW_THREADS return Py_BuildValue("K", ptr2ull(res)); }
EXPORT int collect_pcs_in_mesh2d(TRI_GRID *ntg) { int xmax; int ymax; struct Table *T; P_LINK *hash_table; Locstate *states; COMPONENT *comp; TG_PT *node_pts; BLK_EL0 *blk_el0; BOND ****by; BOND ***byx; CURVE ****cy,***cyx; POINT_COMP_ST *pcs; int ix, iy, l; int **nby, *nbyx; int *offset = ntg->offset; int num_pcs = 0; int h_size; #if defined(DEBUG_TRI_GRID) debug_print("collect_pcs_in_mesh2d", "make_bond_comp_list"); #endif /* defined(DEBUG_TRI_GRID) */ set_dual_interface_topology(ntg); ntg->_locate_on_trigrid = tg_build; #if defined(DEBUG_TRI_GRID) debug_print("collect_pcs_in_mesh2d", "to count_num_pcs2d"); #endif /* defined(DEBUG_TRI_GRID) */ ntg->n_pcs = count_num_pcs2d(ntg); VECTOR(ntg,pcs,ntg->n_pcs,sizeof(POINT_COMP_ST)); T = table_of_interface(ntg->grid_intfc); xmax = ntg->rect_grid.gmax[0]; ymax = ntg->rect_grid.gmax[1]; /* Allocate space for hashing table */ /*P_LINK (int.h) pair of left and right states */ h_size = (ntg->grid_intfc->num_points)*4+1; uni_array(&hash_table,h_size,sizeof(P_LINK)); #if defined(DEBUG_TRI_GRID) debug_print("collect_pcs_in_mesh2d", "to copy_tg_pts_from_intfc"); #endif /* defined(DEBUG_TRI_GRID) */ copy_tg_pts_from_intfc(ntg,hash_table,h_size); /* set the pcs's */ comp = T->components; states = ntg->states; node_pts = ntg->node_points; blk_el0 = ntg->blk_els0; #if defined(DEBUG_TRI_GRID) debug_print("collect_pcs_in_mesh2d", "to set the pcs's"); #endif /* defined(DEBUG_TRI_GRID) */ for (iy = 0, nby = T->num_of_bonds, by = T->bonds, cy = T->curves; iy < ymax; ++iy, ++nby, ++by, ++cy) { for (ix = 0, nbyx = *nby, byx = *by, cyx = *cy; ix < xmax; ++ix, ++nbyx, ++byx, ++cyx) { pcs = blk_el0_pcs_els(blk_el0) = &(ntg->pcs[num_pcs]); if (*nbyx != 0) { for (l = 0; l < 4; ++l) { pcs[l].p = node_pts + offset[l]; pcs[l].comp[0] = comp[offset[l]]; pcs[l].s[0] = states[offset[l]]; pcs[l].comp[1] = NO_COMP; pcs[l].s[1] = NULL; } num_pcs_els_in_blk(blk_el0) = 4; add_intfc_blk_pcs2d(*nbyx,*byx,*cyx,blk_el0, hash_table,h_size); num_pcs += num_pcs_els_in_blk(blk_el0); } else { set_bilinear_blk_el0(blk_el0); pcs[0].p = node_pts; pcs[0].comp[0] = comp[0]; pcs[0].s[0] = states[0]; pcs[0].comp[1] = NO_COMP; pcs[0].s[1] = NULL; ++num_pcs; } ++node_pts; ++states; ++comp; ++blk_el0; } ++node_pts; ++states; ++comp; /* if (iy < ymax -1) { node_pts += xmax+1; states += xmax+1; comp += xmax+1; } */ } free(hash_table); #if defined(DEBUG_TRI_GRID) if (debugging("collect_pcs_in_mesh2d")) { int i; int icoords[MAXD]; float *coords; (void) printf("\t\t PRINTING PCS:\n"); for (i=0;i<ntg->n_pcs ;++i) { coords = (float*)(ntg->pcs[i].p); if (rect_in_which(coords,icoords,&(ntg->rect_grid))) { (void) printf("%d: icoords[%d,%d] ", i,icoords[0],icoords[1]); (void) printf("comp[0] = %d, comp[1] = %d \n", ntg->pcs[i].comp[0],ntg->pcs[i].comp[1]); } else { (void) printf("rect_in_which failed for this pcs\n"); (void) printf("%d: comp[0] = %d, comp[1] = %d \n", i,ntg->pcs[i].comp[0],ntg->pcs[i].comp[1]); } (void) printf("(%g,%g)\n", coords[0],coords[1]); } (void) printf("\t\n\n PRINTING BLK_EL0:\n"); for (icoords[0] = 0; icoords[0] < ntg->rect_grid.gmax[0]; ++icoords[0]) { for (icoords[1] = 0; icoords[1] < ntg->rect_grid.gmax[1]; ++icoords[1]) { blk_el0 = &Blk_el0(icoords,ntg); (void) printf("blk_el0[%d,%d] = %llu\n", icoords[0],icoords[1], ptr2ull(blk_el0)); (void) printf("num_pcs_els_in_blk = %d\n", num_pcs_els_in_blk(blk_el0)); for (i = 0; i < num_pcs_els_in_blk(blk_el0); ++i) { (void) printf("%d: (%g, %g)\n",i, Coords(blk_el0_pcs_els(blk_el0)[i].p)[0], Coords(blk_el0_pcs_els(blk_el0)[i].p)[1]); } } } } if (debugging("tri_grid")) { (void) printf("Grid interface AFTER collect_pcs_in_mesh2d()\n"); print_interface(ntg->grid_intfc); } #endif /* defined(DEBUG_TRI_GRID) */ return GOOD_STEP; } /*end collect_pcs_in_mesh2d*/
LOCAL void add_intfc_blk_pcs2d( int num_bonds, BOND **bond, CURVE **curve, BLK_EL0 *blk_el0, P_LINK *hash_table, int h_size) { BOND *b; CURVE *c; POINT *p; int i; TG_PT *tp; POINT_COMP_ST *pcs = blk_el0_pcs_els(blk_el0); Locstate sl,sr; /* reset points in block bonds */ for (i = 0; i < num_bonds; ++i) { b = bond[i]; sorted(b->start) = NO; sorted(b->end) = NO; } /* add interface points inside cell */ for (i = 0; i < num_bonds; ++i) { b = bond[i]; c = curve[i]; p = b->start; if (sorted(p) == NO) { sorted(p) = YES; tp = (TG_PT*)find_from_hash_table((POINTER)p,hash_table, h_size); slsr(p,Hyper_surf_element(b),Hyper_surf(c),&sl,&sr); pcs[num_pcs_els_in_blk(blk_el0)].p = tp; pcs[num_pcs_els_in_blk(blk_el0)].comp[0] = negative_component(c); pcs[num_pcs_els_in_blk(blk_el0)].comp[1] = positive_component(c); pcs[num_pcs_els_in_blk(blk_el0)].s[0] = sl; pcs[num_pcs_els_in_blk(blk_el0)].s[1] = sr; ++num_pcs_els_in_blk(blk_el0); } p = b->end; if (sorted(p)==NO) { sorted(p) = YES; tp = (TG_PT*)find_from_hash_table((POINTER)p,hash_table, h_size); slsr(p,Hyper_surf_element(b),Hyper_surf(c),&sl,&sr); pcs[num_pcs_els_in_blk(blk_el0)].p = tp; pcs[num_pcs_els_in_blk(blk_el0)].comp[0] = negative_component(c); pcs[num_pcs_els_in_blk(blk_el0)].comp[1] = positive_component(c); pcs[num_pcs_els_in_blk(blk_el0)].s[0] = sl; pcs[num_pcs_els_in_blk(blk_el0)].s[1] = sr; ++num_pcs_els_in_blk(blk_el0); } } if (debugging("add_intfc_blk_pcs2d")) { int i; (void) printf("\nblk_el0 %llu\n", ptr2ull(blk_el0)); (void) printf("\t num_pcs_els_in_blk = %d\n", num_pcs_els_in_blk(blk_el0)); for (i=0; i< num_pcs_els_in_blk(blk_el0);++i) { (void) printf("%d: (%g,%g),", i, Coords(pcs[i].p)[0],Coords(pcs[i].p)[1]); (void) printf("comp = (%d,%d)\n", pcs[i].comp[0],pcs[i].comp[1]); } } } /* end add_intfc_blk_pcs2d */