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 _MOLECULARDYNAMICS_COUPLING_INTERFACE_MAMICOINTERFACEPROVIDER_H_ 6 : #define _MOLECULARDYNAMICS_COUPLING_INTERFACE_MAMICOINTERFACEPROVIDER_H_ 7 : 8 : #include "coupling/interface/MDSolverInterface.h" 9 : #include "coupling/interface/MacroscopicSolverInterface.h" 10 : #include "coupling/services/CouplingCellService.h" 11 : 12 : namespace coupling { 13 : namespace interface { 14 : 15 : /** This is a singleton which returns and stores the interface implementations. 16 : * It can be used if there is no other way to share access to a particular 17 : *interface object between MaMiCo and the MD simulation 18 : * @brief a singleton which returns and stores the interface 19 : *implementations. 20 : * @tparam LinkedCell cell type 21 : * @tparam dim Number of dimensions; it can be 1, 2 or 3 22 : * @author Philipp Neumann 23 : */ 24 : template <class LinkedCell, int dim> class MamicoInterfaceProvider { 25 : public: 26 : /** returns the MamicoInterfaceProvider object 27 : */ 28 28 : static MamicoInterfaceProvider& getInstance() { 29 32 : static MamicoInterfaceProvider singleton; 30 28 : return singleton; 31 : } 32 : 33 : /** sets macroscopic solver interface 34 : * @param macroscopicSolverInterface 35 : */ 36 : void setMacroscopicSolverInterface(coupling::interface::MacroscopicSolverInterface<dim>* macroscopicSolverInterface) { 37 : _macroscopicSolverInterface = macroscopicSolverInterface; 38 : } 39 : 40 : /** returns acroscopic solver interface 41 : * @return _macroscopicSolverInterface 42 : */ 43 : coupling::interface::MacroscopicSolverInterface<dim>* getMacroscopicSolverInterface() { return _macroscopicSolverInterface; } 44 : 45 : /** sets MD solver interface 46 : * @param mdSolverInterface 47 : */ 48 20 : void setMDSolverInterface(coupling::interface::MDSolverInterface<LinkedCell, dim>* mdSolverInterface) { _mdSolverInterface = mdSolverInterface; } 49 : 50 : /** returns MD solver interface 51 : * @return _mdSolverInterface 52 : */ 53 8 : coupling::interface::MDSolverInterface<LinkedCell, dim>* getMDSolverInterface() { return _mdSolverInterface; } 54 : 55 : /** sets coupling cell service 56 : * @return couplingCellService 57 : */ 58 0 : void setCouplingCellService(coupling::services::CouplingCellService<dim>* couplingCellService) { _couplingCellService = couplingCellService; } 59 : 60 : /** returns coupling cell service 61 : * @return _couplingCellService 62 : */ 63 : coupling::services::CouplingCellService<dim>* getCouplingCellService() { return _couplingCellService; } 64 : 65 : private: 66 : /** Private constructor, creation throgh a pointer and set functions 67 : * @note singelton pattern 68 : */ 69 4 : MamicoInterfaceProvider() : _macroscopicSolverInterface(NULL), _mdSolverInterface(NULL), _couplingCellService(NULL) {} 70 : /** Private destructor 71 : * @note singelton pattern 72 : */ 73 4 : ~MamicoInterfaceProvider() { 74 4 : _macroscopicSolverInterface = NULL; 75 4 : _mdSolverInterface = NULL; 76 4 : _couplingCellService = NULL; 77 4 : } 78 : 79 : coupling::interface::MacroscopicSolverInterface<dim>* _macroscopicSolverInterface; 80 : coupling::interface::MDSolverInterface<LinkedCell, dim>* _mdSolverInterface; 81 : coupling::services::CouplingCellService<dim>* _couplingCellService; 82 : }; 83 : 84 : } // namespace interface 85 : } // namespace coupling 86 : #endif // _MOLECULARDYNAMICS_COUPLING_INTERFACE_MAMICOINTERFACEPROVIDER_H_