Exemplo n.º 1
0
LOCAL	void	set_oned_state_from_interface(
	float	     *coords,
	Locstate     s,
	COMP_TYPE    *ct,
	ONED_OVERLAY *olay)
{
	HYPER_SURF		*hs;
	HYPER_SURF_ELEMENT	*hse;
	POINT			*p;
	float			coords_on[MAXD];

	if (nearest_interface_point(coords,ct->comp,olay->intfc1d,
				    INCLUDE_BOUNDARIES,NULL,
				    coords_on,NULL,&hse,&hs) != YES)
	{
	    screen("ERROR in set_oned_state_from_interface(), "
	           "nearest_interface_point() failed\n");
	    clean_up(ERROR);
	}
	coords[0] = coords_on[0];
	p = Point_of_hs(hs);
	if (ct->comp == positive_component(hs))
	    ft_assign(s,right_state(p),ct->params->sizest);
	else if (ct->comp == negative_component(hs))
	    ft_assign(s,left_state(p),ct->params->sizest);
	else
	{
	    screen("ERROR in set_oned_state_from_interface(), "
	           "ct->comp not on interface\n");
	    clean_up(ERROR);
	}
	Init_params(s,ct->params);
}		/*end set_oned_state_from_interface*/
Exemplo n.º 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;
}
Exemplo n.º 3
0
EXPORT	boolean	f_sort_bond_tris(
	INTERFACE	*intfc)
{
	BOND            *b;
	CURVE           **c;
	Locstate        s0, s1;
	int             i, N;
	size_t          sizest;
	static Locstate stemp = NULL;

	if (!i_sort_bond_tris(intfc))
	    return NO;

	sizest = size_of_state(intfc);
	if ((sizest == 0) || !interpolate_intfc_states(intfc))
	    return YES;

	if (stemp == NULL)
	    scalar(&stemp,size_of_state(intfc));

	for (c = intfc->curves; c && *c; ++c)
	{
	    N = (int) size_of_pointers(Btris((*c)->first));
	    for (b = (*c)->first; b != (*c)->last; b = b->next)
	    {
		for (i = 0; i < N; ++i)
		{
		    s0 = left_end_btri_state(Btris(b)[i]);
		    s1 = left_start_btri_state(Btris(b->next)[i]);
		    if (s0 != s1)
		    {
			bi_interpolate_intfc_states(intfc,0.5,0.5,
						    Coords(b->end),s0,
						    Coords(b->end),s1,
						    stemp);
			left_start_btri_state(Btris(b->next)[i]) = s0;
			ft_assign(s0,stemp,sizest);
		    }
		    s0 = right_end_btri_state(Btris(b)[i]);
		    s1 = right_start_btri_state(Btris(b->next)[i]);
		    if (s0 != s1)
		    {
			bi_interpolate_intfc_states(intfc,0.5,0.5,
						    Coords(b->end),s0,
						    Coords(b->end),s1,
						    stemp);
			right_start_btri_state(Btris(b->next)[i]) = s0;
			ft_assign(s0,stemp,sizest);
		    }
		}
	    }
	}
	return YES;
}		/*end f_sort_bond_tris*/
Exemplo n.º 4
0
LOCAL	COMP_TYPE *clone_elliptical_comp_type(
	ELLIPSOID    *ellip,
	COMP_TYPE    *ct,
	Front        *front,
	INIT_PHYSICS *ip)
{
	_ELLIPTICAL          *el, *nel;
	COMP_TYPE            *nct;
	INTERFACE            *intfc = front->interf;
	int                  i, dim;

	nct = comp_type(new_component(NEW_COMP));
	set_elliptical_comp_type(nct,ip);
	nel = Elliptical(nct);
	nel->ellipsoid = ellip;
	switch (ct->type)
	{
	case ELLIPTICAL:
	    dim = intfc->dim;
	    el = Elliptical(ct);
	    nel->rstate = copy_random_state_structure(el->rstate,intfc);
	    ft_assign(nel->state,el->state,front->sizest);
	    ft_assign(nel->wkstate[0],el->wkstate[0],front->sizest);
	    ft_assign(nel->wkstate[1],el->wkstate[1],front->sizest);
	    for (i = 0; i < dim; ++i)
	        nel->weight[i] = el->weight[i];
	    nel->r0 = el->r0;
	    nel->rw1d = el->rw1d;
	    nel->stratification_type = el->stratification_type;
	    break;
	case AMBIENT:
	    nel->rstate = NULL;
	    set_state(nel->state,TGAS_STATE,Ambient(ct));
	    break;
	default:
	    screen("ERROR in copy_elliptical_comp_type(), "
	           "comp_type %s not supported\n",comp_type_name(ct->type));
	    clean_up(ERROR);
	    break;
	}
	return nct;
}		/*end clone_elliptical_comp_type*/
Exemplo n.º 5
0
/*ARGSUSED*/
LOCAL	boolean	SetConstantRegionState(
	Locstate		nst,
	Locstate		ost,
	double			*coords,
	COMPONENT		old_comp,
	FlowSpecifiedRegion	*fsr,
	Front			*fr)
{
	ConstantFlowRegion *cfr = (ConstantFlowRegion*)fsr;
	Locstate	const_state = cfr->state;

	ft_assign(nst,const_state,fr->sizest);
	return YES;
}		/*end SetConstantRegionState*/
Exemplo n.º 6
0
/*ARGSUSED*/
LOCAL	boolean	SetSkipComponentState(
	Locstate		nst,
	Locstate		ost,
	double			*coords,
	COMPONENT		old_comp,
	FlowSpecifiedRegion	*fsr,
	Front			*fr)
{
	if (ComponentsMatch(fsr,old_comp,fsr->comp,fr->interf))
	{
	    ft_assign(nst,ost,fr->sizest);
	    return YES;
	}
	return NO;
}		/*end SetSkipComponentState*/
Exemplo n.º 7
0
EXPORT	ConstantFlowRegion	*SetConstantFlowRegion(
	COMPONENT	comp,
	Locstate	state,
	INTERFACE	*intfc)
{
	ConstantFlowRegion *cfr;
	FlowSpecifiedRegion *fsr;

	fsr = FSR_for_comp(comp,NULL,intfc);
	if (fsr != NULL)
	{
	    size_t sizest = size_of_state(intfc);
	    if (strcmp(fsr->type,"CONSTANT_REGION") != 0)
	    {
		screen("ERROR in SetConstantFlowRegion(), "
		       "attempt to respecify a flow specified region\n");
		clean_up(ERROR);
	    }
	    cfr = (ConstantFlowRegion*)fsr;
	    if (sizest != 0)
	    {
		if (memcmp(state,cfr->state,sizest) != 0)
		{
		    screen("ERROR in SetConstantFlowRegion(), "
		           "attempt to respecify a constant region state\n");
		    clean_up(ERROR);
		}
	    }
	    return cfr;
	}
	scalar(&cfr,sizeof(ConstantFlowRegion));
	cfr->Fsr.comp = comp;
	sprintf(cfr->Fsr.type,"CONSTANT_REGION");
	cfr->Fsr._ComponentsMatch = equivalent_comps;
	cfr->Fsr._SetFlowSpecifiedState = SetConstantRegionState;
	cfr->Fsr._fprint_FlowSpecifiedRegion_data =
				fprint_ConstantFlowRegion_data;
	cfr->Fsr._DestroyFlowSpecifiedRegion = DestroyConstantFlowRegion;
	alloc_state(intfc,&cfr->state,size_of_state(intfc));
	ft_assign(cfr->state,state,size_of_state(intfc));
	(void) AddToFsrList(&cfr->Fsr);
	return cfr;
}		/*end SetConstantFlowRegion*/
Exemplo n.º 8
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*/
Exemplo n.º 9
0
EXPORT void f_curve_propagate2d(
	Front		*fr,
	POINTER		wave,
	CURVE		*oldc,
	CURVE		*newc,
	double		dt)
{
	BOND		*oldb = oldc->first;
	BOND		*newb = newc->first;
	double		V[MAXD];
	int		dim = fr->interf->dim;	
	double		L[MAXD],U[MAXD];	/* propagation boundary */

	debug_print("f_curve_propagate","Entered f_curve_propagate2d\n");

	if ((fr->_point_propagate == NULL)   ||
	    (oldc == NULL)                   ||
	    (newc == NULL)                   ||
	    (correspond_curve(oldc) != newc) ||
	    (correspond_curve(newc) != oldc))
	    return;

	set_propagation_bounds(fr,L,U);
	while (oldb) 
	{
	    if ((oldb != oldc->last) && (!n_pt_propagated(newb->end)))
	    {
	    	n_pt_propagated(newb->end) = YES;
		if (out_of_bound(oldb->end,L,U,dim) &&
		    wave_type(oldc) != MOVABLE_BODY_BOUNDARY &&
		    wave_type(oldc) != ICE_PARTICLE_BOUNDARY) 
		{
		    Locstate newsl,newsr;
		    Locstate oldsl,oldsr;
		    slsr(newb->end,Hyper_surf_element(newb),Hyper_surf(newc),
		    		&newsl,&newsr);
		    slsr(oldb->end,Hyper_surf_element(oldb),Hyper_surf(oldc),
		    		&oldsl,&oldsr);
		    ft_assign(newsl,oldsl,fr->sizest);                 
		    ft_assign(newsr,oldsr,fr->sizest);
		    continue;
		}
	    	point_propagate(fr,wave,oldb->end,newb->end,oldb->next,
				oldc,dt,V);
	    }
	    if (fr->bond_propagate != NULL)
	    	(*fr->bond_propagate)(fr,wave,oldb,newb,oldc,dt);
	    else
	    	set_bond_length(newb,dim); /* Update new bond length */
	    if (oldb == oldc->last)
		break;
	    oldb = oldb->next;
	    newb = newb->next;
	}
	if (wave_type(oldc) == MOVABLE_BODY_BOUNDARY ||
	    wave_type(oldc) == ICE_PARTICLE_BOUNDARY)
        {
            /* Propagate center of mass */
/*            int i,dim;
            dim = fr->rect_grid->dim;
            for (i = 0; i < dim; ++i)
	    {
                center_of_mass_velo(newc)[i] = center_of_mass_velo(oldc)[i];
                center_of_mass(newc)[i] = center_of_mass(oldc)[i] +
                        dt*center_of_mass_velo(oldc)[i];
	    }
	    angular_velo(newc) = angular_velo(oldc);
	    spherical_radius(newc) = spherical_radius(oldc);*/
        }
	debug_print("f_curve_propagate","Leaving f_curve_propagate2d\n");
}		/*end f_curve_propagate2d*/