Exemplo n.º 1
0
void sciddicaTSimulationInit(struct CALModel2D* sciddicaT)
{
	CALreal z, h;
	CALint i, j;

	//initializing substates to 0
	calInitSubstate2Dr(sciddicaT, Q.f[0], 0);
	calInitSubstate2Dr(sciddicaT, Q.f[1], 0);
	calInitSubstate2Dr(sciddicaT, Q.f[2], 0);
	calInitSubstate2Dr(sciddicaT, Q.f[3], 0);

	//sciddicaT parameters setting
	P.r = P_R;
	P.epsilon = P_EPSILON;

	//sciddicaT source initialization
	for (i=0; i<sciddicaT->rows; i++)
		for (j=0; j<sciddicaT->columns; j++)
		{
			h = calGet2Dr(sciddicaT, Q.h, i, j);

			if ( h > 0.0 ) {
				z = calGet2Dr(sciddicaT, Q.z, i, j);
				calSet2Dr(sciddicaT, Q.z, i, j, z-h);
			}
		}
}
Exemplo n.º 2
0
// SciddicaT simulation init function
void sciddicaTSimulationInit(struct CALModel2D* host_CA) {
	CALreal z, h;
	CALint i, j;

	//initializing substates to 0
	calInitSubstate2Dr(host_CA, Q.f[0], 0);
	calInitSubstate2Dr(host_CA, Q.f[1], 0);
	calInitSubstate2Dr(host_CA, Q.f[2], 0);
	calInitSubstate2Dr(host_CA, Q.f[3], 0);

	//sciddicaT parameters setting
	P.r = P_R;
	P.epsilon = P_EPSILON;

	//sciddicaT source initialization
	for (i = 0; i < host_CA->rows; i++)
		for (j = 0; j < host_CA->columns; j++) {
			h = calGet2Dr(host_CA, Q.h, i, j);

			if (h > 0.0) {
				z = calGet2Dr(host_CA, Q.z, i, j);
				calSet2Dr(host_CA, Q.z, i, j, z - h);

#ifdef ACTIVE_CELLS
				//adds the cell (i, j) to the set of active ones
				calAddActiveCell2D(host_CA, i, j);
#endif
			}
		}
}
Exemplo n.º 3
0
//transition function
void s3hexErosion(struct CALModel2D* s3hex, int i, int j)
{
	CALint s;
	CALreal d, p, erosion_depth;

	d = calGet2Dr(s3hex,Q.d,i,j);
	if (d > 0)
	{
		s = calGet2Di(s3hex,Q.s,i,j);
		if (s <  -1)
			calSetCurrent2Di(s3hex,Q.s,i,j,s+1);
		if (s == -1) {
			calSetCurrent2Di(s3hex,Q.s,i,j,0);
			doErosion(s3hex,i,j,d);
#ifdef ACTIVE_CELLS
			calAddActiveCell2D(s3hex,i,j);
#endif
		}

		p = calGet2Dr(s3hex,Q.p,i,j);
		if (p > P.mt) {
			erosion_depth = p * P.pef;
			if (erosion_depth > d)
				erosion_depth = d;
			doErosion(s3hex,i,j,erosion_depth);
		}
	}
}
Exemplo n.º 4
0
void sciddicaT_simulation_init(struct CALModel2D* sciddicaT)
{
    CALreal z, h;
    CALint i, j;

    //sciddicaT parameters setting
    P.r = P_R;
    P.epsilon = P_EPSILON;

    //sciddicaT source initialization
    for (i=0; i<sciddicaT->rows; i++)
        for (j=0; j<sciddicaT->columns; j++)
        {
            h = calGet2Dr(sciddicaT, Q.h, i, j);

            if ( h > 0.0 ) {
                z = calGet2Dr(sciddicaT, Q.z, i, j);
                calSetCurrent2Dr(sciddicaT, Q.z, i, j, z-h);

#ifdef ACTIVE_CELLS
                //adds the cell (i, j) to the set of active ones
                calAddActiveCell2D(sciddicaT, i, j);
#endif
            }
        }
}
Exemplo n.º 5
0
//transition function
void sciddicaT_transition_function(struct CALModel2D* sciddicaT, int i, int j)
{
    CALbyte eliminated_cells[5]= {CAL_FALSE,CAL_FALSE,CAL_FALSE,CAL_FALSE,CAL_FALSE};
    CALbyte again;
    CALint cells_count;
    CALreal average;
    CALreal m;
    CALreal u[5];
    CALint n;
    CALreal z, h;
    CALreal f;


    m = calGet2Dr(sciddicaT, Q.h, i, j) - P.epsilon;
    u[0] = calGet2Dr(sciddicaT, Q.z, i, j) + P.epsilon;
    for (n=1; n<sciddicaT->sizeof_X; n++)
    {
        z = calGetX2Dr(sciddicaT, Q.z, i, j, n);
        h = calGetX2Dr(sciddicaT, Q.h, i, j, n);
        u[n] = z + h;
    }

    //computes outflows
    do {
        again = CAL_FALSE;
        average = m;
        cells_count = 0;

        for (n=0; n<sciddicaT->sizeof_X; n++)
            if (!eliminated_cells[n]) {
                average += u[n];
                cells_count++;
            }

        if (cells_count != 0)
            average /= cells_count;

        for (n=0; n<sciddicaT->sizeof_X; n++)
            if( (average<=u[n]) && (!eliminated_cells[n]) ) {
                eliminated_cells[n]=CAL_TRUE;
                again=CAL_TRUE;
            }

    } while (again);


    for (n=1; n<sciddicaT->sizeof_X; n++)
        if (!eliminated_cells[n])
        {
            f = (average-u[n])*P.r;
            calSet2Dr (sciddicaT,Q.h,i,j,   calGetNext2Dr (sciddicaT,Q.h,i,j)   - f );
            calSetX2Dr(sciddicaT,Q.h,i,j,n, calGetNextX2Dr(sciddicaT,Q.h,i,j,n) + f );

#ifdef ACTIVE_CELLS
            //adds the cell (i, j, n) to the set of active ones
            calAddActiveCellX2D(sciddicaT, i, j, n);
#endif
        }
}
Exemplo n.º 6
0
//second (and last) elementary process
void sciddicaTWidthUpdate(struct CALModel2D* sciddicaT, int i, int j)
{
	CALreal h_next;
	CALint n;

	h_next = calGet2Dr(sciddicaT, Q.h, i, j);
	for(n=1; n<sciddicaT->sizeof_X; n++)
		h_next +=  calGetX2Dr(sciddicaT, Q.f[NUMBER_OF_OUTFLOWS - n], i, j, n) - calGet2Dr(sciddicaT, Q.f[n-1], i, j);

	calSet2Dr(sciddicaT, Q.h, i, j, h_next);
}
Exemplo n.º 7
0
void s3hexClearOutflows(struct CALModel2D* s3hex, int i, int j)
{
  int n;
  for (n=0; n<s3hex->sizeof_X; n++)
    {
      if (calGet2Dr(s3hex, Q.fh[n], i, j) > 0.0)
        calSet2Dr(s3hex, Q.fh[n], i, j, 0.0);
      if (calGet2Dr(s3hex, Q.fp[n], i, j) > 0.0)
        calSet2Dr(s3hex, Q.fp[n], i, j, 0.0);
    }
}
Exemplo n.º 8
0
//first elementary process
void sciddicaTFlowsComputation(struct CALModel2D* sciddicaT, int i, int j)
{
	CALbyte eliminated_cells[5]={CAL_FALSE,CAL_FALSE,CAL_FALSE,CAL_FALSE,CAL_FALSE};
	CALbyte again;
	CALint cells_count;
	CALreal average;
	CALreal m;
	CALreal u[5];
	CALint n;
	CALreal z, h;


	if (calGet2Dr(sciddicaT, Q.h, i, j) <= P.epsilon)
		return;

	m = calGet2Dr(sciddicaT, Q.h, i, j) - P.epsilon;
	u[0] = calGet2Dr(sciddicaT, Q.z, i, j) + P.epsilon;
	for (n=1; n<sciddicaT->sizeof_X; n++)
	{
		z = calGetX2Dr(sciddicaT, Q.z, i, j, n);
		h = calGetX2Dr(sciddicaT, Q.h, i, j, n);
		u[n] = z + h;
	}

	//computes outflows
	do{
		again = CAL_FALSE;
		average = m;
		cells_count = 0;

		for (n=0; n<sciddicaT->sizeof_X; n++)
			if (!eliminated_cells[n]){
				average += u[n];
				cells_count++;
			}

			if (cells_count != 0)
				average /= cells_count;

			for (n=0; n<sciddicaT->sizeof_X; n++)
				if( (average<=u[n]) && (!eliminated_cells[n]) ){
					eliminated_cells[n]=CAL_TRUE;
					again=CAL_TRUE;
				}

	}while (again);

	for (n=1; n<sciddicaT->sizeof_X; n++)
		if (eliminated_cells[n])
			calSet2Dr(sciddicaT, Q.f[n-1], i, j, 0.0);
		else
			calSet2Dr(sciddicaT, Q.f[n-1], i, j, (average-u[n])*P.r);
}
Exemplo n.º 9
0
void MakeBorder() {
	int j, i;

	//prima riga
	i = 0;
	for (j = 0; j < sciara->cols; j++)
		if (calGet2Dr(sciara->model, sciara->substates->Sz, i, j) >= 0) {
			calSetCurrent2Db(sciara->model, sciara->substates->Mb, i, j, CAL_TRUE);
			if (active)
				calAddActiveCell2D(sciara->model, i, j);
		}
	//ultima riga
	i = sciara->rows - 1;
	for (j = 0; j < sciara->cols; j++)
		if (calGet2Dr(sciara->model, sciara->substates->Sz, i, j) >= 0) {
			calSetCurrent2Db(sciara->model, sciara->substates->Mb, i, j, CAL_TRUE);
			if (active)
				calAddActiveCell2D(sciara->model, i, j);
		}
	//prima colonna
	j = 0;
	for (i = 0; i < sciara->rows; i++)
		if (calGet2Dr(sciara->model, sciara->substates->Sz, i, j) >= 0) {
			calSetCurrent2Db(sciara->model, sciara->substates->Mb, i, j, CAL_TRUE);
			if (active)
				calAddActiveCell2D(sciara->model, i, j);
		}
	//ultima colonna
	j = sciara->cols - 1;
	for (i = 0; i < sciara->rows; i++)
		if (calGet2Dr(sciara->model, sciara->substates->Sz, i, j) >= 0) {
			calSetCurrent2Db(sciara->model, sciara->substates->Mb, i, j, CAL_TRUE);
			if (active)
				calAddActiveCell2D(sciara->model, i, j);
		}
	//il resto
	for (int i = 1; i < sciara->rows - 1; i++)
		for (int j = 1; j < sciara->cols - 1; j++)
			if (calGet2Dr(sciara->model, sciara->substates->Sz, i, j) >= 0) {
				for (int k = 1; k < sciara->model->sizeof_X; k++)
					if (calGetX2Dr(sciara->model, sciara->substates->Sz, i, j, k) < 0) {
						calSetCurrent2Db(sciara->model, sciara->substates->Mb, i, j, CAL_TRUE);
						if (active)
							calAddActiveCell2D(sciara->model, i, j);
						break;
					}
			}

}
Exemplo n.º 10
0
void s3hexEnergyLoss(struct CALModel2D* s3hex, int i, int j)
{
	CALreal h, runup;

	if (calGet2Dr(s3hex,Q.h,i,j) <= P.adh)
		return;

	h = calGet2Dr(s3hex,Q.h,i,j);
	if (h > P.adh) {
		runup = calGet2Dr(s3hex,Q.p,i,j) / h - P.rl;
		if (runup < h)
			runup = h;
		calSet2Dr(s3hex,Q.p,i,j,h*runup);
	}
}
Exemplo n.º 11
0
void s3hexRomoveInactiveCells(struct CALModel2D* s3hex, int i, int j)
{
#ifdef ACTIVE_CELLS
	if (calGet2Dr(s3hex,Q.h,i,j) <= P.adh)
		calRemoveActiveCell2D(s3hex,i,j);
#endif
}
Exemplo n.º 12
0
void sciddicaTSimulationInit(struct CALModel2D* s3hex)
{
	int i, j;

	//s3hex parameters setting
	P.adh = P_ADH;
	P.rl = P_RL;
	P.r = P_R;
	P.f = P_F;
	P.mt = P_MT;
	P.pef = P_PEF;
//	P.ltt = P_LTT;

	//initializing debris source
	calInitSubstate2Dr(s3hex, Q.h, 0);
	calInitSubstate2Dr(s3hex, Q.p, 0);

#ifdef ACTIVE_CELLS
	for (i=0; i<s3hex->rows; i++)
		for (j=0; j<s3hex->columns; j++)
			if (calGet2Dr(s3hex,Q.h,i,j) > P.adh) {
				calAddActiveCell2D(s3hex,i,j);
	}
#endif

	//Substates and active cells update
	calUpdate2D(s3hex);
}
Exemplo n.º 13
0
void sciddicaTSimulationInit(struct CALModel2D* s3hex)
{
  int i, j, n;

    //s3hex parameters setting
	P.adh = P_ADH;
	P.rl = P_RL;
	P.r = P_R;
	P.f = P_F;
	P.mt = P_MT;
	P.pef = P_PEF;
//	P.ltt = P_LTT;

	//initializing substates
	calInitSubstate2Dr(s3hex, Q.h, 0);
	calInitSubstate2Dr(s3hex, Q.p, 0);
    for (n=0; n<s3hex->sizeof_X; n++)
    {
      calInitSubstate2Dr(s3hex, Q.fh[n], 0);
      calInitSubstate2Dr(s3hex, Q.fp[n], 0);
    }


#ifdef ACTIVE_CELLS
	for (i=0; i<s3hex->rows; i++)
		for (j=0; j<s3hex->columns; j++)
			if (calGet2Dr(s3hex,Q.h,i,j) > P.adh) {
				calAddActiveCell2D(s3hex,i,j);
	}
#endif
}
Exemplo n.º 14
0
void sciddicaT_remove_inactive_cells(struct CALModel2D* sciddicaT, int i, int j)
{
#ifdef ACTIVE_CELLS
    if (calGet2Dr(sciddicaT, Q.h, i, j) <= P.epsilon)
        calRemoveActiveCell2D(sciddicaT,i,j);
#endif
}
Exemplo n.º 15
0
void doErosion(struct CALModel2D* s3hex, int i, int j, CALreal	erosion_depth)
{
	CALreal z, d, h, p, runup;

	z = calGet2Dr(s3hex,Q.z,i,j);
	d = calGet2Dr(s3hex,Q.d,i,j);
	h = calGet2Dr(s3hex,Q.h,i,j);
	p = calGet2Dr(s3hex,Q.p,i,j);

	if (h > 0)
		runup =  p/h + erosion_depth;
	else
		runup = erosion_depth;

	calSetCurrent2Dr(s3hex,Q.z,i,j, (z - erosion_depth));
	calSetCurrent2Dr(s3hex,Q.d,i,j, (d - erosion_depth));
	calSet2Dr(s3hex,Q.h,i,j, (h + erosion_depth));
	calSet2Dr(s3hex,Q.p,i,j, (h + erosion_depth)*runup);
}
Exemplo n.º 16
0
void s3hexWidthAndPotentialUpdate(struct CALModel2D* s3hex, int i, int j)
{
  CALreal h_next, p_next;
  CALint n, m;

	h_next = calGet2Dr(s3hex, Q.h, i, j) - calGet2Dr(s3hex, Q.fh[0], i, j);
	for(n=1; n<s3hex->sizeof_X; n++)
      {
        if (n <= 3) m = n+3; else m = n-3;
		h_next +=  calGetX2Dr(s3hex, Q.fh[m], i, j, n);
      }
	calSet2Dr(s3hex, Q.h, i, j, h_next);

    p_next = calGet2Dr(s3hex, Q.p, i, j) - calGet2Dr(s3hex, Q.fp[0], i, j);
	for(n=1; n<s3hex->sizeof_X; n++)
      {
        if (n <= 3) m = n+3; else m = n-3;
		p_next +=  calGetX2Dr(s3hex, Q.fp[m], i, j, n);
      }
	calSet2Dr(s3hex, Q.p, i, j, p_next);
}
Exemplo n.º 17
0
void s3hexFlowsComputation(struct CALModel2D* s3hex, int i, int j)
{
	CALbyte eliminated_cells[7]={CAL_FALSE,CAL_FALSE,CAL_FALSE,CAL_FALSE,CAL_FALSE, CAL_FALSE, CAL_FALSE};
	CALbyte again;
	CALint cells_count;
	CALreal average;
	CALreal m;
	CALreal u[7], delta_H[7], delta_z[7];
	CALint n;
	CALreal z_0, h_0, z_n, h_n, runup_0, z_0_plus_runup_0, sum;
	CALreal f;


	if (calGet2Dr(s3hex,Q.h,i,j) <= P.adh)
		return;

	z_0 = calGet2Dr(s3hex, Q.z, i, j);
	h_0 = calGet2Dr(s3hex, Q.h, i, j);
	runup_0 = calGet2Dr(s3hex, Q.p, i, j) / h_0;
	z_0_plus_runup_0 = z_0 + runup_0;

	m = runup_0;
	u[0] = z_0;
	delta_z[0] = 0;
	delta_H[0] = 0;
	for (n=1; n<s3hex->sizeof_X; n++)
	{
		z_n = calGetX2Dr(s3hex, Q.z, i, j, n);
		h_n = calGetX2Dr(s3hex, Q.h, i, j, n);

		u[n] = z_n + h_n;
		delta_z[n] = z_0 - z_n;
		delta_H[n] = z_0_plus_runup_0 - u[n];
	}

	for (n=1; n<s3hex->sizeof_X; n++)
		eliminated_cells[n] = (delta_H[n] < P.f);
	//computes outflows
	do{
		again = CAL_FALSE;
		average = m;
		cells_count = 0;

		for (n=0; n<s3hex->sizeof_X; n++)
			if (!eliminated_cells[n]){
				average += u[n];
				cells_count++;
			}

			if (cells_count != 0)
				average /= cells_count;

			for (n=0; n<s3hex->sizeof_X; n++)
				if( (average<=u[n]) && (!eliminated_cells[n]) ){
					eliminated_cells[n]=CAL_TRUE;
					again=CAL_TRUE;
				}

	}while (again);


	sum = 0;
	for (n=0; n<s3hex->sizeof_X; n++)
		if (!eliminated_cells[n])
			sum += average - u[n];

	for (n=1; n<s3hex->sizeof_X; n++)
		if (!eliminated_cells[n])
		{
			//f = (h_0 - P.adh) * ((average-u[n])/sum) * P.r;
			f = h_0 * ((average-u[n])/sum) * P.r;
			calSet2Dr (s3hex,Q.h,i,j,   calGetNext2Dr (s3hex,Q.h,i,j)   - f );
			calSetX2Dr(s3hex,Q.h,i,j,n, calGetNextX2Dr(s3hex,Q.h,i,j,n) + f );

			calSet2Dr (s3hex,Q.p,i,j,   calGetNext2Dr (s3hex,Q.p,i,j)   - runup_0 * f );
			calSetX2Dr(s3hex,Q.p,i,j,n, calGetNextX2Dr(s3hex,Q.p,i,j,n) + (z_0_plus_runup_0 - u[n]) * f );

#ifdef ACTIVE_CELLS
			//adds the cell (i, j, n) to the set of active ones
            calAddActiveCellX2D(s3hex, i, j, n);
#endif
		}
}