Beispiel #1
0
EXPORT	INTERFACE *f_zoom_interface(
	INTERFACE	*intfc,
	RECT_GRID	*gr,
	float		*L,	/* Lower coord of clip box */
	float		*U,	/* upper coord of clip box */
	float		**Q)	/* Rotation matrix */
{
	INTERFACE	*zoom_intfc;

	DEBUG_ENTER(f_zoom_interface)
	zoom_intfc = i_zoom_interface(intfc,gr,L,U,Q);
	copy_rect_grid(computational_grid(intfc),gr);
	rotate_and_zoom_rect_grid(computational_grid(zoom_intfc),L,U,Q);
	DEBUG_LEAVE(f_zoom_interface)
	return zoom_intfc;
}		/*end f_zoom_interface*/
Beispiel #2
0
EXPORT	PP_GRID *set_pp_grid(
	INIT_DATA	*init,
	RECT_GRID       *comp_glbgr)
{
	float		L[MAXD], U[MAXD], *GL, *GU;
	float		*h = comp_glbgr->h;
	int		lbuf[MAXD], ubuf[MAXD];
	int		gmax[MAXD];
	int		icoords[MAXD];
	int		i, dim = comp_glbgr->dim;
	int		myid = pp_mynode();
	static PP_GRID	Pp_grid;
	PP_GRID		*pp_grid = &Pp_grid;
	char		s[1028];

	debug_print("init_pp_grid","Entered set_pp_grid():\n");

	copy_rect_grid(&pp_grid->Global_grid,comp_glbgr);

	pp_grid->nn = 1;
	for (i = 0; i < dim; ++i)
	{
	    int	Gmax, Pmax, k;
	    int	basic_slices, extra_slices;

	    pp_grid->buf[i] = buffer_zones(init)[i];
	    Pmax = pp_grid->gmax[i] = subdomains(init)[i];
	    pp_grid->nn *= Pmax;

	    uni_array(&pp_grid->dom[i],Pmax + 1,FLOAT);

	    pp_grid->dom[i][0]    = comp_glbgr->L[i];
	    pp_grid->dom[i][Pmax] = comp_glbgr->U[i];
	    Gmax = comp_glbgr->gmax[i];

	    basic_slices = Gmax / Pmax;
	    extra_slices = Gmax % Pmax;

	    for (k = 1; k < Pmax; ++k)
	    {
	    	if (k < extra_slices)
	            pp_grid->dom[i][k] = k*(basic_slices + 1)*h[i]
	        			 + pp_grid->dom[i][0];
	        else
	            pp_grid->dom[i][k] = (k*basic_slices + extra_slices)*h[i]
	        			 + pp_grid->dom[i][0];
	    }
	}

	/* Clip rectangular grid to subdomain */

	GL = pp_grid->Global_grid.L;    GU = pp_grid->Global_grid.U;
	find_Cartesian_coordinates(myid,pp_grid,icoords);
	for (i = 0; i < dim; ++i)
	{
	    L[i] = pp_grid->dom[i][icoords[i]];
	    U[i] = pp_grid->dom[i][icoords[i] + 1];
	    gmax[i] = irint((U[i] - L[i])/h[i]);
	    switch (dim) /* TODO Unify 2 and 3 D */
	    {
	    case 1:
	    case 2:
	    	lbuf[i] = (icoords[i] > 0) ? pp_grid->buf[i] : 0;
	    	ubuf[i] =  (icoords[i]<(pp_grid->gmax[i]-1))?pp_grid->buf[i]:0;
	    	break;
	    case 3:
	    	lbuf[i] = pp_grid->buf[i];
	    	ubuf[i] = pp_grid->buf[i];
	    	break;
	    }
	}
	set_rect_grid(L,U,GL,GU,lbuf,ubuf,gmax,dim,&comp_glbgr->Remap,
		      &pp_grid->Zoom_grid);

	if (debugging("init_pp_grid"))
	{
	    (void) printf("pp_grid after set_pp_grid()\n");
	    (void) print_PP_GRID_structure(pp_grid);
	}
	debug_print("init_pp_grid","Left i_set_pp_grid():\n");
	return pp_grid;
}		/*end set_pp_grid*/
Beispiel #3
0
EXPORT void set_topological_grid(
	INTERFACE *intfc,
	RECT_GRID *input_grid)
{
	enum { DEFAULT_GMAX = 20 };
	HYPER_SURF	*hs;
	HYPER_SURF_ELEMENT *hse;
	POINT		*p;
	RECT_GRID	*top_grid = &topological_grid(intfc);
	double		*L, *U;
	int		dim = intfc->dim;
	int		i;
	static int	dgmax[3] = {DEFAULT_GMAX, DEFAULT_GMAX, DEFAULT_GMAX};

	if (DEBUG)
	    (void) printf("\n\nEntered set_topological_grid()\n");
	intfc->table->new_grid = YES;
	if (input_grid != NULL)
	{
	    copy_rect_grid(top_grid,input_grid);
	    intfc->table->fixed_grid = YES;
	    if (DEBUG)
		(void) printf("Left set_topological_grid()\n\n");
	    return;
	}
	else
	    intfc->table->fixed_grid = NO;

			/* Find Rectangle Containing INTERFACE: */
	L = top_grid->L;
	U = top_grid->U;
	for (i = 0; i < dim; ++i)
	{
	    L[i] = HUGE_VAL;
	    U[i] = -HUGE_VAL;
	}

	(void) next_point(intfc,NULL,NULL,NULL);
	while (next_point(intfc,&p,&hse,&hs))
	{
	    for (i = 0; i < dim; ++i)
	    {
	    	L[i] = min(L[i],Coords(p)[i]);
	    	U[i] = max(U[i],Coords(p)[i]);
	    }
	}


	if (DEBUG) 
	{
	    (void) printf("Rectsolid: ");
	    print_general_vector("L = ",L,dim,"");
	    print_general_vector("U = ",L,dim,"\n");
	}

	set_rect_grid(L,U,L,U,NOBUF,NOBUF,dgmax,dim,remap_info(),top_grid);

	if (DEBUG)
	    (void) printf("Left set_topological_grid()\n\n");
	return;
}		/*end set_toplogical_grid*/
Beispiel #4
0
EXPORT	void init_topological_grid(
	RECT_GRID *top_grid,
	const RECT_GRID *r_grid)
{
	char       *c;
	const char *dimname;
	static const char *blanks = " \t";
	const char *fmt1,*fmt2,*fmt3;
	char	   *message;
	double	   cor_fac;
	int	   len;
	int	   i, dim = r_grid->dim;
	int	   n_ints, n_floats, gmax[3];
	static const char *dimnames[] = {"one", "two", "three"};
	char    s[Gets_BUF_SIZE];

	dimname = dimnames[dim-1];
	copy_rect_grid(top_grid,r_grid);
	(void) adjust_top_grid_for_square(top_grid,r_grid);
	for (i = 0; i < dim; ++i)
		gmax[i] = top_grid->gmax[i];

	fmt1 =
		"The topological grid is a grid used for the construction of "
		"the tracked front topology. "
		"It is constrained to be a square grid. "
		"You specify the grid in one of two ways. "
		"If you enter a single number,  it will be used as a "
		"coarseness factor for the topological grid relative to the "
		"computational grid entered above. "
		"In this case the length of a topological grid block cell "
		"side is the nearest allowable multiple of the shortest side "
		"of the computational grid by the coarseness factor. ";
	fmt2 =
		"Otherwise the code will read the %s integers input for the "
		"number of grid cells in each coordinate direction of the "
		"topological grid. "
		"If your input values do not yield a square grid they will "
		"be corrected to produce a square grid. "
		"This correction will attempt to produce values close to those "
		"input, but if the input values are highly rectangular, "
		"the resulting values may differ considerably from those "
		"entered. ";
	fmt3 =
		"The default for this input option is the nearest "
		"square grid that matches the computational grid. "
		"Generally the topological grid is coarser than the "
		"computational grid. "
		"Larger coarseness factors yield coarser grids,  a value one "
		"gives the nearest square grid to the computational grid.\n";

	len = 500;
	uni_array(&message,len,CHAR);
	(void) sprintf(message,fmt1,dimname);
	screen_print_long_string(message);
	(void) sprintf(message,fmt2,dimname);
	screen_print_long_string(message);
	(void) sprintf(message,fmt3,dimname);
	screen_print_long_string(message);
	free(message);
	message = NULL;
	if (dim == 1)
	{
		screen_print_long_string(
			"\tBe sure to use a decimal point to "
			"indicate a floating point number "
			"if you choose to input a coarseness factor.\n");
	}
	screen("Enter your choice (cor_fac, %s integer%s, or return)\n",
		dimname,(dim > 1) ? "s" : "");
	screen("\t(defaults are");
	for (i = 0; i < dim; ++i) screen(" %d",gmax[i]);
	screen("): ");
	(void) Gets(s);
	if (s[0] != '\0')
	{
	    n_floats = sscan_float(s,&cor_fac);
	    if (dim == 1)
	    {
	        /*
	        *  To distinguish whether the input is a
	        *  coarseness factor search for a "." in s
	        */
	        if (strstr(s,".") == NULL)
	        {
	            n_floats = 0;
	            cor_fac = ERROR_FLOAT;
	        }
	    }
	    for (n_ints = 0, c = strtok(s,blanks); c != NULL;
	                     c = strtok(NULL,blanks), ++n_ints)
	    {
	        (void) sscanf(c,"%d",gmax+n_ints%dim);
	    }
	    if (n_ints == 2*dim)
	    {
	        /* There is a secret undocumemted option here.
	        *  Enter the topological grid sizes twice and the
	        *  code will use these values whether they give a square grid
	        *  or not.  This makes nearest_interface_point()
	        *  invalid,  but you can get what you ask for.
	        */
	        set_rect_grid(top_grid->L,top_grid->U,top_grid->L,top_grid->U,
	                      NOBUF,NOBUF,gmax,dim,&r_grid->Remap,top_grid);
	    }
	    else if ((n_ints == 1) && (n_floats > 0))
	    {
	        int imin;
	        imin = 0;
	        for (i = 1; i < dim; ++i)
	            if (r_grid->h[i] < r_grid->h[imin]) imin = i;

	        top_grid->gmax[imin] = irint(r_grid->gmax[imin]/cor_fac);
	        if (top_grid->gmax[imin] <= 0) top_grid->gmax[imin] = 1;
	        top_grid->h[imin] = (top_grid->U[imin] - top_grid->L[imin]) /
	                    top_grid->gmax[imin];
	        for (i = 0; i < dim; ++i)
	        {
	            double   tmp_gmax;
	            if (i == imin) continue;
	            tmp_gmax = (top_grid->U[i] - top_grid->L[i]) /
	                    top_grid->h[imin];
	            top_grid->gmax[i] = (int)(tmp_gmax);
	        }
	        (void) adjust_top_grid_for_square(top_grid,r_grid);
	        set_rect_grid(top_grid->L,top_grid->U,top_grid->L,top_grid->U,
	            NOBUF,NOBUF,top_grid->gmax,dim,&r_grid->Remap,top_grid);
	    }
	    else if (n_ints == dim)
	    {
	        for (i = 0; i < dim; ++i)
	            top_grid->gmax[i] = gmax[i];
	        (void) adjust_top_grid_for_square(top_grid,r_grid);
	        set_rect_grid(top_grid->L,top_grid->U,top_grid->L,top_grid->U,
	            NOBUF,NOBUF,top_grid->gmax,dim,&r_grid->Remap,top_grid);
	    }
	    else
	    {
	        screen("ERROR in init_topological_grid(), "
	               "invalid input of topogical grid mesh\n");
	        clean_up(ERROR);
	    }
	}
	screen("The topological mesh used is ");
	for (i = 0; i < dim; ++i) screen(" %d",top_grid->gmax[i]);
	screen("\n\n");
}		/*end init_topological_grid*/