Skip to content

Commit aa88ca3

Browse files
committed
Finish de-templating sim master, make RBC cope and move path manager into config where it belongs
1 parent 1475365 commit aa88ca3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+193
-261
lines changed

Code/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ if (HEMELB_USE_DEBUGGER)
123123
set(CMAKE_BUILD_TYPE Debug)
124124
endif()
125125

126-
add_executable(${HEMELB_EXECUTABLE} SimulationMaster.cc main.cc)
126+
add_library(hemelb_sim OBJECT SimulationMaster.cc)
127+
list(APPEND heme_libraries hemelb_sim)
128+
add_executable(${HEMELB_EXECUTABLE} main.cc)
127129
codesign(${HEMELB_EXECUTABLE})
128130

129131
include_directories(${PROJECT_SOURCE_DIR})

Code/SimulationMaster.cc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,9 @@ namespace hemelb
3737
* Initialises member variables including the network topology
3838
* object.
3939
*/
40-
SimulationMaster::SimulationMaster(configuration::CommandLine & options,
41-
const net::IOCommunicator& ioComm) :
40+
SimulationMaster::SimulationMaster(const net::IOCommunicator& ioComm) :
4241
build_info(), ioComms(ioComm.Duplicate()), communicationNet(ioComms)
4342
{
44-
// Start the main timer!
45-
timings.total().Start();
46-
47-
fileManager = std::make_shared<io::PathManager>(options,
48-
IsCurrentProcTheIOProc(),
49-
GetProcessorCount());
50-
log::Logger::Log<log::Info, log::Singleton>("Reading configuration from %s", fileManager->GetInputFile().c_str());
51-
// Convert XML to configuration
52-
simConfig = configuration::SimConfig::New(fileManager->GetInputFile());
53-
// Use it to initialise self
54-
auto builder = configuration::SimBuilder(simConfig);
55-
log::Logger::Log<log::Info, log::Singleton>("Beginning Initialisation.");
56-
builder.build<>(*this);
5743
}
5844

5945
/// Destructor for the SimulationMaster class.

Code/SimulationMaster.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "util/UnitConverter.h"
1717
#include "configuration/SimConfig.h"
1818
#include "configuration/CommandLine.h"
19-
#include "io/PathManager.h"
19+
#include "configuration/PathManager.h"
2020
#include "reporting/Reporter.h"
2121
#include "reporting/Timers.h"
2222
#include "reporting/BuildInfo.h"
@@ -53,7 +53,7 @@ namespace hemelb
5353
std::shared_ptr<lb::LBMBase> latticeBoltzmannModel;
5454
std::shared_ptr<geometry::neighbouring::NeighbouringDataManager> neighbouringDataManager;
5555

56-
std::shared_ptr<io::PathManager> fileManager;
56+
std::shared_ptr<configuration::PathManager> fileManager;
5757
std::shared_ptr<reporting::Reporter> reporter;
5858

5959
std::shared_ptr<lb::SimulationState> simulationState;
@@ -77,9 +77,8 @@ namespace hemelb
7777
std::shared_ptr<net::phased::StepManager> stepManager;
7878
std::shared_ptr<net::phased::NetConcern> netConcern;
7979

80+
SimulationMaster(const net::IOCommunicator& ioComm);
8081
public:
81-
SimulationMaster(configuration::CommandLine &options,
82-
const net::IOCommunicator& ioComms);
8382
virtual ~SimulationMaster();
8483

8584
void Abort();

