MaMiCo 1.2
Loading...
Searching...
No Matches
Constant.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
3
4#pragma once
5#include "coupling/filtering/interfaces/FilterInterface.h"
6#include <algorithm>
7#include <vector>
8
9namespace coupling {
10namespace filtering {
11template <unsigned int dim> class Constant;
12}
13} // namespace coupling
14
22
23template <unsigned int dim> class coupling::filtering::Constant : public coupling::filtering::FilterInterface<dim> {
24public:
25 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 : coupling::filtering::FilterInterface<dim>(inputCellVector, outputCellVector, filteredValues, "Constant"), _constant(constant),
29 _filteredDims(filteredDims) {}
30
31 void operator()() {
33 for (unsigned int i = 0; i < this->_inputCells.size(); ++i) {
34 // apply to scalars
35 for (auto scalarProperty : FilterInterface<dim>::_scalarAccessFunctionPairs) {
36 (FilterInterface<dim>::_outputCells[i]->*scalarProperty.set)(_constant);
37 }
38
39 // apply to vectors
40 for (auto vectorProperty : FilterInterface<dim>::_vectorAccessFunctionPairs) {
41 // TODO: perhaps check if _filteredDims == true,..,true before this for
42 // performance reasons?
43 vec_buf = (FilterInterface<dim>::_inputCells[i]->*vectorProperty.get)();
44
45 for (unsigned int d = 0; d < dim; d++) {
46 if (_filteredDims[d])
47 vec_buf[d] = _constant;
48 }
49
50 (FilterInterface<dim>::_outputCells[i]->*vectorProperty.set)(vec_buf);
51 }
52 }
53 }
54
55private:
56 const double _constant;
57 const tarch::la::Vector<dim, bool> _filteredDims;
58};
defines the cell type with cell-averaged quantities only (no linked cells).
Definition CouplingCell.h:29
Definition Constant.h:23
Definition FilterInterface.h:32
std::vector< coupling::datastructures::CouplingCell< dim > * > _inputCells
Definition FilterInterface.h:181
Definition Vector.h:24
Definition FilterPipeline.h:21
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15