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 4 : #ifndef _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_MAMICOCONFIGURATION_H_ 5 : #define _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_MAMICOCONFIGURATION_H_ 6 : 7 : #include "coupling/configurations/BoundaryForceConfiguration.h" 8 : #include "coupling/configurations/CouplingCellConfiguration.h" 9 : #include "coupling/configurations/MomentumInsertionConfiguration.h" 10 : #include "coupling/configurations/ParallelTopologyConfiguration.h" 11 : #include "coupling/configurations/ParticleInsertionConfiguration.h" 12 : #include "coupling/configurations/ThermostatConfiguration.h" 13 : #include "coupling/configurations/TimeIntegrationConfiguration.h" 14 : #include "coupling/configurations/TransferStrategyConfiguration.h" 15 : #include "tarch/configuration/Configuration.h" 16 : #include "tarch/la/Vector.h" 17 : #include <iostream> 18 : 19 : namespace coupling { 20 : namespace configurations { 21 : template <unsigned int dim> class MaMiCoConfiguration; 22 : } 23 : } // namespace coupling 24 : 25 : /** parses all sub-tags for MaMiCo configuration. Derive from the class 26 : * tarch::configuration::Configuration 27 : * @brief parses all sub-tags for MaMiCo configuration. 28 : * @tparam dim Number of dimensions; it can be 1, 2 or 3 29 : * @author Philipp Neumann 30 : */ 31 : template <unsigned int dim> class coupling::configurations::MaMiCoConfiguration : public tarch::configuration::Configuration { 32 : public: 33 : /** Constructor, initializes the class */ 34 336 : MaMiCoConfiguration() 35 672 : : _isValid(true), _isDefinedParticleInsertion(false), _isDefinedMomentumInsertion(false), _isDefinedBoundaryForce(false), 36 672 : _isDefinedTransferStrategy(false), _isDefinedParallelTopology(false), _isDefinedThermostat(false) {} 37 : 38 : /** Destructor */ 39 336 : virtual ~MaMiCoConfiguration() {} 40 : 41 : /** parseSubtag 42 : * @param node 43 : */ 44 : void parseSubtag(tinyxml2::XMLElement* node); 45 : 46 : /** Returns name of xml tag that is associated to the configuration. 47 : * @return name of xml tag that is associated to the configuration 48 : */ 49 0 : std::string getTag() const { return "mamico"; } 50 : 51 : /** 52 : * Is config valid? 53 : * 54 : * This operation usually fails, if 55 : * 56 : * - parseSubtag() hasn't been called, i.e. configuration has not been 57 : * used, or 58 : * - parseSubtag() failed due to a wrong file. 59 : * 60 : * If a tag ain't optional and parseSubtag() was not called (first case) 61 : * @return _isValid 62 : */ 63 4 : bool isValid() const { return _isValid; } 64 : 65 : /** 66 : * @return _couplingCellConfiguration 67 : */ 68 : const coupling::configurations::CouplingCellConfiguration<dim>& getCouplingCellConfiguration() const { return _couplingCellConfiguration; } 69 : 70 : /** 71 : * @return _particleInsertionConfiguration 72 : */ 73 : const coupling::configurations::ParticleInsertionConfiguration& getParticleInsertionConfiguration() const { 74 : if (!_isDefinedParticleInsertion) { 75 : std::cout << "ERROR coupling::configurations::MaMiCoConfiguration: " 76 : "Particle insertion not defined!" 77 : << std::endl; 78 : exit(EXIT_FAILURE); 79 : } 80 : return _particleInsertionConfiguration; 81 : } 82 : 83 : /** 84 : * @return _momentumInsertionConfiguration 85 : */ 86 : const coupling::configurations::MomentumInsertionConfiguration& getMomentumInsertionConfiguration() const { 87 : if (!_isDefinedMomentumInsertion) { 88 : std::cout << "ERROR coupling::configurations::MaMiCoConfiguration: " 89 : "Momentum insertion not defined!" 90 : << std::endl; 91 : exit(EXIT_FAILURE); 92 : } 93 : return _momentumInsertionConfiguration; 94 : } 95 : 96 : /** 97 : * @return _boundaryForceConfiguration 98 : */ 99 : const coupling::configurations::BoundaryForceConfiguration<dim>& getBoundaryForceConfiguration() const { 100 : if (!_isDefinedBoundaryForce) { 101 : std::cout << "ERROR coupling::configurations::MaMiCoConfiguration: " 102 : "Boundary force not defined!" 103 : << std::endl; 104 : exit(EXIT_FAILURE); 105 : } 106 : return _boundaryForceConfiguration; 107 : } 108 : 109 : /** 110 : * @return _transferStrategyConfiguration 111 : */ 112 : const coupling::configurations::TransferStrategyConfiguration<dim>& getTransferStrategyConfiguration() const { 113 : if (!_isDefinedTransferStrategy) { 114 : std::cout << "ERROR coupling::configurations::MaMiCoConfiguration: " 115 : "Transfer-Strategy not defined!" 116 : << std::endl; 117 : exit(EXIT_FAILURE); 118 : } 119 : return _transferStrategyConfiguration; 120 : } 121 : 122 : /** 123 : * @return _parallelTopologyConfiguration 124 : */ 125 : const coupling::configurations::ParallelTopologyConfiguration& getParallelTopologyConfiguration() const { 126 : if (!_isDefinedParallelTopology) { 127 : std::cout << "ERROR coupling::configurations::MaMiCoConfiguration: " 128 : "Parallel-Topology not defined!" 129 : << std::endl; 130 : exit(EXIT_FAILURE); 131 : } 132 : return _parallelTopologyConfiguration; 133 : } 134 : 135 : /** 136 : * @return _timeIntegrationConfiguration 137 : */ 138 : const coupling::configurations::TimeIntegrationConfiguration& getTimeIntegrationConfiguration() const { 139 : // is optional, thus always defined 140 : return _timeIntegrationConfiguration; 141 : } 142 : 143 : /** 144 : * @return _thermostatConfiguration 145 : */ 146 : const coupling::configurations::ThermostatConfiguration& getThermostatConfiguration() const { 147 : if (!_isDefinedThermostat) { 148 : std::cout << "ERROR coupling::configurations::MaMiCoConfiguration: " 149 : "Thermostat not defined!" 150 : << std::endl; 151 : exit(EXIT_FAILURE); 152 : } 153 : return _thermostatConfiguration; 154 : } 155 : 156 : private: 157 : bool _isValid; 158 : coupling::configurations::CouplingCellConfiguration<dim> _couplingCellConfiguration; 159 : coupling::configurations::ParticleInsertionConfiguration _particleInsertionConfiguration; 160 : coupling::configurations::MomentumInsertionConfiguration _momentumInsertionConfiguration; 161 : coupling::configurations::BoundaryForceConfiguration<dim> _boundaryForceConfiguration; 162 : coupling::configurations::TransferStrategyConfiguration<dim> _transferStrategyConfiguration; 163 : coupling::configurations::ParallelTopologyConfiguration _parallelTopologyConfiguration; 164 : coupling::configurations::TimeIntegrationConfiguration _timeIntegrationConfiguration; 165 : coupling::configurations::ThermostatConfiguration _thermostatConfiguration; 166 : bool _isDefinedParticleInsertion; 167 : bool _isDefinedMomentumInsertion; 168 : bool _isDefinedBoundaryForce; 169 : bool _isDefinedTransferStrategy; 170 : bool _isDefinedParallelTopology; 171 : bool _isDefinedThermostat; 172 : }; 173 : #include "coupling/configurations/MaMiCoConfiguration.cpph" 174 : 175 : #endif // _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_MAMICOCONFIGURATION_H_