Beispiel #1
0
LOCAL void verbose_ses_print_curve_states(
	CURVE 		  *curve,
	SESAME_TABLE_TYPE eos_type,
	SESAME_EOS	  *seos)
{
	BOND 	*bb;

	(void) printf("EOS states on curve %llu\n",curve_number(curve));
	verbose_ses_print_state("Left state",Coords(curve->start->posn),
	      left_start_state(curve),eos_type,seos);
	verbose_ses_print_state("Right state",Coords(curve->start->posn),
	      right_start_state(curve),eos_type,seos);
	for (bb = curve->first; bb != NULL; bb = bb->next)
	{
	    verbose_ses_print_state("Left state",Coords(bb->end),
			            left_state_at_point_on_curve(bb->end,bb,
								 curve),
			            eos_type,seos);
	    verbose_ses_print_state("Right state",Coords(bb->end),
			            right_state_at_point_on_curve(bb->end,bb,
								  curve),
			            eos_type,seos);
	}
	(void) printf("End of EOS states on curve %llu\n",curve_number(curve));
}		/*end verbose_ses_print_curve_states*/
Beispiel #2
0
LOCAL	bool i_consistent_interface2d(
	INTERFACE	*intfc)
{
	CURVE              **c;
	NODE               **n;
	bool               status = YES;
	const char         *warn = "WARNING in i_consistent_interface(), ";

	/* Check Nodes */
	for (n = intfc->nodes; n && *n; ++n)
	{
	    if ((*n)->interface != intfc)
	    {
		(void) printf("%s n = %llu n->interface (%llu) != intfc (%llu)\n",
			      warn,node_number(*n),
			      interface_number((*n)->interface),
			      interface_number(intfc));
		status = NO;
	    }
	    for (c = (*n)->in_curves; c && *c; ++c)
	    {
		if ((*c)->end != *n)
		{
		    (void) printf("%s inconsistent node (%llu) "
				  "curve (%llu) pair, "
				  "curve->end != n\n",
				  warn,node_number(*n),curve_number(*c));
		    status = NO;
		}
	    }
	    for (c = (*n)->out_curves; c && *c; ++c)
	    {
		if ((*c)->start != *n)
		{
		    (void) printf("%s inconsistent node (%llu) "
				  "curve (%llu) pair, "
				  "curve->start != n\n",
				  warn,node_number(*n),curve_number(*c));
		    status = NO;
		}
	    }
	}

	/* Check Curves */
	for (c = intfc->curves; c && *c; c++)
	{
	    if (!check_curve2d(*c,intfc))
	    {
	        (void) printf("%s inconsistency in curve (%llu) found\n",
			      warn,curve_number(*c));
		status = NO;
	    }
	}
	return status;

}	/* end i_consistent_interface2d */
Beispiel #3
0
LOCAL int advance_front2d(
	double    dt,
	double    *dt_frac,
	Front    *front,
	Front    **newfront,
	POINTER  wave)
{
	CURVE      *oldc,*tempc,*newc;
	CURVE	   **c;
	INTERFACE  *tempintfc;
	NODE 	   *oldn,*tempn,*newn;
	NODE_FLAG  flag;
	RPROBLEM   *rp;
	RPROBLEM   *rp1;
	boolean	   scatter_normally_propagated_front = YES;
	boolean	   scatter_tangentially_propagated_front = YES;
	boolean	   stat;
	boolean       do_redist;
	int        status;
	long       intfc_modified;
	long       redo_advance_front;
	static const char *fname = "advance_front2d()";
	int	   debug_flag = NO;

	debug_print("front","Entered %s(step %d time %g dt %g)\n",fname,
	        	        front->step,front->time,dt);
	debug_front("old_front","into advance front",front);

	*newfront = copy_front(front);
	Interface_redistributed(*newfront) = NO;
	do_redist = (front->num_mts == 0) ? YES : NO;

begin_advance_front2d:
	redo_advance_front = 0;
	tempintfc = NULL;
	rp = NULL;
	set_to_next_node_only(flag);

	set_node_doubly_linked_list(front->interf);

	        /* Initialize Newfront */

	start_clock("init_new_front");
	capture_waves(front);
	print_storage("before init_new_front","ADV_storage");
	        /* TODO: Remove this option!!!!! */
	if (front->init_topology_of_new_interface)
	    status = (*front->init_topology_of_new_interface)(front,*newfront);
	else 
	{
	    set_size_of_intfc_state(size_of_state(front->interf));
	    set_copy_intfc_states(NO);
	    set_add_to_correspond_list(YES);
	    (*newfront)->interf = pp_copy_interface(front->interf);
	    reset_hs_flags_on_intfc((*newfront)->interf);
	    status = ((*newfront)->interf != NULL) ? GOOD_STEP : ERROR_IN_STEP;
	    set_copy_intfc_states(YES);
	}
	if (front->pp_grid)
	    status = syncronize_time_step_status(status,front->pp_grid);
	if (status != GOOD_STEP) 
	{
	    (void) printf("WARNING in advance_front2d(), "
	                  "unable to copy interface\n");
	    status = ERROR_IN_STEP;
	    stop_clock("init_new_front");
	    return return_advance_front(front,newfront,status,fname);
	}
	print_storage("after init_new_front","ADV_storage");
	stop_clock("init_new_front");

	        /* Set Default Propagation Limits */

	set_propagation_limits(front,*newfront);

	        /* Propagate the Curves */

	if (front->intfc_propagate != NULL)
	{
	    start_clock("intfc_propagate");
	    intfc_propagate(front,wave,front->interf,(*newfront)->interf,dt);
	    debug_front("cp_front","after intfc prop",*newfront);
	    stop_clock("curve_propagate");
	}
	else if (front->curve_propagate != NULL) 
	{
	    start_clock("curve_propagate");
	    if (debugging("front"))
	    	(void) printf("Loop over Curves\n");
	    for (c = front->interf->curves; c && *c; ++c)
	    {
	        oldc = *c;
	        if (((newc = correspond_curve(oldc)) != NULL) &&
	    	     (correspond_curve(newc) != NULL))
	        {
	    	    if (debugging("propagate"))
	                (void) printf("\t\tpropagating curve %llu\n",
		                      (long long unsigned int)curve_number(oldc));
		    curve_propagate(front,wave,oldc,newc,dt);
		    /*f_curve_propagate2d */
		}
	    }
	    debug_front("cp_front","after curve prop",*newfront);
	    stop_clock("curve_propagate");
	}

		/* Propagate the Nodes */

	if (debugging("front"))
	{
	    print_correspond_hyper_surf_list(front->interf);
	    print_correspond_hyper_surf_list((*newfront)->interf);
	}
	if (front->node_propagate != NULL) 
	{
	    start_clock("node_propagate");
	    set_corresponds_for_node_prop(front->interf,(*newfront)->interf);
	    oldn = first_node(front->interf);
	    while (oldn != NULL) 
	    {
	        newn = correspond_node(oldn);
	        if (debugging("crx_status"))
	            print_linked_node_list((*newfront)->interf);
	        status = (newn != NULL) ?
	            (*front->node_propagate)(front,wave,oldn,newn,&rp,
	        			     dt,dt_frac,flag,NULL) : GOOD_NODE;

	        if (debugging("crx_status"))
	        if (is_bad_status(status) &&
	          (point_in_buffer(Coords(oldn->posn),front->rect_grid) == YES))
	        {
	            print_node_status("WARNING in advance_front2d(), "
	                              "node_propagation returns ",status,"\n");
	            (void) printf("Problem occurs in buffer zone - ignoring\n");
	            if (set_node_states_and_continue(oldn,newn,front))
	                status = GOOD_NODE;
	        }

	        switch (status) 
	        {
	        case GOOD_NODE:
	            oldn = adv_node_loop_after_good_prop(oldn,newn,&rp);
	            break;
	        case PSEUDOCROSS_NODE_NODE:
	            debug_print("PSEUDOCROSS","PSEUDOCROSS case\n");
	            oldn = reorder_node_loop(oldn,newn);
	            break;
	        case CROSS_NODE_NODE:
	        case BIFURCATION_NODE:
	            debug_print("CROSS","CROSS case\n");
	            oldn = next_node(oldn);
	            break;
	        case CROSS_PAST_CURVE_NODE:
	            print_node_status("WARNING in advance_front2d(), "
	                              "node_propagate failed with status ",
				      status,"\n");
	            print_node(oldn);
	            if (debugging("CROSS_PAST"))
	            {
	                (void) printf("Cross past curve case\n"
	                              "dt_frac = %g\n",*dt_frac);
	                (void) printf("Reducing time step\n");
	            }
		    status = node_modify_time_step(oldn,front,dt_frac,
					           MODIFY_TIME_STEP);
	            free_rp_list(&rp);
	            goto sync_prop_stat1;
	        case MODIFY_TIME_STEP_NODE:
	            (void) printf("WARNING in advance_front2d(), "
	                          "node_propagate returns "
	                          "MODIFY_TIME_STEP_NODE\n");
	            free_rp_list(&rp);
		    status = node_modify_time_step(oldn,front,NULL,
						   MODIFY_TIME_STEP);
	            goto sync_prop_stat1;
	        case REPEAT_TIME_STEP_NODE:
	            (void) printf("WARNING in advance_front2d(), "
	                          "node_propagate returns "
	                          "REPEAT_TIME_STEP_NODE\n");
	            free_rp_list(&rp);
		    status = node_modify_time_step(oldn,front,NULL,
					           REPEAT_TIME_STEP);
	            goto sync_prop_stat1;
	        case NO_CROSS_NODE:
	            print_node_status("WARNING in advance_front2d(), "
	                              "node_propagate failed with status ",
	                              status,"\n");
	            print_node(oldn);
	            if (debugging("NO_CROSS"))
	            {
	                (void) printf("No cross case\n");
	                (void) printf("dt_frac = %g\n",*dt_frac);
	                (void) printf("Reducing time step\n");
	            }
	            free_rp_list(&rp);
		    status = node_modify_time_step(oldn,front,dt_frac,
					           MODIFY_TIME_STEP);
	            goto sync_prop_stat1;
	        case ERROR_NODE:
	        default:
	            print_node_status("WARNING in advance_front2d(), "
	                              "node_propagate failed with status ",
	                              status,"\n");
	            print_node(oldn);
	            if (debugging("ERROR_NODE"))
	            {
	                (void) printf("Old interface:\n");
	                print_interface(front->interf);
	                print_correspond_hyper_surf_list(front->interf);
	                (void) printf("New interface:\n");
	                print_interface((*newfront)->interf);
	                print_correspond_hyper_surf_list((*newfront)->interf);
	            }
		    status = node_modify_time_step(oldn,front,dt_frac,
					           ERROR_IN_STEP);
	            free_rp_list(&rp);
	            goto sync_prop_stat1;
	        }
	    } /* end of while (oldn != NULL) */
	    set_correspond_hyper_surf_bdrys_to_NULL(front->interf);
	    set_correspond_hyper_surf_bdrys_to_NULL((*newfront)->interf);
	    if (rp && (front->twodrproblem != NULL)) 
	    {
	        for (rp1 = rp; rp1; rp1 = rp1->prev) 
	        {
	            debug_front("2drp_front",
	                "new between node loop and rp loop",*newfront);
	                    
	            status = (*front->twodrproblem)(front,*newfront,wave,&rp1);

	            /* At this point, rp is nothing more than a valid element
	             * of the list which provides a starting point
	             * for deleting the list.  If we delete an element of
	             * the list in front->twodrproblem (presumably due to
	             * merging two RPROBLEM's), then rp may point to freed
	             * storage and will need to be updated.  rp1 should still
	             * be a valid element of the list.
	             */
	            rp = rp1;

		    if (status != GOOD_STEP)
		    {
	                print_time_step_status("WARNING in advance_front2d(), "
					       "rp failed with status = ",
					       status,"\n");
	                switch (status) 
	                {
	                case GOOD_STEP:
			    break;

		        case REPEAT_TIME_STEP:
	                    break;

	                case MODIFY_TIME_STEP:
		            status = rp_modify_time_step(rp1,front,status);
			    if (status == MODIFY_TIME_STEP)
			    {
	                        *dt_frac = rp1->dt_frac;
	                        if (debugging("2drp"))
	                        {
	                            print_rproblem(rp1);
	                            (void) printf("dt_frac %g\n",*dt_frac);
	                            (void) printf("Reducing time step\n");
	                        }
			        *dt_frac = limit_dt_frac(*dt_frac,front);
			    }
	                    break;

	                case ERROR_IN_STEP:
	                default:
	                    print_rproblem(rp1);
	                    /* Try reducing the time step */
		            status = rp_modify_time_step(rp1,front,status);
	                    if (status == MODIFY_TIME_STEP)
	                        *dt_frac *=
				    TIME_STEP_REDUCTION_FACTOR(front->interf);
	                    break;
	                }
		    }
	            if (status != GOOD_STEP)
			break;
	        }
	        free_rp_list(&rp);
	        debug_front("2drp_front","after 2drp loop",*newfront);
	    }
	    else if (rp) 
	    {
	        for (rp1 = rp; rp1; rp1 = rp1->prev) 
	            print_rproblem(rp1);
	        free_rp_list(&rp);
	        (void) printf("WARNING in advance_front2d(), "
	                      "CROSS code needed\n");
	        status = ERROR_IN_STEP;
	    }

sync_prop_stat1:
	    stop_clock("node_propagate");
	    if (front->pp_grid)
	    	status = syncronize_time_step_status(status,front->pp_grid);
	    if (status != GOOD_STEP)
	        return return_advance_front(front,newfront,status,fname);
	}
	if (*front->max_scaled_propagation > 0.5)
	{
	    (void) printf("WARNING in advance_front2d(), "
	                  "front->max_scaled_propagation = %f\n",
			  *(front->max_scaled_propagation));
	    *dt_frac = 0.4/(*front->max_scaled_propagation);
	    status = MODIFY_TIME_STEP;
	    goto sync_prop_stat2;
	}

	stat = consistent_propagated_loop_orientations(dt,dt_frac,front,wave);
	if (stat == NO)
	{
	    (void) printf("WARNING in advance_front2d(), "
		          "Inconsistent orientation of propagated loop "
	                  "detected after point and node propagations");
	    if (pp_numnodes() > 1)
		(void) printf(" on processor %d\n",pp_mynode());
	    else
		(void) printf("\n");
	}
	if (pp_min_status(stat) == NO)
	{
	    if (stat == YES)
	    {
	        (void) printf("WARNING in advance_front2d(), "
		              "Inconsistent orientation of propagated loop "
	                      "detected on a remote processor "
			      "after point and node propagations ");
	    }
	    status = MODIFY_TIME_STEP;
	    goto sync_prop_stat2;
	}

	/* Make Temp Interface for Tangential Propagation */

	set_node_doubly_linked_list((*newfront)->interf);
	if (front->snd_node_propagate) 
	{
	    start_clock("snd_copy_interface");
	    print_storage("before snd_copy_interface","ADV_storage");
	    tempintfc = (*newfront)->interf;
	    set_size_of_intfc_state(size_of_state(tempintfc));
	    set_add_to_correspond_list(YES);
	    if (((*newfront)->interf = pp_copy_interface(tempintfc)) == NULL)
	    {
	    	(void) printf("WARNING in advance_front2d(), "
		              "unable to copy interface\n");
		status = ERROR_IN_STEP;
		goto sync_prop_stat2;
	    }
	    copy_hypersurface_flags((*newfront)->interf);
	    print_storage("after snd_copy_interface","ADV_storage");
	    stop_clock("snd_copy_interface");
	}
	interpolate_intfc_states((*newfront)->interf) = YES;

	/* Second Propagation for the States Around the Nodes */

	if (front->snd_node_propagate) 
	{
	    start_clock("snd_node_propagate");
	    if (debugging("front"))
	    	(void) printf("Second Loop over Nodes\n");

	    tempn = first_node(tempintfc);
	    newn = first_node((*newfront)->interf);
	    while (newn != NULL)
	    {
	    	(*front->snd_node_propagate)(front,*newfront,wave,
	    				     tempintfc,tempn,newn,dt);
	    	tempn = next_node(tempn);
	    	newn = next_node(newn);
	    }

	    debug_front("snd_front","after snd_node prop",*newfront);
	    stop_clock("snd_node_propagate");
	}

	if (tempintfc)
	    (void) delete_interface(tempintfc);
	print_storage("after delete tempintfc","ADV_storage");

		/* Redistribute the New Front */

	switch (redistribute(*newfront,do_redist,NO)) 
	{
	case	GOOD_REDISTRIBUTION:
	    status = GOOD_STEP;
	    break;
	
	case	UNABLE_TO_UNTANGLE:
	    (void) printf("WARNING in advance_front2d(), "
	                  "redistribution of front failed\n"
	                  "Restarting advance_front2d()\n");
	    *dt_frac = Min_time_step_modification_factor(front);
	    status = MODIFY_TIME_STEP;
	    break;

	case	MODIFY_TIME_STEP_REDISTRIBUTE:
	    (void) printf("WARNING in advance_front2d(), "
	                  "redistribute returns\n"
	                  "\t\tMODIFY_TIME_STEP_REDISTRIBUTE, dt_frac = %g\n",
			  *dt_frac);
	    *dt_frac = Min_time_step_modification_factor(front);
	    status = MODIFY_TIME_STEP;
	    break;
		
	case	BAD_REDISTRIBUTION:
	default:
	    (void) printf("WARNING in advance_front2d(), "
	                  "redistribution of front failed\n");
	    debug_front("ERROR_front","after error",*newfront);
	    *dt_frac = Min_time_step_modification_factor(front);
	    status = MODIFY_TIME_STEP;
	    break;
	}
	if (front->pp_grid)
	    status = syncronize_time_step_status(status,front->pp_grid);
	if (status != GOOD_STEP)
	    return return_advance_front(front,newfront,status,fname);

	Redistribution_count(front) = Redistribution_count(*newfront);
	(*newfront)->step = front->step + 1;
	(*newfront)->time = front->time + dt;
	debug_front("redist_front","after redistribution",*newfront);

	/* Communicate topologically propagated front */
	if (scatter_normally_propagated_front == YES)
	{
	    start_clock("scatter_front");
	    if (!scatter_front(*newfront))
	    {
	    	(void) printf("WARNING in advance_front2d(), "
	    	              "scatter_front() failed for "
	    	              "normally propagated front\n");
	    	scatter_normally_propagated_front = NO;
	    	scatter_tangentially_propagated_front = NO;
	    	(void) delete_interface((*newfront)->interf);
	    	(*newfront)->interf = NULL;
	    	goto begin_advance_front2d;
	    }
	    stop_clock("scatter_front");
	}

	debug_front("node_front","after node loop",*newfront);
	if (debugging("front"))
	{
	    print_correspond_hyper_surf_list(front->interf);
	    print_correspond_hyper_surf_list((*newfront)->interf);
	}

	if (front->mass_consv_diagn_driver)
	    (*front->mass_consv_diagn_driver)(front,wave,dt);

	if (debugging("bond_lengths"))
	    check_bond_lengths((*newfront)->interf);

	/* Check for the geometric orientation of loops */

	/* ONLY check loops that will not be deleted !!!! */
	delete_small_loops(*newfront);

		/* Delete non-boundary curves that lie  */
		/* fully on or exterior to the boundary */

	delete_exterior_curves(*newfront,front->interf);
	intfc_delete_fold_back_bonds(*newfront);
	debug_front("dec_front","after delete_exterior_curves:",*newfront);

	interpolate_intfc_states((*newfront)->interf) = YES;

	/* Make Temp Interface for Tangential Propagation */

	if (front->tan_curve_propagate) 
	{
	    start_clock("snd_copy_interface");
	    print_storage("before snd_copy_interface","ADV_storage");
	    tempintfc = (*newfront)->interf;
	    set_size_of_intfc_state(size_of_state(tempintfc));
	    set_add_to_correspond_list(YES);
	    if (((*newfront)->interf = pp_copy_interface(tempintfc)) == NULL)
	    {
	    	(void) printf("WARNING in advance_front2d(), "
		              "unable to copy interface\n");
		status = ERROR_IN_STEP;
		goto sync_prop_stat2;
	    }
	    copy_hypersurface_flags((*newfront)->interf);
	    interpolate_intfc_states((*newfront)->interf) = YES;
	    print_storage("after snd_copy_interface","ADV_storage");
	    stop_clock("snd_copy_interface");
	}

	/* Tangential Sweep for States on the Curves */

	if (front->tan_curve_propagate) 
	{
	    start_clock("tan_curve_propagate");
	    if (debugging("front"))
	    	(void) printf("Second Loop over Curves\n");
	    for (c = tempintfc->curves; c && *c; ++c)
	    {
	    	tempc = *c;
	    	newc = correspond_curve(tempc);
	    	(*front->tan_curve_propagate)(front,*newfront,
	    				      tempintfc,tempc,newc,dt);
	    }
	    debug_front("tcp_front","after tan_curve_propagate:",*newfront);
	    stop_clock("tan_curve_propagate");
	}
	if (tempintfc)
	    (void) delete_interface(tempintfc);
	print_storage("after delete tempintfc","ADV_storage");


		/* Provide robustness for untangle algorithms */

		/*   delete remnants of scalar physical   */
		/*  curves sticking to NEUMANN boundaries */
		/* Add to delete_exterior_curves()? */

	if (pp_min_status(delete_phys_remn_on_bdry(*newfront)) == NO)
	{
	    (void) printf("WARNING in advance_front2d(), "
	                  "delete_phys_remn_on_bdry() detected error\n");
	    debug_front("ERROR_front","after error",*newfront);
	    *dt_frac = Min_time_step_modification_factor(front);
	    status = MODIFY_TIME_STEP;
	    goto sync_prop_stat2;
	}
	debug_front("dspr_front",
		    "after 1st delete_phys_remn_on_bdry():",*newfront);

sync_prop_stat2:
	if (front->pp_grid)
	    status = syncronize_time_step_status(status,front->pp_grid);
	if (status != GOOD_STEP)
	    return return_advance_front(front,newfront,status,fname);

	/* Communicate tangentially propagated front */
	if (scatter_tangentially_propagated_front == YES)
	{
	    start_clock("scatter_front");
	    if (!scatter_front(*newfront))
	    {
	    	(void) printf("WARNING in advance_front2d(), "
	    	              "scatter_front() failed for "
	    	              "tangentially propagated front\n");
	    	scatter_normally_propagated_front = NO;
	    	scatter_tangentially_propagated_front = NO;
	    	(void) delete_interface((*newfront)->interf);
	    	(*newfront)->interf = NULL;
	    	goto begin_advance_front2d;
	    }
	    stop_clock("scatter_front");
	}

	if (status != GOOD_STEP)
	    return return_advance_front(front,newfront,status,fname);


		/* 	Post-process newfront->interf	   */
		/* Provide robustness after redistribution */
		/*   for node propagate on next time step  */

		/* Delete non-boundary curves that lie  */
		/* fully on or exterior to the boundary */

	delete_exterior_curves(*newfront,front->interf);
	debug_front("dec_front","after delete_exterior_curves:",*newfront);

		/*  delete remnants of scalar physical    */
		/* curves sticking to NEUMANN boundaries  */
		/* Add to delete_exterior_curves()? */

	if (pp_min_status(delete_phys_remn_on_bdry(*newfront)) == NO)
	{
	    (void) printf("WARNING in advance_front2d(), "
	                  "delete_phys_remn_on_bdry() detected error\n");
	    debug_front("ERROR_front","after error",*newfront);
	    *dt_frac = Min_time_step_modification_factor(front);
	    status = MODIFY_TIME_STEP;
	    return return_advance_front(front,newfront,status,fname);
	}
	debug_front("dspr_front",
		    "after 2nd delete_phys_remn_on_bdry():",*newfront);


	/* These guys keep sneaking through !! */
	/* This should be the most effective place for this call */
	/* Brent - I believe it is better to have the function at
	*  the end of advance_front2d() applied to the newfront
	*  instead of at the beginning applied to front.
	*  In general our policy should be never to modify the
	*  old interface data.
	*/
	delete_small_loops(*newfront);
	debug_front("dsloop_front","after delete_small_loops():",*newfront);

	test_for_mono_comp_curves((*newfront)->interf);

	/* Check if post processing has changed topology */

	intfc_modified = (*newfront)->interf->modified;
	pp_global_lmax(&intfc_modified,1L);
	if (intfc_modified)
	{
	    if (!scatter_front(*newfront))
	    {
	    	(void) printf("WARNING in advance_front2d(), "
	    	              "final scatter_front() failed\n");
	    	*dt_frac = Max_time_step_modification_factor(front);
	        return return_advance_front(front,newfront,
		                            MODIFY_TIME_STEP,fname);
	    }
	    stat = make_bond_comp_lists((*newfront)->interf);
	    if (pp_min_status(stat) == FUNCTION_FAILED)
	    {
	    	screen("ERROR in advance_front2d(), "
	    	       "make_bond_comp_lists() failed\n");
	    	clean_up(ERROR);
	    }
	}

	return return_advance_front(front,newfront,GOOD_STEP,fname);
}		/*end advance_front2d*/
Beispiel #4
0
/*ARGSUSED*/
EXPORT	boolean consistent_propagated_loop_orientations(
	double		dt,
	double		*dt_frac,
	Front		*fr,
	POINTER		wave)
{
	static const double AREA_FAC = 0.01;	/*TOLERANCE*/
	static const int   num_attempts = 5;	/*TOLERANCE*/
	CURVE	**c,*oldc,*newc;
	NODE	*oldn, *newn;
	double	dt_f, dT;
	double	A_old, A_new;
	double	min_area = AREA_FAC*fr->rect_grid->h[0]*fr->rect_grid->h[1];
	boolean	status = YES;
	int	i;

	debug_print("orient_consistency",
	      "Entered consistent_propagated_loop_orientations()\n");

	for (c = fr->interf->curves; c && *c; ++c)
	{
	    oldc = *c;
	    if (!is_closed_curve(oldc))
		continue;
	    newc = correspond_curve(oldc);

	    /*TODO: this needs to be solved correctly.*/
	    if ((newc == NULL) || (newc->interface == NULL) ||
	        (!is_closed_curve(newc)))
	    	continue;
	    if (newc->num_points > 20)
	    	continue;	/* sufficiently long curve cannot fully flip */

	    A_old = area_of_closed_curve(oldc);
	    A_new = area_of_closed_curve(newc);

	    if (debugging("orient_consistency"))
	    	(void) printf("A_old = %g, A_new = %g\n",A_old,A_new);

	    if (A_old*A_new > 0.0)
		continue;

	    status = NO;
	    if (debugging("orient_consistency"))
	    {
	    	(void) printf("Loop %llu inverted after propagation\n",
	    		      (long long unsigned int)curve_number(oldc));
	    	(void) printf("Old loop\n");
	    	print_curve(oldc);
	    	(void) printf("Propagated loop\n");
	    	print_curve(newc);
	    }

	    /* Determine dt_frac */

	    if (A_old < min_area)
	    {
	    	*dt_frac *= 0.9;
	    	continue;
	    }

	    dt_f = 1.0;
	    oldn = oldc->start;	newn = newc->start;
	    for (i = 0; i < num_attempts; ++i)
	    {
	    	dt_f *= 0.5;
	    	dT = dt_f * dt;
	    	if (fr->curve_propagate != NULL) 
	    	    curve_propagate(fr,wave,oldc,newc,dT);
		(void) closed_node_propagate(fr,wave,oldn,newn,dT);
		A_new = area_of_closed_curve(newc);

		if (debugging("orient_consistency"))
		{
	            (void) printf("In loop, dt_f = %g, dT = %g, ",dt_f,dT);
		    (void) printf("A_old = %g, A_new = %g\n",A_old,A_new);
		}
		if (A_old*A_new >= 0.0)
		    break;
	    }
	    if (i == num_attempts)
	    {
	        (void) printf("WARNING in "
			      "consistent_propagated_loop_orientations(), "
		              "cannot produce consistent loop "
		              "orientations by reduction of time step\n");
		(void) printf("modifying interface\n");
		(void) delete_curve(newc);
		status = YES;
		continue;
	    }
	    *dt_frac = min(*dt_frac,dt_f);

		/* Restore newc to original state ? 			*/
		/* This is unnecessary if reduce time step is called,   */
		/* as the newc->interface will be deleted, but this	*/
		/* may be desirable for consistency reasons if future	*/
		/* resolutions solve this problem without having to	*/
		/* reduce the time step.  For now this section is	*/
		/* commented out.					*/

	}
	debug_print("orient_consistency",
		"Left consistent_propagated_loop_orientations()\n");
	return status;
}		/*end consistent_propagated_loop_orientation*/
Beispiel #5
0
/* ARGSUSED */
EXPORT	void f_tan_curve_propagate(
	Front		*fr,
	Front		*newfr,
	INTERFACE	*tempintfc,
	CURVE		*tempc,
	CURVE		*newc,
	double		dt)
{
	BOND		    *tempb, *newb;
	Locstate	    ansl, ansr;
	boolean		    curveIsClosed;
	double		    *h = fr->rect_grid->h;
	double		    tngt[MAXD], ds, sbl;
	int		    i, dim = fr->rect_grid->dim;
	static	int	    nrad = 0;
	static	Tan_stencil *sten = NULL;

	debug_print("f_tan_prop","Entered f_tan_curve_propagate()\n");
	if (debugging("f_tan_prop"))
	{
	    (void) printf("tempc %llu  newc %llu\n",(long long unsigned int)curve_number(tempc),
	    	          (long long unsigned int)curve_number(newc));
	    (void) printf("tempc\n");	print_curve(tempc);
	    (void) printf("\nnewc\n");	print_curve(newc);
	}

	if (sten == NULL) 
	{
	    nrad = fr->npts_tan_sten/2;
	    sten = alloc_tan_stencil(fr,nrad);
	}

	switch (wave_type(tempc))
	{
	case PASSIVE_BOUNDARY:
	case SUBDOMAIN_BOUNDARY:
	    return;
	default:
	    break;
	}

	curveIsClosed = (is_closed_node(newc->end)) ? YES : NO;

	tempb = tempc->first;		newb  = newc->first;

		/* Check if zero length curve */

	if (tempc->first == tempc->last)
	{
	    sbl = scaled_bond_length(tempc->first,h,dim);
	    if (sbl < MIN_SC_SEP(tempintfc))
	    {
	    	debug_print("f_tan_prop","Left f_tan_curve_propagate()\n");
	    	return;
	    }
	}

	for (;  newb;  tempb = tempb->next, newb = newb->next)
	{
	    if (t_pt_propagated(newb->end))
	        continue;

	    /* stop at tempc->last if no continuation */

	    if ((tempb == tempc->last) &&
	        !curveIsClosed && !is_fixed_node(newc->end))
	    {
	    	break;
	    }

	    /* calculate tangential displacement */

	    /*
	     *  TODO:  the upgrade of this function
	     *  to 3 dimensions is non-trivial.
	     *  There will need to be either two
	     *  operator splitting sweeps,  or one
	     *  unsplit solver.  There is arbitrary
	     *  choice of tangent directions and this
	     *  will have to be resolved.
	     */

	    tangent(newb->end,newb,newc,tngt,newfr);

	    ds = grid_size_in_direction(tngt,h,dim);

	    /* find the stencil states */

	    states_at_distance_along_curve(tempb->end,tempb,tempc,
			                   NEGATIVE_ORIENTATION,ds,nrad,
			                   sten->leftst-1,sten->rightst-1,
			                   sten->hs-1,sten->hse-1,sten->t-1,
					   sten->p-1,newfr);

	    if (tempb->next != NULL)
	    {
	    	ansl  = left_state(newb->end);
	    	ansr  = right_state(newb->end);
	    }
	    else
	    {
	    	ansl  = left_end_state(newc);
	    	ansr  = right_end_state(newc);
	    }

	    states_at_distance_along_curve(tempb->end,tempb,tempc,
			                   POSITIVE_ORIENTATION,ds,nrad,
			                   sten->leftst+1,sten->rightst+1,
			                   sten->hs+1,sten->hse+1,sten->t+1,
					   sten->p+1,newfr);

	    sten->p[0] = tempb->end;
	    sten->hse[0] = Hyper_surf_element(tempb);
	    sten->hs[0] = Hyper_surf(tempc);
	    sten->t[0] = 1.0;
	    sten->curvature = mean_curvature_at_point(sten->p[0],sten->hse[0],
	                                              sten->hs[0],fr);

	    if (debugging("f_tan_prop")) 
	    {
	    	int        j;
	    	static const char *xyz[3] = { "x", "y", "z" };

	        (void) printf("state locations\n");
		(void) printf("%-8s"," ");
		for (i = 0; i < dim; ++i)
		    (void) printf("%-14s",xyz[i]);
		(void) printf("\n");
		for (j = -nrad; j <= nrad; ++j)
		{
		    for (i = 0; i < dim; ++i)
			(void) printf("%-14g",Coords(sten->p[j])[i]);
		    (void) printf("\n");
		}
		(void) printf("\n");
		(void) printf("State values\n");
		for (j = -nrad; j <= nrad; ++j)
		{
		    (void) printf("left state[%d] at ",j);
		    print_general_vector("",Coords(sten->p[j]),dim,"\n");
		    (*fr->print_state)(
			left_state_at_point_on_curve(sten->p[j],
						     Bond_of_hse(sten->hse[j]),
					             Curve_of_hs(sten->hs[j])));
		    (void) printf("right state[%d] at ",j);
		    print_general_vector("",Coords(sten->p[j]),dim,"\n");
		    (*fr->print_state)(
	                right_state_at_point_on_curve(sten->p[j],
						      Bond_of_hse(sten->hse[j]),
					              Curve_of_hs(sten->hs[j])));
		    (void) printf("\n");
		}
	    }

	    /* update using n-point stencil tangential op */

	    sten->newhs = Hyper_surf(newc);
	    sten->dir = tngt;
	    npt_tang_solver(ds,dt,sten,ansl,ansr,fr);
            if (fr->parab == YES)
                npt_parab_tan_solver2d(ds,dt,sten,ansl,ansr,fr);
	    t_pt_propagated(newb->end) = YES;

	    if (debugging("f_tan_prop"))
	    {
		(void) printf("answers: left right\n");
		(*newfr->print_state)(ansl);
		(*newfr->print_state)(ansr);
		(void) printf("\n");
	    }
	}

	if (curveIsClosed)
	{
	    /* assign start states to end states */
	    ft_assign(left_start_state(newc),left_end_state(newc),fr->sizest);
	    ft_assign(right_start_state(newc),right_end_state(newc),fr->sizest);
	}
	debug_print("f_tan_prop","Left f_tan_curve_propagate()\n");
}		/*end f_tan_curve_propagate*/
Beispiel #6
0
EXPORT int normal_advance_front2d(
	float    dt,
	float    *dt_frac,
	Front    *front,
	Front    **newfront,
	POINTER  wave)
{
	CURVE      *oldc,*newc;
	CURVE	   **c;
	NODE 	   *oldn,*newn;
	RPROBLEM   *rp,*rp1;
	int        status, node_stat;
        NODE_FLAG  flag;  
	const char *fname = "normal_advance_front2d()";

	debug_print("front","Entered %s(step %d time %g dt %g)\n",fname,
	        	        front->step,front->time,dt);
	debug_front("old_front","into advance front",front);

	*newfront = copy_front(front);
	Interface_redistributed(*newfront) = NO;

        if(front->interf->nodes == NULL)
        {
            bool       sav_copy;
            INTERFACE  *sav_intfc;  
            sav_intfc = current_interface();
            sav_copy = copy_intfc_states();
            set_size_of_intfc_state(size_of_state(front->interf));
            set_copy_intfc_states(YES);
            (*newfront)->interf = copy_interface(front->interf);
            set_current_interface(sav_intfc);
            set_copy_intfc_states(sav_copy);
            return return_advance_front(front,newfront,GOOD_STEP,fname);  
        }

	rp = NULL;

        set_to_next_node_only(flag);  

	set_node_doubly_linked_list(front->interf);

	        /* Initialize Newfront */

	start_clock("init_new_front");
	capture_waves(front);
	print_storage("before init_new_front","ADV_storage");
	        /* TODO: Remove this option!!!!! */
	if (front->init_topology_of_new_interface)
	    status = (*front->init_topology_of_new_interface)(front,*newfront);
	else 
	{
	    set_size_of_intfc_state(size_of_state(front->interf));
	    set_copy_intfc_states(NO);
	    set_add_to_correspond_list(YES);
            /* 
            If USE_OVERTURE, can not syncronize_time_step at here 
	    (*newfront)->interf = pp_copy_interface(front->interf);
            */ 
	    (*newfront)->interf = copy_interface(front->interf);
	    reset_hs_flags_on_intfc((*newfront)->interf);
	    status = ((*newfront)->interf != NULL) ? GOOD_STEP : ERROR_IN_STEP;
	    set_copy_intfc_states(YES);
	}
        if (status != GOOD_STEP)
        {
            (void) printf("ERROR in normal_advance_front2d(), "
                          "unable to copy interface\n");
            print_storage("after init_new_front","ADV_storage");
            clean_up(ERROR);
        }
	print_storage("after init_new_front","ADV_storage");
	stop_clock("init_new_front");

	        /* Set Default Propagation Limits */

	set_propagation_limits(front,*newfront);

	        /* Propagate the Curves */

	if (front->curve_propagate != NULL) 
	{
	    start_clock("curve_propagate");
	    if (debugging("front"))
	    	(void) printf("Loop over Curves\n");
	    for (c = front->interf->curves; c && *c; c++)
	    {
	        oldc = *c;
	        if (((newc = correspond_curve(oldc)) != NULL) &&
	    	     (correspond_curve(newc) != NULL))
	        {
	    	    if (debugging("propagate"))
	                (void) printf("\t\tpropagating curve %lu\n",
		                      curve_number(oldc));
		    curve_propagate(front,wave,oldc,newc,dt);
		}
	    }
	    debug_front("cp_front","after curve prop",*newfront);
	    stop_clock("curve_propagate");
	}

		/* Propagate the Nodes */

	if (debugging("front"))
	{
	    print_correspond_hyper_surf_list(front->interf);
	    print_correspond_hyper_surf_list((*newfront)->interf);
	}
	if (front->node_propagate != NULL) 
	{
	    start_clock("node_propagate");
	    set_corresponds_for_node_prop(front->interf,(*newfront)->interf);
	    oldn = first_node(front->interf);
	    while (oldn != NULL) 
	    {
	        newn = correspond_node(oldn);
	        if (debugging("crx_status"))
	            print_linked_node_list((*newfront)->interf);
                if(DEBUG)
                {
                    /* 
                    printf("IN normal_advance_front2d\n");  
                    printf("node propagate\n");
                    print_node(oldn);
                    print_node(newn); 
                    printf("oldnode is virtual fixed = %s\n",
                       is_virtual_fixed_node(oldn) == YES ?
                       "YES" : "NO"); 
                    printf("newnode is virtual fixed = %s\n",
                       is_virtual_fixed_node(newn) == YES ?
                       "YES" : "NO"); 
                    printf("End of print new and old nodes\n");  
                    */  
                } 
	        status = (newn != NULL) ?
	            (*front->node_propagate)(front,wave,oldn,newn,&rp,
	        			     dt,dt_frac,flag,NULL) : GOOD_NODE;
	        if (is_bad_status(status) &&
	          (point_in_buffer(Coords(oldn->posn),front->rect_grid) == YES))
	        {
	            (void) printf("WARNING in normal_advance_front2d(), "
	                          "node_propagation returns ");
                    print_node_status("WARNING in normal_advance_front2d(), "
                                      "node_propagation returns ",status,"\n"); 
                    /* 
	            print_node_status(status);
                    */  
	            (void) printf("Problem occurs in buffer zone - ignoring\n");
	            if (set_node_states_and_continue(oldn,newn,front))
	                status = GOOD_NODE;
	        }

	        switch (status) 
	        {
	        case GOOD_NODE:
	            oldn = adv_node_loop_after_good_prop(oldn,newn,&rp);
	            break;
	        case PSEUDOCROSS_NODE_NODE:
	            debug_print("PSEUDOCROSS","PSEUDOCROSS case\n");
	            oldn = reorder_node_loop(oldn,newn);
	            break;
	        case CROSS_NODE_NODE:
	        case BIFURCATION_NODE:
	            debug_print("CROSS","CROSS case\n");
	            oldn = next_node(oldn);
	            break;
	        case CROSS_PAST_CURVE_NODE:
	            (void) printf("WARNING in normal_advance_front2d(), ");
	            (void) printf("node_propagate failed, ");
                    print_node_status("WARNING in normal_advance_front2d(), "
                                      "node_propagate failed with status ",
                                      status,"\n");
	            print_node(oldn);
	            if (debugging("CROSS_PAST"))
	            {
	                (void) printf("Cross past curve case\n"
	                              "dt_frac = %g\n",*dt_frac);
	                (void) printf("Reducing time step\n");
	            }
	            *dt_frac *= TIME_STEP_REDUCTION_FACTOR(front->interf);
	            free_rp_list(&rp);
	            status = MODIFY_TIME_STEP;
	            goto sync_prop_stat1;
	        case MODIFY_TIME_STEP_NODE:
	            (void) printf("WARNING in normal_advance_front2d(), "
	                          "node_propagate returns "
	                          "MODIFY_TIME_STEP_NODE\n");
	            free_rp_list(&rp);
	            status = MODIFY_TIME_STEP;
	            goto sync_prop_stat1;
	        case REPEAT_TIME_STEP_NODE:
	            (void) printf("WARNING in normal_advance_front2d(), "
	                          "node_propagate returns "
	                          "REPEAT_TIME_STEP_NODE\n");
	            free_rp_list(&rp);
	            status = REPEAT_TIME_STEP;
	            goto sync_prop_stat1;
	        case NO_CROSS_NODE:
	            (void) printf("WARNING in normal_advance_front2d(), ");
	            (void) printf("node_propagate failed, ");
                    print_node_status("WARNING in normal_advance_front2d(), "
                                      "node_propagate failed with status ",
                                      status,"\n"); 
	            print_node(oldn);
	            if (debugging("NO_CROSS"))
	            {
	                (void) printf("No cross case\n");
	                (void) printf("dt_frac = %g\n",*dt_frac);
	                (void) printf("Reducing time step\n");
	            }
	            *dt_frac *= TIME_STEP_REDUCTION_FACTOR(front->interf);
	            free_rp_list(&rp);
	            status = MODIFY_TIME_STEP;
	            goto sync_prop_stat1;
	        case ERROR_NODE:
	        default:
	            (void) printf("WARNING in normal_advance_front2d(), ");
	            (void) printf("node_propagate failed, ");
                    print_node_status("WARNING in normal_advance_front2d(), "
                                      "node_propagate failed with status ",
                                      status,"\n");
	            print_node(oldn);
	            if (debugging("ERROR_NODE"))
	            {
	                (void) printf("Old interface:\n");
	                print_interface(front->interf);
	                print_correspond_hyper_surf_list(front->interf);
	                (void) printf("New interface:\n");
	                print_interface((*newfront)->interf);
	                print_correspond_hyper_surf_list((*newfront)->interf);
	            }
	            *dt_frac = Min_time_step_modification_factor(front);
	            free_rp_list(&rp);
	            status = MODIFY_TIME_STEP;
	            goto sync_prop_stat1;
	        }
	    } /* end of while (oldn != NULL) */

	    set_correspond_hyper_surf_bdrys_to_NULL(front->interf);
	    set_correspond_hyper_surf_bdrys_to_NULL((*newfront)->interf);
	    if (rp && (front->twodrproblem != NULL)) 
	    {
	        for (rp1 = rp; rp1; rp1 = rp1->prev) 
	        {
	            debug_front("2drp_front",
	                "new between node loop and rp loop",*newfront);
	                    
	            status = (*front->twodrproblem)(front,*newfront,wave,&rp1);

	            /* At this point, rp is nothing more than a valid element
	             * of the list which provides a starting point
	             * for deleting the list.  If we delete an element of
	             * the list in front->twodrproblem (presumably due to
	             * merging two RPROBLEM's), then rp may point to freed
	             * storage and will need to be updated.  rp1 should still
	             * be a valid element of the list.
	             */
	            rp = rp1;

                    if (status != GOOD_STEP)
                    {
                        print_time_step_status("WARNING in advance_front2d(), "
                                               "rp failed with status = ",
                                               status,"\n");
                        switch (status)
                        {
                        case GOOD_STEP:
                            break;

                        case REPEAT_TIME_STEP:
                            break;
                        case MODIFY_TIME_STEP:
                            status = rp_modify_time_step(rp1,front,status);
                            if (status == MODIFY_TIME_STEP)
                            {
                                *dt_frac = rp1->dt_frac;
                                if (debugging("2drp"))
                                {
                                    print_rproblem(rp1);
                                    (void) printf("dt_frac %g\n",*dt_frac);
                                    (void) printf("Reducing time step\n");
                                }
                                *dt_frac = limit_dt_frac(*dt_frac,front);
                            }
                            break;

                        case ERROR_IN_STEP:
                        default:
                            print_rproblem(rp1);
                            /* Try reducing the time step */
                            status = rp_modify_time_step(rp1,front,status);
                            if (status == MODIFY_TIME_STEP)
                                *dt_frac *=
                                    TIME_STEP_REDUCTION_FACTOR(front->interf);
                            break;
                        }
                    }
                    if (status != GOOD_STEP)
                        break;
	        }
	        free_rp_list(&rp);
	        debug_front("2drp_front","after 2drp loop",*newfront);
	    }
	    else if (rp) 
	    {
	        for (rp1 = rp; rp1; rp1 = rp1->prev) 
	        {
	            print_rproblem(rp1);
	        }
	        free_rp_list(&rp);
	        (void) printf("WARNING in normal_advance_front2d(), ");
	        (void) printf("CROSS code needed\n");
	        status = ERROR_IN_STEP;
	    }
	}
        /* 061003 closed, since the correspondence is reset. 
         * The second node prop. is done in tangential step now. 
        node_stat = second_node_propagate2d(dt,dt_frac,front,newfront,wave);
        if(GOOD_STEP != node_stat) 
        {
            (void) printf("WARNING in normal_advance_front2d(), "
                      "second node_propagation returns stat= %d", node_stat);
            clean_up(ERROR);  
        }  
        */
sync_prop_stat1:
	return return_advance_front(front,newfront,GOOD_STEP,fname);
}		/*end normal_advance_front2d*/
Beispiel #7
0
LOCAL	bool	check_curve3d(
	CURVE     *c,
	INTERFACE *intfc)
{
	BOND     *b;
	BOND_TRI **bts, **bts0;
	NODE     *ns, *ne;
	SURFACE  *s, **ss;
	TRI      *tri, **tris;
	bool     status = YES;
	char     warn[1024];
	int      nsides, nbts, i;
	int      ntris;

	(void) sprintf(warn,"WARNING in check_curve3d(), curve %llu inconsistent ",
		       curve_number(c));
	if (c->interface != intfc)
	{
	    (void) printf("%s c->interface (%llu) != intfc (%llu)\n",
			  warn,interface_number(c->interface),
			  interface_number(intfc));
	    status = NO;
	}
	ns = c->start;
	if (!pointer_is_in_array(c,ns->out_curves))
	{
	    (void) printf("%s curve in not in start node (%llu) "
			  "out_curves\n",warn,node_number(ns));
	    status = NO;
	}
	ne = c->end;
	if (!pointer_is_in_array(c,ne->in_curves))
	{
	    (void) printf("%s curve in not in end node (%llu) "
			  "in_curves\n",warn,node_number(ne));
	    status = NO;
	}
	if (ns->posn != c->first->start)
	{
	    (void) printf("%s ns->posn != c->first->start\n"
			  "c->first->start = %llu, "
			  "ns = %llu, ns->posn = %llu\n",
			  warn,point_number(c->first->start),
			  node_number(ns),point_number(ns->posn));
	    status = NO;
	}
	if (ne->posn != c->last->end)
	{
	    (void) printf("%s ne->posn != c->last->end\n"
			  "c->last->end = %llu, "
			  "ne = %llu, ne->posn = %llu\n",
			  warn,point_number(c->last->end),
			  node_number(ne),point_number(ne->posn));

	    print_general_vector("c->last->end", Coords(c->last->end), 3, "\n");
	    print_general_vector("ne->posn", Coords(ne->posn), 3, "\n");
	    print_curve(c);
	    status = NO;
	}
	if (!Boundary_point(ns->posn))
	{
	    (void) printf("%s ns->posn (ns = %llu, ns->posn = %llu) is not a "
			  "boundary point\n",
			  warn,node_number(ns),point_number(ns->posn));
	    status = NO;
	}
	if (!Boundary_point(ne->posn))
	{
	    (void) printf("%s ne->posn (ne = %llu, ne->posn = %llu) is not a "
			  "boundary point\n",
			  warn,node_number(ne),point_number(ne->posn));
	    status = NO;
	}
	if (!Boundary_point(c->first->start))
	{
	    (void) printf("%s c->first->start = %llu is not a "
			  "boundary point\n",
			  warn,point_number(c->first->start));
	    status = NO;
	}
	if (!Boundary_point(c->last->end))
	{
	    (void) printf("%s c->last->end = %llu is not a "
			  "boundary point\n",
			  warn,point_number(c->last->end));
	    status = NO;
	}
	for (ss = c->pos_surfaces; ss && *ss; ++ss)
	{
	    if (!pointer_is_in_array(c,(*ss)->pos_curves))
	    {
	        (void) printf("%s curve in not s->pos_curves "
			      " s = %llu but s is in c->neg_surfaces\n",
			      warn,surface_number(*ss));
		status = NO;
	    }
	}
	for (ss = c->neg_surfaces; ss && *ss; ++ss)
	{
	    if (!pointer_is_in_array(c,(*ss)->neg_curves))
	    {
	        (void) printf("%s curve in not s->neg_curves "
			      " s = %llu but s is in c->neg_surfaces\n",
			      warn,surface_number(*ss));
		status = NO;
	    }
	}
	b = c->first;
	bts0 = Btris(b);
	for (nbts = 0, bts = Btris(b); bts && *bts; ++nbts, ++bts);
	if (nbts == 0)
	{
	    if (c->pos_surfaces || c->neg_surfaces)
	    {
		(void) printf("%s curve has no bond tris but is "
			      "connected to some surface\n",warn);
		status = NO;
	    }
	}
	if (c->first->prev != NULL)
	{
	    (void) printf("%s c->first->prev != NULL\n",warn);
	    print_bond(c->first);
	    print_bond(c->first->prev);
	    status = NO;
	}
	if (c->last->next != NULL)
	{
	    (void) printf("%s c->last->next != NULL\n",warn);
	    print_bond(c->last);
	    print_bond(c->last->next);
	    status = NO;
	}
	for (b = c->first; b != NULL; b = b->next)
	{
	    if (b->next && b->next->start != b->end)
	    {
	        (void) printf("%s bond pair (%llu -> %llu) point pointers "
			      "inconsistent\n",
			      warn,bond_number(b,intfc),
			      bond_number(b->next,intfc));
		print_bond(b);
		print_bond(b->next);
	        status = NO;
	    }
	    if (!Boundary_point(b->start))
	    {
	        (void) printf("%s b->start = %llu is not a "
			      "boundary point\n",
			      warn,point_number(b->start));
		print_bond(b);
	        status = NO;
	    }
	    if (!Boundary_point(b->end))
	    {
	        (void) printf("%s b->end = %llu is not a "
			      "boundary point\n",
			      warn,point_number(b->end));
		print_bond(b);
	        status = NO;
	    }
	    for (i = 0, bts = Btris(b); bts && *bts; ++i, ++bts)
	    {
		if ((i < nbts) &&
		    !(((*bts)->surface == bts0[i]->surface) &&
		          ((*bts)->orient == bts0[i]->orient)))
		{
	            (void) printf("%s inconsistent surface numbers on "
				  "bond tri\n",warn);
		    (void) printf("surface = %llu surface[%d] = %llu\n",
				  surface_number((*bts)->surface),i,
				  surface_number(bts0[i]->surface));
		    (void) printf("orient = %s orient[%d] = %s\n",
				  orientation_name((*bts)->orient),i,
				  orientation_name(bts0[i]->orient));
		    print_bond(b);
	            status = NO;
		}
	    }
	    if (i != nbts)
	    {
	        (void) printf("%s inconsistent %d != %d number of bond tris "
			      "on bond\n",warn,i,nbts);
		print_bond(b);
	        status = NO;
	    }
	    for (bts = Btris(b); bts && *bts; ++bts)
	    {
		if ((*bts)->curve != c)
		{
		    (void) printf("%s bond tri curve field (%llu) != c\n",
				  warn,curve_number((*bts)->curve));
		    print_bond(b);
		    status = NO;
		}
		if ((*bts)->bond != b)
		{
		    (void) printf("%s bond tri bond field (%llu) != b (%llu)\n",
				  warn,bond_number((*bts)->bond,intfc),
				  bond_number(b,intfc));
		    print_bond(b);
		    status = NO;
		}
		tri = (*bts)->tri;
		s = Surface_of_tri(tri);
		if ((*bts)->surface != s)
		{
		    (void) printf("%s bond tri surface field (%llu)"
				  "!= Surface_of_tri(tri) (%llu)\n",
				  warn,surface_number((*bts)->surface),
				  surface_number(s));
		    print_bond(b);
		    status = NO;
		}
		for (nsides = 0, i = 0; i < 3; ++i)
		{
		    if (is_side_bdry(tri,i) && (b==Bond_on_side(tri,i)))
			++nsides;
		}
		if (nsides == 0)
		{
		    (void) printf("%s bond not found on tri side\n",warn);
		    print_bond(b);
		    print_tri(tri,intfc);
		    status = NO;
		}
		else if (nsides > 1)
		{
		    (void) printf("%s bond found on multiple tri sides\n",warn);
		    print_bond(b);
		    print_tri(tri,intfc);
		    status = NO;
		}
		else
		{
		    if (orientation_of_bond_at_tri(b,tri) != (*bts)->orient)
		    {
		        (void) printf("%s inconsistent orientation at "
				      "bond tri\n",warn);
		        print_tri(tri,intfc);
		        print_bond(b);
		        status = NO;
		    }
		    switch ((*bts)->orient)
		    {
		    case POSITIVE_ORIENTATION:
	                if (!pointer_is_in_array(c,s->pos_curves))
	                {
	                    (void) printf("%s curve in not s->pos_curves "
					  " s = %llu\n",
			                  warn,surface_number(s));
		            print_bond(b);
		            print_tri(tri,intfc);
	                    status = NO;
	                }
	                if (!pointer_is_in_array(s,c->pos_surfaces))
	                {
	                    (void) printf("%s surface in not c->pos_surfaces "
					  " s = %llu\n",
			                  warn,surface_number(s));
		            print_bond(b);
		            print_tri(tri,intfc);
	                    status = NO;
	                }
			break;
		    case NEGATIVE_ORIENTATION:
	                if (!pointer_is_in_array(c,s->neg_curves))
	                {
	                    (void) printf("%s curve in not s->neg_curves "
					  " s = %llu\n",
			                  warn,surface_number(s));
		            print_bond(b);
		            print_tri(tri,intfc);
	                    status = NO;
	                }
	                if (!pointer_is_in_array(s,c->neg_surfaces))
	                {
	                    (void) printf("%s surface in not c->neg_surfaces "
					  " s = %llu\n",
			                  warn,surface_number(s));
		            print_bond(b);
		            print_tri(tri,intfc);
	                    status = NO;
	                }
			break;
		    case ORIENTATION_NOT_SET:
			(void) printf("%s inconsistent point and tri "
				      "points\n",warn);
		        print_bond(b);
		        print_tri(tri,intfc);
	                status = NO;
			break;
		    }
		}
		if (b->prev)
		{
		    TRI *t0, *t1;
	            ntris = set_tri_list_around_point(b->start,tri,&tris,intfc);
		    t0 = tris[0]; t1 = tris[ntris-1];
		    if (!(((side_of_tri_with_bond(b,t0) < 3) &&
			      (side_of_tri_with_bond(b->prev,t1) < 3))
		        ||
			     ((side_of_tri_with_bond(b,t1) < 3) &&
			      (side_of_tri_with_bond(b->prev,t0) < 3)))
		       )
		    {
			(void) printf("%s, corrupt tri list at b->start\n",
				      warn);
		        (void) printf("Bond b\n"); print_bond(b);
		        (void) printf("Bond b->prev\n"); print_bond(b->prev);
		        print_tri(tri,intfc);
			(void) printf("number of tris at point = %d\n",ntris);
			for (i = 0; i < ntris; ++i)
			{
			    (void) printf("tris[%d] - ",i);
			    print_tri(tris[i],intfc);
			}
			status = NO;
		    }
		}
	    }
	}
	return status;
}		/*end check_curve3d*/
Beispiel #8
0
LOCAL	bool i_consistent_interface3d(
	INTERFACE	*intfc)
{
	HYPER_SURF_ELEMENT *hse;
	HYPER_SURF         *hs;
	CURVE              **c;
	NODE               **n;
	POINT              *p;
	SURFACE	           **ss, *s;
	TRI	           *tri;
	bool               status = YES;
	const char         *warn = "WARNING in i_consistent_interface(), ";

	/* Check Nodes */
	for (n = intfc->nodes; n && *n; ++n)
	{
	    if ((*n)->interface != intfc)
	    {
		(void) printf("%s n = %llu n->interface (%llu) != intfc (%llu)\n",
			      warn,node_number(*n),
			      interface_number((*n)->interface),
			      interface_number(intfc));
		status = NO;
	    }
	    for (c = (*n)->in_curves; c && *c; ++c)
	    {
		if ((*c)->end != *n)
		{
		    (void) printf("%s inconsistent node (%llu) "
				  "curve (%llu) pair, "
				  "curve->end != n\n",
				  warn,node_number(*n),curve_number(*c));
		    status = NO;
		}
	    }
	    for (c = (*n)->out_curves; c && *c; ++c)
	    {
		if ((*c)->start != *n)
		{
		    (void) printf("%s inconsistent node (%llu) "
				  "curve (%llu) pair, "
				  "curve->start != n\n",
				  warn,node_number(*n),curve_number(*c));
		    status = NO;
		}
	    }
	}

	/* Check Curves */
	for (c = intfc->curves; c && *c; c++)
	{
	    if (!check_curve3d(*c,intfc))
	    {
	        (void) printf("%s inconsistency in curve (%llu) found\n",
			      warn,curve_number(*c));
		status = NO;
	    }
	}

	for (ss = intfc->surfaces; ss && *ss; ++ss)
	{
	    if (!check_consistency_of_tris_on_surface(*ss))
	    {
		(void) printf("%s inconsistency in surface (%llu) found\n",
				  warn,surface_number(*ss));
		status = NO;
	    }
	}

	(void) next_point(intfc,NULL,NULL,NULL);
	while (next_point(intfc,&p,&hse,&hs))
	{
	    BOND        *b = NULL, *bb;
	    BOND_TRI    **bts;
	    CURVE       **c;
	    TRI         **tris;
	    int         i, ntris;
	    int         v, pside, nside;

	    tri = Tri_of_hse(hse);
	    s = Surface_of_hs(hs);
	    if ((v = Vertex_of_point(tri,p)) == ERROR)
	    {
	        (void) printf("%s point not on tri, s = %llu\n",
			      warn,surface_number(s));
	    	(void) printf("p(%llu) - (%g, %g, %g), ",
	    		      point_number(p),
	    		      Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		print_tri(tri,hs->interface);
		status = NO;
	    }
	    if (!Boundary_point(p))
	    {
		ntris = set_tri_list_around_point(p,tri,&tris,intfc);
		if ((tri != tris[0]) ||
		    (tri != Prev_tri_at_vertex(tris[ntris-1],p)))
		{
		    bool consistent_tri_list = NO;
		    if (allow_null_sides)
		    {
			if ((Next_tri_at_vertex(tris[0],p) == NULL) &&
		            (Prev_tri_at_vertex(tris[ntris-1],p) == NULL))
			  consistent_tri_list = YES;  
		    }
		    if (!consistent_tri_list)
		    {
		        (void) printf("\n%s Corrupt tri list s (%llu) "
	    	                      "p(%llu) - (%g, %g, %g)\n",
				      warn,surface_number(s),
	    		              point_number(p),
	    		              Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		        print_tri(tri,hs->interface);
		        (void) printf("%d tris about point\n",ntris);
		        for (i = 0; i < ntris; ++i)
		        {
			    (void) printf("tris[%d] - ",i);
			    print_tri(tris[i],hs->interface);
		        }
		        (void) printf("End printout of "
				      "Corrupt tri list s (%llu) "
	    	                      "p(%llu) - (%g, %g, %g)\n\n",
				      surface_number(s),point_number(p),
	    		              Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		        status = NO;
		    }
		}
		continue;
	    }
	    nside = v;
	    pside = Prev_m3(v);
	    if (is_side_bdry(tri,nside))
		b = Bond_on_side(tri,nside);
	    else if (is_side_bdry(tri,pside))
		b = Bond_on_side(tri,pside);
	    else    //#bjet2
	    {
		ntris = set_tri_list_around_point(p,tri,&tris,intfc);
		v = Vertex_of_point(tris[0],p);
		nside = v;
		pside = Prev_m3(v);
		if (is_side_bdry(tris[0],nside))
		    b = Bond_on_side(tris[0],nside);
		else if (is_side_bdry(tris[0],pside))
		    b = Bond_on_side(tris[0],pside);
		else
		{
		    int i;
	            (void) printf("%s Boundary_point has no adjacent "
				  "tri with a bond\n",warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",
	    		          point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    for (i = 0; i < ntris; ++i)
		    {
			(void) printf("tris[%d] - ",i);
			print_tri(tris[i],hs->interface);
		    }
		    status = NO;
		}
		tri = tris[0];
	    }
	    for (bts = Btris(b); bts && *bts; ++bts)
	        if ((*bts)->tri == tri)
	    	    break;
	    if ((bts == NULL) || (*bts == NULL))
	    {
		(void) printf("%s bond tri for tri  not found\n",warn);
	    	(void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		      Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		print_tri(tri,hs->interface);
		print_bond(b);
		status = NO;
	    }
	    else
	    {
	        if ((*bts)->bond != b)
	        {
		    (void) printf("%s (*bts)->bond != b\n",warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
	        }
	        if ((*bts)->surface != s)
	        {
	            (void) printf("%s inconsistent surfaces at bond tri\n",
				  warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
	        }
		if (orientation_of_bond_at_tri(b,tri) != (*bts)->orient)
		{
		    (void) printf("%s inconsistent orientation at bond tri\n",
				  warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
		}
	        switch ((*bts)->orient)
	        {
	        case POSITIVE_ORIENTATION:
		    for (c = s->pos_curves; c && *c; c++)
		        if ((*c) == (*bts)->curve)
			    break;
	            break;
	        case NEGATIVE_ORIENTATION:
		    for (c = s->neg_curves; c && *c; c++)
		        if ((*c) == (*bts)->curve)
			    break;
	            break;
	        case ORIENTATION_NOT_SET:
		    c = NULL;
	            (void) printf("%s undetermined orientation at "
				  "bond on tri\n",warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
		    break;
	        }
	        if ((c == NULL) || (*c == NULL))
	        {
		    (void) printf("%s curve with bond on tri not found\n",warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
	        }
	        else
	        {
	            for (bb = (*c)->first; bb != NULL; bb = bb->next)
		        if (bb == b)
		            break;
	            if (bb == NULL)
	            {
		        (void) printf("%s bond not on curve\n",warn);
	    	        (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		              Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		        print_tri(tri,hs->interface);
		        print_bond(b);
		        print_curve(*c);
		        status = NO;
	            }
	        }
	    }
	}

	if (status == NO)
	{
	    (void) printf("WARNING in i_consistent_interface(), "
	                  "Inconsistent interface found\n");
	    print_interface(intfc);
	}

	allow_null_sides = NO;
	return status;
}		/*end i_consistent_interface*/
Beispiel #9
0
LOCAL	bool	check_curve2d(
	CURVE     *c,
	INTERFACE *intfc)
{
	BOND     *b;
	NODE     *ns, *ne;
	bool     status = YES;
	char     warn[1024];

	(void) sprintf(warn,"WARNING in check_curve(), curve %llu inconsistent ",
		       curve_number(c));
	if (c->interface != intfc)
	{
	    (void) printf("%s c->interface (%llu) != intfc (%llu)\n",
			  warn,interface_number(c->interface),
			  interface_number(intfc));
	    status = NO;
	}
	ns = c->start;
	if (!pointer_is_in_array(c,ns->out_curves))
	{
	    (void) printf("%s curve in not in start node (%llu) "
			  "out_curves\n",warn,node_number(ns));
	    status = NO;
	}
	ne = c->end;
	if (!pointer_is_in_array(c,ne->in_curves))
	{
	    (void) printf("%s curve in not in end node (%llu) "
			  "in_curves\n",warn,node_number(ne));
	    status = NO;
	}
	if (ns->posn != c->first->start)
	{
	    (void) printf("%s ns->posn != c->first->start\n"
			  "c->first->start = %llu, "
			  "ns = %llu, ns->posn = %llu\n",
			  warn,point_number(c->first->start),
			  node_number(ns),point_number(ns->posn));
	    status = NO;
	}
	if (ne->posn != c->last->end)
	{
	    (void) printf("%s ne->posn != c->last->end\n"
			  "c->last->end = %llu, "
			  "ne = %llu, ne->posn = %llu\n",
			  warn,point_number(c->last->end),
			  node_number(ne),point_number(ne->posn));
	    status = NO;
	}
	if (c->first->prev != NULL)
	{
	    (void) printf("%s c->first->prev != NULL\n",warn);
	    print_bond(c->first);
	    print_bond(c->first->prev);
	    status = NO;
	}
	if (c->last->next != NULL)
	{
	    (void) printf("%s c->last->next != NULL\n",warn);
	    print_bond(c->last);
	    print_bond(c->last->next);
	    status = NO;
	}
	for (b = c->first; b != NULL; b = b->next)
	{
	    if (b->next && b->next->start != b->end)
	    {
	        (void) printf("%s bond pair (%llu -> %llu) point pointers "
			      "inconsistent\n",
			      warn,bond_number(b,intfc),
			      bond_number(b->next,intfc));
		print_bond(b);
		print_bond(b->next);
	        status = NO;
	    }
	    if ((b->next && b->next->prev != b) || 
	 	(b->prev && b->prev->next != b) ||
		b->next == b || b->prev == b)
	    {
	        (void) printf("%s bond pair (%llu -> %llu) link pointers "
			      "inconsistent\n",
			      warn,bond_number(b,intfc),
			      bond_number(b->next,intfc));
		print_bond(b);
		print_bond(b->next);
		return NO;	/* this is a potential deadloop, so exit */
	    }
	}
	return status;
}		/*end check_curve2d*/