LCOV - code coverage report
Current view: top level - coupling/filtering/sequencing - AsymmetricalFilterJunction.cpph (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 39 0
Test Date: 2026-08-21 15:14:06 Functions: 0.0 % 1 0

            Line data    Source code
       1              : // This file is part of the Mamico proJunctionn conditions of distribution
       2              : // and use, please see the copyright notice in Mamico's main folder, or at
       3              : // www5.in.tum.de/mamic::o
       4              : 
       5              : // Member functions of coupling::filtering::AsymmetricalFilterJunction
       6              : 
       7              : template <unsigned int dim>
       8            0 : int coupling::filtering::AsymmetricalFilterJunction<dim>::loadFiltersFromXML(
       9              :     tinyxml2::XMLElement* sequenceNode) { // in our case "junctionNode" would be more precise
      10            0 :   if (!sequenceNode)
      11              :     return EXIT_FAILURE;
      12              : 
      13              :   // null if junction is empty
      14            0 :   tinyxml2::XMLElement* currJunctorNode = sequenceNode->FirstChildElement();
      15              : 
      16              :   // These four are not to be confused with member variables of similar names.
      17              :   // Watch out for the "_" in front of member variables.
      18            0 :   std::vector<coupling::datastructures::CouplingCell<dim>*> inputCellVector_primary = coupling::filtering::FilterSequence<dim>::_inputCellVector;
      19            0 :   std::vector<coupling::datastructures::CouplingCell<dim>*> outputCellVector_primary = coupling::filtering::FilterSequence<dim>::_cellVector2;
      20              : 
      21            0 :   std::vector<coupling::datastructures::CouplingCell<dim>*> inputCellVector_secondary = _inputCellVector_secondary;
      22              :   // Note: To prevent counter intuitive design, secondary output has been
      23              :   // disabled, i.e. all junctors in an AFJ take the same secondary input.
      24              :   // There
      25              :   // is a chance that this will be re-enabled in the future, if it is needed for
      26              :   // a certain junctor to work.
      27              :   // std::vector<coupling::datastructures::CouplingCell<dim>* >
      28              :   // outputCellVector_secondary = _cellVector2_secondary;
      29              : 
      30              : #ifdef DEBUG_FILTER_PIPELINE
      31              :   std::cout << PRINT_PREFIX() << "Initializing junctor objects of asymmetrical junction." << std::endl;
      32              : #endif
      33              : 
      34              :   // Keep track of this for each indivial input partition.
      35              :   bool firstIteration = {true};
      36              : 
      37            0 :   while (currJunctorNode) {
      38              : 
      39              :     // All Junctors must implement one of the {X,Y}-Junctor interfaces, each of
      40              :     // which implement FilterInterface.
      41            0 :     coupling::filtering::FilterInterface<dim>* newjunctor = nullptr;
      42              : 
      43              :     // ###############################################################
      44              :     //  This is where you have to define how to handle each junctor individually.
      45              : 
      46              :     // Write To File Junction
      47              :     // TODO: documentation about parametrization in .xml
      48            0 :     if (std::strcmp(currJunctorNode->Value(), "write-to-file-junction") == 0) {
      49              : 
      50              :       // Check "overwrite" property for both underlying WriteToFile instances.
      51            0 :       std::array<bool, 2> overwrite = {false};
      52            0 :       if (currJunctorNode->Attribute("wtf1-overwrite"))
      53            0 :         if (std::strcmp(currJunctorNode->Attribute("wtf1-overwrite"), "true") == 0)
      54            0 :           overwrite[0] = true;
      55            0 :       if (currJunctorNode->Attribute("wtf2-overwrite"))
      56            0 :         if (std::strcmp(currJunctorNode->Attribute("wtf2-overwrite"), "true") == 0)
      57            0 :           overwrite[1] = true;
      58              : 
      59              :       // Check "one-cell-only" property for both underlying WriteToFile
      60              :       // instances.
      61              :       // TODO: replace std::couts with proper exceptions
      62            0 :       std::array<int, 2> oco = {-1, -1};
      63            0 :       tarch::configuration::ParseConfiguration::readIntOptional(oco[0], currJunctorNode, "wtf1-one-cell-only");
      64            0 :       if (oco[0] < -1 || oco[0] >= (int)inputCellVector_primary.size()) {
      65            0 :         std::cout << "ERROR: XML config file references undefined cell index " << oco[0] << " for primary write-to-file in write-to-file-junctor." << std::endl;
      66            0 :         exit(EXIT_FAILURE);
      67              :       }
      68            0 :       tarch::configuration::ParseConfiguration::readIntOptional(oco[1], currJunctorNode, "wtf2-one-cell-only");
      69            0 :       if (oco[1] < -1 || oco[1] >= (int)inputCellVector_secondary.size()) {
      70            0 :         std::cout << "ERROR: XML config file references undefined cell index " << oco[1] << " for secondary write-to-file in write-to-file-junctor."
      71            0 :                   << std::endl;
      72            0 :         exit(EXIT_FAILURE);
      73              :       }
      74              : 
      75            0 :       newjunctor = new coupling::filtering::WriteToFileJunctor<dim>(
      76              :           inputCellVector_primary, outputCellVector_primary, inputCellVector_secondary, this->_filteredValues,
      77            0 :           {currJunctorNode->Attribute("wtf1-location"), currJunctorNode->Attribute("wtf2-location")}, overwrite, oco);
      78              :     }
      79              : 
      80              :     // ###############################################################
      81              : 
      82              :     // Unknown junctor identifier
      83              :     else {
      84              :       std::cout << "ERROR: Asymmetrical Filter-Junction does not recognize "
      85              :                    "junctor called "
      86            0 :                 << currJunctorNode->Value() << std::endl;
      87            0 :       return EXIT_FAILURE;
      88              :     }
      89              : 
      90            0 :     if (firstIteration) {
      91            0 :       inputCellVector_primary = coupling::filtering::FilterSequence<dim>::_cellVector1;
      92            0 :       inputCellVector_secondary = _cellVector1_secondary;
      93              :       firstIteration = false;
      94              :     }
      95              : 
      96            0 :     inputCellVector_primary.swap(outputCellVector_primary);
      97              : 
      98              :     // See comment above regarding secondary output of junctors.
      99              :     // inputCellVector_secondary.swap(outputCellVector_secondary);
     100              : 
     101            0 :     coupling::filtering::FilterSequence<dim>::_filters.push_back(newjunctor);
     102            0 :     currJunctorNode = currJunctorNode->NextSiblingElement();
     103              :   }
     104              : 
     105              : #ifdef DEBUG_FILTER_JUNCTION_ASYM
     106            0 :   std::cout << PRINT_PREFIX();
     107            0 :   this->printOutputCellVector();
     108              : #endif
     109              : 
     110              :   return 0;
     111            0 : }
        

Generated by: LCOV version 2.0-1