LCOV - code coverage report
Current view: top level - coupling/filtering/filters - ReadFromFile.cpph (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 28 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 project. For conditions of distribution
       2              : // and use, please see the copyright notice in Mamico's main folder, or at
       3              : // www5.in.tum.de/mamico
       4              : 
       5              : /** Implementation of ReadFromFile.h
       6              :  *  @author Felix Maurer
       7              :  */
       8              : 
       9              : // Member functions of ReadFromFile.h:
      10            0 : template <unsigned int dim> void coupling::filtering::ReadFromFile<dim>::operator()() {
      11              : #ifdef DEBUG_READ_FROM_FILE
      12              :   std::cout << "             RFF: Now reading input data from: " << _location;
      13              : #endif
      14              : 
      15            0 :   _file.open(_location);
      16              : 
      17              :   // Skip all lines of previous iterations
      18            0 :   std::string skipstr;
      19            0 :   for (unsigned int s = 0; s < _iteration * ((coupling::filtering::FilterInterface<dim>::_inputCells.size()) + 1); s++)
      20            0 :     std::getline(_file, skipstr);
      21              : 
      22              :   // TODO: check if number of lines match number of cells
      23              : 
      24            0 :   for (unsigned int ic_index = 0; ic_index < coupling::filtering::FilterInterface<dim>::_inputCells.size(); ic_index++) {
      25              :     // get next input line
      26            0 :     std::string linestr;
      27            0 :     std::getline(_file, linestr);
      28            0 :     std::istringstream lineiss(linestr);
      29              : 
      30              :     // store all values from line
      31            0 :     std::vector<double> doublesFromLine;
      32              : 
      33              :     // interpret substrings as doubles
      34            0 :     std::string d;
      35            0 :     while (std::getline(lineiss, d, ';')) {
      36            0 :       if (d != " ") { // ignore what comes after last ';'
      37            0 :         doublesFromLine.push_back(std::stod(d));
      38              : 
      39              : #ifdef DEBUG_READ_FROM_FILE
      40              :         if (ic_index == 0)
      41              :           std::cout << "             RFF: New double read for cell 0: " << doublesFromLine.back() << std::endl;
      42              : #endif
      43              :       }
      44              :     }
      45              : 
      46              :     // TODO: check if number of doubles match dim*_vectorSetters.size() +
      47              :     // _scalarSetters.size()
      48              : 
      49              :     // iteration, indexes. Adjust this if write-to-file's output changes!
      50            0 :     const unsigned int const_offset = 1;
      51              : 
      52              :     // increases for each double read from line
      53            0 :     unsigned int incr_offset = 0;
      54              : 
      55              :     // Apply scalar setters
      56            0 :     for (const auto scalarProperty : coupling::filtering::FilterInterface<dim>::_scalarAccessFunctionPairs) {
      57            0 :       (coupling::filtering::FilterInterface<dim>::_outputCells[ic_index]->*scalarProperty.set)(doublesFromLine[const_offset + incr_offset]);
      58              : 
      59              : #ifdef DEBUG_READ_FROM_FILE
      60              :       if (ic_index == 0)
      61              :         std::cout << "               RFF: Scalar sent to cell 0: " << doublesFromLine[0 /*const_offset + incr_offset*/] << std::endl;
      62              : #endif
      63              : 
      64            0 :       incr_offset++;
      65              :     }
      66              :     // Apply vector setters
      67            0 :     for (const auto vectorProperty : coupling::filtering::FilterInterface<dim>::_vectorAccessFunctionPairs) {
      68            0 :       tarch::la::Vector<dim, double> tempVec;
      69            0 :       for (unsigned int d = 0; d < dim; d++) {
      70            0 :         tempVec[d] = doublesFromLine[const_offset + incr_offset + d];
      71              :       }
      72              : 
      73              : #ifdef DEBUG_READ_FROM_FILE
      74              :       if (ic_index == 0)
      75              :         std::cout << "               RFF: Vector sent to cell 0: " << tempVec << std::endl;
      76              : #endif
      77              : 
      78            0 :       (coupling::filtering::FilterInterface<dim>::_outputCells[ic_index]->*vectorProperty.set)(tempVec);
      79            0 :       incr_offset += dim;
      80              :     }
      81              :   }
      82              : 
      83            0 :   _file.close();
      84            0 :   _iteration++;
      85              : 
      86              : #ifdef DEBUG_READ_FROM_FILE
      87              :   std::cout << " ... done" << std::endl;
      88              : #endif
      89            0 : }
        

Generated by: LCOV version 2.0-1