/* TODO renumber doesn't work in parallel */ static INT RenumberVertices (MULTIGRID *theMG, INT min_level, INT max_level) { INT l, i; ResetVertexFlags(theMG, min_level, max_level); /* reset used flags in vertices */ i = 0; for (l=min_level; l<=max_level; l++) { NODE *theNode; GRID *theGrid = GRID_ON_LEVEL(theMG,l); /* reset USED flags in all vertices */ for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) { if (USED(MYVERTEX(theNode))) continue; SETUSED(MYVERTEX(theNode),1); ID(MYVERTEX(theNode)) = i; i++; } } return(0); }
static INT ComputeSurfaceGridStats (MULTIGRID *theMG, COVISE_HEADER *covise) { NODE *theNode; INT l, n_vertices, n_elem, n_conn; /* surface grid up to current level */ n_vertices = n_elem = n_conn = 0; for (l=covise->min_level; l<=covise->max_level; l++) { ELEMENT *theElement; GRID *theGrid = GRID_ON_LEVEL(theMG,l); /* reset USED flags in all vertices to be counted */ for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) { SETUSED(MYVERTEX(theNode),0); } /* count geometric objects */ for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { if ((EstimateHere(theElement)) || (l==covise->max_level)) { int i, coe = CORNERS_OF_ELEM(theElement); n_elem++; for (i=0; i<coe; i++) { theNode = CORNER(theElement,i); n_conn++; if (USED(MYVERTEX(theNode))) continue; SETUSED(MYVERTEX(theNode),1); if ((SONNODE(theNode)==NULL) || (l==covise->max_level)) { #ifdef ModelP if (PRIO(theNode) == PrioMaster) #endif n_vertices++; } } } } } #ifdef ModelP n_vertices = UG_GlobalSumINT(n_vertices); n_elem = UG_GlobalSumINT(n_elem); n_conn = UG_GlobalSumINT(n_conn); #endif covise->n_vertices = n_vertices; covise->n_elems = n_elem; covise->n_conns = n_conn; return(0); }
static INT ResetVertexFlags (MULTIGRID *theMG, INT min_level, INT max_level) { INT l; /* reset used flags in vertices */ for (l=min_level; l<=max_level; l++) { NODE *theNode; GRID *theGrid = GRID_ON_LEVEL(theMG,l); /* reset USED flags in all vertices */ for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) { SETUSED(MYVERTEX(theNode),0); } } return(0); /* no error */ }
static INT SendSolution (MULTIGRID *theMG, COVISE_HEADER *covise, INT idx_sol) { INT l, remaining, sent, n_comp_sol; TokenBuffer tb; Message* msg = new Message; msg->type = (covise_msg_type)0; printf("CoviseIF: SendSolution start, idx_sol=%d\n", idx_sol); n_comp_sol = covise->solutions[idx_sol].n_components; /* reset vertex flags */ ResetVertexFlags(theMG, covise->min_level, covise->max_level); /* start first buffer */ tb.reset(); remaining = MIN(covise->n_vertices,MAX_ITEMS_SENT); tb << MT_UGSCALAR; tb << idx_sol; tb << remaining; sent = 0; /* extract data, loop from max_level to min_level! */ /* TODO: special handling in ModelP */ for (l=covise->max_level; l>=covise->min_level; l--) { NODE *theNode; GRID *theGrid = GRID_ON_LEVEL(theMG,l); for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) { VECTOR *theVector; INT i; INT vid; if (USED(MYVERTEX(theNode))) continue; SETUSED(MYVERTEX(theNode),1); /* NOTE: vid is sent along with data! this increases msg sizes, but is the secure solution (resistent to message order a.s.o.) */ vid = ID(MYVERTEX(theNode)); tb << (INT32)vid; theVector = NVECTOR(theNode); /* extract data from vector */ for(i=0; i<n_comp_sol; i++) { INT comp = covise->solutions[idx_sol].comps[i]; tb << (FLOAT32) VVALUE(theVector,comp); } remaining--; sent++; if (remaining==0) { /* send this buffer */ msg->data = (char*)tb.get_data(); msg->length = tb.get_length(); covise_connection->send_msg(msg); /* start next buffer */ tb.reset(); remaining = MIN(covise->n_vertices - sent, MAX_ITEMS_SENT); tb << MT_UGSCALAR; tb << idx_sol; tb << remaining; } } } delete msg; printf("CoviseIF: SendSolution stop\n"); return(0); }
static INT SendSurfaceGrid (MULTIGRID *theMG, COVISE_HEADER *covise) { INT l, remaining, sent; TokenBuffer tb; Message* msg = new Message; msg->type = (covise_msg_type)0; printf("CoviseIF: SendSurfaceGrid start\n"); /* renumber vertex IDs */ /* TODO doesn't work in ModelP */ RenumberVertices(theMG, covise->min_level, covise->max_level); /* send surface vertices, part1: set flags */ ResetVertexFlags(theMG, covise->min_level, covise->max_level); /* send surface vertices, part2: send data */ sent = 0; /* start first buffer */ tb.reset(); remaining = MIN(covise->n_vertices,MAX_ITEMS_SENT); tb << MT_UGGRIDV; tb << remaining; for (l=covise->min_level; l<=covise->max_level; l++) { NODE *theNode; GRID *theGrid = GRID_ON_LEVEL(theMG,l); for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) { INT vid; DOUBLE *pos; if (USED(MYVERTEX(theNode))) continue; SETUSED(MYVERTEX(theNode),1); /* extract data from vertex */ /* TODO use VXGID in ModelP */ vid = ID(MYVERTEX(theNode)); pos = CVECT(MYVERTEX(theNode)); tb << (INT32)vid; tb << (FLOAT32)pos[0]; tb << (FLOAT32)pos[1]; tb << (FLOAT32)pos[2]; remaining--; sent++; if (remaining==0) { /* send this buffer */ msg->data = (char*)tb.get_data(); msg->length = tb.get_length(); covise_connection->send_msg(msg); /* start next buffer */ tb.reset(); tb << MT_UGGRIDV; remaining = MIN(covise->n_vertices - sent, MAX_ITEMS_SENT); tb << remaining; } } } printf("CoviseIF: SendSurfaceGrid ...\n"); /* next buffer */ tb.reset(); tb << MT_UGGRIDE; remaining = MIN(covise->n_elems,MAX_ITEMS_SENT); tb << remaining; sent = 0; /* send surface elems and connectivity */ for (l=covise->min_level; l<=covise->max_level; l++) { ELEMENT *theElement; GRID *theGrid = GRID_ON_LEVEL(theMG,l); for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { if ((EstimateHere(theElement)) || (l==covise->max_level)) { int i, coe = CORNERS_OF_ELEM(theElement); tb << (INT32)coe; for (i=0; i<coe; i++) { NODE *theNode = CORNER(theElement,i); INT vid; vid = ID(MYVERTEX(theNode)); /* TODO use VXGID in ModelP */ tb << (INT32)vid; } remaining--; sent++; if (remaining==0) { /* send this buffer */ msg->data = (char*)tb.get_data(); msg->length = tb.get_length(); covise_connection->send_msg(msg); /* start next buffer */ tb.reset(); tb << MT_UGGRIDE; remaining = MIN(covise->n_elems - sent, MAX_ITEMS_SENT); tb << remaining; } } } } /* cleanup */ delete msg; printf("CoviseIF: SendSurfaceGrid stop\n"); return(0); }
void NS_DIM_PREFIX SetGhostObjectPriorities (GRID *theGrid) { ELEMENT *theElement,*theNeighbor,*SonList[MAX_SONS]; NODE *theNode; EDGE *theEdge; VECTOR *theVector; INT i,prio,*proclist,hghost,vghost; /* reset USED flag for objects of ghostelements */ for (theElement=PFIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { SETUSED(theElement,0); SETTHEFLAG(theElement,0); for (i=0; i<EDGES_OF_ELEM(theElement); i++) { theEdge = GetEdge(CORNER(theElement,CORNER_OF_EDGE(theElement,i,0)), CORNER(theElement,CORNER_OF_EDGE(theElement,i,1))); ASSERT(theEdge != NULL); SETUSED(theEdge,0); SETTHEFLAG(theEdge,0); } if (VEC_DEF_IN_OBJ_OF_GRID(theGrid,SIDEVEC)) for (i=0; i<SIDES_OF_ELEM(theElement); i++) { theVector = SVECTOR(theElement,i); if (theVector != NULL) { SETUSED(theVector,0); SETTHEFLAG(theVector,0); } } } /* to reset also nodes which are at corners of the boundary */ /* reset of nodes need to be done through the node list */ for (theNode=PFIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) { SETUSED(theNode,0); SETTHEFLAG(theNode,0); SETMODIFIED(theNode,0); } /* set FLAG for objects of horizontal and vertical overlap */ for (theElement=PFIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { if (PARTITION(theElement) == me) continue; /* check for horizontal ghost */ hghost = 0; for (i=0; i<SIDES_OF_ELEM(theElement); i++) { theNeighbor = NBELEM(theElement,i); if (theNeighbor == NULL) continue; if (PARTITION(theNeighbor) == me) { hghost = 1; break; } } /* check for vertical ghost */ vghost = 0; GetAllSons(theElement,SonList); for (i=0; SonList[i]!=NULL; i++) { if (PARTITION(SonList[i]) == me) { vghost = 1; break; } } /* one or both of vghost and hghost should be true here */ /* except for elements which will be disposed during Xfer */ if (vghost) SETTHEFLAG(theElement,1); if (hghost) SETUSED(theElement,1); for (i=0; i<CORNERS_OF_ELEM(theElement); i++) { theNode = CORNER(theElement,i); if (vghost) SETTHEFLAG(theNode,1); if (hghost) SETUSED(theNode,1); } for (i=0; i<EDGES_OF_ELEM(theElement); i++) { theEdge = GetEdge(CORNER_OF_EDGE_PTR(theElement,i,0), CORNER_OF_EDGE_PTR(theElement,i,1)); ASSERT(theEdge != NULL); if (vghost) SETTHEFLAG(theEdge,1); if (hghost) SETUSED(theEdge,1); } if (VEC_DEF_IN_OBJ_OF_GRID(theGrid,SIDEVEC)) for (i=0; i<SIDES_OF_ELEM(theElement); i++) { theVector = SVECTOR(theElement,i); if (theVector != NULL) { if (vghost) SETTHEFLAG(theVector,1); if (hghost) SETUSED(theVector,1); } } } DEBUG_TIME(0); /* set USED flag for objects of master elements */ /* reset FLAG for objects of master elements */ for (theElement=PFIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { if (PARTITION(theElement) != me) continue; SETUSED(theElement,0); SETTHEFLAG(theElement,0); for (i=0; i<CORNERS_OF_ELEM(theElement); i++) { theNode = CORNER(theElement,i); SETUSED(theNode,0); SETTHEFLAG(theNode,0); SETMODIFIED(theNode,1); } for (i=0; i<EDGES_OF_ELEM(theElement); i++) { theEdge = GetEdge(CORNER_OF_EDGE_PTR(theElement,i,0), CORNER_OF_EDGE_PTR(theElement,i,1)); ASSERT(theEdge != NULL); SETUSED(theEdge,0); SETTHEFLAG(theEdge,0); } if (VEC_DEF_IN_OBJ_OF_GRID(theGrid,SIDEVEC)) for (i=0; i<SIDES_OF_ELEM(theElement); i++) { theVector = SVECTOR(theElement,i); if (theVector != NULL) { SETUSED(theVector,0); SETTHEFLAG(theVector,0); } } } DEBUG_TIME(0); /* set object priorities for ghostelements */ for (theElement=PFIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { if (PARTITION(theElement) == me) continue; if (USED(theElement) || THEFLAG(theElement)) { prio = PRIO_CALC(theElement); PRINTDEBUG(gm,1,("SetGhostObjectPriorities(): e=" EID_FMTX " new prio=%d\n", EID_PRTX(theElement),prio)) SETEPRIOX(theElement,prio); if (VEC_DEF_IN_OBJ_OF_GRID(theGrid,ELEMVEC)) { theVector = EVECTOR(theElement); if (theVector != NULL) SETPRIOX(theVector,prio); } } /* set edge priorities */ for (i=0; i<EDGES_OF_ELEM(theElement); i++) { theEdge = GetEdge(CORNER(theElement,CORNER_OF_EDGE(theElement,i,0)), CORNER(theElement,CORNER_OF_EDGE(theElement,i,1))); ASSERT(theEdge != NULL); if (USED(theEdge) || THEFLAG(theEdge)) { PRINTDEBUG(dddif,3,(PFMT " dddif_SetGhostObjectPriorities():" " downgrade edge=" EDID_FMTX " from=%d to PrioHGhost\n", me,EDID_PRTX(theEdge),prio)); EDGE_PRIORITY_SET(theGrid,theEdge,PRIO_CALC(theEdge)); } else EDGE_PRIORITY_SET(theGrid,theEdge,PrioMaster); } #ifdef __THREEDIM__ /* if one(all) of the side nodes is (are) a hghost (vghost) node */ /* then its a hghost (vghost) side vector */ if (VEC_DEF_IN_OBJ_OF_GRID(theGrid,SIDEVEC)) for (i=0; i<SIDES_OF_ELEM(theElement); i++) { if (USED(theVector) || THEFLAG(theVector)) SETPRIOX(theVector,PRIO_CALC(theVector)); } #endif } /* to set also nodes which are at corners of the boundary */ /* set them through the node list */ for (theNode=PFIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) { /* check if its a master node */ if (USED(theNode) || THEFLAG(theNode)) { PRINTDEBUG(dddif,3,(PFMT " dddif_SetGhostObjectPriorities():" " downgrade node=" ID_FMTX " from=%d to PrioHGhost\n", me,ID_PRTX(theNode),prio)); /* set node priorities of node to ghost */ NODE_PRIORITY_SET(theGrid,theNode,PRIO_CALC(theNode)) } else if (MODIFIED(theNode) == 0)