Line data Source code
1 : // Copyright (C) 2015 Technische Universitaet Muenchen
2 : // This file is part of the Mamico project. For conditions of distribution
3 : // and use, please see the copyright notice in Mamico's main folder, or at
4 : // www5.in.tum.de/mamico
5 : #ifndef _MAMICO_COUPLING_SCENARIO_SCENARIO_H_
6 : #define _MAMICO_COUPLING_SCENARIO_SCENARIO_H_
7 :
8 : class Scenario;
9 :
10 : #include "coupling/CouplingMDDefinitions.h"
11 : #include "coupling/solvers/CouetteSolver.h"
12 : #include "mamico_git_version_info.h"
13 : #include <iostream>
14 : #include <string>
15 :
16 : #define __MAMICO_STRINGIFY_EXPAND(x) #x
17 : #define MAMICO_STRINGIFY(x) __MAMICO_STRINGIFY_EXPAND(x)
18 :
19 : class Scenario {
20 : public:
21 : Scenario(std::string scenarioname) : _scenarioname(scenarioname) {
22 : int rank = 0;
23 : #if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
24 : MPI_Comm_rank(MPI_COMM_WORLD, &rank);
25 : #endif
26 : _isRootRank = (rank == 0);
27 : if (_isRootRank) {
28 : std::cout << "Run " << scenarioname << "..." << std::endl;
29 : std::cout << "MaMiCo git commit hash = " << MAMICO_STRINGIFY(MAMICO_COMMIT_HASH) << std::endl;
30 : }
31 : }
32 : virtual ~Scenario() {
33 : if (_isRootRank) {
34 : std::cout << "Shut down " << _scenarioname << std::endl;
35 : }
36 : }
37 :
38 : virtual void run() = 0;
39 : virtual void init() = 0;
40 : virtual void runOneCouplingCycle(int cycle) = 0;
41 : virtual void equilibrateMicro() = 0;
42 :
43 : virtual coupling::solvers::AbstractCouetteSolver<3>* getSolver() = 0;
44 0 : const coupling::services::ParallelTimeIntegrationService<3>* getTimeIntegrationService() const { return _timeIntegrationService.get(); }
45 :
46 : protected:
47 : std::unique_ptr<coupling::services::ParallelTimeIntegrationService<3>> _timeIntegrationService;
48 :
49 : /** @brief if this is the world global root process */
50 : bool _isRootRank;
51 :
52 : private:
53 : const std::string _scenarioname;
54 : };
55 :
56 : #endif // _MAMICO_COUPLING_SCENARIO_SCENARIO_H_
|