peanoclaw::runners::PeanoClawLibraryRunner* pyclaw_peano_new ( double initialMaximalMeshWidthScalar, double domainOffsetX0, double domainOffsetX1, double domainOffsetX2, double domainSizeX0, double domainSizeX1, double domainSizeX2, int subdivisionFactorX0, int subdivisionFactorX1, int subdivisionFactorX2, int unknownsPerSubcell, int auxiliarFieldsPerSubcell, int ghostlayerWidth, double initialTimestepSize, char* configurationFile, bool useDimensionalSplittingOptimization, bool reduceReductions, InitializationCallback initializationCallback, BoundaryConditionCallback boundaryConditionCallback, SolverCallback solverCallback, RefinementCriterionCallback refinementCriterionCallback, AddPatchToSolutionCallback addPatchToSolutionCallback, InterPatchCommunicationCallback interpolationCallback, InterPatchCommunicationCallback restrictionCallback, InterPatchCommunicationCallback fluxCorrectionCallback, bool enablePeanoLogging, int forkLevelIncrement, int *rank ) { peano::fillLookupTables(); #if defined(Parallel) char argv[2][256]; memset(argv, 0, sizeof(char) * 2 * 256); int argc = 1; //sprintf(argv[0], "%s", "peanoclaw"); peano::initParallelEnvironment(&argc,(char ***)&argv); peano::initSharedMemoryEnvironment(); #endif //Initialize Python _calledFromPython = Py_IsInitialized(); if(_calledFromPython) { //Needed to take over the Python context from the calling process. _pythonState = PyGILState_Ensure(); } else { Py_Initialize(); } importArrays(); //Initialize Logger static tarch::logging::Log _log("::pyclawBindings"); logInfo("pyclaw_peano_new(...)", "Initializing Peano"); configureLogFilter(enablePeanoLogging); //Numerics -- this object is copied to the runner and is stored there. peanoclaw::NumericsFactory numericsFactory; peanoclaw::Numerics* numerics = numericsFactory.createPyClawNumerics( initializationCallback, boundaryConditionCallback, solverCallback, refinementCriterionCallback, addPatchToSolutionCallback, interpolationCallback, restrictionCallback, fluxCorrectionCallback ); _configuration = new peanoclaw::configurations::PeanoClawConfigurationForSpacetreeGrid; //Construct parameters tarch::la::Vector<DIMENSIONS, double> domainOffset = convertToVector(domainOffsetX0, domainOffsetX1, domainOffsetX2); tarch::la::Vector<DIMENSIONS, double> domainSize = convertToVector(domainSizeX0, domainSizeX1, domainSizeX2); tarch::la::Vector<DIMENSIONS, double> initialMinimalMeshWidth(initialMaximalMeshWidthScalar); tarch::la::Vector<DIMENSIONS, int> subdivisionFactor = convertToVector(subdivisionFactorX0, subdivisionFactorX1, subdivisionFactorX2); //Check parameters assertion1(tarch::la::greater(domainSizeX0, 0.0) && tarch::la::greater(domainSizeX1, 0.0), domainSize); if(initialMaximalMeshWidthScalar > domainSizeX0 || initialMaximalMeshWidthScalar > domainSizeX1) { logError("pyclaw_peano_new(...)", "Domainsize or initialMinimalMeshWidth not set properly."); } if(tarch::la::oneGreater(tarch::la::Vector<DIMENSIONS, int>(1), subdivisionFactor) ) { logError("pyclaw_peano_new(...)", "subdivisionFactor not set properly."); } //Create runner peanoclaw::runners::PeanoClawLibraryRunner* runner = new peanoclaw::runners::PeanoClawLibraryRunner( *_configuration, *numerics, domainOffset, domainSize, initialMinimalMeshWidth, subdivisionFactor, ghostlayerWidth, unknownsPerSubcell, auxiliarFieldsPerSubcell, initialTimestepSize, useDimensionalSplittingOptimization, reduceReductions, forkLevelIncrement ); assertion(runner != 0); #if defined(Parallel) *rank = tarch::parallel::Node::getInstance().getRank(); #else *rank = 0; #endif if(_calledFromPython) { PyGILState_Release(_pythonState); } return runner; }
void InitTestItem(void) { FILE *wCfgFile; char fname[256]; testItem = FindItemByClassname ("item_test"); if(!testItem) { return; } strcpy(fname, gamedir->string); strcat(fname, "/testitem.cfg"); wCfgFile = fopen(fname, "rt"); if(!wCfgFile) { return; } if(!fgets(testItem_className, 256, wCfgFile)) { fclose(wCfgFile); return; } testItem_className[strlen(testItem_className) - 1] = 0; if(!fgets(testItem_gModel, 256, wCfgFile)) { fclose(wCfgFile); return; } testItem_gModel[strlen(testItem_gModel) - 1] = 0; if(!fgets(testItem_icon, 256, wCfgFile)) { fclose(wCfgFile); return; } testItem_icon[strlen(testItem_icon) - 1] = 0; if(!fgets(testItem_name, 256, wCfgFile)) { fclose(wCfgFile); return; } testItem_name[strlen(testItem_name) - 1] = 0; if(!fgets(testItem_aminationFramesStr, 4096, wCfgFile)) { fclose(wCfgFile); return; } convertToNumbers(testItem_aminationFramesStr, testItem_aminationFrames); if(!fgets(testItem_aminationFramesStr, 4096, wCfgFile)) { fclose(wCfgFile); return; } convertToVector(testItem_aminationFramesStr, &(testItem_Size[0])); if(!fgets(testItem_aminationFramesStr, 4096, wCfgFile)) { fclose(wCfgFile); return; } convertToVector(testItem_aminationFramesStr, &(testItem_Size[1])); testItem->classname = testItem_className; testItem->world_model = testItem_gModel; testItem->view_model = testItem_gModel; testItem->icon = testItem_icon; testItem->pickup_name = testItem_name; }