MolSim
Loading...
Searching...
No Matches
Simulation.h
Go to the documentation of this file.
1
9#pragma once
12#include "io/output/XMLWriter.h"
15#include "objects/Thermostat.h"
17#include "utils/Arguments.h"
18#include "utils/Timer.h"
19#include <cassert>
20#include <memory>
21#include <optional>
22#include <string>
23
24#if (!defined(DO_BENCHMARKING) && !defined(DO_PROFILING))
25#define SIM_SERIALIZE_XML(_a, _b, _c, _d, _e) \
26 do { \
27 XMLWriter xmlw{_a}; \
28 xmlw.serialize(_b, _c, _d, _e); \
29 } while (0)
30#define SIM_INIT_WRITER(_a, _b, _c) _a = WriterFactory::createWriter(_b, _c)
31#define SIM_WRITE_OUTPUT(_a, _b, _c, _d, _e) \
32 do { \
33 if (_a % _b == 0) { \
34 _c->writeParticles(_d, _a, _e); \
35 } \
36 } while (0)
37#define SIM_ANALYZE_FLOW(_a, _b) \
38 do { \
39 _a.analyzeFlow(_b); \
40 } while (0)
41#else
42#define SIM_SERIALIZE_XML(_a, _b, _c, _d, _e) (void)0
43#define SIM_INIT_WRITER(_a, _b, _c) (void)0
44#define SIM_WRITE_OUTPUT(_a, _b, _c, _d, _e) (void)0
45#define SIM_ANALYZE_FLOW(_a, _b) (void)0
46#endif
47
48#ifdef NOUTFLOW
49#define CHECK_NOUTFLOW(_x, _y) \
50 if (std::any_of(_x._y.begin(), _x._y.end(), \
51 [](BoundaryCondition condition) { return condition == BoundaryCondition::OUTFLOW; })) { \
52 CLIUtils::error("Cannot run simulation with outflow conditions when NOUTFLOW is defined! Please recompile " \
53 "the program without defining it."); \
54 }
55#else
56#define CHECK_NOUTFLOW(_x, _y) (void)0
57#endif
58
Configurable program and simulation arguments.
General class used to strictly write particle data to some output file. data.
Component for analyzing particle density and velocity profiles.
Class for encapsulating and iterating over multiple Particle objects.
Factory class for choosing the appropriate functions based on the Simulation.
Model of a thermostat.
Header-only class for timing code execution.
Factory class for creating different types of file output generators.
Serialize simulation data to an XML file.
Cell encapsulation class for implementing the linked cell method.
Definition CellContainer.h:31
Class modeling and analyzer that computes statistics about the state of a nano-scale flow simulation.
Definition FlowSimulationAnalyzer.h:16
Class for encapsulating multiple Particle objects..
Definition ParticleContainer.h:17
Class defining a time-integration simulation.
Definition Simulation.h:60
ParticleContainer & getParticles()
Gets a reference to the ParticleContainer storing the simulation's particles.
ParticleContainer & m_particles
Reference to the ParticleContainer containing the particles used in the simulation.
Definition Simulation.h:63
Thermostat & m_thermostat
Reference to the Thermostat, for temperature regulation.
Definition Simulation.h:69
TimeIntegrationFuncs::VFunc m_calculateV
Function for calculating the Particle velocities.
Definition Simulation.h:81
virtual void runSimulation()
Main function for running the simulation.
StrategyFactory::FFunc m_calculateF
Function for calculating the force effective on each Particle.
Definition Simulation.h:87
Simulation(ParticleContainer &pc, Arguments &args, Thermostat &t, FlowSimulationAnalyzer &analyzer)
Constructs a new Simulation.
Timer m_timer
Timer used to measure simulation runtime and log molecule updates per second (MUPS).
Definition Simulation.h:90
Arguments & m_args
Reference to the Arguments struct containing simulation parameters.
Definition Simulation.h:66
virtual ~Simulation()
Destroys the current Simulation object.
FlowSimulationAnalyzer & m_analyzer
Reference to the FlowSimulationAnalyzer, for statistics computation.
Definition Simulation.h:72
TimeIntegrationFuncs::XFunc m_calculateX
Function for calculating the Particle positions.
Definition Simulation.h:84
void initializeBase()
Base function for initializing Simulation parameters.
int m_totalIt
The total number of iterations for which the simulation will run.
Definition Simulation.h:75
void runSimulationLoop(CellContainer *lc=nullptr)
Runs a basic simulation loop.
std::unique_ptr< FileWriter > m_writer
A pointer to the FileWriter object used for writing file output.
Definition Simulation.h:78
void(*)(ParticleContainer &, double, CellContainer *) FFunc
Typedef for force-calculating functions.
Definition StrategyFactory.h:43
Class modeling a thermostat which regulates the temperature of a Particle system.
Definition Thermostat.h:14
Class used to measure runtime performance and log molecule updates per second (MUPS).
Definition Timer.h:29
Struct containing each option configurable via command line arguments.
Definition Arguments.h:31
void(*)(ParticleContainer &, double, double, CellContainer *, bool) XFunc
Typedef for position-calculating functions.
Definition StrategyFactory.h:22
void(*)(ParticleContainer &, double) VFunc
Typedef for velocity-calculating functions.
Definition StrategyFactory.h:20