void sciddicaTCADef() { //cadef and rundef sciddicaT = calCADef2D (ROWS, COLS, CAL_VON_NEUMANN_NEIGHBORHOOD_2D, CAL_SPACE_TOROIDAL, CAL_NO_OPT); sciddicaT_simulation = calRunDef2D(sciddicaT, 1, CAL_RUN_LOOP, CAL_UPDATE_IMPLICIT); //put OpenCAL - OMP in unsafe state execution(to allow unsafe operation to be used) calSetUnsafe2D(sciddicaT); //add transition function's elementary processes calAddElementaryProcess2D(sciddicaT, sciddicaTFlowsComputation); calAddElementaryProcess2D(sciddicaT, sciddicaTWidthUpdate); //add substates Q.z = calAddSubstate2Dr(sciddicaT); Q.h = calAddSubstate2Dr(sciddicaT); Q.f[0] = calAddSubstate2Dr(sciddicaT); Q.f[1] = calAddSubstate2Dr(sciddicaT); Q.f[2] = calAddSubstate2Dr(sciddicaT); Q.f[3] = calAddSubstate2Dr(sciddicaT); //load configuration sciddicaTLoadConfig(); //simulation run setup calRunAddInitFunc2D(sciddicaT_simulation, sciddicaTSimulationInit); calRunInitSimulation2D(sciddicaT_simulation); calRunAddSteeringFunc2D(sciddicaT_simulation, sciddicaTSteering); calRunAddStopConditionFunc2D(sciddicaT_simulation, sciddicaTSimulationStopCondition); }
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); }
void CADef(struct CellularAutomaton* ca) { //cadef and rundef life.model = calCADef2D (ROWS, COLS, CAL_MOORE_NEIGHBORHOOD_2D, CAL_SPACE_TOROIDAL, CAL_NO_OPT); life.run = calRunDef2D(life.model, 1, CAL_RUN_LOOP, CAL_UPDATE_IMPLICIT); //add substates life.Q = calAddSubstate2Di(life.model); //add transition function's elementary processes calAddElementaryProcess2D(life.model, lifeTransitionFunction); //simulation run setup calRunAddInitFunc2D(life.run, randSimulationInit); }
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); }
int main() { // define of the life CA and life_simulation simulation objects life = calCADef2D(8, 16, CAL_MOORE_NEIGHBORHOOD_2D, CAL_SPACE_TOROIDAL, CAL_NO_OPT); life_simulation = calRunDef2D(life, 1, 1, CAL_UPDATE_IMPLICIT); //put OpenCAL - OMP in unsafe state execution(to allow unsafe operation to be used) calSetUnsafe2D(life); // add the Q substate to the life CA Q = calAddSubstate2Di(life); // add transition function's elementary process calAddElementaryProcess2D(life, lifeTransitionFunction); // set the whole substate to 0 calInitSubstate2Di(life, Q, 0); // set a glider calInit2Di(life, Q, 0, 2, 1); calInit2Di(life, Q, 1, 0, 1); calInit2Di(life, Q, 1, 2, 1); calInit2Di(life, Q, 2, 1, 1); calInit2Di(life, Q, 2, 2, 1); // save the Q substate to file calSaveSubstate2Di(life, Q, "./life_0000.txt"); // simulation run calRun2D(life_simulation); // save the Q substate to file calSaveSubstate2Di(life, Q, "./life_LAST.txt"); // finalize simulation and CA objects calRunFinalize2D(life_simulation); calFinalize2D(life); return 0; }
int main() { time_t start_time, end_time; //cadef and rundef struct CALModel2D* sciddicaT = calCADef2D (ROWS, COLS, CAL_VON_NEUMANN_NEIGHBORHOOD_2D, CAL_SPACE_TOROIDAL, CAL_OPT_ACTIVE_CELLS); struct CALRun2D* sciddicaT_simulation = calRunDef2D(sciddicaT, 1, STEPS, CAL_UPDATE_IMPLICIT); //add transition function's elementary processes calAddElementaryProcess2D(sciddicaT, sciddicaT_transition_function); calAddElementaryProcess2D(sciddicaT, sciddicaT_remove_inactive_cells); //add substates Q.z = calAddSingleLayerSubstate2Dr(sciddicaT); Q.h = calAddSubstate2Dr(sciddicaT); //load configuration calLoadSubstate2Dr(sciddicaT, Q.z, DEM_PATH); calLoadSubstate2Dr(sciddicaT, Q.h, SOURCE_PATH); //simulation run calRunAddInitFunc2D(sciddicaT_simulation, sciddicaT_simulation_init); printf ("Starting simulation...\n"); start_time = time(NULL); calRun2D(sciddicaT_simulation); end_time = time(NULL); printf ("Simulation terminated.\nElapsed time: %d\n", end_time-start_time); //saving configuration calSaveSubstate2Dr(sciddicaT, Q.h, OUTPUT_PATH); //finalizations calRunFinalize2D(sciddicaT_simulation); calFinalize2D(sciddicaT); return 0; }