LCOV - code coverage report
Current view: top level - coupling/configurations - ThermostatConfiguration.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 50.0 % 26 13
Test Date: 2026-08-21 15:14:06 Functions: 25.0 % 4 1

            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_CONFIGURATIONS_THERMOSTATCONFIGURATION_H_
       6              : #define _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_THERMOSTATCONFIGURATION_H_
       7              : 
       8              : #include "coupling/paralleltopology/ParallelTopologyFactory.h"
       9              : #include "tarch/configuration/Configuration.h"
      10              : #include "tarch/configuration/ParseConfiguration.h"
      11              : #include "tarch/la/Vector.h"
      12              : #include <iostream>
      13              : 
      14              : namespace coupling {
      15              : namespace configurations {
      16              : class ThermostatConfiguration;
      17              : }
      18              : } // namespace coupling
      19              : 
      20              : /** reads the configuartion for the domain of the thermostat.
      21              :  *  @author Helene Wittenberg
      22              :  */
      23              : class coupling::configurations::ThermostatConfiguration : public tarch::configuration::Configuration {
      24              : public:
      25              :   enum ThermostatRegion { onlyOutestLayer, outerLayers, all, nowhere, none };
      26              :   ThermostatConfiguration() : _type{none}, _isValid(true) {}
      27              : 
      28          412 :   virtual ~ThermostatConfiguration() {}
      29              : 
      30            4 :   void parseSubtag(tinyxml2::XMLElement* node) {
      31            4 :     std::string value;
      32            4 :     tarch::configuration::ParseConfiguration::readStringMandatory(value, node, "type");
      33            4 :     if (value == "onlyOutestLayer") {
      34            0 :       _type = onlyOutestLayer;
      35            4 :     } else if (value == "outerLayers") {
      36            4 :       _type = outerLayers;
      37            4 :       tarch::configuration::ParseConfiguration::readIntMandatory(_cells, node, "number-layers");
      38            4 :       if (_cells < 0) {
      39            0 :         std::cout << "ERROR coupling::ThermostatConfiguration: Wrong number of cells to use!" << std::endl;
      40            0 :         _isValid = false;
      41            0 :         exit(EXIT_FAILURE);
      42              :       }
      43            0 :     } else if (value == "all") {
      44            0 :       _type = all;
      45            0 :     } else if (value == "nowhere") {
      46            0 :       _type = nowhere;
      47              :     } else {
      48            0 :       std::cout << "ERROR coupling::ThermostatConfiguration: Wrong type!" << std::endl;
      49            0 :       _isValid = false;
      50            0 :       exit(EXIT_FAILURE);
      51              :     }
      52            4 :   }
      53              : 
      54              :   /**
      55              :    * Return name of xml tag that is associated to the configuration.
      56              :    */
      57            4 :   std::string getTag() const { return "thermostat"; }
      58              : 
      59              :   /**
      60              :    * Is config valid?
      61              :    *
      62              :    * This operation usually fails, if
      63              :    *
      64              :    * - parseSubtag() hasn't been called, i.e. configuration has not been
      65              :    *   used, or
      66              :    * - parseSubtag() failed due to a wrong file.
      67              :    *
      68              :    * If a tag ain't optional and parseSubtag() was not called (first case)
      69              :    */
      70            0 :   bool isValid() const { return _isValid; }
      71              : 
      72            4 :   ThermostatRegion getThermostatRegionType() const { return _type; }
      73              : 
      74            0 :   unsigned int getCells2Use() const { return _cells; }
      75              : 
      76              : protected:
      77            4 :   ThermostatConfiguration(ThermostatRegion type) : _type{type}, _isValid(true) {}
      78              : 
      79              : private:
      80              :   ThermostatRegion _type;
      81              :   int _cells{0};
      82              :   bool _isValid;
      83              : };
      84              : 
      85              : #endif // _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_THERMOSTATCONFIGURATION_H_
        

Generated by: LCOV version 2.0-1