diff --git a/Code/CMakeLists.txt b/Code/CMakeLists.txt index 8d00ecac8..056d52a6a 100644 --- a/Code/CMakeLists.txt +++ b/Code/CMakeLists.txt @@ -123,7 +123,9 @@ if (HEMELB_USE_DEBUGGER) set(CMAKE_BUILD_TYPE Debug) endif() -add_executable(${HEMELB_EXECUTABLE} SimulationMaster.cc main.cc) +add_library(hemelb_sim OBJECT SimulationMaster.cc) +list(APPEND heme_libraries hemelb_sim) +add_executable(${HEMELB_EXECUTABLE} main.cc) codesign(${HEMELB_EXECUTABLE}) include_directories(${PROJECT_SOURCE_DIR}) diff --git a/Code/SimulationMaster.cc b/Code/SimulationMaster.cc index d2bc383ee..5ac4fe0ae 100644 --- a/Code/SimulationMaster.cc +++ b/Code/SimulationMaster.cc @@ -37,23 +37,9 @@ namespace hemelb * Initialises member variables including the network topology * object. */ - SimulationMaster::SimulationMaster(configuration::CommandLine & options, - const net::IOCommunicator& ioComm) : + SimulationMaster::SimulationMaster(const net::IOCommunicator& ioComm) : build_info(), ioComms(ioComm.Duplicate()), communicationNet(ioComms) { - // Start the main timer! - timings.total().Start(); - - fileManager = std::make_shared(options, - IsCurrentProcTheIOProc(), - GetProcessorCount()); - log::Logger::Log("Reading configuration from %s", fileManager->GetInputFile().c_str()); - // Convert XML to configuration - simConfig = configuration::SimConfig::New(fileManager->GetInputFile()); - // Use it to initialise self - auto builder = configuration::SimBuilder(simConfig); - log::Logger::Log("Beginning Initialisation."); - builder.build<>(*this); } /// Destructor for the SimulationMaster class. diff --git a/Code/SimulationMaster.h b/Code/SimulationMaster.h index fb3182225..e71e7d6c1 100644 --- a/Code/SimulationMaster.h +++ b/Code/SimulationMaster.h @@ -16,7 +16,7 @@ #include "util/UnitConverter.h" #include "configuration/SimConfig.h" #include "configuration/CommandLine.h" -#include "io/PathManager.h" +#include "configuration/PathManager.h" #include "reporting/Reporter.h" #include "reporting/Timers.h" #include "reporting/BuildInfo.h" @@ -53,7 +53,7 @@ namespace hemelb std::shared_ptr latticeBoltzmannModel; std::shared_ptr neighbouringDataManager; - std::shared_ptr fileManager; + std::shared_ptr fileManager; std::shared_ptr reporter; std::shared_ptr simulationState; @@ -77,9 +77,8 @@ namespace hemelb std::shared_ptr stepManager; std::shared_ptr netConcern; + SimulationMaster(const net::IOCommunicator& ioComm); public: - SimulationMaster(configuration::CommandLine &options, - const net::IOCommunicator& ioComms); virtual ~SimulationMaster(); void Abort(); diff --git a/Code/configuration/CMakeLists.txt b/Code/configuration/CMakeLists.txt index fee5df7de..9f07717d4 100644 --- a/Code/configuration/CMakeLists.txt +++ b/Code/configuration/CMakeLists.txt @@ -5,6 +5,7 @@ add_library(hemelb_configuration OBJECT CommandLine.cc + PathManager.cc SimConfig.cc SimBuilder.cc SimConfigReader.cc diff --git a/Code/io/PathManager.cc b/Code/configuration/PathManager.cc similarity index 97% rename from Code/io/PathManager.cc rename to Code/configuration/PathManager.cc index 0950481cb..e4facf2d8 100644 --- a/Code/io/PathManager.cc +++ b/Code/configuration/PathManager.cc @@ -3,13 +3,13 @@ // file AUTHORS. This software is provided under the terms of the // license in the file LICENSE. -#include "io/PathManager.h" +#include "configuration/PathManager.h" #include "Exception.h" #include "configuration/CommandLine.h" namespace fs = std::filesystem; -namespace hemelb::io +namespace hemelb::configuration { PathManager::PathManager(const configuration::CommandLine & commandLine, const bool & io, diff --git a/Code/io/PathManager.h b/Code/configuration/PathManager.h similarity index 93% rename from Code/io/PathManager.h rename to Code/configuration/PathManager.h index 92e4c13de..43740db24 100644 --- a/Code/io/PathManager.h +++ b/Code/configuration/PathManager.h @@ -3,8 +3,8 @@ // file AUTHORS. This software is provided under the terms of the // license in the file LICENSE. -#ifndef HEMELB_IO_PATHMANAGER_H -#define HEMELB_IO_PATHMANAGER_H +#ifndef HEMELB_CONFIGURATION_PATHMANAGER_H +#define HEMELB_CONFIGURATION_PATHMANAGER_H #include #include @@ -14,12 +14,6 @@ namespace hemelb::configuration { class CommandLine; class SimConfig; -} - -namespace hemelb::io -{ - // Forward declare the Writer - namespace writers { class Writer; } /** * Manage the input and output file system locations for HemeLB reports, extracted data, and input xml. @@ -82,4 +76,4 @@ namespace hemelb::io } -#endif //HEMELB_IO_PATHMANAGER_H +#endif //HEMELB_CONFIGURATION_PATHMANAGER_H diff --git a/Code/configuration/SimBuilder.cc b/Code/configuration/SimBuilder.cc index 5082a7b29..56ea9fcf7 100644 --- a/Code/configuration/SimBuilder.cc +++ b/Code/configuration/SimBuilder.cc @@ -291,7 +291,7 @@ namespace hemelb::configuration { } std::shared_ptr SimBuilder::BuildReporter( - io::PathManager const& fileManager, + PathManager const& fileManager, std::vectorconst& reps ) const { auto reporter = std::make_shared(fileManager.GetReportPath(), diff --git a/Code/configuration/SimBuilder.h b/Code/configuration/SimBuilder.h index bb93a2075..001961e5a 100644 --- a/Code/configuration/SimBuilder.h +++ b/Code/configuration/SimBuilder.h @@ -54,6 +54,31 @@ namespace hemelb::configuration { std::shared_ptr unit_converter; public: + template + static std::unique_ptr CreateSim( + CommandLine const& options, + net::IOCommunicator const& ioComms + ) { + auto ans = std::unique_ptr(new SimulationMaster(ioComms)); + // Start the main timer! + ans->timings.total().Start(); + + ans->fileManager = std::make_shared( + options, + ioComms.OnIORank(), + ioComms.Size() + ); + auto&& infile = ans->fileManager->GetInputFile(); + log::Logger::Log("Reading configuration from %s", infile.c_str()); + // Convert XML to configuration + ans->simConfig = configuration::SimConfig::New(infile); + // Use it to initialise self + auto builder = configuration::SimBuilder(ans->simConfig); + log::Logger::Log("Beginning Initialisation."); + builder.build(*ans); + return ans; + } + explicit SimBuilder(SimConfig const& conf, bool construct_unit_converter = true); virtual ~SimBuilder() = default; @@ -111,7 +136,7 @@ namespace hemelb::configuration { ) const; [[nodiscard]] std::shared_ptr BuildReporter( - io::PathManager const& fileManager, + PathManager const& fileManager, std::vector const & reps ) const; }; @@ -299,8 +324,6 @@ namespace hemelb::configuration { [[nodiscard]] std::shared_ptr SimBuilder::BuildCellController(SimulationMaster const& control, reporting::Timers& timings) const { if (config.HasRBCSection()) { #ifdef HEMELB_BUILD_RBC - using traitsType = typename T::Traits; - auto ccb = redblood::CellControllerBuilder(unit_converter); auto& ioComms = control.ioComms; @@ -324,4 +347,4 @@ namespace hemelb::configuration { return {}; } } -#endif \ No newline at end of file +#endif diff --git a/Code/extraction/PropertyActor.h b/Code/extraction/PropertyActor.h index 9820fdc4f..1aad55199 100644 --- a/Code/extraction/PropertyActor.h +++ b/Code/extraction/PropertyActor.h @@ -7,7 +7,6 @@ #define HEMELB_EXTRACTION_PROPERTYACTOR_H #include "extraction/PropertyWriter.h" -#include "io/PathManager.h" #include "lb/MacroscopicPropertyCache.h" #include "lb/SimulationState.h" #include "net/IteratedAction.h" diff --git a/Code/io/CMakeLists.txt b/Code/io/CMakeLists.txt index d95ce1720..73144588d 100644 --- a/Code/io/CMakeLists.txt +++ b/Code/io/CMakeLists.txt @@ -12,7 +12,6 @@ endif() add_library(hemelb_io OBJECT FILE.cc - PathManager.cc writers/AsciiFileWriter.cc writers/AsciiStreamWriter.cc readers/XdrFileReader.cc readers/XdrMemReader.cc diff --git a/Code/io/Checkpointer.h b/Code/io/Checkpointer.h index 89604c679..4ec2e6c61 100644 --- a/Code/io/Checkpointer.h +++ b/Code/io/Checkpointer.h @@ -9,7 +9,7 @@ #include #include -#include "io/PathManager.h" +#include "configuration/SimConfig.h" #include "io/TimePattern.h" #include "lb/SimulationState.h" #include "net/IteratedAction.h" diff --git a/Code/main.cc b/Code/main.cc index ba5286406..7664a348f 100644 --- a/Code/main.cc +++ b/Code/main.cc @@ -6,9 +6,9 @@ #include "net/mpi.h" #include "net/IOCommunicator.h" #include "configuration/CommandLine.h" +#include "configuration/SimBuilder.h" #include "io/ensure_hexfloat.h" #include "debug.h" -#include "SimulationMaster.h" int main(int argc, char *argv[]) { @@ -40,10 +40,10 @@ int main(int argc, char *argv[]) debug::Init(options.GetDebug(), argv[0], commWorld); // Prepare main simulation object... - SimulationMaster master(options, hemelbCommunicator); + auto master = configuration::SimBuilder::CreateSim>(options, hemelbCommunicator); // ..and run it. - master.RunSimulation(); + master->RunSimulation(); } // Interpose this catch to print usage before propagating the error. diff --git a/Code/multiscale/MultiscaleSimulationMaster.h b/Code/multiscale/MultiscaleSimulationMaster.h index 30394fe3f..a0491312d 100644 --- a/Code/multiscale/MultiscaleSimulationMaster.h +++ b/Code/multiscale/MultiscaleSimulationMaster.h @@ -199,7 +199,7 @@ namespace hemelb::multiscale } } - void DoTimeStep() + void DoTimeStep() override { bool advance = intercomms.DoMultiscale(GetState().GetTime()); log::Logger::Log("At time step %i, should advance %i, time %f", diff --git a/Code/net/IOCommunicator.h b/Code/net/IOCommunicator.h index dd8225609..fdab1854f 100644 --- a/Code/net/IOCommunicator.h +++ b/Code/net/IOCommunicator.h @@ -27,6 +27,7 @@ namespace hemelb::net { public: static constexpr int IO_RANK = 0; + IOCommunicator() = default; explicit IOCommunicator(const MpiCommunicator& comm); inline bool OnIORank() const { diff --git a/Code/redblood/CellArmy.h b/Code/redblood/CellArmy.h index 4b74b3011..8d7e698c7 100644 --- a/Code/redblood/CellArmy.h +++ b/Code/redblood/CellArmy.h @@ -324,8 +324,8 @@ namespace hemelb log::Logger::Log(message.str()); cellDnC.remove(*i_current); - cells.erase(i_current); auto const numErased = nodeDistributions.erase((*i_current)->GetTag()); + cells.erase(i_current); assert(numErased == 1); } } diff --git a/Code/redblood/CellControllerBuilder.cc b/Code/redblood/CellControllerBuilder.cc index c2b622f69..1f05a503a 100644 --- a/Code/redblood/CellControllerBuilder.cc +++ b/Code/redblood/CellControllerBuilder.cc @@ -5,7 +5,7 @@ #include "redblood/CellControllerBuilder.h" -#include "io/PathManager.h" +#include "configuration/PathManager.h" #include "redblood/CellIO.h" #include "redblood/FaderCell.h" #include "redblood/MeshIO.h" @@ -350,7 +350,7 @@ namespace hemelb::redblood { CellChangeListener CellControllerBuilder::build_full_cell_output( configuration::CellOutputConfig const& conf, std::shared_ptr simState, - std::shared_ptr fileManager, + std::shared_ptr fileManager, net::IOCommunicator const& ioComms ) const { auto conv = conf.physical_units ? unit_converter : nullptr; @@ -360,7 +360,7 @@ namespace hemelb::redblood { CellChangeListener CellControllerBuilder::build_summary_cell_output( configuration::CellOutputConfig const& conf, std::shared_ptr simState, - std::shared_ptr fileManager, + std::shared_ptr fileManager, net::IOCommunicator const& ioComms ) const { auto conv = conf.physical_units ? unit_converter : nullptr; diff --git a/Code/redblood/CellControllerBuilder.h b/Code/redblood/CellControllerBuilder.h index 2eb787f10..1c6d21a23 100644 --- a/Code/redblood/CellControllerBuilder.h +++ b/Code/redblood/CellControllerBuilder.h @@ -17,7 +17,7 @@ #include "redblood/CellController.h" #include "redblood/RBCInserter.h" -namespace hemelb::io { class PathManager; } +namespace hemelb::configuration { class PathManager; } namespace hemelb::redblood { @@ -86,13 +86,13 @@ namespace hemelb::redblood { CellChangeListener build_full_cell_output( configuration::CellOutputConfig const& conf, std::shared_ptr simState, - std::shared_ptr fileManager, + std::shared_ptr fileManager, net::IOCommunicator const& ioComms ) const; CellChangeListener build_summary_cell_output( configuration::CellOutputConfig const& conf, std::shared_ptr simState, - std::shared_ptr fileManager, + std::shared_ptr fileManager, net::IOCommunicator const& ioComms ) const; @@ -104,7 +104,7 @@ namespace hemelb::redblood { CountedIoletView const& inlets, CountedIoletView const& outlets, std::shared_ptr simState, - std::shared_ptr fileManager + std::shared_ptr fileManager ) { log::Logger::Log("Initialising RBCs."); timings.cellInitialisation().Start(); diff --git a/Code/redblood/CellIO.cc b/Code/redblood/CellIO.cc index dcf15533a..325234c90 100644 --- a/Code/redblood/CellIO.cc +++ b/Code/redblood/CellIO.cc @@ -9,8 +9,8 @@ #include #include +#include "configuration/PathManager.h" #include "io/formats/rbc.h" -#include "io/PathManager.h" #include "io/writers/XdrWriter.h" #include "io/readers/XdrFileReader.h" #include "io/readers/XdrMemReader.h" @@ -21,6 +21,7 @@ #include "redblood/FaderCell.h" #include "redblood/MeshIO.h" #include "util/Iterator.h" +#include "util/span.h" namespace hemelb::redblood { @@ -74,7 +75,7 @@ namespace hemelb::redblood { CellBarycentreOutput::CellBarycentreOutput(hemelb::LatticeTimeStep period, std::shared_ptr unitConverter, std::shared_ptr simState, - std::shared_ptr fileManager, + std::shared_ptr fileManager, net::IOCommunicator comms) : CellOutputBase{ period, std::move(unitConverter), std::move(simState), std::move(fileManager), comms @@ -134,7 +135,7 @@ namespace hemelb::redblood { const std::size_t local_write_start = ioComms.OnIORank() ? 0 : (fmt::rbc::header_size + n_cells_before_me * fmt::rbc::row_size); auto bary_file = net::MpiFile::Open(ioComms, bary_filename, MPI_MODE_WRONLY | MPI_MODE_CREATE | MPI_MODE_EXCL); - bary_file.WriteAt(local_write_start, buffer); + bary_file.WriteAt(local_write_start, to_const_span(buffer)); bary_file.Close(); } @@ -172,7 +173,7 @@ namespace hemelb::redblood { auto read_size = n * fmt::rbc::row_size; std::vector read_buf(read_size); - inputFile.ReadAt(read_start, read_buf); + inputFile.ReadAt(read_start, to_span(read_buf)); auto reader = io::XdrMemReader(read_buf); std::vector ans(n); boost::uuids::string_generator gen; diff --git a/Code/redblood/CellIO.h b/Code/redblood/CellIO.h index 7906824d8..76211452b 100644 --- a/Code/redblood/CellIO.h +++ b/Code/redblood/CellIO.h @@ -15,7 +15,7 @@ #include "net/IOCommunicator.h" #include "redblood/types_fwd.h" -namespace hemelb::io { class PathManager; } +namespace hemelb::configuration { class PathManager; } namespace hemelb::lb { class SimulationState; } namespace hemelb::util { class UnitConverter; } @@ -30,7 +30,7 @@ namespace hemelb::redblood { // nullptr => use lattice units std::shared_ptr unitConverter; std::shared_ptr simState; - std::shared_ptr fileManager; + std::shared_ptr fileManager; net::IOCommunicator ioComms; }; @@ -46,7 +46,7 @@ namespace hemelb::redblood { LatticeTimeStep period, std::shared_ptr unitConverter, std::shared_ptr simState, - std::shared_ptr fileManager, + std::shared_ptr fileManager, net::IOCommunicator comms ); diff --git a/Code/redblood/VelocityInterpolation.h b/Code/redblood/VelocityInterpolation.h index 14e487fb8..446b34842 100644 --- a/Code/redblood/VelocityInterpolation.h +++ b/Code/redblood/VelocityInterpolation.h @@ -83,7 +83,7 @@ namespace hemelb::redblood // Follows approach in Timm's code return latticeData.GetFNew(index); } else { - return site.GetFOld(); + return site.template GetFOld(); } }(); LatticeType::CalculateDensityAndMomentum(fDistribution, diff --git a/Code/redblood/WallCellPairIterator.h b/Code/redblood/WallCellPairIterator.h index 7057a7720..71b443ef5 100644 --- a/Code/redblood/WallCellPairIterator.h +++ b/Code/redblood/WallCellPairIterator.h @@ -110,7 +110,8 @@ namespace hemelb::redblood pointer operator->() const { HASSERT(static_cast(*this)); - return std::make_unique(*firstCellNode, firstWallNode->second.node); + value_type tmp{*firstCellNode, firstWallNode->second.node}; + return std::make_unique(tmp); } bool operator++(); diff --git a/Code/redblood/parallel/GraphBasedCommunication.cc b/Code/redblood/parallel/GraphBasedCommunication.cc index 058280dd3..1e0f33073 100644 --- a/Code/redblood/parallel/GraphBasedCommunication.cc +++ b/Code/redblood/parallel/GraphBasedCommunication.cc @@ -83,8 +83,7 @@ namespace hemelb::redblood::parallel auto rank = comm.Rank(); // Loop over this process's edge - auto first_edge_site_i = domain.GetMidDomainSiteCount(); - auto last_edge_site_i = first_edge_site_i + domain.GetDomainEdgeSiteCount(); + auto [first_edge_site_i, last_edge_site_i] = domain.GetAllDomainEdgeSiteRange(); for (auto siteIndex = first_edge_site_i; siteIndex < last_edge_site_i; ++siteIndex) { diff --git a/Code/reporting/Reportable.h b/Code/reporting/Reportable.h index 20d210633..2839cd21a 100644 --- a/Code/reporting/Reportable.h +++ b/Code/reporting/Reportable.h @@ -8,20 +8,18 @@ #include "reporting/Dict.h" -namespace hemelb + +namespace hemelb::reporting { - namespace reporting - { /** * Defines the interface for classes that can have entries in reports. */ class Reportable { - public: + public: virtual ~Reportable() noexcept = default; virtual void Report(Dict& dictionary) = 0; }; - } } #endif /* HEMELB_REPORTING_REPORTABLE_H */ diff --git a/Code/tests/CMakeLists.txt b/Code/tests/CMakeLists.txt index 4023a0ee6..ed27a2939 100644 --- a/Code/tests/CMakeLists.txt +++ b/Code/tests/CMakeLists.txt @@ -42,9 +42,6 @@ add_to_resources(resources/four_cube.gmy resources/four_cube.xml resources/four_ resources/large_cylinder.gmy resources/large_cylinder.xml ) -if (HEMELB_BUILD_MULTISCALE) - add_to_resources(multiscale/mpwide/MPWSettings.cfg) -endif() add_test_executable(hemelb-tests main.cc SimulationMasterTests.cc) @@ -60,11 +57,15 @@ add_to_tests(extraction) add_to_tests(geometry) add_to_tests(io) add_to_tests(lb) -add_to_tests(multiscale) add_to_tests(net) add_to_tests(reporting) add_to_tests(util) +if (HEMELB_BUILD_MULTISCALE) + add_to_resources(multiscale/mpwide/MPWSettings.cfg) + add_to_tests(multiscale) +endif() + if (HEMELB_BUILD_RBC) add_to_resources( resources/red_blood_cell.txt resources/red_blood_cube.txt diff --git a/Code/tests/SimulationMasterTests.cc b/Code/tests/SimulationMasterTests.cc index 4889c95fb..1399f8f25 100644 --- a/Code/tests/SimulationMasterTests.cc +++ b/Code/tests/SimulationMasterTests.cc @@ -6,7 +6,7 @@ #include -#include "SimulationMaster.h" +#include "configuration/SimBuilder.h" #include "tests/helpers/FolderTestFixture.h" #include "tests/helpers/LaddFail.h" @@ -27,7 +27,7 @@ namespace hemelb::tests CopyResourceToTempdir("four_cube.gmy"); auto options = std::make_unique(argc, argv); - auto master = std::make_unique(*options, Comms()); + auto master = configuration::SimBuilder::CreateSim>(*options, Comms()); SECTION("Running a simulation creates outputs") { // TODO: This test is fatal if run with LADDIOLET. See ticket #605. diff --git a/Code/tests/configuration/CMakeLists.txt b/Code/tests/configuration/CMakeLists.txt index 49071db6b..57c9ddb80 100644 --- a/Code/tests/configuration/CMakeLists.txt +++ b/Code/tests/configuration/CMakeLists.txt @@ -5,4 +5,5 @@ add_test_lib(test_configuration CommandLineTests.cc SimConfigTests.cc + PathManagerTests.cc ) diff --git a/Code/tests/io/PathManagerTests.cc b/Code/tests/configuration/PathManagerTests.cc similarity index 88% rename from Code/tests/io/PathManagerTests.cc rename to Code/tests/configuration/PathManagerTests.cc index 44b764168..f0845d7b0 100644 --- a/Code/tests/io/PathManagerTests.cc +++ b/Code/tests/configuration/PathManagerTests.cc @@ -8,7 +8,7 @@ #include #include "configuration/CommandLine.h" -#include "io/PathManager.h" +#include "configuration/PathManager.h" #include "tests/helpers/FolderTestFixture.h" @@ -17,7 +17,7 @@ namespace fs = std::filesystem; namespace hemelb::tests { - std::unique_ptr setup(const char* confXml) { + std::unique_ptr setup(const char* confXml) { const int processorCount = 5; const int argc = 3; const char* argv[] = { @@ -27,7 +27,7 @@ namespace hemelb::tests }; auto cl = configuration::CommandLine(argc, argv); - return std::make_unique(cl, true, processorCount); + return std::make_unique(cl, true, processorCount); } TEST_CASE_METHOD(helpers::FolderTestFixture, "PathManager") { diff --git a/Code/tests/io/CMakeLists.txt b/Code/tests/io/CMakeLists.txt index ac8b66a40..074933d5c 100644 --- a/Code/tests/io/CMakeLists.txt +++ b/Code/tests/io/CMakeLists.txt @@ -4,7 +4,6 @@ # license in the file LICENSE. add_test_lib(test_io xdr_test_data.cc - PathManagerTests.cc XdrWriterTests.cc XdrReaderTests.cc xml.cc diff --git a/Code/tests/redblood/CellArmyTests.cc b/Code/tests/redblood/CellArmyTests.cc index 3130b90b4..a03b27854 100644 --- a/Code/tests/redblood/CellArmyTests.cc +++ b/Code/tests/redblood/CellArmyTests.cc @@ -16,11 +16,11 @@ namespace hemelb::tests { //! Mock cell for ease of use - class FakeCell : public hemelb::redblood::Cell + class FakeCell : public redblood::Cell { public: mutable size_t nbcalls = 0; - using hemelb::redblood::Cell::Cell; + using redblood::Cell::Cell; //! Facet bending energy LatticeEnergy operator()() const override { @@ -38,7 +38,7 @@ namespace hemelb::tests using namespace redblood; LatticeDistance const cutoff = 5.0; - using Traits = hemelb::Traits; diff --git a/Code/tests/redblood/CellIOTests.cc b/Code/tests/redblood/CellIOTests.cc index 63b0fac37..439085132 100644 --- a/Code/tests/redblood/CellIOTests.cc +++ b/Code/tests/redblood/CellIOTests.cc @@ -203,7 +203,7 @@ namespace hemelb::tests cells.insert(cell); auto outConf = configuration::CellOutputConfig{10, false}; configuration::CommandLine cmdline({"hemelb", "-in", "empty_for_relative_paths.xml"}); - auto pathmgr = std::make_shared(cmdline, Comms().OnIORank(), Comms().Size()); + auto pathmgr = std::make_shared(cmdline, Comms().OnIORank(), Comms().Size()); auto simState = std::make_shared(0.1, 1000); auto full_out = cell_builder.build_full_cell_output(outConf, simState, pathmgr, Comms()); auto summ_out = cell_builder.build_summary_cell_output(outConf, simState, pathmgr, Comms()); @@ -215,7 +215,7 @@ namespace hemelb::tests // Check barycentre auto bary_path = fs::path{"results/Cells/0/barycentres.rbc"}; REQUIRE(fs::exists(bary_path)); - auto bci = CellBarycentreInput(bary_path); + auto bci = CellBarycentreInput{bary_path}; auto ncells = bci.ReadHeader(); REQUIRE(ncells == 1); auto cell_summary = bci.ReadRows(Comms(), 0, 1); diff --git a/Code/tests/redblood/CellIntegrationTests.cc b/Code/tests/redblood/CellIntegrationTests.cc index 4d7cc2eb1..42a9366ec 100644 --- a/Code/tests/redblood/CellIntegrationTests.cc +++ b/Code/tests/redblood/CellIntegrationTests.cc @@ -8,9 +8,9 @@ #include "Traits.h" #include "SimulationMaster.h" +#include "configuration/SimBuilder.h" #include "redblood/Cell.h" #include "redblood/CellController.h" -#include "tests/redblood/Fixtures.h" #include "tests/helpers/LatticeDataAccess.h" #include "tests/helpers/FolderTestFixture.h" @@ -21,7 +21,6 @@ namespace hemelb::tests { using MyTraits = Traits; using CellControll = CellController; - using MasterSim = SimulationMaster; public: CellIntegrationTests() : FolderTestFixture(), timings() { @@ -31,16 +30,16 @@ namespace hemelb::tests CopyResourceToTempdir("large_cylinder.xml"); ModifyXMLInput("large_cylinder.xml", {"simulation", "steps", "value"}, 8); CopyResourceToTempdir("large_cylinder.gmy"); - options = std::make_shared(argc, argv); + options = std::make_unique(argc, argv); auto cell = std::make_shared(icoSphere(4)); - templates = std::make_shared(); + templates = std::make_unique(); (*templates)["icosphere"] = cell; cell->moduli = Cell::Moduli(1e-6, 1e-6, 1e-6, 1e-6); cells.insert(cell); //timings = std::make_unique(Comms()); - master = std::make_shared(*options, Comms()); + master = configuration::SimBuilder::CreateSim(*options, Comms()); helpers::LatticeDataAccess(&master->GetFieldData()).ZeroOutForces(); } @@ -120,8 +119,8 @@ namespace hemelb::tests } private: - std::shared_ptr master; - std::shared_ptr options; + std::unique_ptr master; + std::unique_ptr options; CellContainer cells; std::shared_ptr templates; reporting::Timers timings; diff --git a/Code/tests/redblood/FadeInOutIntegrationTests.cc b/Code/tests/redblood/FadeInOutIntegrationTests.cc index 0e4c33392..1ed6a00d6 100644 --- a/Code/tests/redblood/FadeInOutIntegrationTests.cc +++ b/Code/tests/redblood/FadeInOutIntegrationTests.cc @@ -4,10 +4,10 @@ // license in the file LICENSE. #include -#include #include #include "SimulationMaster.h" +#include "configuration/SimBuilder.h" #include "lb/lattices/D3Q19.h" #include "Traits.h" #include "redblood/Mesh.h" @@ -23,7 +23,6 @@ namespace hemelb::tests "[redblood][.long]") { using Traits = Traits; using CellControl = CellController; - using MasterSim = SimulationMaster; CopyResourceToTempdir("large_cylinder_rbc.xml"); CopyResourceToTempdir("large_cylinder.gmy"); @@ -45,15 +44,15 @@ namespace hemelb::tests "hemelb", "-in", "large_cylinder_rbc.xml", }; - auto options = hemelb::configuration::CommandLine{argc, argv}; - auto master = std::make_shared(options, Comms()); + auto options = configuration::CommandLine{argc, argv}; + auto master = configuration::SimBuilder::CreateSim(options, Comms()); SECTION("testIntegration") { auto const & converter = master->GetUnitConverter(); auto const volumeFactor = std::pow(converter.ConvertToLatticeUnits("m", 1e0), -3) * 1e12; bool didDropCell = false; - auto checkDidDropCell = [&didDropCell](const hemelb::redblood::CellContainer & cells) + auto checkDidDropCell = [&didDropCell](const CellContainer & cells) { didDropCell |= not cells.empty(); }; @@ -149,7 +148,7 @@ namespace hemelb::tests AssertPresent("results/report.xml"); REQUIRE(iter > 0); REQUIRE(didDropCell); - REQUIRE(0ul == controller->GetCells().size()); + REQUIRE(controller->GetCells().empty()); } } diff --git a/Code/tests/redblood/FedosovValidationTests.cc b/Code/tests/redblood/FedosovValidationTests.cc index 9b9233e26..9ae316622 100644 --- a/Code/tests/redblood/FedosovValidationTests.cc +++ b/Code/tests/redblood/FedosovValidationTests.cc @@ -8,6 +8,7 @@ #include #include "SimulationMaster.h" +#include "configuration/SimBuilder.h" #include "lb/lattices/D3Q19.h" #include "Traits.h" #include "redblood/MeshIO.h" @@ -22,8 +23,7 @@ namespace hemelb::tests TEST_CASE_METHOD(helpers::FolderTestFixture, "Fedosov validation tests", "[redblood][.long]") { using Traits = Traits; - using CellControl = hemelb::redblood::CellController; - using MasterSim = SimulationMaster; + using CellControl = CellController; CopyResourceToTempdir("fedosov1c.xml"); CopyResourceToTempdir("fedosov1c.gmy"); @@ -36,7 +36,7 @@ namespace hemelb::tests argv[2] = "fedosov1c.xml"; configuration::CommandLine options(argc, argv); - auto master = std::make_shared(options, Comms()); + auto master = configuration::SimBuilder::CreateSim(options, Comms()); redblood::VTKMeshIO vtk_io = {}; SECTION("Integration test") { @@ -44,7 +44,7 @@ namespace hemelb::tests auto const & converter = master->GetUnitConverter(); auto controller = std::static_pointer_cast(master->GetCellController()); REQUIRE(controller); - controller->AddCellChangeListener([vtk_io, &converter](const hemelb::redblood::CellContainer &cells) { + controller->AddCellChangeListener([vtk_io, &converter](const CellContainer &cells) { static int iter = 0; if(cells.empty()) { return; diff --git a/Code/tests/redblood/InterpolationTests.cc b/Code/tests/redblood/InterpolationTests.cc index 39e594ae5..a87c4e900 100644 --- a/Code/tests/redblood/InterpolationTests.cc +++ b/Code/tests/redblood/InterpolationTests.cc @@ -311,11 +311,12 @@ namespace hemelb::tests //KERNEL kernel(initParams); VelocityFromLatticeData velocityFunctor(*latDat); - size_t const N(dom->GetMidDomainCollisionCount(0)); + auto [begin, end] = dom->GetMidDomainSiteRange(0); + auto const N = end - begin; REQUIRE(N > 0); - for (size_t index(0); index < N; ++index) { + for (auto index = begin; index < end; ++index) { geometry::Site const site(index, *latDat); // Value to test @@ -352,9 +353,9 @@ namespace hemelb::tests velocityFromLatticeDataTester(kernel, false); } SECTION("VelocityDataFromLatticeWithForces") { - size_t const N = dom->GetMidDomainCollisionCount(0); + auto [begin, end] = dom->GetMidDomainSiteRange(0); - for (size_t i = 0; i < N; ++i) + for (size_t i = begin; i < end; ++i) latDat->GetSite(i).SetForce(LatticeForceVector(i, 2 * i, double(i * i) * 0.0001)); GuoForcingLBGK kernel{initParams}; diff --git a/Code/tests/redblood/LoadDeformedCellTests.cc b/Code/tests/redblood/LoadDeformedCellTests.cc index 68a8bf63e..c7c7d0649 100644 --- a/Code/tests/redblood/LoadDeformedCellTests.cc +++ b/Code/tests/redblood/LoadDeformedCellTests.cc @@ -8,7 +8,7 @@ #include #include -#include "SimulationMaster.h" +#include "configuration/SimBuilder.h" #include "lb/lattices/D3Q19.h" #include "Traits.h" #include "redblood/Mesh.h" @@ -25,7 +25,6 @@ namespace hemelb::tests using Traits = Traits; using CellControl = hemelb::redblood::CellController; - using MasterSim = SimulationMaster; redblood::VTKMeshIO io = {}; @@ -54,7 +53,7 @@ namespace hemelb::tests "hemelb", "-in", "large_cylinder_rbc.xml", }; auto options = std::make_shared(argc, argv); - auto master = std::make_shared(*options, Comms()); + auto master = configuration::SimBuilder::CreateSim(*options, Comms()); SECTION("testIntegration") { // Read meshes from disc diff --git a/Code/tests/redblood/MulticellBenchmarkTests.cc b/Code/tests/redblood/MulticellBenchmarkTests.cc index 5698c8d22..b2f3b3ded 100644 --- a/Code/tests/redblood/MulticellBenchmarkTests.cc +++ b/Code/tests/redblood/MulticellBenchmarkTests.cc @@ -7,7 +7,7 @@ #include #include -#include "SimulationMaster.h" +#include "configuration/SimBuilder.h" #include "Traits.h" #include "redblood/Mesh.h" #include "redblood/MeshIO.h" @@ -26,9 +26,8 @@ namespace hemelb::tests { using MyTraits = Traits; using CellControl = hemelb::redblood::CellController; - using MasterSim = SimulationMaster; - std::shared_ptr master; + std::unique_ptr master; static constexpr auto argv = std::array{"hemelb", "-in", "large_cylinder_rbc.xml"}; configuration::CommandLine options = {argv.size(), argv.data()}; @@ -69,14 +68,14 @@ namespace hemelb::tests "value" }, 3e-6); - master = std::make_shared(options, Comms()); + master = configuration::SimBuilder::CreateSim(options, Comms()); } void testBenchmark() { unsigned timestep = 0; auto output_callback = - [this, ×tep](const hemelb::redblood::CellContainer & cells) { + [this, ×tep](const redblood::CellContainer & cells) { if ((timestep % 100) == 0) { for (auto& cell: cells) { std::stringstream filename; diff --git a/Code/tests/redblood/NodeIntegrationTests.cc b/Code/tests/redblood/NodeIntegrationTests.cc index 6057e3e20..55e107f14 100644 --- a/Code/tests/redblood/NodeIntegrationTests.cc +++ b/Code/tests/redblood/NodeIntegrationTests.cc @@ -9,7 +9,7 @@ #include #include "Traits.h" -#include "SimulationMaster.h" +#include "configuration/SimBuilder.h" #include "redblood/Cell.h" #include "redblood/CellController.h" #include "tests/redblood/Fixtures.h" @@ -41,7 +41,7 @@ namespace hemelb::tests } //! Creates a simulation. Does not run it. - std::shared_ptr> simulationMaster(size_t steps, + auto simulationMaster(size_t steps, Dimensionless cell, Dimensionless wall) const { CopyResourceToTempdir(xml_name); @@ -60,7 +60,7 @@ namespace hemelb::tests ModifyXMLInput(xml_name, { "redbloodcells", "cell2Wall", "intensity", "value" }, wall); ModifyXMLInput(xml_name, { "redbloodcells", "cell2Wall", "cutoffdistance", "value" }, 1); auto options = std::make_shared(argc, argv); - auto const master = std::make_shared>(*options, Comms()); + auto master = configuration::SimBuilder::CreateSim(*options, Comms()); helpers::LatticeDataAccess(&master->GetFieldData()).ZeroOutForces(); return master; } diff --git a/Code/tests/redblood/SadCellIntegrationTests.cc b/Code/tests/redblood/SadCellIntegrationTests.cc index 19c0c1e90..4dd800011 100644 --- a/Code/tests/redblood/SadCellIntegrationTests.cc +++ b/Code/tests/redblood/SadCellIntegrationTests.cc @@ -8,6 +8,7 @@ #include #include "SimulationMaster.h" +#include "configuration/SimBuilder.h" #include "lb/lattices/D3Q19.h" #include "Traits.h" #include "redblood/Mesh.h" @@ -22,12 +23,11 @@ namespace hemelb::tests TEST_CASE_METHOD(helpers::FolderTestFixture, "SadCellIntegrationTests", "[redblood][.long]") { - using Traits = Traits; - using CellControl = hemelb::redblood::CellController; - using MasterSim = SimulationMaster; + using Traits = Traits; + using CellControl = CellController; - redblood::KruegerMeshIO msh_io = {}; - redblood::VTKMeshIO vtk_io = {}; + KruegerMeshIO msh_io = {}; + VTKMeshIO vtk_io = {}; CopyResourceToTempdir("large_cylinder_rbc.xml"); CopyResourceToTempdir("large_cylinder.gmy"); @@ -56,9 +56,9 @@ namespace hemelb::tests "-in", "large_cylinder_rbc.xml", }; - hemelb::configuration::CommandLine options(argc, argv); + configuration::CommandLine options(argc, argv); - auto master = std::make_shared(options, Comms()); + auto master = configuration::SimBuilder::CreateSim(options, Comms()); SECTION("integration test") { auto const normal = msh_io.readFile(resources::Resource("rbc_ico_1280.msh").Path(), true); diff --git a/Code/tests/redblood/parallel/GraphCommsTests.cc b/Code/tests/redblood/parallel/GraphCommsTests.cc index bb3db45f8..3f0b05867 100644 --- a/Code/tests/redblood/parallel/GraphCommsTests.cc +++ b/Code/tests/redblood/parallel/GraphCommsTests.cc @@ -3,7 +3,6 @@ // file AUTHORS. This software is provided under the terms of the // license in the file LICENSE. -#include "tests/helpers/FolderTestFixture.h" #include "tests/redblood/Fixtures.h" #include "tests/redblood/parallel/ParallelFixtures.h" #include "lb/iolets/InOutLet.h" @@ -12,7 +11,7 @@ namespace hemelb::tests { using namespace redblood; - class GraphCommsTests : public helpers::FolderTestFixture + class GraphCommsTests : public OpenSimFixture { public: GraphCommsTests(); @@ -24,28 +23,28 @@ namespace hemelb::tests void testComputeGlobalCoordsToProcMap(); protected: - std::shared_ptr options; - - //! Meta-function to create simulation type - template - using MasterSim = OpenedSimulationMaster< - Traits< - lb::DefaultLattice, lb::GuoForcingLBGK, lb::Normal, - lb::DefaultStreamer, lb::DefaultWallStreamer, lb::DefaultInletStreamer, lb::DefaultOutletStreamer, - STENCIL - > - >; - - //! Creates a master simulation - template - [[nodiscard]] auto CreateMasterSim(net::IOCommunicator const &comm) const - { - return std::make_shared>(*options, comm); - } +// std::shared_ptr options; +// +// //! Meta-function to create simulation type +// template +// using MasterSim = OpenedSimulationMaster< +// Traits< +// lb::DefaultLattice, lb::GuoForcingLBGK, lb::Normal, +// lb::DefaultStreamer, lb::DefaultWallStreamer, lb::DefaultInletStreamer, lb::DefaultOutletStreamer, +// STENCIL +// > +// >; +// +// //! Creates a master simulation +// template +// [[nodiscard]] auto CreateMasterSim(net::IOCommunicator const &comm) const +// { +// return std::make_shared>(*options, comm); +// } }; - GraphCommsTests::GraphCommsTests() : FolderTestFixture() { + GraphCommsTests::GraphCommsTests() : OpenSimFixture() { // Have everything ready to creates simulations if (Comms().Rank() == 0) { CopyResourceToTempdir("large_cylinder_rbc.xml"); @@ -127,7 +126,7 @@ namespace hemelb::tests REQUIRE(4 == comms.Size()); // Setup simulation with cylinder - auto master = CreateMasterSim(comms); + auto master = CreateMasterSim(comms); REQUIRE(master); auto &latticeData = master->GetFieldData(); @@ -158,7 +157,7 @@ namespace hemelb::tests // Setup simulation with cylinder auto comms = Comms(); - auto master = CreateMasterSim(comms); + auto master = CreateMasterSim(comms); REQUIRE(master); auto simConf = master->GetSimConfig(); @@ -198,7 +197,7 @@ namespace hemelb::tests REQUIRE(4 == comms.Size()); // Setup simulation with cylinder - auto master = CreateMasterSim(comms); + auto master = CreateMasterSim(comms); REQUIRE(master); auto &domain = master->GetFieldData().GetDomain(); auto graphComm = comms.DistGraphAdjacent( diff --git a/Code/tests/redblood/parallel/MPIIntegrateVelocities.cc b/Code/tests/redblood/parallel/MPIIntegrateVelocities.cc index 4e20e819e..2ef9ffffb 100644 --- a/Code/tests/redblood/parallel/MPIIntegrateVelocities.cc +++ b/Code/tests/redblood/parallel/MPIIntegrateVelocities.cc @@ -24,7 +24,7 @@ namespace hemelb::tests { using namespace redblood; - class MPIIntegrateVelocitiesTests : public helpers::FolderTestFixture + class MPIIntegrateVelocitiesTests : public OpenSimFixture { public: MPIIntegrateVelocitiesTests(); @@ -46,30 +46,11 @@ namespace hemelb::tests } protected: - std::shared_ptr options; - - //! Meta-function to create simulation type - template - using MasterSim = OpenedSimulationMaster< - Traits< - lb::DefaultLattice, lb::GuoForcingLBGK, lb::Normal, - lb::DefaultStreamer, lb::DefaultWallStreamer, lb::DefaultInletStreamer, lb::DefaultOutletStreamer, - STENCIL - > - >; - - //! Creates a master simulation - template - auto CreateMasterSim(net::IOCommunicator const &comm) const - { - return std::make_shared>(*options, comm); - } - template void Check(size_t mid, size_t edges, size_t nCells); }; - MPIIntegrateVelocitiesTests::MPIIntegrateVelocitiesTests() : FolderTestFixture() + MPIIntegrateVelocitiesTests::MPIIntegrateVelocitiesTests() : OpenSimFixture() { using hemelb::configuration::CommandLine; @@ -99,7 +80,7 @@ namespace hemelb::tests { using hemelb::redblood::CellContainer; using hemelb::redblood::TemplateCellContainer; - using Traits = typename MasterSim::Traits; + using Traits = MyTraits; auto const world = net::MpiCommunicator::World(); auto const color = world.Rank() == 0; diff --git a/Code/tests/redblood/parallel/MPILockStepTests.cc b/Code/tests/redblood/parallel/MPILockStepTests.cc index d56f85458..a9183ce7e 100644 --- a/Code/tests/redblood/parallel/MPILockStepTests.cc +++ b/Code/tests/redblood/parallel/MPILockStepTests.cc @@ -24,7 +24,7 @@ namespace hemelb::tests { using namespace redblood; //! Parallel and Sequential move in lock step - class MPILockStepTests : public helpers::FolderTestFixture + class MPILockStepTests : public OpenSimFixture { public: MPILockStepTests(); @@ -35,28 +35,12 @@ namespace hemelb::tests } protected: - std::shared_ptr options; - - //! Meta-function to create simulation type - template - using MasterSim = OpenedSimulationMaster>; - - //! Creates a master simulation - template - [[nodiscard]] auto CreateMasterSim(net::IOCommunicator const &comm) const - { - return std::make_shared>(*options, comm); - } template void Check(); }; - MPILockStepTests::MPILockStepTests(): FolderTestFixture() { + MPILockStepTests::MPILockStepTests(): OpenSimFixture() { // Have everything ready to creates simulations if (Comms().Rank() == 0) { CopyResourceToTempdir("cyl_l100_r5.xml"); @@ -144,7 +128,7 @@ namespace hemelb::tests template void MPILockStepTests::Check() { - using Traits = typename MasterSim::Traits; + using Traits = MyTraits; auto const world = Comms(); auto const color = world.Rank() == 0; diff --git a/Code/tests/redblood/parallel/MPIParallelIntegrationTests.cc b/Code/tests/redblood/parallel/MPIParallelIntegrationTests.cc index b406317cd..15306464d 100644 --- a/Code/tests/redblood/parallel/MPIParallelIntegrationTests.cc +++ b/Code/tests/redblood/parallel/MPIParallelIntegrationTests.cc @@ -22,7 +22,7 @@ namespace hemelb::tests { using namespace redblood; - class MPIParallelIntegrationTests : public helpers::FolderTestFixture + class MPIParallelIntegrationTests : public OpenSimFixture { public: MPIParallelIntegrationTests(); @@ -33,29 +33,10 @@ namespace hemelb::tests } protected: - std::shared_ptr options; - - //! Meta-function to create simulation type - template - using MasterSim = OpenedSimulationMaster< - Traits< - lb::DefaultLattice, lb::GuoForcingLBGK, lb::Normal, - lb::DefaultStreamer, lb::DefaultWallStreamer, lb::DefaultInletStreamer, lb::DefaultOutletStreamer, - STENCIL - > - >; - - //! Creates a master simulation - template - [[nodiscard]] auto CreateMasterSim(net::IOCommunicator const &comm) const - { - return std::make_shared>(*options, comm); - } - template void Check(); }; - MPIParallelIntegrationTests::MPIParallelIntegrationTests() : FolderTestFixture() + MPIParallelIntegrationTests::MPIParallelIntegrationTests() : OpenSimFixture() { // Have everything ready to creates simulations if (net::MpiCommunicator::World().Rank() == 0) { @@ -91,7 +72,7 @@ namespace hemelb::tests void MPIParallelIntegrationTests::Check() { using hemelb::redblood::CellContainer; using hemelb::redblood::TemplateCellContainer; - using Traits = typename MasterSim::Traits; + using T = MyTraits; auto const world = net::MpiCommunicator::World(); auto const color = world.Rank() == 0; @@ -101,11 +82,11 @@ namespace hemelb::tests REQUIRE(master); unsigned num_cells; - auto checkNumCells = [&num_cells]( const hemelb::redblood::CellContainer & cells) { + auto checkNumCells = [&num_cells]( const CellContainer & cells) { num_cells = cells.size(); }; - auto controller = std::static_pointer_cast>(master->GetCellController()); + auto controller = std::static_pointer_cast>(master->GetCellController()); REQUIRE(controller); controller->AddCellChangeListener(checkNumCells); diff --git a/Code/tests/redblood/parallel/MPISpreadForcesTests.cc b/Code/tests/redblood/parallel/MPISpreadForcesTests.cc index 8c0a4c3bd..8b307725e 100644 --- a/Code/tests/redblood/parallel/MPISpreadForcesTests.cc +++ b/Code/tests/redblood/parallel/MPISpreadForcesTests.cc @@ -21,7 +21,7 @@ namespace hemelb::tests { - class MPISpreadForcesTests : public helpers::FolderTestFixture + class MPISpreadForcesTests : public OpenSimFixture { public: MPISpreadForcesTests(); @@ -40,29 +40,10 @@ namespace hemelb::tests } protected: - std::shared_ptr options; - - //! Meta-function to create simulation type - template - using MasterSim = OpenedSimulationMaster< - Traits< - lb::DefaultLattice, lb::GuoForcingLBGK, lb::Normal, - lb::DefaultStreamer, lb::DefaultWallStreamer, lb::DefaultInletStreamer, lb::DefaultOutletStreamer, - STENCIL - > - >; - - //! Creates a master simulation - template - auto CreateMasterSim(net::IOCommunicator const &comm) const - { - return std::make_shared>(*options, comm); - } - template void Check(size_t mid, size_t edges, size_t nCells); }; - MPISpreadForcesTests::MPISpreadForcesTests() : FolderTestFixture::FolderTestFixture() + MPISpreadForcesTests::MPISpreadForcesTests() : OpenSimFixture() { using hemelb::configuration::CommandLine; @@ -117,8 +98,8 @@ namespace hemelb::tests mpi_spreader.PostMessageLength(distributions, owned); mpi_spreader.ComputeForces(owned); mpi_spreader.PostForcesAndNodes(distributions, owned); - mpi_spreader.SpreadLocalForces::Traits>(fieldData, owned); - mpi_spreader.SpreadNonLocalForces::Traits>(fieldData); + mpi_spreader.SpreadLocalForces>(fieldData, owned); + mpi_spreader.SpreadNonLocalForces>(fieldData); std::vector indices; std::vector forces; diff --git a/Code/tests/redblood/parallel/ParallelFixtureTests.cc b/Code/tests/redblood/parallel/ParallelFixtureTests.cc index ac11f1f94..71b706f3b 100644 --- a/Code/tests/redblood/parallel/ParallelFixtureTests.cc +++ b/Code/tests/redblood/parallel/ParallelFixtureTests.cc @@ -11,6 +11,7 @@ #include "util/span.h" #include "redblood/parallel/NodeCharacterizer.h" #include "configuration/CommandLine.h" +#include "configuration/SimBuilder.h" #include "tests/redblood/Fixtures.h" #include "tests/helpers/LatticeDataAccess.h" #include "tests/helpers/FolderTestFixture.h" @@ -20,36 +21,17 @@ namespace hemelb::tests { using namespace redblood; //! Parallel and Sequential move in lock step - class ParallelFixtureTests : public helpers::FolderTestFixture + class ParallelFixtureTests : public OpenSimFixture { public: ParallelFixtureTests(); //! if owner procs thinks position affects proc i, then proc i knows it as well void testTransitiveOwnership(); - protected: - std::shared_ptr options; - - //! Meta-function to create simulation type - template - using MasterSim = OpenedSimulationMaster< - Traits< - lb::DefaultLattice, lb::GuoForcingLBGK, lb::Normal, - lb::DefaultStreamer, lb::DefaultWallStreamer, lb::DefaultInletStreamer, lb::DefaultOutletStreamer, - STENCIL - > - >; - - //! Creates a master simulation - template - auto CreateMasterSim(net::IOCommunicator const &comm) const - { - return std::make_shared>(*options, comm); - } }; - ParallelFixtureTests::ParallelFixtureTests() : FolderTestFixture() + ParallelFixtureTests::ParallelFixtureTests() : OpenSimFixture() { // Have everything ready to create simulations if (Comms().Rank() == 0) diff --git a/Code/tests/redblood/parallel/ParallelFixtures.cc b/Code/tests/redblood/parallel/ParallelFixtures.cc index b9c3d787d..c223d8347 100644 --- a/Code/tests/redblood/parallel/ParallelFixtures.cc +++ b/Code/tests/redblood/parallel/ParallelFixtures.cc @@ -19,8 +19,8 @@ namespace hemelb::tests std::random_device rd; std::mt19937 g(rd()); - int const nMids = domain.GetMidDomainCollisionCount(0); - int const nEdges = domain.GetDomainEdgeCollisionCount(0); + int const nMids = domain.GetMidDomainSiteCount(0); + int const nEdges = domain.GetDomainEdgeSiteCount(0); std::vector positions(c.Size() * (mid + edges)); std::vector shuf(nMids); std::iota(shuf.begin(), shuf.end(), 0); diff --git a/Code/tests/redblood/parallel/ParallelFixtures.h b/Code/tests/redblood/parallel/ParallelFixtures.h index eef9d5d4a..b7587c151 100644 --- a/Code/tests/redblood/parallel/ParallelFixtures.h +++ b/Code/tests/redblood/parallel/ParallelFixtures.h @@ -8,7 +8,9 @@ #include "redblood/Cell.h" #include "tests/redblood/Fixtures.h" +#include "tests/helpers/FolderTestFixture.h" #include "SimulationMaster.h" +#include "configuration/SimBuilder.h" namespace hemelb::tests { @@ -20,16 +22,17 @@ namespace hemelb::tests net::MpiCommunicator const &c); //! Make some functionality available - template - class OpenedSimulationMaster : public SimulationMaster + class OpenedSimulationMaster : public SimulationMaster { public: - using SimulationMaster::SimulationMaster; - using SimulationMaster::Finalise; + //using SimulationMaster::SimulationMaster; + using SimulationMaster::Finalise; + OpenedSimulationMaster(SimulationMaster&& src) : SimulationMaster(src) { + } void DoTimeStep() { - SimulationMaster::DoTimeStep(); + SimulationMaster::DoTimeStep(); } configuration::SimConfig const& GetSimConfig() @@ -38,6 +41,26 @@ namespace hemelb::tests } }; + class OpenSimFixture : public helpers::FolderTestFixture { + protected: + template + using MyTraits = Traits< + lb::DefaultLattice, lb::GuoForcingLBGK, lb::Normal, + lb::DefaultStreamer, lb::DefaultWallStreamer, lb::DefaultInletStreamer, lb::DefaultOutletStreamer, + STENCIL + >; + + std::shared_ptr options; + template + [[nodiscard]] auto CreateMasterSim(net::IOCommunicator const &comm) const { + using T = MyTraits; + auto tmp = configuration::SimBuilder::CreateSim( + *options, comm + ); + return std::unique_ptr(new OpenedSimulationMaster(std::move(*tmp))); + } + }; + class DummyCell : public NodeCell { public: LatticeForce force;