EXPORT void check_double_cone_point( INTERFACE *intfc) { SURFACE **s; TRI *tri,*ptris[30],**tris; int i,j,num_ptris,num_tris; POINT *p; HYPER_SURF *hs; HYPER_SURF_ELEMENT *hse; bool ptri_in_tri_list; (void) printf("Start checking double cone point\n"); next_point(intfc,NULL,NULL,NULL); while (next_point(intfc,&p,&hse,&hs)) { num_ptris = 0; num_tris = set_tri_list_around_point(p,Tri_of_hse(hse), &tris,intfc); for (s = intfc->surfaces; s && *s; ++s) { for (tri = first_tri(*s); !at_end_of_tri_list(tri,*s); tri = tri->next) { if (Point_of_tri(tri)[0] == p || Point_of_tri(tri)[1] == p || Point_of_tri(tri)[2] == p) ptris[num_ptris++] = tri; } } for (i = 0; i < num_ptris; ++i) { ptri_in_tri_list = NO; tri = ptris[i]; for (j = 0; j < num_tris; ++j) { if (tri == tris[j]) { ptri_in_tri_list = YES; break; } } if (!ptri_in_tri_list) { (void) printf("double cone point found:\n"); (void) printf("double cone point p(%d) = %f %f %f\n",p, Coords(p)[0],Coords(p)[1],Coords(p)[2]); } } } (void) printf("End checking double cone point\n"); } /* end check_double_cone_point */
LOCAL bool check_tri( TRI *tri, INTERFACE *intfc) { POINT **p; bool status = YES; int side; if (tri == NULL) { (void) printf("WARNING in check_tri(), tri is NULL\n"); return NO; } p = Point_of_tri(tri); if ((p[0] == p[1]) || (p[0] == p[2]) || (p[1] == p[2])) { (void) printf("WARNING in check_tri(), two points are equal\n"); print_tri(tri,intfc); status = NO; } for (side = 0; side < 3; ++side) { if (!tri_side_consistent(tri,Tri_neighbor(tri)+side,side,intfc)) { (void) printf("WARNING in check_tri(), " "side %d of tri inconsistent\n",side); print_tri(tri,intfc); status = NO; } } return status; } /*end check_tri*/
LIB_LOCAL void check_tri_and_bond( TRI *tri, BOND *b, const char *str, INTERFACE *intfc) { POINT *ps,*pe,*p; int i, j = 0; char s1[256],s2[256],s3[256]; (void) sprintf(s2,"in check_tri_and_bond()\n %s: ps==pe\n",str); (void) sprintf(s3,"in check_tri_and_bond()\n %s: bond not match tri\n", str); (void) sprintf(s1,"in check_tri_and_bond()\n %s: NULL tri\n",str); if (tri == NULL) { (void) printf("%s",s1); print_bond(b); return; } ps = b->start, pe = b->end; if (ps == pe) { (void) printf("%s",s2); print_bond(b); return; } for (i = 0; i < 3; ++i) { p = Point_of_tri(tri)[i]; if ((p == ps) || (p == pe)) ++j; } if (j != 2) { (void) printf("%s",s3); print_bond(b); print_tri(tri,intfc); return; } } /*end check_tri_and_bond*/
LOCAL TRI *find_inner_seed_tri( C_CURVE *cc, SURFACE *surf, TRI **tris, int nt) { C_BOND *cb; TRI *t,*nbt; int i,j,k,ii; POINT *p; for (cb = cc->first; cb != NULL; cb = cb->next) { for (k = 0; k < 2; ++k) { t = cb->s[k].t; if (t->surf != surf) continue; for (i = 0; i < 3; ++i) { if (is_side_bdry(t,i)) continue; nbt = Tri_on_side(t,i); if (pointer_in_list((POINTER)nbt,nt,(POINTER*)tris)) continue; for (j = 0; j < 3; ++j) { if (is_side_bdry(nbt,j)) continue; if (Tri_on_side(nbt,j) != t) continue; p = Point_of_tri(nbt)[(j+2)%3]; if (point_inside_c_curve(p,cc)) { return nbt; } } } } } return NULL; } /* end find_inner_seed_tri */
LOCAL void set_tr_tf_pf_list( Front *front, C_CURVE *cc, TRI ***tr_list, int *num_trs, TRI ***tf_list, int *num_tfs, POINT ***pf_list, int *num_pfs) { int i,j,k,num_cbs,num_tf,num_tr,nt; C_BOND *cb,**cbs; SURFACE *sr,*sf; /* rigid and fabric surfaces */ TRI **tr,**tf; /* rigid and fabric tri lists */ POINT *p,**pf; /* fabric point lists */ int npf,ntr,ntf; int max_npf,max_ntr,max_ntf; COMPONENT comp,ext_comp,int_comp; /* ext_comp is the component exterior to comp domain */ /* int_comp is the component interior to comp domain */ SIDE status; TRI *t,*nbt,*tr_on,**ptris; double nearest_pt[MAXD],nor[MAXD]; int id; char dirname[100]; POINTER_Q *seed_queue,*pq; set_pointer_queue_opts(PQ_BLOCK_SIZE,200,PQ_ALLOC_TYPE,"vmalloc", PQ_ALLOC_SIZE_FOR_POINTERS,sizeof(TRI*),0); /* resetting */ num_cbs = 0; sr = sf = NULL; tr = tf = NULL; pf = NULL; npf = ntf = ntr = 0; max_npf = max_ntf = max_ntr = 0; for (cb = cc->first; cb != NULL; cb = cb->next) num_cbs++; for (i = 0; i < 2; ++i) { if (wave_type(cc->s[i]) == NEUMANN_BOUNDARY || wave_type(cc->s[i]) == MOVABLE_BODY_BOUNDARY) sr = cc->s[i]; if (wave_type(cc->s[i]) == ELASTIC_BOUNDARY) sf = cc->s[i]; } ext_comp = exterior_component(front->interf); int_comp = (positive_component(sr) == ext_comp) ? negative_component(sr) : positive_component(sr); /* Tri lists of collision rings */ for (i = 0, cb = cc->first; cb != NULL; i++, cb = cb->next) { for (k = 0; k < 2; ++k) { t = cb->s[k].t; if (t->surf == sr) check_add_tri(&tr,t,&ntr,&max_ntr); if (t->surf == sf) check_add_tri(&tf,t,&ntf,&max_ntf); } } /* Find seed tri inside the rigid surface ring */ t = find_inner_seed_tri(cc,sr,tr,ntr); if (debugging("collision")) { int ns = (t == NULL) ? 0 : 1; sprintf(dirname,"cross-tris/rigid-seed-%d",front->step); gview_plot_crossing_tris(dirname,tr,ntr,&t,ns); } /* Fill tr list with tris inside the ring */ if (t != NULL) { seed_queue = add_to_pointer_queue(NULL,NULL); seed_queue->pointer = (POINTER)t; check_add_tri(&tr,t,&ntr,&max_ntr); while (seed_queue) { pq = head_of_pointer_queue(seed_queue); t = (TRI*)(pq->pointer); for (i = 0; i < 3; ++i) { if (is_side_bdry(t,i)) continue; nbt = Tri_on_side(t,i); if (pointer_in_list((POINTER)nbt,ntr,(POINTER*)tr)) continue; seed_queue = add_to_pointer_queue(NULL,seed_queue); seed_queue->pointer = (POINTER)nbt; check_add_tri(&tr,nbt,&ntr,&max_ntr); } seed_queue = delete_from_pointer_queue(pq); } } /* Find seed tri inside the fabric surface ring */ t = find_inner_seed_tri(cc,sf,tf,ntf); if (debugging("collision")) { int ns = (t == NULL) ? 0 : 1; sprintf(dirname,"cross-tris/fabric-seed-%d",front->step); gview_plot_crossing_tris(dirname,tf,ntf,&t,ns); } /* Fill tf list with tris inside the ring */ if (t != NULL) { seed_queue = add_to_pointer_queue(NULL,NULL); seed_queue->pointer = (POINTER)t; check_add_tri(&tf,t,&ntf,&max_ntf); while (seed_queue) { pq = head_of_pointer_queue(seed_queue); t = (TRI*)(pq->pointer); for (i = 0; i < 3; ++i) { if (is_side_bdry(t,i)) continue; nbt = Tri_on_side(t,i); if (pointer_in_list((POINTER)nbt,ntf,(POINTER*)tf)) continue; seed_queue = add_to_pointer_queue(NULL,seed_queue); seed_queue->pointer = (POINTER)nbt; check_add_tri(&tf,nbt,&ntf,&max_ntf); } seed_queue = delete_from_pointer_queue(pq); } } if (debugging("collision")) { sprintf(dirname,"cross-tris/convex-%d",front->step); gview_plot_crossing_tris(dirname,tr,ntr,tf,ntf); } for (i = 0; i < ntf; ++i) { for (j = 0; j < 3; ++j) { p = Point_of_tri(tf[i])[j]; if (pointer_in_list((POINTER)p,npf,(POINTER*)pf)) continue; comp = component_wrt_tri_cluster(Coords(p),sr,tr,ntr); if (comp == ext_comp) { check_add_pt(&pf,p,&npf,&max_npf); nt = set_tri_list_around_point(p,tf[i],&ptris, front->interf); for (k = 0; k < nt; ++k) check_add_tri(&tf,ptris[k],&ntf,&max_ntf); } status = nearest_point_to_tri_cluster(Coords(p),int_comp, sr,tr,ntr,&tr_on,&id,nearest_pt,nor); add_neighbors_of_landing_tri(&tr,&ntr,sr,&max_ntr,tr_on); } } if (debugging("collision")) { (void) printf("ntr = %d ntf = %d npf = %d\n",ntr,ntf,npf); } *tr_list = tr; *num_trs = ntr; *tf_list = tf; *num_tfs = ntf; *pf_list = pf; *num_pfs = npf; } /* end set_tr_tf_pf_list */
LOCAL void fabric_rigid_collision( Front *front, C_CURVE *cc) { int i,j,k,num_trs,num_tfs,num_pfs; TRI **tr_list,**tf_list,*tri_on; POINT *p,**pf_list; double scaled_gap_tol = 0.05; double **newpts; SIDE status; SURFACE *sr = NULL; SURFACE *sf = NULL; double nearest_pt[MAXD],nor[MAXD]; double hdir,*h = front->rect_grid->h; COMPONENT int_comp,ext_comp; POINT **pr_list; int num_prs,max_num_prs; int id; char dirname[200]; if (debugging("collision")) (void) printf("Entering fabric_rigid_collision()\n"); for (i = 0; i < 2; ++i) { if (wave_type(cc->s[i]) == NEUMANN_BOUNDARY || wave_type(cc->s[i]) == MOVABLE_BODY_BOUNDARY) sr = cc->s[i]; if (wave_type(cc->s[i]) == ELASTIC_BOUNDARY) sf = cc->s[i]; } if (sr == NULL) { (void) printf("In fabric_rigid_collision(): "); (void) printf("cannot find rigid body surface!\n"); clean_up(ERROR); } ext_comp = exterior_component(front->interf); int_comp = (positive_component(sr) == ext_comp) ? negative_component(sr) : positive_component(sr); set_tr_tf_pf_list(front,cc,&tr_list,&num_trs,&tf_list,&num_tfs, &pf_list,&num_pfs); FT_MatrixMemoryAlloc((POINTER*)&newpts,num_pfs,MAXD,sizeof(double)); for (i = 0; i < num_pfs; ++i) { status = nearest_point_to_tri_cluster(Coords(pf_list[i]),int_comp, sr,tr_list,num_trs,&tri_on,&id,nearest_pt,nor); hdir = grid_size_in_direction(nor,h,3); for (k = 0; k < 3; ++k) newpts[i][k] = nearest_pt[k] + scaled_gap_tol*hdir*nor[k]; } for (i = 0; i < num_pfs; ++i) { for (k = 0; k < 3; ++k) Coords(pf_list[i])[k] = newpts[i][k]; } if (debugging("collision")) { sprintf(dirname,"cross-tris/after-lifting-%d",front->step); gview_plot_crossing_tris(dirname,tr_list,num_trs,tf_list,num_tfs); } for (i = 0; i < num_pfs; ++i) { COMPONENT comp; p = pf_list[i]; comp = component_wrt_tri_cluster(Coords(p),sr,tr_list, num_trs); } num_prs = max_num_prs = 0; pr_list = NULL; for (i = 0; i < num_trs; ++i) { double v[MAXD]; for (k = 0; k < 3; ++k) { p = Point_of_tri(tr_list[i])[k]; status = nearest_point_to_tri_cluster(Coords(p),int_comp, sf,tf_list,num_tfs,&tri_on,&id,nearest_pt,nor); for (j = 0; j < 3; ++j) { v[j] = Coords(p)[j] - nearest_pt[j]; } if (Dot3d(v,nor) > 0.0) check_add_pt(&pr_list,p,&num_prs,&max_num_prs); } } add_to_debug("tri_cluster"); for (i = 0; i < num_prs; ++i) { p = pr_list[i]; status = nearest_point_to_tri_cluster(Coords(p),int_comp, sf,tf_list,num_tfs,&tri_on,&id,nearest_pt,nor); if (status == ONEDGE) printf("ie = %d\n",id); else printf("\n"); } remove_from_debug("tri_cluster"); if (debugging("collision")) { sprintf(dirname,"cross-tris/before-leaving-%d",front->step); gview_plot_crossing_tris(dirname,tr_list,num_trs,tf_list,num_tfs); } free_these(4,tr_list,tf_list,pf_list,newpts); } /* end fabric_rigid_collision */
EXPORT INTERFACE *remap_interface( INTERFACE *intfc, void (*remap)(POINT*,BOND*,CURVE*,POINT*, BOND*,CURVE*,boolean,RECT_GRID*,POINTER), void (*remap_rect_grid)(INTERFACE*,INTERFACE*, void (*)(POINT*,BOND*,CURVE*, POINT*,BOND*,CURVE*,boolean, RECT_GRID*,POINTER), POINTER), POINTER params) { HYPER_SURF *hs, *nhs; HYPER_SURF_ELEMENT *hse, *nhse; POINT *p, *np; INTERFACE *new_intfc; RECT_GRID *rgr; boolean first = YES; double eps; if (DEBUG) (void) printf("Entering remap_interface(%llu)\n", (long long unsigned int)interface_number(intfc)); if (remap == NULL || remap_rect_grid == NULL) return NULL; if (exists_interface(intfc) != YES) return NULL; if ((new_intfc = copy_interface(intfc)) == NULL) return NULL; rgr = &topological_grid(new_intfc); /* TODO: check for validity at hyper surface boundaries */ (void) next_point(intfc,NULL,NULL,NULL); (void) next_point(new_intfc,NULL,NULL,NULL); while (next_point(intfc,&p,&hse,&hs) && next_point(new_intfc,&np,&nhse,&nhs)) { (*remap)(p,Bond_of_hse(hse),Curve_of_hs(hs),np, Bond_of_hse(nhse),Curve_of_hs(nhs),first,rgr,params); first = NO; } /* Remap the Underlying Grid: */ (*remap_rect_grid)(intfc,new_intfc,remap,params); /* Reset boundary flags */ eps = grid_tolerance(rgr); if (new_intfc->dim == 1) { POINT **pt; for (pt = new_intfc->points; pt && *pt; pt++) { if (boundary_side(Coords(*pt),rgr,eps) == NOT_A_BDRY) set_not_bdry(*pt); else set_is_bdry(*pt); } } if (new_intfc->dim == 2) { CURVE **c; NODE **n; for (n = new_intfc->nodes; n && *n; n++) { if (boundary_side(Coords((*n)->posn),rgr,eps) == NOT_A_BDRY) set_not_bdry(*n); else set_is_bdry(*n); } for (c = new_intfc->curves; c && *c; c++) { BDRY_SIDE side_start, side_end, side; BOND *b; NODE *ns, *ne; ns = (*c)->start; ne = (*c)->end; side_start = boundary_side(Coords(ns->posn),rgr,eps); side_end = boundary_side(Coords(ne->posn),rgr,eps); if ((side_start != side_end) || (side_start == NOT_A_BDRY)) { set_not_bdry(*c); continue; } side = side_start; for (b = (*c)->first; b != (*c)->last; b = b->next) { if (boundary_side(Coords(b->end),rgr,eps) != side) { side = NOT_A_BDRY; break; } } if (side == NOT_A_BDRY) set_not_bdry(*c); else set_is_bdry(*c); } } if (new_intfc->dim == 3) { CURVE **c; NODE **n; SURFACE **s; for (n = new_intfc->nodes; n && *n; n++) { if (boundary_side(Coords((*n)->posn),rgr,eps) == NOT_A_BDRY) set_not_bdry(*n); else set_is_bdry(*n); } for (c = new_intfc->curves; c && *c; c++) { BDRY_SIDE side_start, side_end, side; BOND *b; NODE *ns, *ne; ns = (*c)->start; ne = (*c)->end; side_start = boundary_side(Coords(ns->posn),rgr,eps); side_end = boundary_side(Coords(ne->posn),rgr,eps); if ((side_start != side_end) || (side_start == NOT_A_BDRY)) { set_not_bdry(*c); continue; } side = side_start; for (b = (*c)->first; b != (*c)->last; b = b->next) { if (boundary_side(Coords(b->end),rgr,eps) != side) { side = NOT_A_BDRY; break; } } if (side == NOT_A_BDRY) set_not_bdry(*c); else set_is_bdry(*c); } for (s = new_intfc->surfaces; s && *s; s++) { TRI *t; BDRY_SIDE side0, side1, side2, side; const double *p0, *p1, *p2; t = first_tri(*s); p0 = Coords(Point_of_tri(t)[0]); p1 = Coords(Point_of_tri(t)[1]); p2 = Coords(Point_of_tri(t)[2]); side0 = boundary_side(p0,rgr,eps); side1 = boundary_side(p1,rgr,eps); if ((side0 != side1) || (side0 == NOT_A_BDRY)) { set_not_bdry(*s); continue; } side = side0; side2 = boundary_side(p2,rgr,eps); if (side2 != side0) { set_not_bdry(*s); continue; } for (t = t->next; !at_end_of_tri_list(t,*s); t = t->next) { p0 = Coords(Point_of_tri(t)[0]); p1 = Coords(Point_of_tri(t)[1]); p2 = Coords(Point_of_tri(t)[2]); if ((boundary_side(p0,rgr,eps) != side) || (boundary_side(p1,rgr,eps) != side) || (boundary_side(p2,rgr,eps) != side)) { side = NOT_A_BDRY; break; } } if (side == NOT_A_BDRY) set_not_bdry(*s); else set_is_bdry(*s); } } if (DEBUG) (void) printf("Leaving remap_interface()\n\n"); return new_intfc; } /*end remap_interface*/
LOCAL void add_intfc_blk_pcs3d( int num_tris, TRI **tris, SURFACE **surfs, BLK_EL0 *blk_el0, P_LINK *hash_table, int h_size) { POINT_COMP_ST *pcs = blk_el0_pcs_els(blk_el0); TRI *t, *tri; SURFACE *s; BOND *b; BOND_TRI **btris; POINT *p; int i,j,k, npcs; TG_PT *tp; Locstate sl,sr; /* reset points in block tris */ for (i = 0; i < num_tris; ++i) { t = tris[i]; for (k = 0; k < 3; ++k) sorted(Point_of_tri(t)[k]) = NO; } //see count_num_pcs3d for alloc //#bjet2 add points in the boundary of the surfaces for (i = 0; i < num_tris; ++i) { t = tris[i]; for (k = 0; k < 3; ++k) { if(!is_side_bdry(t, k)) continue; b = Bond_on_side(t, k); for(j = 0; j < 2; j++) { p = Point_of_tri(t)[(k+j)%3]; //two points on side k if(sorted(p)) continue; sorted(p) = YES; tp = (TG_PT*)find_from_hash_table((POINTER)p, hash_table, h_size); for(btris = Btris(b); btris && *btris; btris++) { tri = (*btris)->tri; s = (*btris)->surface; slsr(p,Hyper_surf_element(tri),Hyper_surf(s),&sl,&sr); npcs = num_pcs_els_in_blk(blk_el0); pcs[npcs].p = tp; pcs[npcs].comp[0] = negative_component(s); pcs[npcs].comp[1] = positive_component(s); pcs[npcs].s[0] = sl; pcs[npcs].s[1] = sr; ++num_pcs_els_in_blk(blk_el0); if(debugging("pcs_cell")) { printf("npcsc %d comp %d %d\n", npcs, pcs[npcs].comp[0], pcs[npcs].comp[1]); print_general_vector("p ", Coords(tp), 3, "\n"); } } //for btris } // for j, two points for a side } // for k, sides for t } // add points in the interior of the surface for (i = 0; i < num_tris; ++i) { t = tris[i]; s = surfs[i]; for (k = 0; k < 3; ++k) { p = Point_of_tri(t)[k]; if (sorted(p) == YES) continue; sorted(p) = YES; tp = (TG_PT*)find_from_hash_table((POINTER)p,hash_table, h_size); slsr(p,Hyper_surf_element(t),Hyper_surf(s),&sl,&sr); npcs = num_pcs_els_in_blk(blk_el0); pcs[npcs].p = tp; pcs[npcs].comp[0] = negative_component(s); pcs[npcs].comp[1] = positive_component(s); pcs[npcs].s[0] = sl; pcs[npcs].s[1] = sr; ++num_pcs_els_in_blk(blk_el0); if(debugging("pcs_cell")) { printf("npcs %d comp %d %d\n", npcs, pcs[npcs].comp[0], pcs[npcs].comp[1]); print_general_vector("p ", Coords(tp), 3, "\n"); } } } } /* end add_intfc_blk_pcs3d */
LOCAL bool tri_side_consistent( TRI *tri, TRI_NEIGHBOR *neighbor, int side, INTERFACE *intfc) { TRI *side_tri; POINT *ps = Point_of_tri(tri)[side]; POINT *pe = Point_of_tri(tri)[Next_m3(side)]; bool status = YES; int i, bd; bd = Boundary_tri(tri); if (bd < 0 || bd > 7) { (void) printf("WARNING in tri_side_consistent(), " "Boundary_tri(tri) = %d is bad\n", bd); print_tri(tri,intfc); status = NO; } if (neighbor == NULL) { if (!allow_null_sides) { (void) printf("WARNING in tri_side_consistent(), " "neighbor is null\n"); print_tri(tri,intfc); status = NO; } } else if (is_side_bdry(tri,side)) { BOND *b; BOND_TRI *bt = neighbor->btri; BOND_TRI **btris; ORIENTATION orient; bool btri_is_in_list; int num_tri_in_btri; if (bt == NULL) { (void) printf("WARNING in tri_side_consistent(), " "NULL BOND_TRI on tri side %d\n",side); print_tri(tri,intfc); status = NO; } else if ((b = bt->bond) == NULL) { (void) printf("WARNING in tri_side_consistent(), " "NULL bond on BOND_TRI on side %d\n",side); print_tri(tri,intfc); status = NO; } else { btri_is_in_list = NO; for (num_tri_in_btri = 0, btris = Btris(b); btris && *btris; ++btris) { if ((*btris)->tri == tri) { ++num_tri_in_btri; if (bt == *btris) btri_is_in_list = YES; } } if (num_tri_in_btri == 0) { (void) printf("WARNING in tri_side_consistent(), " "Tri is not on bond btris list,\n"); (void) printf("ps(%llu) - (%g, %g, %g), ", point_number(ps), Coords(ps)[0],Coords(ps)[1],Coords(ps)[2]); (void) printf("\tpe(%llu) - (%g, %g, %g)\n", point_number(pe), Coords(pe)[0],Coords(pe)[1],Coords(pe)[2]); (void) printf("tri - \n"); print_tri(tri,intfc); (void) printf("bond - \n"); print_bond(b); status = NO; } else if (num_tri_in_btri != 1) { (void) printf("WARNING in tri_side_consistent(), Tri is " "in bond btris list more than once,\n"); (void) printf("ps(%llu) - (%g, %g, %g), ", point_number(ps), Coords(ps)[0],Coords(ps)[1],Coords(ps)[2]); (void) printf("\tpe(%llu) - (%g, %g, %g)\n", point_number(pe), Coords(pe)[0],Coords(pe)[1],Coords(pe)[2]); (void) printf("tri - \n"); print_tri(tri,intfc); (void) printf("bond - \n"); print_bond(b); status = NO; } if (!btri_is_in_list) { (void) printf("WARNING in tri_side_consistent(), Bond tri " "is not in bond btris list,\n"); (void) printf("ps(%llu) - (%g, %g, %g), ", point_number(ps), Coords(ps)[0],Coords(ps)[1],Coords(ps)[2]); (void) printf("\tpe(%llu) - (%g, %g, %g)\n", point_number(pe), Coords(pe)[0],Coords(pe)[1],Coords(pe)[2]); (void) printf("tri - \n"); print_tri(tri,intfc); (void) printf("bond - \n"); print_bond(b); status = NO; } orient = orientation_of_bond_at_tri(b,tri); if (orient == ORIENTATION_NOT_SET) { (void) printf("WARNING in tri_side_consistent(), " "Tri side points not on bond,\n"); (void) printf("ps(%llu) - (%g, %g, %g), ", point_number(ps), Coords(ps)[0],Coords(ps)[1],Coords(ps)[2]); (void) printf("\tpe(%llu) - (%g, %g, %g)\n", point_number(pe), Coords(pe)[0],Coords(pe)[1],Coords(pe)[2]); (void) printf("tri - \n"); print_tri(tri,intfc); (void) printf("bond - \n"); print_bond(b); status = NO; } if (orient != bt->orient) { (void) printf("WARNING in tri_side_consistent(), " "inconsistent bond tri orientation,\n"); (void) printf("ps(%llu) - (%g, %g, %g), ", point_number(ps), Coords(ps)[0],Coords(ps)[1],Coords(ps)[2]); (void) printf("\tpe(%llu) - (%g, %g, %g)\n", point_number(pe), Coords(pe)[0],Coords(pe)[1],Coords(pe)[2]); (void) printf("tri - \n"); print_tri(tri,intfc); (void) printf("bond - \n"); print_bond(b); status = NO; } } } else { if ((side_tri = neighbor->tri) == NULL) { if (!allow_null_sides) { status = NO; (void) printf("WARNING in tri_side_consistent(), " "neighbor->tri == NULL\n"); (void) printf("tri - \n"); print_tri(tri,intfc); } } else { for (i = 0; i < 3; ++i) { if (Tri_on_side(side_tri,i) == tri) { POINT *p0, *p1; p0 = Point_of_tri(side_tri)[i]; p1 = Point_of_tri(side_tri)[Next_m3(i)]; if (p0 != pe || p1 != ps) { (void) printf("WARNING in tri_side_consistent(), " "Points on side %d do not match,\n",i); (void) printf("ps(%llu) - (%g, %g, %g), ", point_number(ps), Coords(ps)[0], Coords(ps)[1], Coords(ps)[2]); (void) printf("\tpe(%llu) - (%g, %g, %g)\n", point_number(pe), Coords(pe)[0], Coords(pe)[1], Coords(pe)[2]); (void) printf("p1(%llu) - (%g, %g, %g), ", point_number(p1), Coords(p1)[0], Coords(p1)[1], Coords(p1)[2]); (void) printf("\tp0(%llu) - (%g, %g, %g)\n", point_number(p0), Coords(p0)[0], Coords(p0)[1], Coords(p0)[2]); (void) printf("tri - "); print_tri(tri,intfc); (void) printf("side_tri - "); print_tri(side_tri,intfc); status = NO; } break; } } if (i == 3) { (void) printf("WARNING in tri_side_consistent(), " "No side matches tri\n"); (void) printf("ps(%llu): (%g, %g, %g), " "\tpe(%llu): (%g, %g, %g)\n", point_number(ps), Coords(ps)[0],Coords(ps)[1],Coords(ps)[2], point_number(pe), Coords(pe)[0],Coords(pe)[1],Coords(pe)[2]); (void) printf("tri - \n"); print_tri(tri,intfc); (void) printf("side_tri - \n"); print_tri(side_tri,intfc); status = NO; } } } return status; } /*end tri_side_consistent*/