virtual bool action() { if ( ! this->input(this->storages->in) ) { return false; } this->output(solver->solve(this->storages->in, this->storages->out)); return true; }
void SimulationExperimentViewInformationSolversWidget::updateSolverGui(SimulationExperimentViewInformationSolversWidgetData *pSolverData) { // Make sure that we have some solver data if (pSolverData == nullptr) { return; } // Make sure that we have a solver QString solverName = pSolverData->solversListProperty()->value(); SolverInterface *solverInterface = pSolverData->solversInterfaces().value(solverName); if (solverInterface == nullptr) { return; } // Retrieve our solver properties values Core::Properties solverProperties = pSolverData->solversProperties().value(solverName); QMap<QString, QString> solverPropertiesValues = QMap<QString, QString>(); for (auto solverProperty : solverProperties) { solverPropertiesValues.insert(solverProperty->id(),solverProperty->value()); } // Ask our solver interface to tell us about the visibility of its // properties based on their values QMap<QString, bool> solverPropertiesVisibility = solverInterface->solverPropertiesVisibility(solverPropertiesValues); // Update the visilibity of our solver properties // Note: if there is no visibility information for a given solver property, // then it means that it should be visible... for (auto solverProperty : solverProperties) { solverProperty->setVisible(solverPropertiesVisibility.value(solverProperty->id(), true)); } }
~ParallelTestFixture() { utils::Parallel::setGlobalCommunicator(utils::Parallel::getCommunicatorWorld()); reset(); } }; BOOST_AUTO_TEST_SUITE(PreciceTests) BOOST_FIXTURE_TEST_SUITE(Parallel, ParallelTestFixture) BOOST_AUTO_TEST_CASE(TestMasterSlaveSetup, * testing::OnSize(4)) { SolverInterface interface ( "SolverOne", utils::Parallel::getProcessRank(), 4 ); std::string configFilename = _pathToTests + "config1.xml"; config::Configuration config; xml::configure(config.getXMLTag(), configFilename); interface._impl->configure(config.getSolverInterfaceConfiguration()); BOOST_TEST ( interface.getDimensions() == 3 ); if(utils::Parallel::getProcessRank()==0){ BOOST_TEST(utils::MasterSlave::_masterMode == true); BOOST_TEST(utils::MasterSlave::_slaveMode == false); } else { BOOST_TEST(utils::MasterSlave::_masterMode == false); BOOST_TEST(utils::MasterSlave::_slaveMode == true); }
void SolverInterfaceTestRemote:: testGeometryModeParallel() { preciceTrace("testGeometryModeParalell()"); using namespace tarch::la; using utils::DynVector; for ( int dim=2; dim <= 3; dim++ ){ std::string configFilename; if (dim == 2){ configFilename = _pathToTests + "geomode-2D.xml"; } else { configFilename = _pathToTests + "geomode-3D.xml"; } int rank = utils::Parallel::getProcessRank(); if ( (rank == 0) || (rank == 1) ){ SolverInterface interface ( "TestAccessor", rank, 2 ); configureSolverInterface ( configFilename, interface ); validateEquals ( interface.getDimensions(), dim ); interface.initialize(); interface.initializeData(); // is skipped due to geometry mode int meshID = interface.getMeshID("CuboidMesh"); std::set<int> ids; ids.insert(meshID); typedef query::tests::GeometryTestScenarios GeoTests; GeoTests geoTests; // Test inquireClosestMesh() const GeoTests::PointQueryScenario& pointScen = geoTests.pointQueryScenario(dim); std::list<DynVector>::const_iterator coordIter = pointScen.queryCoords.begin(); std::list<double>::const_iterator distIter = pointScen.validDistances.begin(); std::list<DynVector>::const_iterator distVectorIter = pointScen.validDistanceVectors.begin(); DynVector distanceVec(dim); while ( coordIter != pointScen.queryCoords.end() ){ ClosestMesh closest = interface.inquireClosestMesh ( raw(*coordIter), ids ); for(int i=0; i<dim; i++) distanceVec[i] = closest.distanceVector()[i]; validate ( equals(*distVectorIter, distanceVec) ); validate ( equals(*distIter, closest.distance()) ); coordIter ++; distIter ++; distVectorIter ++; } // Test inquirePosition() const GeoTests::PositionQueryScenario & posScen = geoTests.positionQueryScenario(dim); coordIter = posScen.queryCoords.begin(); std::list<int>::const_iterator posIter = posScen.validPositions.begin(); while ( coordIter != posScen.queryCoords.end() ){ int position = interface.inquirePosition ( raw(*coordIter), ids ); validateEquals ( position, *posIter ); coordIter ++; posIter ++; } // Test inquireVoxelPosition() const GeoTests::VoxelQueryScenario& voxelScen = geoTests.voxelQueryScenario(dim); std::list<DynVector>::const_iterator centerIter = voxelScen.queryCenters.begin(); std::list<DynVector>::const_iterator hIter = voxelScen.queryHalflengths.begin(); std::list<bool>::const_iterator includeBoundsIter = voxelScen.includeBoundaries.begin(); posIter = voxelScen.validPositions.begin(); while ( centerIter != voxelScen.queryCenters.end() ){ VoxelPosition pos = interface.inquireVoxelPosition ( raw(*centerIter), raw(*hIter), *includeBoundsIter, ids ); validateEquals ( pos.position(), *posIter ); centerIter ++; hIter ++; includeBoundsIter ++; posIter ++; } int meshIDScalar = interface.getMeshID ( "AccessorMeshScalar" ); int meshIDVector = interface.getMeshID ( "AccessorMeshVector" ); // Test write data DynVector pos(dim, 0.0); int posIndex = interface.setMeshVertex(meshIDScalar, raw(pos)); int dataID = interface.getDataID("ScalarData", meshIDScalar); double value = 1.0; interface.writeScalarData(dataID, posIndex, value); assign(pos) = 1.0; posIndex = interface.setMeshVertex(meshIDScalar, raw(pos)); value = 2.0; interface.writeScalarData(dataID, posIndex, value); // Let the written data of both processes be accumulated interface._impl->_requestManager->requestPing(); utils::Parallel::synchronizeLocalProcesses(); // Test read data (not really good test...) assign(pos) = 0.0; posIndex = interface.setMeshVertex(meshIDVector, raw(pos)); dataID = interface.getDataID("VectorData", meshIDVector); DynVector readValue(dim, 4.0); interface.readVectorData(dataID, posIndex, raw(readValue)); validate(equals(readValue, DynVector(dim,0.0))); // Test exporting mesh std::ostringstream filename; filename << "remote-parallel-rank" << rank; interface.exportMesh(filename.str()); interface.advance(1.0); interface.finalize(); } else { assertion1(rank == 2, rank); bool isServer = true; impl::SolverInterfaceImpl server("TestAccessor", 0, 1, isServer); // Perform manual configuration without overwritting logging config mesh::Mesh::resetGeometryIDsGlobally(); mesh::Data::resetDataCount(); impl::Participant::resetParticipantCount(); config::Configuration config; utils::configure(config.getXMLTag(), configFilename); server.configure(config.getSolverInterfaceConfiguration()); validateEquals(server.getDimensions(), dim); server.runServer(); } } }