Peano 4
Loading...
Searching...
No Matches
Intersection.cpp
Go to the documentation of this file.
1#include "Intersection.h"
2
3
6
7
8#include "tarch/la/Vector.h"
10
11
12tarch::logging::Log convert::filter::Intersection::_log( "convert::filter::Intersection" );
13
14
16 _strategy(strategy) {
17}
18
19
20void convert::filter::Intersection::apply( convert::data::DataSet& dataSet, convert::data::Variable& inputVariable, std::string targetSelectorName ) {
21 convert::data::Variable targetVariable( targetSelectorName, inputVariable.dofsPerAxis, inputVariable.unknowns, inputVariable.type, inputVariable.dimensions );
22
23 std::vector<convert::data::PatchData> inputData = dataSet.getData( inputVariable );
24 std::vector<convert::data::PatchData> targetData;
25
26 for (auto p: inputData) {
27 bool memberOfFineGrid = true;
28 for (auto pp: inputData) {
29 if (
30 not p.samePatch(pp)
31 and
32 p.overlaps(pp)
33 ) {
34 bool allSizesSmaller = true;
35 for (int d=0; d<inputVariable.dimensions; d++)
36 allSizesSmaller &= tarch::la::smaller( pp.size[d], p.size[d] );
37
38 if (allSizesSmaller)
39 memberOfFineGrid = false;
40 }
41 }
42
43 if (memberOfFineGrid) {
45 inputVariable.dimensions,
46 p.offset,
47 p.size,
48 inputVariable.dofsPerAxis,
49 inputVariable.unknowns,
50 p.originTree
51 );
52
53 newPatch.copyData(p,inputVariable.dofsPerAxis,inputVariable.unknowns);
54
55 targetData.push_back( newPatch );
56 }
57 }
58
59 dataSet.add( targetVariable, targetData );
60
61 logInfo( "apply(...)", "extracted " << targetData.size() << " patches from " << inputData.size() << " that belong to the fine grid" );
62}
#define logInfo(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Definition Log.h:411
A dataset is a wrapper around one big map.
Definition DataSet.h:34
std::vector< PatchData > getData(const Variable &selector) const
Definition DataSet.cpp:29
void add(Variable variable, const std::vector< PatchData > &patchData)
If you add a patch, don't free the patch, i.e.
Definition DataSet.cpp:86
A patch is a square or cube in the domain.
Definition PatchData.h:25
void copyData(const PatchData &otherData, int dofsPerAxis, int unknownsPerDoF)
Definition PatchData.cpp:53
Represents one variable that is subsequently attached to the patches of a file.
Definition Variable.h:18
const PeanoDataType type
Definition Variable.h:32
const int unknowns
If this unknown holds 1, it is scalar, for d it is vector data, and so forth.
Definition Variable.h:30
static tarch::logging::Log _log
Intersection(Strategy strategy)
virtual void apply(convert::data::DataSet &dataSet, convert::data::Variable &inputVariable, std::string targetSelectorName) override
Log Device.
Definition Log.h:516
static bool smaller(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) InlineMethod
Smaller operator for floating point values.