LCOV - code coverage report
Current view: top level - coupling/configurations - ParallelTopologyConfiguration.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 16 68.8 %
Date: 2025-06-25 11:26:37 Functions: 1 5 20.0 %

          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_PARALLELTOPOLOGYCONFIGURATION_H_
       6             : #define _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_PARALLELTOPOLOGYCONFIGURATION_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 ParallelTopologyConfiguration;
      17             : }
      18             : } // namespace coupling
      19             : 
      20             : /** reads parallel topology configuration. XYZ and ZYX are supported.. Derive
      21             :  *from the class tarch::configuration::Configuration
      22             :  *      @brief reads parallel topology configuration. XYZ and ZYX are supported.
      23             :  *  @author Philipp Neumann
      24             :  */
      25             : class coupling::configurations::ParallelTopologyConfiguration : public tarch::configuration::Configuration {
      26             : public:
      27             :   /** Constructor, initializes the class  */
      28         336 :   ParallelTopologyConfiguration() : _type(coupling::paralleltopology::UNDEFINED), _isValid(true) {}
      29             : 
      30             :   /** Destructor */
      31         340 :   virtual ~ParallelTopologyConfiguration() {}
      32             : 
      33           4 :   void parseSubtag(tinyxml2::XMLElement* node) {
      34           4 :     std::string value;
      35           4 :     tarch::configuration::ParseConfiguration::readStringMandatory(value, node, "type");
      36           4 :     if (value == "xyz") {
      37           4 :       _type = coupling::paralleltopology::XYZ;
      38           0 :     } else if (value == "zyx") {
      39           0 :       _type = coupling::paralleltopology::ZYX;
      40             :     } else {
      41           0 :       std::cout << "ERROR coupling::ParallelTopologyConfiguration: Wrong type!" << std::endl;
      42           0 :       _isValid = false;
      43           0 :       exit(EXIT_FAILURE);
      44             :     }
      45           4 :   }
      46             : 
      47             :   /** Returns name of xml tag that is associated to the configuration.
      48             :    *    @return name of xml tag that is associated to the configuration
      49             :    */
      50          12 :   std::string getTag() const { return "parallel-topology"; }
      51             : 
      52             :   /** checks if the configuration is valid. This operation usually fails, if
      53             :    *e.g.
      54             :    *    1. parseSubtag() hasn't been called, i.e. configuration has not been
      55             :    *used, or
      56             :    *  2. parseSubtag() failed due to a wrong file.
      57             :    *    @return _isValid
      58             :    */
      59           4 :   bool isValid() const { return _isValid; }
      60             : 
      61             :   /** Returns the parallel topology type.
      62             :    *    @return _type
      63             :    */
      64             :   coupling::paralleltopology::ParallelTopologyType getParallelTopologyType() const { return _type; }
      65             : 
      66             : protected:
      67           4 :   ParallelTopologyConfiguration(coupling::paralleltopology::ParallelTopologyType type) : _type(type), _isValid(true) {}
      68             : 
      69             : private:
      70             :   coupling::paralleltopology::ParallelTopologyType _type;
      71             : 
      72             :   bool _isValid;
      73             : };
      74             : 
      75             : #endif // _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_PARALLELTOPOLOGYCONFIGURATION_H_

Generated by: LCOV version 1.14