LCOV - code coverage report
Current view: top level - coupling/configurations - ParticleInsertionConfiguration.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 71 14.1 %
Date: 2025-06-25 11:26:37 Functions: 3 3 100.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             : #include "coupling/configurations/ParticleInsertionConfiguration.h"
       6             : 
       7             : const std::string coupling::configurations::ParticleInsertionConfiguration::INSERT_DELETE_MASS_EVERY_TIMESTEP("insert-every-timestep");
       8             : const std::string coupling::configurations::ParticleInsertionConfiguration::RSIGMA_COEFF("r_sigma");
       9             : const std::string coupling::configurations::ParticleInsertionConfiguration::MEAN_POTENTIAL_ENERGY_FACTOR("u_0-factor");
      10             : const std::string coupling::configurations::ParticleInsertionConfiguration::UOVERLAP_COEFF("u_ovlp");
      11             : const std::string coupling::configurations::ParticleInsertionConfiguration::STEPREF_COEFF("reference-stepsize");
      12             : const std::string coupling::configurations::ParticleInsertionConfiguration::ITER_MAX("maximum-number-of-iterations");
      13             : const std::string coupling::configurations::ParticleInsertionConfiguration::RESTART_MAX("maximum-number-of-restarts");
      14             : const std::string coupling::configurations::ParticleInsertionConfiguration::TOLERANCE("tolerance");
      15             : const std::string coupling::configurations::ParticleInsertionConfiguration::OFFSET_FROM_OUTER_BOUNDARY("offset-from-outer-boundary");
      16             : 
      17           4 : void coupling::configurations::ParticleInsertionConfiguration::parseSubtag(tinyxml2::XMLElement* node) {
      18           4 :   int buf = -1;
      19             : 
      20             :   // specify the type of insertion
      21           4 :   std::string thisType;
      22           4 :   tarch::configuration::ParseConfiguration::readStringMandatory(thisType, node, "type");
      23             :   // in this case, no insertion should be carried out, no more parameters need to be parsed -> thus: return
      24           4 :   if (thisType == "none") {
      25           4 :     _particleInsertionType = NO_INSERTION;
      26           4 :     return;
      27           0 :   } else if (thisType == "usher") {
      28           0 :     _particleInsertionType = USHER;
      29             :   } else {
      30           0 :     std::cout << "ERROR "
      31             :                  "coupling::configurations::ParticleInsertionConfiguration::"
      32           0 :                  "parseSubtag(): 'type' not specified!"
      33           0 :               << std::endl;
      34           0 :     exit(EXIT_FAILURE);
      35             :   }
      36             : 
      37           0 :   buf = 1;
      38           0 :   tarch::configuration::ParseConfiguration::readIntOptional(buf, node, INSERT_DELETE_MASS_EVERY_TIMESTEP);
      39           0 :   if (buf <= 0) {
      40           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::";
      41           0 :     std::cout << "parseSubtag(): " << INSERT_DELETE_MASS_EVERY_TIMESTEP << " smaller than or equal zero!" << std::endl;
      42           0 :     exit(EXIT_FAILURE);
      43             :   } else {
      44           0 :     _insertDeleteMassEveryTimestep = (unsigned int)buf;
      45             :   }
      46             : 
      47           0 :   _rSigmaCoeff = 0.9;
      48           0 :   tarch::configuration::ParseConfiguration::readDoubleOptional(_rSigmaCoeff, node, RSIGMA_COEFF);
      49           0 :   if (_rSigmaCoeff <= 0.0) {
      50           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::";
      51           0 :     std::cout << "parseSubtag(): " << RSIGMA_COEFF << " smaller than or equal zero!" << std::endl;
      52           0 :     exit(EXIT_FAILURE);
      53             :   }
      54             : 
      55           0 :   _meanPotentialEnergyFactor = 1.0;
      56           0 :   tarch::configuration::ParseConfiguration::readDoubleOptional(_meanPotentialEnergyFactor, node, MEAN_POTENTIAL_ENERGY_FACTOR);
      57           0 :   if (_meanPotentialEnergyFactor <= 0.0) {
      58           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::";
      59           0 :     std::cout << "parseSubtag(): " << MEAN_POTENTIAL_ENERGY_FACTOR << " smaller than or equal zero!" << std::endl;
      60           0 :     exit(EXIT_FAILURE);
      61             :   }
      62             : 
      63             :   // default setting of last commit
      64           0 :   _tolerance = _meanPotentialEnergyFactor * 2.0;
      65           0 :   tarch::configuration::ParseConfiguration::readDoubleOptional(_tolerance, node, TOLERANCE);
      66           0 :   if (_tolerance <= 0.0) {
      67           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::parseSubtag(): " << TOLERANCE << " is smaller than or equal zero!"
      68           0 :               << std::endl;
      69           0 :     exit(EXIT_FAILURE);
      70             :   }
      71             : 
      72           0 :   _uOverlapCoeff = 10000.0;
      73           0 :   tarch::configuration::ParseConfiguration::readDoubleOptional(_uOverlapCoeff, node, UOVERLAP_COEFF);
      74           0 :   if (_uOverlapCoeff <= 0.0) {
      75           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::";
      76           0 :     std::cout << "parseSubtag(): " << UOVERLAP_COEFF << " smaller than or equal zero!" << std::endl;
      77           0 :     exit(EXIT_FAILURE);
      78             :   }
      79             : 
      80             :   // if not defined, choose optimal ref. step strategy (see usher-paper)
      81           0 :   _stepRefCoeff = -1.0;
      82           0 :   tarch::configuration::ParseConfiguration::readDoubleOptional(_stepRefCoeff, node, STEPREF_COEFF);
      83           0 :   if ((_stepRefCoeff != -1.0) && (_stepRefCoeff <= 0.0)) {
      84           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::";
      85           0 :     std::cout << "parseSubtag(): " << STEPREF_COEFF << " smaller than or equal zero!" << std::endl;
      86           0 :     exit(EXIT_FAILURE);
      87             :   }
      88             : 
      89             :   // if not defined, set offset for particle insertions from outer boundary to
      90             :   // 0.0; may yield instabilities for dense fluids
      91           0 :   _offsetFromOuterBoundary = 0.0;
      92           0 :   tarch::configuration::ParseConfiguration::readDoubleOptional(_offsetFromOuterBoundary, node, OFFSET_FROM_OUTER_BOUNDARY);
      93           0 :   if (_offsetFromOuterBoundary < 0.0) {
      94           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::";
      95           0 :     std::cout << "parseSubtag(): " << OFFSET_FROM_OUTER_BOUNDARY << " smaller than zero!" << std::endl;
      96           0 :     exit(EXIT_FAILURE);
      97             :   }
      98             : 
      99           0 :   tarch::configuration::ParseConfiguration::readIntMandatory(buf, node, ITER_MAX);
     100           0 :   if (buf <= 0) {
     101           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::";
     102           0 :     std::cout << "parseSubtag(): " << ITER_MAX << " smaller than or equal zero!" << std::endl;
     103           0 :     exit(EXIT_FAILURE);
     104             :   } else {
     105           0 :     _iterMax = (unsigned int)buf;
     106             :   }
     107             : 
     108           0 :   tarch::configuration::ParseConfiguration::readIntMandatory(buf, node, RESTART_MAX);
     109           0 :   if (buf <= 0) {
     110           0 :     std::cout << "ERROR coupling::configurations::ParticleInsertionConfiguration::";
     111           0 :     std::cout << "parseSubtag(): " << RESTART_MAX << " smaller or equal zero!" << std::endl;
     112           0 :     exit(EXIT_FAILURE);
     113             :   } else {
     114           0 :     _restartMax = (unsigned int)buf;
     115             :   }
     116           4 : }
     117             : 
     118          24 : std::string coupling::configurations::ParticleInsertionConfiguration::getTag() const { return "particle-insertion"; }
     119             : 
     120           4 : bool coupling::configurations::ParticleInsertionConfiguration::isValid() const { return true; }

Generated by: LCOV version 1.14