int main(int argc, char** argv) { time_t start_time, end_time; //cadef and rundef heatModel = calCADef3D(ROWS, COLS, LAYERS, CAL_MOORE_NEIGHBORHOOD_3D, CAL_SPACE_FLAT, CAL_NO_OPT); heat_simulation = calRunDef3D(heatModel, 1, STEPS, CAL_UPDATE_IMPLICIT); //add substates Q_temperature = calAddSubstate3Dr(heatModel); Q_heat_source = calAddSubstate3Db(heatModel); //add transition function's elementary processes calAddElementaryProcess3D(heatModel, heatModel_TransitionFunction); //simulation run setup calRunAddInitFunc3D(heat_simulation, heatModel_SimulationInit); calRunInitSimulation3D(heat_simulation); //It is required in the case the simulation main loop is explicitated; similarly for calRunFinalizeSimulation3D // calRunAddStopConditionFunc3D(heat_simulation, heatModel_SimulationStopCondition); start_time = time(NULL); calRun3D(heat_simulation); end_time = time(NULL); printf("%lds", end_time - start_time); // Save the substate to file calSaveSubstate3Dr(heatModel, Q_temperature, "./heat.txt"); calRunFinalize3D(heat_simulation); calFinalize3D(heatModel); return 0; }
void life3DCADef() { //cadef and rundef mod2 = calCADef3D (ROWS, COLS, LAYERS, CAL_MOORE_NEIGHBORHOOD_3D, CAL_SPACE_TOROIDAL, CAL_NO_OPT); mod2_simulation = calRunDef3D(mod2, 1, CAL_RUN_LOOP, CAL_UPDATE_IMPLICIT); //add transition function's elementary processes calAddElementaryProcess3D(mod2, mod2TransitionFunction); //add substates Q.life = calAddSubstate3Db(mod2); //simulation run setup calRunAddInitFunc3D(mod2_simulation, mod2SimulationInit); calRunInitSimulation3D(mod2_simulation); calRunAddStopConditionFunc3D(mod2_simulation, mod2SimulationStopCondition); }
int main(int argc, char** argv){ calglSetApplicationNameGlobalSettings("3D life"); calglSetRowsAndColumnsGlobalSettings(25, 25); calglSetStepGlobalSettings(4000); calglSetWindowDimensionGlobalSettings(400, 400); calglSetWindowPositionGlobalSettings(40, 40); struct CALDrawModel3D* drawModel; //cadef and rundef life3D = calCADef3D(calglGetGlobalSettings()->rows, calglGetGlobalSettings()->columns, LAYERS, CAL_MOORE_NEIGHBORHOOD_3D, CAL_SPACE_TOROIDAL, CAL_NO_OPT); life3Dsimulation = calRunDef3D(life3D, 1, CAL_RUN_LOOP, CAL_UPDATE_IMPLICIT); //add substates Q.life = calAddSubstate3Db(life3D); //add transition function's elementary processes calAddElementaryProcess3D(life3D, life3DTransitionFunction); //simulation run setup calRunAddInitFunc3D(life3Dsimulation, life3DSimulationInit); calRunInitSimulation3D(life3Dsimulation); //It is required in the case the simulation main loop is explicitated; similarly for calRunFinalizeSimulation3D calRunAddStopConditionFunc3D(life3Dsimulation, life3DSimulationStopCondition); //drawModel definition drawModel = calglDefDrawModel3D(CALGL_DRAW_MODE_FLAT, "Life", life3D, life3Dsimulation); calglAddToDrawModel3Db(drawModel, NULL, &Q.life, CALGL_TYPE_INFO_VERTEX_DATA, CALGL_TYPE_INFO_USE_DEFAULT, CALGL_DATA_TYPE_DYNAMIC); calglColor3D(drawModel, 0.5f, 0.5f, 0.5f, 1.0f); calglAddToDrawModel3Db(drawModel, Q.life, &Q.life, CALGL_TYPE_INFO_COLOR_DATA, CALGL_TYPE_INFO_USE_CONST_VALUE, CALGL_DATA_TYPE_DYNAMIC); calglAddToDrawModel3Db(drawModel, Q.life, &Q.life, CALGL_TYPE_INFO_NORMAL_DATA, CALGL_TYPE_INFO_USE_DEFAULT, CALGL_DATA_TYPE_DYNAMIC); calglStartProcessWindow3D(argc, argv); //finalizations calRunFinalize3D(life3Dsimulation); calFinalize3D(life3D); calglDestroyGlobalSettings(); calglCleanDrawModelList3D(); return 0; }