MaMiCo 1.2
Loading...
Searching...
No Matches
FilterInterfaceReadOnly.h
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#include "FilterInterface.h"
7
8namespace coupling {
9namespace filtering {
10template <unsigned int dim> class FilterInterfaceReadOnly;
11}
12} // namespace coupling
13
14/*
15 * Extension of FilterInterface.h for cases in which the filter itself does not
16 * produce any output data. For such filters, you want to make use of
17 * copyInputToOutput() (see below) in every filter step.
18 *
19 * @author Felix Maurer
20 */
21
23public:
24 FilterInterfaceReadOnly(const std::vector<coupling::datastructures::CouplingCell<dim>*>& inputCellVector,
25 const std::vector<coupling::datastructures::CouplingCell<dim>*>& outputCellVector, const std::array<bool, 7> filteredValues,
26 const char* type)
27 : coupling::filtering::FilterInterface<dim>(inputCellVector, outputCellVector, filteredValues, type) {}
28
29protected:
30 /*
31 * Copies all filtered data from input to output. You always want to call this
32 * as part of any implementation of coupling::FilterInterface<dim>::operator()
33 * when implementing this interface, that is implementing a read-only
34 * filter (e.g WriteToFile, Storuhal) If you would not do that, the successors
35 * of the implementing filter in a sequence would get faulty input data.
36 */
37 void copyInputToOutput() {
38 /*
39 * In certain cases, e.g. read-only filters that operate on secondary cells
40 * of an AsymmetricalFilterJunction, we don't want the filter to produce any
41 * output. Then, and only then, the output cells vector will be empty.
42 */
43 if (coupling::filtering::FilterInterface<dim>::_outputCells.empty())
44 return;
45
46 for (unsigned int ci = 0; ci < coupling::filtering::FilterInterface<dim>::_outputCells.size(); ci++) {
47 for (const auto scalarProperty : coupling::filtering::FilterInterface<dim>::_scalarAccessFunctionPairs) {
48 (coupling::filtering::FilterInterface<dim>::_outputCells[ci]->*scalarProperty.set)(
49 (coupling::filtering::FilterInterface<dim>::_inputCells[ci]->*scalarProperty.get)()); // call setter from output cell
50 // using getter from input cell.
51 }
52 for (const auto vectorProperty : coupling::filtering::FilterInterface<dim>::_vectorAccessFunctionPairs) {
53 (coupling::filtering::FilterInterface<dim>::_outputCells[ci]->*vectorProperty.set)(
54 (coupling::filtering::FilterInterface<dim>::_inputCells[ci]->*vectorProperty.get)()); // call setter from output cell
55 // using getter from input cell.
56 }
57 }
58 }
59};
defines the cell type with cell-averaged quantities only (no linked cells).
Definition CouplingCell.h:29
Definition FilterInterfaceReadOnly.h:22
Definition FilterInterface.h:32
std::vector< coupling::datastructures::CouplingCell< dim > * > _inputCells
Definition FilterInterface.h:181
Definition FilterPipeline.h:21
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15