LCOV - code coverage report
Current view: top level - coupling/filtering - FilterPipeline.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 4 0.0 %
Date: 2025-06-25 11:26:37 Functions: 0 1 0.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             : #pragma once
       6             : 
       7             : // #define DEBUG_FILTER_PIPELINE
       8             : #define POST_MULTI_INSTANCE_FILTERING_YES true
       9             : #define POST_MULTI_INSTANCE_FILTERING_NO false
      10             : 
      11             : // include dependencies
      12             : #include "coupling/filtering/sequencing/AsymmetricalFilterJunction.h"
      13             : #include "coupling/filtering/sequencing/FilterJunction.h"
      14             : #include "coupling/filtering/sequencing/FilterSequence.h"
      15             : #include "tarch/configuration/ParseConfiguration.h"
      16             : #include "tarch/tinyxml2/tinyxml2.h"
      17             : 
      18             : using tarch::configuration::ParseConfiguration;
      19             : 
      20             : namespace coupling {
      21             : namespace filtering {
      22             : template <class CellIndex_T, unsigned int dim> class FilterPipeline;
      23             : 
      24             : /*
      25             :  * Used as member of FilterPipeline. Displays where that FP is used.
      26             :  * per instance:                apply filtering for each MD instance
      27             :  * individually, before merging instances post multi instance:  apply filtering
      28             :  * after MD instances have been merged
      29             :  */
      30             : enum class Scope { perInstance, postMultiInstance };
      31             : } // namespace filtering
      32             : } // namespace coupling
      33             : 
      34             : /*
      35             :  * Manages different branches of filtering sequences.
      36             :  * These filtering sequences may be interdependant by using another's sequences
      37             :  * input or completely isolated. As this entire filtering process is applied
      38             :  * during MD to Macro communication, it uses the MD simulation's output
      39             :  * Macro-Cells as input and output. All configuration is made using an
      40             :  * XML-config file and does not require recompilation when modified.
      41             :  *
      42             :  * @author Felix Maurer
      43             :  */
      44             : template <class CellIndex_T, unsigned int dim> class coupling::filtering::FilterPipeline {
      45             : public:
      46             :   FilterPipeline(const coupling::datastructures::CellContainer<CellIndex_T, dim> inputCells, const coupling::filtering::Scope scope,
      47             :                  const tarch::utils::MultiMDService<dim>& multiMDService, const char* cfgpath);
      48             : 
      49           0 :   ~FilterPipeline() {
      50           0 :     for (auto sequence : _sequences)
      51           0 :       delete sequence;
      52             :       // TODO: do i have to delete the _...cells as well?
      53             : 
      54             : #ifdef DEBUG_FILTER_PIPELINE
      55             :     std::cout << "FP: FilterPipeline deconstructed." << std::endl;
      56             : #endif
      57           0 :   }
      58             : 
      59             :   /*
      60             :    * Applies each FilterSequence in order of their appearance in the config
      61             :    * file. Ouput of the specified output-FilterSequence will be written to
      62             :    * _md2MacroCells.
      63             :    *
      64             :    * @returns The runtime of the filter pipeline in usec.
      65             :    */
      66             :   double operator()();
      67             : 
      68             :   /*
      69             :    * Getters for FilterSequences.
      70             :    * Not that Junction is a subtype of Sequence, so this is how to get Junctions
      71             :    * as well.
      72             :    */
      73             :   coupling::filtering::FilterSequence<dim>* getSequence(const char* identifier) const;
      74             :   std::vector<coupling::filtering::FilterSequence<dim>*> getAllSequences() const { return _sequences; }
      75             : 
      76             : #if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
      77             :   /*
      78             :    * Get MPI communicator used by all parallel filters.
      79             :    */
      80             :   MPI_Comm getFilteringCommunicator() { return _comm; };
      81             : #endif
      82             : 
      83             : private:
      84             :   /*
      85             :    * Detects errors in XML config file.
      86             :    */
      87             :   bool configIsValid(ParseConfiguration::XMLConfiguration& xmlConfig);
      88             : 
      89             :   /*
      90             :    * Interprets configuration of sequences and intializes them. Parameters
      91             :    * known:
      92             :    *   -"input": Name of another FilterSequence previously defined (optional,
      93             :    * uses MD output (i.e. _md2MacroCells) by default)
      94             :    *
      95             :    * Also detects which sequence will be used as output to this FilterPipeline.
      96             :    */
      97             :   void loadSequencesFromXML(tinyxml2::XMLElement* metaNode);
      98             : 
      99             :   /*
     100             :    * Input cells within the local, md2macro, ghost layer excluding domain
     101             :    */
     102             :   std::vector<coupling::datastructures::CouplingCell<dim>*> _md2MacroCells;
     103             :   /*
     104             :    * Input cells that do not match the criteria to be in _md2MacroCells.
     105             :    */
     106             :   std::vector<coupling::datastructures::CouplingCell<dim>*> _outerCells;
     107             : 
     108             :   ParseConfiguration::XMLConfiguration _config;
     109             : 
     110             :   /*
     111             :    * Scope in which this FilterPipeline is applied. Cf. coupling::Scope
     112             :    * definition.
     113             :    */
     114             :   const coupling::filtering::Scope _scope;
     115             : 
     116             :   std::vector<coupling::filtering::FilterSequence<dim>*> _sequences;
     117             : 
     118             : #if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
     119             :   MPI_Comm _comm;
     120             : #endif
     121             : };
     122             : 
     123             : // include implementation of header
     124             : #include "FilterPipeline.cpph"

Generated by: LCOV version 1.14