LCOV - code coverage report
Current view: top level - coupling/configurations - TimeIntegrationConfiguration.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 35 11.4 %
Date: 2025-06-25 11:26:37 Functions: 0 5 0.0 %

          Line data    Source code
       1             : // Copyright (C) 2023 Helmut Schmidt University
       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             : 
       5             : #pragma once
       6             : 
       7             : #include "tarch/configuration/Configuration.h"
       8             : #include "tarch/configuration/ParseConfiguration.h"
       9             : #include <iostream>
      10             : 
      11             : namespace coupling {
      12             : namespace configurations {
      13             : class TimeIntegrationConfiguration;
      14             : }
      15             : } // namespace coupling
      16             : 
      17             : /**
      18             :  *  Reads time integration configuration. Use number-subdomains="1" to disable PinT.
      19             :  *  Derived from tarch::configuration::Configuration
      20             :  *      @brief reads time integration configuration
      21             :  *  @author Piet Jarmatz
      22             :  */
      23             : class coupling::configurations::TimeIntegrationConfiguration : public tarch::configuration::Configuration {
      24             : public:
      25             :   /** Constructor, initializes the class  */
      26         672 :   TimeIntegrationConfiguration() : _pint_domains(1), _pint_iterations(1), _auto_iteration(false), _visc_multiplier(1), _isValid(true) {}
      27             : 
      28             :   /** Destructor */
      29         336 :   virtual ~TimeIntegrationConfiguration() {}
      30             : 
      31           0 :   void parseSubtag(tinyxml2::XMLElement* node) {
      32           0 :     int buf;
      33           0 :     tarch::configuration::ParseConfiguration::readIntMandatory(buf, node, "number-subdomains");
      34           0 :     if (buf <= 0) {
      35           0 :       std::cout << "ERROR coupling::TimeIntegrationConfiguration: "
      36           0 :                    "number-subdomains = "
      37           0 :                 << buf << "!" << std::endl;
      38           0 :       _isValid = false;
      39           0 :       exit(EXIT_FAILURE);
      40             :     }
      41           0 :     _pint_domains = buf;
      42             : 
      43           0 :     if (isPintEnabled()) {
      44             : #if (COUPLING_MD_PARALLEL != COUPLING_MD_YES)
      45             :       std::cout << "ERROR coupling::TimeIntegrationConfiguration: PinT is enabled but COUPLING_MD_PARALLEL disabled" << std::endl;
      46             :       std::cout << "Disable PinT in XML config, or enable BUILD_WITH_MPI in cmake." << std::endl;
      47             :       _isValid = false;
      48             :       exit(EXIT_FAILURE);
      49             : #endif
      50             : 
      51           0 :       std::string value;
      52           0 :       tarch::configuration::ParseConfiguration::readStringMandatory(value, node, "number-iterations");
      53           0 :       if (value == "auto") {
      54           0 :         _auto_iteration = true;
      55           0 :         _pint_iterations = 0;
      56             :       } else {
      57           0 :         _auto_iteration = false;
      58           0 :         tarch::configuration::ParseConfiguration::readIntMandatory(buf, node, "number-iterations");
      59           0 :         if (buf <= 0) {
      60           0 :           std::cout << "ERROR TimeIntegrationConfiguration::number-iterations too small!" << std::endl;
      61           0 :           _isValid = false;
      62           0 :           exit(EXIT_FAILURE);
      63             :         }
      64           0 :         if (buf > _pint_domains) {
      65           0 :           std::cout << "ERROR TimeIntegrationConfiguration::number-iterations too large!" << std::endl;
      66           0 :           _isValid = false;
      67           0 :           exit(EXIT_FAILURE);
      68             :         }
      69           0 :         _pint_iterations = buf;
      70             :       }
      71             : 
      72           0 :       tarch::configuration::ParseConfiguration::readDoubleOptional(_visc_multiplier, node, "visc-multiplier");
      73           0 :     }
      74           0 :   }
      75             : 
      76             :   /** Returns name of xml tag that is associated to the configuration.
      77             :    *    @return name of xml tag that is associated to the configuration
      78             :    */
      79           4 :   std::string getTag() const { return "time-integration"; }
      80             : 
      81             :   /** checks if the configuration is valid.
      82             :    *    @return _isValid
      83             :    */
      84           4 :   bool isValid() const { return _isValid; }
      85             : 
      86             :   int getPintDomains() const { return _pint_domains; }
      87           0 :   bool isPintEnabled() const { return _pint_domains > 1; }
      88             :   int getPintIterations() const { return _pint_iterations; }
      89             :   bool isAutoIteration() const { return _auto_iteration; }
      90             :   double getViscMultiplier() const { return _visc_multiplier; }
      91             : 
      92             : private:
      93             :   int _pint_domains;
      94             :   int _pint_iterations;
      95             :   bool _auto_iteration;
      96             :   double _visc_multiplier;
      97             : 
      98             :   bool _isValid;
      99             : };

Generated by: LCOV version 1.14