Пример #1
0
EXPORT	NODE *make_node(
	POINT		*p)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(current_interface())._make_node)(p);
}		/*end make_node*/
Пример #2
0
/*#bjet2 */
EXPORT boolean  f_assign_btri_states(
        BOND_TRI *newbtri,
        BOND_TRI *btri)
{
	INTERFACE       *cintfc = current_interface();
	size_t          sizest = size_of_state(cintfc);        

        if (sizest == 0)
        { 
            left_start_btri_state(newbtri) = NULL;            
            right_start_btri_state(newbtri) = NULL;
            left_end_btri_state(newbtri) = NULL;            
            right_end_btri_state(newbtri) = NULL;
            return YES;
        }
	
	if (copy_intfc_states() == YES)
	{
            ft_assign(left_start_btri_state(newbtri),
			left_start_btri_state(btri),sizest);
            ft_assign(left_end_btri_state(newbtri),
			left_end_btri_state(btri),sizest);
            ft_assign(right_start_btri_state(newbtri),
			right_start_btri_state(btri),sizest);
            ft_assign(right_end_btri_state(newbtri),
			right_end_btri_state(btri),sizest);
        }
	return YES;
}
Пример #3
0
/*Hypersurface boundary utilities*/
EXPORT	HYPER_SURF_BDRY *make_hypersurface_boundary(void)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._make_hypersurface_boundary)();
}		/*end make_hypersurface_boundary*/
Пример #4
0
/* Point utilities */
EXPORT	POINT *Point(
	double		*crds)
{
	INTERFACE	*intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._Point)(crds);
}		/*end Point*/
Пример #5
0
EXPORT	POINT *copy_point(
	POINT		*p)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._copy_point)(p);
}		/*end copy_point*/
Пример #6
0
EXPORT SURFACE  *detach_one_surface(
	SURFACE  *s)
{
	INTERFACE	*intfc = current_interface();
	
	if (intfc==NULL ||
	    i_user_interface(intfc)._detach_one_surface==NULL)
	    return NO;
	return (*i_user_interface(intfc)._detach_one_surface)(s);
}
Пример #7
0
EXPORT	void reverse_bond(
	BOND *b)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return;
	(*i_user_interface(intfc)._reverse_bond)(b);
	return;
}	/*end reverse_bond */
Пример #8
0
EXPORT	void reorder_curve_link_list(
	CURVE *c)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return;
	(*i_user_interface(intfc)._reorder_curve_link_list)(c);
	return;
}	/*end reorder_curve_link_list */
Пример #9
0
/* BOND utilities */
EXPORT	BOND *Bond(
	POINT	*start,
	POINT	*end)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._Bond)(start,end);
}		/*end Bond*/
Пример #10
0
/*Hypersurface utilities*/
EXPORT	HYPER_SURF *make_hypersurface(
	COMPONENT	left_c,
	COMPONENT	right_c)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._make_hypersurface)(left_c,right_c);
}		/*end make_hypersurface*/
Пример #11
0
EXPORT	void switch_btris_of_bond(
	BOND_TRI *btri1,
	BOND_TRI *btri2)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return;
	(*i_user_interface(intfc)._switch_btris_of_bond)(btri1,btri2);
	return;
}		/*end link_tri_to_bond*/
Пример #12
0
EXPORT	boolean	assign_btri_states(
	BOND_TRI	*newbtri,
	BOND_TRI	*btri)
{
	INTERFACE	*intfc = current_interface();
	
	if (intfc==NULL ||
	    i_user_interface(intfc)._assign_btri_states==NULL)
	    return NO;
	return (*i_user_interface(intfc)._assign_btri_states)(newbtri, btri);
}		/*end assign_btri_states*/
Пример #13
0
EXPORT	POINT *make_point(
	double		*crds,
	COMPONENT	ncomp,
	COMPONENT	pcomp)
{
	INTERFACE	*intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._make_point)(crds,ncomp,pcomp);
}		/*end make_point*/
Пример #14
0
EXPORT	INTERFACE *receive_interface(
	int		src_id)
{
	INTERFACE	*intfc = current_interface();
	INTERFACE	*recvd_intfc;

	if (intfc == NULL)
	    return NULL;
	recvd_intfc = (*i_user_interface(intfc)._receive_interface)(src_id);
	set_current_interface(intfc);
	return recvd_intfc;
}		/*end receive_interface*/
Пример #15
0
/* Surface utilities */
EXPORT	SURFACE *make_surface(
	COMPONENT	nc,
	COMPONENT	pc,
	CURVE		**neg,
	CURVE		**pos)
{
	INTERFACE	*intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._make_surface)(nc,pc,neg,pos);
}		/*end make_surface*/
Пример #16
0
/* Curve utilities */
EXPORT	CURVE *make_curve(
	COMPONENT	left_c,
	COMPONENT	right_c,
	NODE		*start,
	NODE		*end)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._make_curve)(left_c,right_c,start,end);
}		/*end make_curve*/
Пример #17
0
/* C_BOND utilities */
EXPORT	C_BOND *CBond(
	C_BOND *cb,
	POINT  *start,
	POINT  *end,
	TRI    *t1,
	TRI    *t2)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._CBond)(cb,start,end,t1,t2);
}		/*end Bond*/
Пример #18
0
EXPORT	BOND_TRI *link_tri_to_bond(
	BOND_TRI *btri,
	TRI	 *tri,
	SURFACE  *s,
	BOND	 *b,
	CURVE    *c)
{
	INTERFACE *intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._link_tri_to_bond)(btri,tri,s,b,c);
}		/*end link_tri_to_bond*/
Пример #19
0
/* Tri utilities */
EXPORT	TRI	*make_tri(
	POINT		*p0,
	POINT		*p1,
	POINT		*p2,
	POINTER		neighbor01,
	POINTER		neighbor12,
	POINTER		neighbor20,
	int		bdry)
{
	INTERFACE	*intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._make_tri)(p0,p1,p2,neighbor01,
						   neighbor12,neighbor20,bdry);
}		/*end make_tri*/
Пример #20
0
EXPORT	void fprint_point(
	FILE		*file,
	POINT		*p)
{
        INTERFACE *intfc = current_interface();
	int       dim = intfc->dim;
	if (p == NULL || (p->interface == NULL && dim == 1))
	{
	    if (p == NULL)
		fprintf(file,"NULL point\n");
	    else
		fprintf(file,"NULL interface of point\n");
	    return;
	}
	(*i_user_interface(intfc)._fprint_point)(file,p);
}		/*end fprint_point*/
Пример #21
0
EXPORT	POINT *average_points(
	boolean               newpoint,
	POINT		   *p1,
	HYPER_SURF_ELEMENT *hse1,
	HYPER_SURF	   *hs1,
	POINT		   *p2,
	HYPER_SURF_ELEMENT *hse2,
	HYPER_SURF	   *hs2)
{
	INTERFACE *intfc;
	if (hs1->interface != NULL)
	    intfc = hs1->interface;
	else if (hs2->interface != NULL)
	    intfc = hs2->interface;
	else
	    intfc = current_interface();

	if (intfc == NULL)
	    return NULL;
	return (*i_user_interface(intfc)._average_points)(newpoint,p1,hse1,hs1,
		                                                   p2,hse2,hs2);
}		/*end average_points*/
Пример #22
0
LOCAL 	void insert_cuts_and_bdry2d(
	INTERFACE	*intfc,	/* an orginal intfc	*/
	double		**pc)	/* given corners of the subdomain */
{
	COMPONENT	comp;
	CROSS		*cross;
	CURVE		**cc, *c[4];
	CURVE		**curves1, **curves2;
	POINT		*p;
	INTERFACE	*sav_intfc;
	NODE		*n, **nn, *bn[4];
	int		i;

	sav_intfc = current_interface();
	set_current_interface(intfc);
	comp = (intfc->modified) ? long_component(pc[0],intfc) :
			component(pc[0],intfc);

redo_curve_list:
	for (cc = intfc->curves; cc && *cc; cc++)
	{
	    if (is_bdry(*cc))
	    {
	    	(void) delete_curve(*cc);
	    	goto redo_curve_list;
	    }
	}
	for (nn = intfc->nodes; nn && *nn; nn++)
	{
	    if (is_bdry(*nn))
	    {
	    	int num_in, num_out;
	    	if (num_curves_at_node(*nn,&num_in,&num_out) == 0)
	    	    (void) delete_node(*nn);
	    	else
	    	    set_not_bdry(*nn);
	    }
	}
	bn[0] = make_node(Point(pc[0]));
	bn[1] = make_node(Point(pc[2]));
	bn[2] = make_node(Point(pc[3]));
	bn[3] = make_node(Point(pc[1]));
	for (i = 0; i < 4; i++)
	{
	    c[i] = make_curve(NO_COMP,NO_COMP,bn[i],bn[(i+1)%4]);
	    set_is_bdry(c[0]);
	}

	if (intersections(intfc,&cross,YES) == FUNCTION_FAILED)
	{
	    screen("ERROR in insert_cuts_and_bdry2d(), "
	           "intersections() failed\n");
	    clean_up(ERROR);
	}

	if (cross == NULL)
	{
	    for (i = 0; i < 4; i++)
	    {
	    	positive_component(c[i]) = comp;
	    	negative_component(c[i]) = exterior_component(intfc);
	    }
	    return;
	}
	for (; cross != NULL; cross = cross->next)
	{
	    p = cross->p;
	    if (insert_point_in_bond(p,cross->b1,cross->c1)!=FUNCTION_SUCCEEDED)
	    {
	        screen("ERROR in insert_cuts_and_bdry2d(), "
		       "insert_point_in_bond() failed\n");
	        clean_up(ERROR);
	    }
	    rcl_after_insert_point(cross,p,cross->b1);
	    curves1 = split_curve(p,cross->b1,cross->c1,
	    		          positive_component(cross->c1),
	    		          negative_component(cross->c1),
	    		          positive_component(cross->c1),
	    		          negative_component(cross->c1));
	    rcl_after_split(cross,p,cross->b1,cross->c1,curves1);
	    if (insert_point_in_bond(p,cross->b2,cross->c2)!=FUNCTION_SUCCEEDED)
	    {
	        screen("ERROR in insert_cuts_and_bdry2d(), "
		       "insert_point_in_bond() failed\n");
	        clean_up(ERROR);
	    }
	    rcl_after_insert_point(cross,p,cross->b2);
	    curves2 = split_curve(p,cross->b2,cross->c2,
	    		          positive_component(cross->c2),
	    		          negative_component(cross->c2),
	    		          positive_component(cross->c2),
	    		          negative_component(cross->c2));
	    rcl_after_split(cross,p,cross->b2,cross->c2,curves1);
	    n = curves2[0]->end;
	    change_node_of_curve(curves2[0],
				NEGATIVE_ORIENTATION,curves1[0]->end);
	    change_node_of_curve(curves2[1],
				POSITIVE_ORIENTATION,curves1[0]->end);
	    (void) delete_node(n);
	}

	set_current_interface(sav_intfc);
	return;
}		/*end insert_cuts_and_bdry2d*/
Пример #23
0
/*ARGSUSED*/
EXPORT INTERFACE *i_zoom_interface(
	INTERFACE	*given_intfc,
	RECT_GRID	*gr,
	double		*L,
	double		*U,
	double		**Q)
{
	INTERFACE	*cur_intfc;
	INTERFACE	*zoom_intfc;
	RECT_GRID	*t_gr;
	int		dim = given_intfc->dim;
	int		i, j;
	double		**Qi = NULL;
	static double	**pc = NULL;

	debug_print("zoom","Entered zoom_interface()\n");

	cur_intfc = current_interface();
	if ((zoom_intfc = copy_interface(given_intfc)) == NULL)
	{
		Error(ERROR,"Unable to copy interface.");
		clean_up(ERROR);
	}

	if (debugging("zoom"))
	{
		(void) output();
		(void) printf("INTERFACE before zoom:\n\n");
		print_interface(zoom_intfc);
	}

	if (Q != NULL)
	{	
		static	double** M = NULL;
		
		if (M == NULL)
			bi_array(&M,MAXD,MAXD,FLOAT);

		Qi = M;
		for (i = 0; i < dim; i++)
			for (j = 0; j < dim; j++)
				Qi[i][j] = Q[j][i];
	}

	if (pc == NULL)
		bi_array(&pc,MAXNCORNERS,MAXD,FLOAT);

	calculate_box(L,U,pc,Q,Qi,dim);

	/* Shrink topological grid to cutting boundary */
	t_gr = &topological_grid(zoom_intfc);
	rotate_and_zoom_rect_grid(t_gr,L,U,Q);
	switch(dim)
	{
	case 1:
	    /* TODO */
	    return NULL;
	case 2:
	    insert_cuts_and_bdry2d(zoom_intfc,pc);
	    clip_interface2d(zoom_intfc);
	    break;
	case 3:
	    /* TODO */
	    return NULL;
	}
	rotate_interface(zoom_intfc,pc[0],Qi);

	if (set_boundary(zoom_intfc,t_gr,component(pc[0],given_intfc),
			 grid_tolerance(gr) != FUNCTION_SUCCEEDED))
	{
	    screen("ERROR in i_zoom_interface(), set_boundary failed\n");
	    clean_up(ERROR);
	}
	set_current_interface(cur_intfc);

	if (debugging("zoom"))
	{
	    (void) printf("INTERFACE after zoom:\n\n");
	    print_interface(zoom_intfc);
	}
	debug_print("zoom","Leaving zoom_interface()\n");
	return zoom_intfc;
}		/*end i_zoom_interface*/
Пример #24
0
EXPORT	void	set_pointer_queue_opts(
	int		opt,
			...)
{
	va_list		ap;
	int		i, size;
	char		*alloc_type;

	va_start(ap,opt);

	for (i = 0; (opt != 0) && (i < N_PQ_OPTS); opt = va_arg(ap,int), ++i)
	{
	    switch (opt)
	    {
	    case PQ_BLOCK_SIZE:
	    	size = va_arg(ap,int);
	    	n_pqs_in_blk = size;
	    	break;

	    case PQ_ALLOC_TYPE:
	    	alloc_type = va_arg(ap,char *);
	    	if (alloc_type == NULL)
	    	{
		    pq_alloc_type = DEFAULT_ALLOC;
		    break;
		}
		switch (alloc_type[0])
		{
		case 's':
		case 'S':
		    pq_alloc_type = USE_STORE_FOR_ALLOC;
		    break;
		case 'v':
		case 'V':
		    pq_alloc_type = USE_VMALLOC_FOR_ALLOC;
		    break;
		default:
		    pq_alloc_type = DEFAULT_ALLOC;
		    break;
		}
		break;

	    case PQ_ALLOC_SIZE_FOR_POINTERS:
	    	size = va_arg(ap,int);
	    	p2sz = size;
	    	break;

	    case PQ_DEFAULTS:
	    default:
	    	n_pqs_in_blk = DEFAULT_N_PQS_IN_BLK;
	    	pq_alloc_type = DEFAULT_ALLOC;
	    	p2sz = 0;
	    	break;
	    }
	}
	if (pq_alloc_type == USE_STORE_FOR_ALLOC)
	{
	    INTERFACE	*intfc = current_interface();
	    int		max_blk_len;

	    max_blk_len = (int)(ChunkSize(intfc) / max(p2sz,sizeof(PTR_LIST)));

	    if (n_pqs_in_blk > max_blk_len)
	    {
	    	screen("ERROR in set_pointer_queue_opts(), "
	    	       "block size too large for store\n"
	    	       "Maximum block size = %d\n",max_blk_len);
	    	clean_up(ERROR);
	    }
	}

	va_end(ap);
}		/*end set_pointer_queue_opts*/
Пример #25
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*/
Пример #26
0
EXPORT void g_fprint_state(
	FILE		*file,
	Locstate	state)
{
	int dim;
	if (is_obstacle_state(state))
	{
	    (void) fprintf(file,"state %p (OBSTACLE STATE)\n\n",state);
	    return;
	}
	if (current_interface())
	    dim = current_interface()->dim;
	else
	    dim = Params(state)->dim;
	g_fprint_raw_state(file,state,dim);

#if !defined(COMBUSTION_CODE)
	(void) fprintf(file,"\n");
#else /* !defined(COMBUSTION_CODE) */
	if (Composition_type(state) == PURE_NON_REACTIVE)
	{
	    (void) fprintf(file,"\n");
	    return;
	}
	(void) fprintf(file,"burned = %s   q = %"FFMT"   t_crit = %"FFMT"\n",
			    Burned(state)? "BURNED" : "UNBURNED",
			    Params(state)->q,
			    Params(state)->critical_temperature);

	if ((Composition_type(state) == PTFLAME) ||
	    (Composition_type(state) == THINFLAME))
	{
	    (void) fprintf(file,"\n");
	    return;
	}

	(void) fprintf(file,"product density = %"FFMT"\n",Prod(state));

	if (Composition_type(state) == ZND)
	{
	    (void) fprintf(file,"\n");
	    return;
	}

	(void) fprintf(file," rho1 = %"FFMT"\n\n",Dens1(state));
#endif /* !defined(COMBUSTION_CODE) */
	(void) fprintf(file,"%-24s = %-24s %-24s = %-"FFMT"\n\n","gamma_set",
                      Local_gamma_set(state)?"YES" : "NO","local_gamma",
                      Local_gamma(state));
        if(g_composition_type() == MULTI_COMP_NON_REACTIVE)
        {
            if(Params(state) != NULL &&
               Params(state)->n_comps != 1)
            {
                int i;
                for(i = 0; i < Params(state)->n_comps; i++)
                    (void) fprintf(file,"partial density[%2d] = %"FFMT"\n",
                       i,pdens(state)[i]);
                (void) fprintf(file,"\n");
            }
        }
}		/*end g_fprint_state*/
Пример #27
0
LOCAL	void	rt_add_to_state(
	float		*coords,
	Locstate	state, /* assumed to be TGAS_STATE */
	COMP_TYPE	*ct,
	INIT_DATA	*init)
{
#if defined(float)
	static const float ACC = 1.0e-14;		/*TOLERANCE*/
#else /* defined(float) */
	static const float ACC = 1.0e-7;		/*TOLERANCE*/
#endif /* defined(float) */

	int		i, j, k0, k1, dim, layer_label, num_modes, nstep;
	float		rho, csq, rho_prime, a_z, b_z, k_dot_r, sig, phase;
	float		tmp, ub, lb, z0, z1, a0, a1, b0, b1, z, h_z, g_z;
	const float	*grav;
	_RT_PERTURBED	*rtp = Rt_perturbed(ct);
	NORMAL_MODE	*n_m;

	dim = ct->params->dim;
	layer_label = rtp->layer_label;
	nstep = rtp->lin_pert_intvl;
	num_modes = rtp->num_modes;

	if (num_modes <= 0)	return;

	z0 = lb = get_surf_height(coords, rtp->lower_surf);
	z1 = ub = get_surf_height(coords, rtp->upper_surf);
	h_z = (ub-lb)/nstep;
	z = coords[dim-1];
	grav = gravity(coords,initial_time(init));
	g_z = grav[dim-1];

	/* find out which interval z belongs */
	if (ub < lb)
	{
	    screen("\nERROR in rt_add_to_state(), ");
	    screen("Interfaces are already tangled.\n");
	    (void) printf("ub = %g, lb = %g\n",ub,lb);
	    print_interface(current_interface());
	    clean_up(ERROR);
	}
	if (z >= ub)
	    k0 = k1 = nstep;
	else if (z <= lb)
	    k0 = k1 = 0;
	else
	{
	    k0 = 0,		k1 = nstep;
	    for (;;)
	    {
	    	tmp = (z0+z1)/2.0;
	    	if (z >= tmp)
	    	    k0 = (k0+k1)/2, 	z0 = tmp;
	    	else
	    	    k1 = (k0+k1)/2, 	z1 = tmp;
	    	if (k1-k0 == 1)	break;
	    }
	}

	z0 = lb+k0*h_z;	
	z1 = lb+k1*h_z;	
	rho = Dens(state);
	csq = sound_speed_squared(state);
	rho_prime = get_rho_prime(state,ct,g_z);
	/* sum over all the normal modes */
	for (i = 0; i < num_modes; ++i)
	{
	    n_m = rtp->normal_mode[i];
	    if (k0 == k1)
	    {
	    	a_z = n_m->a[layer_label][k1];
	    	b_z = n_m->b[layer_label][k1];
	    }
	    else
	    {
	    	a0 = n_m->a[layer_label][k0];
	    	a1 = n_m->a[layer_label][k1];
	    	a_z = ((a1-a0)*z+(a0*z1-a1*z0))/h_z;
	    	b0 = n_m->b[layer_label][k0];
	    	b1 = n_m->b[layer_label][k1];
	    	b_z = ((b1-b0)*z+(b0*z1-b1*z0))/h_z;
	    }
	    if ((fabs(a_z) < ACC) && (fabs(b_z) < ACC))	continue;

	    sig = n_m->sigma_r;
	    phase = n_m->phase;
	    k_dot_r = 0.0;
	    for (j = 0; j <= dim-2; ++j)
	    	k_dot_r += n_m->wv_num[j]*coords[j];
	    phase += k_dot_r;
	    Dens(state) += ((g_z*rho/csq-rho_prime)*a_z+b_z/csq)/sig*sin(phase);
	    Press(state) += b_z/sig*sin(phase);
	    Vel(state)[dim-1] += a_z*sin(phase);
	    set_type_of_state(state,TGAS_STATE);
	    phase += 3.0*PI/2;
	    for (j = 0; j <= dim-2; ++j)
	        Vel(state)[j] += sin(phase)*n_m->wv_num[j]*b_z/(rho*sig*sig);
            reset_gamma(state);
	}
}		/*end rt_add_to_state*/
Пример #28
0
EXPORT void geomview_amr_fronts_plot2d(
        const char    *dname,
        Front         **frs,
        int           num_patches,
        Wv_on_pc      **redistr_table,
        int           max_n_patch)
{
        FILE              *fp;
        int               i; 
        char              fmt[256];
        static const char *indent = "    ";
        static char       *fname = NULL, *ppfname = NULL;
        static size_t     fname_len = 0, ppfname_len = 0;
        INTERFACE         *intfc = frs[0]->interf; 
        INTERFACE         *tmpintfc;  
        CURVE             **c;
        INTERFACE         *sav_intfc;
        bool              sav_copy; 
        float             **clrmap = NULL; 
        float             ccolor[4] = {0.0, 0.0, 0.0, 1.0};
        int               myid, numnodes;
        const char        *nstep;
        char              outname[256],outdir[256];

        myid = pp_mynode(); numnodes = pp_numnodes();
        sprintf(outdir,"%s/%s",dname,"geomintfc"); 
        ppfname = set_ppfname(ppfname,"intfc",&ppfname_len);
        nstep = right_flush(frs[0]->step,7);
        sprintf(outname,"%s.ts%s",ppfname,nstep);

        if (create_directory(dname,YES) == FUNCTION_FAILED)
        {
            (void) printf("WARNING in geomview_intfc_plot2d(), directory "
                          "%s doesn't exist and can't be created\n",dname);
            return;
        }
        if (create_directory(outdir,YES) == FUNCTION_FAILED)
        {
            (void) printf("WARNING in geomview_intfc_plot2d(), directory "
                         "%s doesn't exist and can't be created\n",outdir);
            return;
        }

        sav_intfc = current_interface();
        sav_copy = copy_intfc_states();
        set_size_of_intfc_state(size_of_state(intfc));
        set_copy_intfc_states(YES);
        tmpintfc = copy_interface(intfc);
  
        /* 
        clip_to_interior_region(tmpintfc,
            frs[0]->rect_grid->lbuf,frs[0]->rect_grid->ubuf); 
        */

        uni_array(&clrmap,6,sizeof(float*));  
        for(i = 0; i < 6; i++)
            uni_array(&clrmap[i],4,sizeof(float)); 

        i = 0;  
        clrmap[i][0] = 0.098; clrmap[i][1] = 0.647;
        clrmap[i][2] = 0.400; clrmap[i][3] = 1.000;
        i++;
        clrmap[i][0] = 0.898; clrmap[i][1] = 0.400;
        clrmap[i][2] = 0.000; clrmap[i][3] = 1.000;
        i++;
        clrmap[i][0] = 0.500; clrmap[i][1] = 1.000;
        clrmap[i][2] = 0.500; clrmap[i][3] = 1.000;
        i++;
        clrmap[i][0] = 1.000; clrmap[i][1] = 0.000;
        clrmap[i][2] = 1.000; clrmap[i][3] = 1.000;
        i++;
        clrmap[i][0] = 0.000; clrmap[i][1] = 0.800;
        clrmap[i][2] = 1.000; clrmap[i][3] = 1.000;
        i++;
        clrmap[i][0] = 0.250; clrmap[i][1] = 0.808;
        clrmap[i][2] = 0.098; clrmap[i][3] = 1.000;
        i++;

        
        fname = get_list_file_name(fname,outdir,outname,&fname_len); 
        if ((fp = fopen(fname,"w")) == NULL)
        {
            (void) printf("WARNING in gview_plot_intfc2d(), "
                           "can't open %s\n",fname);
            delete_interface(tmpintfc);  
            set_current_interface(sav_intfc);
            set_copy_intfc_states(sav_copy);
            return;
        }
        fprintf(fp,"{ LIST \n");
        /* beginning of writting Vect to file */
        for(c = tmpintfc->curves; c and *c;  c++)
            gview_plot_curve2d(fp,*c,ccolor); 

        for(int i = 0; i < num_patches; i++)
        {
           int use_clr;  
           /* 
           gview_plot_box2d(fp, frs[i]->rect_grid->L,
                frs[i]->rect_grid->U,clrmap[i%3]); 
           */ 
           if(NULL != redistr_table)
               use_clr = redistr_table[myid][i].pc_id % 6;
           else
               use_clr = 1;  
           gview_plot_grid2d(fp,frs[i]->rect_grid,clrmap[use_clr]);  
        }  

        /* end of LIST OBJ */
        fprintf(fp,"}\n");
        fclose(fp); 

        set_current_interface(sav_intfc);
        set_copy_intfc_states(sav_copy);
        delete_interface(tmpintfc);  

        for(int i = 0; i < 6; i++)
            free(clrmap[i]); 
        free(clrmap);  
}