LCOV - code coverage report
Current view: top level - coupling/filtering/filters - Constant.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 15 0
Test Date: 2026-08-21 15:14:06 Functions: 0.0 % 2 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
       3              : 
       4              : #pragma once
       5              : #include "coupling/filtering/interfaces/FilterInterface.h"
       6              : #include <algorithm>
       7              : #include <vector>
       8              : 
       9              : namespace coupling {
      10              : namespace filtering {
      11              : template <unsigned int dim> class Constant;
      12              : }
      13              : } // namespace coupling
      14              : 
      15              : /**
      16              :  * Filter applying a constant floating point value to all cells for all filtered
      17              :  * values. Optionally, one can specify to apply this filter only to certain
      18              :  * directions of multidimensional cell properties.
      19              :  *
      20              :  * @author Felix Maurer
      21              :  */
      22              : 
      23              : template <unsigned int dim> class coupling::filtering::Constant : public coupling::filtering::FilterInterface<dim> {
      24              : public:
      25            0 :   Constant(const std::vector<coupling::datastructures::CouplingCell<dim>*>& inputCellVector,
      26              :            const std::vector<coupling::datastructures::CouplingCell<dim>*>& outputCellVector, const std::array<bool, 7> filteredValues,
      27              :            const tarch::la::Vector<dim, bool> filteredDims, const double constant)
      28            0 :       : coupling::filtering::FilterInterface<dim>(inputCellVector, outputCellVector, filteredValues, "Constant"), _constant(constant),
      29            0 :         _filteredDims(filteredDims) {}
      30              : 
      31            0 :   void operator()() {
      32            0 :     tarch::la::Vector<dim, double> vec_buf;
      33            0 :     for (unsigned int i = 0; i < this->_inputCells.size(); ++i) {
      34              :       // apply to scalars
      35            0 :       for (auto scalarProperty : FilterInterface<dim>::_scalarAccessFunctionPairs) {
      36            0 :         (FilterInterface<dim>::_outputCells[i]->*scalarProperty.set)(_constant);
      37              :       }
      38              : 
      39              :       // apply to vectors
      40            0 :       for (auto vectorProperty : FilterInterface<dim>::_vectorAccessFunctionPairs) {
      41              :         // TODO: perhaps check if _filteredDims == true,..,true before this for
      42              :         // performance reasons?
      43            0 :         vec_buf = (FilterInterface<dim>::_inputCells[i]->*vectorProperty.get)();
      44              : 
      45            0 :         for (unsigned int d = 0; d < dim; d++) {
      46            0 :           if (_filteredDims[d])
      47            0 :             vec_buf[d] = _constant;
      48              :         }
      49              : 
      50            0 :         (FilterInterface<dim>::_outputCells[i]->*vectorProperty.set)(vec_buf);
      51              :       }
      52              :     }
      53            0 :   }
      54              : 
      55              : private:
      56              :   const double _constant;
      57              :   const tarch::la::Vector<dim, bool> _filteredDims;
      58              : };
        

Generated by: LCOV version 2.0-1