VPTissue Reference Manual
CoupledSim.h
Go to the documentation of this file.
1 #ifndef COUPLED_SIM_H_INCLUDED
2 #define COUPLED_SIM_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "CoreData.h"
23 #include "event/CoupledSimEvent.h"
24 #include "sim/Sim.h"
25 #include "SimInterface.h"
26 
28 #include "util/misc/Subject.h"
29 
30 #include <boost/property_tree/ptree.hpp>
31 #include <string>
32 #include <unordered_map>
33 #include <vector>
34 
35 namespace SimPT_Sim {
36 
37 class ICoupler;
38 
43  public SimPT_Sim::Util::Subject<SimPT_Sim::Event::CoupledSimEvent, std::weak_ptr<const void>>,
44  public std::enable_shared_from_this<CoupledSim>
45 {
46 public:
48  CoupledSim();
49 
51  virtual ~CoupledSim() {}
52 
54  CoreData& GetCoreData() override final { return m_cd; }
55 
57  const boost::property_tree::ptree& GetParameters() const;
58 
60  std::string GetProjectName() const;
61 
63  std::string GetRunDate() const;
64 
66  int GetSimStep() const;
67 
69  Timings GetTimings() const;
70 
72  void IncrementStepCount() { ++m_sim_step; }
73 
75  void Initialize(const boost::property_tree::ptree& pt,
76  const std::vector<std::shared_ptr<Sim>>& simulators);
77 
79  bool IsAtTermination() const;
80 
82  bool IsStationary() const;
83 
85  void Reinitialize(const boost::property_tree::ptree& parameters);
86 
88  void TimeStep();
89 
90 private:
91  std::unordered_map<std::string, std::shared_ptr<Sim>> m_simulators;
92  std::vector<std::shared_ptr<ICoupler>> m_couplers;
93  CoreData m_cd;
94  std::string m_project_name;
95  std::string m_run_date;
96  unsigned int m_sim_step;
97  unsigned int m_sim_ODE_steps;
98  Timings m_timings;
99 };
100 
101 } // namespace
102 
103 #endif // end_of_include_guard
CoreData & GetCoreData() override final
Definition: CoupledSim.h:54
Simulator interface.
Core data with mesh, parameters, random engine and time data.
Definition: CoreData.h:38
std::string GetRunDate() const
Definition: CoupledSim.cpp:54
Core data used during model execution.
void Initialize(const boost::property_tree::ptree &pt, const std::vector< std::shared_ptr< Sim >> &simulators)
Initialize with full configuration (complete setup prior to first use).
Definition: CoupledSim.cpp:73
void IncrementStepCount()
Increase the current time step counter by one.
Definition: CoupledSim.h:72
std::string GetProjectName() const
Definition: CoupledSim.cpp:49
bool IsStationary() const
Definition: CoupledSim.cpp:102
const boost::property_tree::ptree & GetParameters() const
Definition: CoupledSim.cpp:44
void Reinitialize(const boost::property_tree::ptree &parameters)
Definition: CoupledSim.cpp:112
Namespace for the core simulator.
bool IsAtTermination() const
Definition: CoupledSim.cpp:92
Interface/Implementation of Subject.
virtual ~CoupledSim()
Destructor is virtual.
Definition: CoupledSim.h:51
Sim, the actual simulator.
Definition for CoupledSimEvent.
Interface for Timeable.
Subject in Observer pattern.
Definition: Subject.h:34
Simulator interface.
Definition: SimInterface.h:36
Timings GetTimings() const
Definition: CoupledSim.cpp:64
Coupled Simulator: multiple simulators and couplers.
Definition: CoupledSim.h:42
CoupledSim()
Constructor does almost no initialization work (.
Definition: CoupledSim.cpp:39
int GetSimStep() const
Definition: CoupledSim.cpp:59
see the online C++11 documentation