Code/configuration/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
add_library(hemelb_configuration OBJECT
77
CommandLine.cc
8+
PathManager.cc
89
SimConfig.cc
910
SimBuilder.cc
1011
SimConfigReader.cc

Code/io/PathManager.cc renamed to Code/configuration/PathManager.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
// file AUTHORS. This software is provided under the terms of the
44
// license in the file LICENSE.
55

6-
#include "io/PathManager.h"
6+
#include "configuration/PathManager.h"
77

88
#include "Exception.h"
99
#include "configuration/CommandLine.h"
1010

1111
namespace fs = std::filesystem;
12-
namespace hemelb::io
12+
namespace hemelb::configuration
1313
{
1414

1515
PathManager::PathManager(const configuration::CommandLine & commandLine, const bool & io,

Code/io/PathManager.h renamed to Code/configuration/PathManager.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// file AUTHORS. This software is provided under the terms of the
44
// license in the file LICENSE.
55

6-
#ifndef HEMELB_IO_PATHMANAGER_H
7-
#define HEMELB_IO_PATHMANAGER_H
6+
#ifndef HEMELB_CONFIGURATION_PATHMANAGER_H
7+
#define HEMELB_CONFIGURATION_PATHMANAGER_H
88

99
#include <filesystem>
1010
#include <string>
@@ -14,12 +14,6 @@ namespace hemelb::configuration
1414
{
1515
class CommandLine;
1616
class SimConfig;
17-
}
18-
19-
namespace hemelb::io
20-
{
21-
// Forward declare the Writer
22-
namespace writers { class Writer; }
2317

2418
/**
2519
* Manage the input and output file system locations for HemeLB reports, extracted data, and input xml.
@@ -82,4 +76,4 @@ namespace hemelb::io
8276

8377
}
8478

85-
#endif //HEMELB_IO_PATHMANAGER_H
79+
#endif //HEMELB_CONFIGURATION_PATHMANAGER_H

Code/configuration/SimBuilder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ namespace hemelb::configuration {
291291
}
292292

293293
std::shared_ptr<reporting::Reporter> SimBuilder::BuildReporter(
294-
io::PathManager const& fileManager,
294+
PathManager const& fileManager,
295295
std::vector<reporting::Reportable*>const& reps
296296
) const {
297297
auto reporter = std::make_shared<reporting::Reporter>(fileManager.GetReportPath(),

Code/configuration/SimBuilder.h

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,31 @@ namespace hemelb::configuration {
5454
std::shared_ptr<util::UnitConverter> unit_converter;
5555

5656
public:
57+
template <typename TraitsT>
58+
static std::unique_ptr<SimulationMaster> CreateSim(
59+
CommandLine const& options,
60+
net::IOCommunicator const& ioComms
61+
) {
62+
auto ans = std::unique_ptr<SimulationMaster>(new SimulationMaster(ioComms));
63+
// Start the main timer!
64+
ans->timings.total().Start();
65+
66+
ans->fileManager = std::make_shared<configuration::PathManager>(
67+
options,
68+
ioComms.OnIORank(),
69+
ioComms.Size()
70+
);
71+
auto&& infile = ans->fileManager->GetInputFile();
72+
log::Logger::Log<log::Info, log::Singleton>("Reading configuration from %s", infile.c_str());
73+
// Convert XML to configuration
74+
ans->simConfig = configuration::SimConfig::New(infile);
75+
// Use it to initialise self
76+
auto builder = configuration::SimBuilder(ans->simConfig);
77+
log::Logger::Log<log::Info, log::Singleton>("Beginning Initialisation.");
78+
builder.build<TraitsT>(*ans);
79+
return ans;
80+
}
81+
5782
explicit SimBuilder(SimConfig const& conf, bool construct_unit_converter = true);
5883
virtual ~SimBuilder() = default;
5984

@@ -111,7 +136,7 @@ namespace hemelb::configuration {
111136
) const;
112137

113138
[[nodiscard]] std::shared_ptr<reporting::Reporter> BuildReporter(
114-
io::PathManager const& fileManager,
139+
PathManager const& fileManager,
115140
std::vector<reporting::Reportable*> const & reps
116141
) const;
117142
};
@@ -299,8 +324,6 @@ namespace hemelb::configuration {
299324
[[nodiscard]] std::shared_ptr<net::IteratedAction> SimBuilder::BuildCellController(SimulationMaster const& control, reporting::Timers& timings) const {
300325
if (config.HasRBCSection()) {
301326
#ifdef HEMELB_BUILD_RBC
302-
using traitsType = typename T::Traits;
303-
304327
auto ccb = redblood::CellControllerBuilder(unit_converter);
305328

306329
auto& ioComms = control.ioComms;
@@ -324,4 +347,4 @@ namespace hemelb::configuration {
324347
return {};
325348
}
326349
}
327-
#endif
350+
#endif

Code/extraction/PropertyActor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#define HEMELB_EXTRACTION_PROPERTYACTOR_H
88

99
#include "extraction/PropertyWriter.h"
10-
#include "io/PathManager.h"
1110
#include "lb/MacroscopicPropertyCache.h"
1211
#include "lb/SimulationState.h"
1312
#include "net/IteratedAction.h"

Code/io/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ endif()
1212

1313
add_library(hemelb_io OBJECT
1414
FILE.cc
15-
PathManager.cc
1615
writers/AsciiFileWriter.cc writers/AsciiStreamWriter.cc
1716
readers/XdrFileReader.cc
1817
readers/XdrMemReader.cc

0 commit comments

Comments
 (0)