Exemplo n.º 1
0
void sciddicaTCADef()
{
	//cadef and rundef
	s3hex = calCADef2D (ROWS, COLS, CAL_HEXAGONAL_NEIGHBORHOOD_2D, CAL_SPACE_TOROIDAL, CAL_OPT_ACTIVE_CELLS);
	s3hexSimulation = calRunDef2D(s3hex, 1, CAL_RUN_LOOP, CAL_UPDATE_EXPLICIT);

	//add transition function's elementary processes
	calAddElementaryProcess2D(s3hex, s3hexErosion);
	calAddElementaryProcess2D(s3hex, s3hexFlowsComputation);
	calAddElementaryProcess2D(s3hex, s3hexRomoveInactiveCells);
	calAddElementaryProcess2D(s3hex, s3hexEnergyLoss);

	//add substates
	Q.z = calAddSingleLayerSubstate2Dr(s3hex);
	Q.d = calAddSingleLayerSubstate2Dr(s3hex);
	Q.s = calAddSingleLayerSubstate2Di(s3hex);
	Q.h = calAddSubstate2Dr(s3hex);
	Q.p = calAddSubstate2Dr(s3hex);

	//load configuration
	sciddicaTLoadConfig();

	//simulation run setup
	calRunAddInitFunc2D(s3hexSimulation, sciddicaTSimulationInit); calRunInitSimulation2D(s3hexSimulation);
	calRunAddGlobalTransitionFunc2D(s3hexSimulation, sciddicaTransitionFunction);
	calRunAddStopConditionFunc2D(s3hexSimulation, sciddicaTSimulationStopCondition);
}
Exemplo n.º 2
0
void initSciara(char * demPath) {

	sciara = new Sciara;
	FILE * demFile = fopen(demPath, "r");
	if (demFile == NULL) {
		perror("Cannot open dem file\n");
		exit(EXIT_FAILURE);
	}
	TGISInfo sciaraINFO;
	int err = LeggiGISInfo(sciaraINFO, demFile);
	if (err > 0) {
		perror("Error while reading GIS INFO\n");
		exit(EXIT_FAILURE);
	}

	sciara->rows = sciaraINFO.nrows;
	sciara->cols = sciaraINFO.ncols;
	sciara->elapsed_time = 0.0;
	sciara->parameters.rad2 = sqrt(2.0);
	sciara->parameters.effusion_duration = 0;

	if (active)
		sciara->model = calCADef2D(sciara->rows, sciara->cols, CAL_MOORE_NEIGHBORHOOD_2D, CAL_SPACE_TOROIDAL, CAL_OPT_ACTIVE_CELLS);
	else
		sciara->model = calCADef2D(sciara->rows, sciara->cols, CAL_MOORE_NEIGHBORHOOD_2D, CAL_SPACE_TOROIDAL, CAL_NO_OPT);

	sciara->substates = new SciaraSubstates();

	sciara->substates->Sz = calAddSubstate2Dr(sciara->model);
	sciara->substates->Slt = calAddSubstate2Dr(sciara->model);
	sciara->substates->St = calAddSubstate2Dr(sciara->model);

	sciara->substates->Mb = calAddSingleLayerSubstate2Db(sciara->model);
	sciara->substates->Mv = calAddSingleLayerSubstate2Di(sciara->model);
	sciara->substates->Msl = calAddSingleLayerSubstate2Dr(sciara->model);
	sciara->substates->Sz_t0 = calAddSingleLayerSubstate2Dr(sciara->model);

	calInitSubstate2Dr(sciara->model, sciara->substates->Sz, 0);
	calInitSubstate2Dr(sciara->model, sciara->substates->Slt, 0);
	calInitSubstate2Dr(sciara->model, sciara->substates->St, 0);

	//TODO single layer initialization
	for (int i = 0; i < sciara->rows * sciara->cols; ++i) {
		sciara->substates->Mb->current[i] = CAL_FALSE;
		sciara->substates->Mv->current[i] = 0;
		sciara->substates->Msl->current[i] = 0;
		sciara->substates->Sz_t0->current[i] = 0;
	}

	for (int i = 0; i < NUMBER_OF_OUTFLOWS; ++i) {
		sciara->substates->f[i] = calAddSubstate2Dr(sciara->model);
		calInitSubstate2Dr(sciara->model, sciara->substates->f[i], 0);
	}

	fclose(demFile);

}
Exemplo n.º 3
0
void sciddicaTCADef()
{
  int n;
  CALbyte optimization_type = CAL_NO_OPT;

#ifdef ACTIVE_CELLS
  optimization_type = CAL_OPT_ACTIVE_CELLS;
#endif

  //cadef and rundef
  s3hex = calCADef2D (ROWS, COLS, CAL_HEXAGONAL_NEIGHBORHOOD_2D, CAL_SPACE_TOROIDAL, optimization_type);
	s3hexSimulation = calRunDef2D(s3hex, 1, CAL_RUN_LOOP, CAL_UPDATE_IMPLICIT);

	//put OpenCAL - OMP in unsafe state execution(to allow unsafe operation to be used)
	calSetUnsafe2D(s3hex);

	//add transition function's elementary processes
    calAddElementaryProcess2D(s3hex, s3hexErosion);
    calAddElementaryProcess2D(s3hex, s3hexFlowsComputation);
    calAddElementaryProcess2D(s3hex, s3hexWidthAndPotentialUpdate);
    calAddElementaryProcess2D(s3hex, s3hexClearOutflows);
    calAddElementaryProcess2D(s3hex, s3hexEnergyLoss);
    calAddElementaryProcess2D(s3hex, s3hexRomoveInactiveCells);

	//add substates
	Q.z = calAddSingleLayerSubstate2Dr(s3hex);
	Q.d = calAddSingleLayerSubstate2Dr(s3hex);
	Q.s = calAddSingleLayerSubstate2Di(s3hex);
	Q.h = calAddSubstate2Dr(s3hex);
	Q.p = calAddSubstate2Dr(s3hex);
    for (n=0; n<s3hex->sizeof_X; n++)
      {
        Q.fh[n] = calAddSubstate2Dr(s3hex);
        Q.fp[n] = calAddSubstate2Dr(s3hex);
      }

	//load configuration
	sciddicaTLoadConfig();

	//simulation run setup
	calRunAddInitFunc2D(s3hexSimulation, sciddicaTSimulationInit); calRunInitSimulation2D(s3hexSimulation);
	calRunAddStopConditionFunc2D(s3hexSimulation, sciddicaTSimulationStopCondition);
}