Peano 4
Loading...
Searching...
No Matches
PatchData.cpp
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <fstream>
4#include <unordered_map>
5#include <vector>
6#include <limits>
7
8#include "PatchData.h"
9
11#include "tarch/la/Vector.h"
13
14
15convert::data::PatchData::PatchData(int dimensions_, double* offset_, double* size_, int dofsPerAxis, int unknownsPerDoF, int originTree_):
16 dimensions(dimensions_),
17 originTree(originTree_){
18 for (int d=0; d<dimensions; d++) {
19 offset[d] = offset_[d];
20 size[d] = size_[d];
21 }
22
23 int points = tarch::la::aPowI(dimensions,dofsPerAxis) * unknownsPerDoF;
24
25 data = new double[points];
26}
27
28
30 bool equal = true;
31
32 for (int d=0; d<dimensions; d++) {
33 equal &= tarch::la::equals( size[d], otherPatch.size[d] );
34 equal &= tarch::la::equals( offset[d], otherPatch.offset[d] );
35 }
36
37 return equal;
38}
39
40
42 bool overlaps = true;
43
44 for (int d=0; d<dimensions; d++) {
45 overlaps &= tarch::la::smaller( offset[d], otherPatch.offset[d] + otherPatch.size[d] );
46 overlaps &= tarch::la::greater( offset[d]+size[d], otherPatch.offset[d] );
47 }
48
49 return overlaps;
50}
51
52
53void convert::data::PatchData::copyData( const PatchData& otherData, int dofsPerAxis, int unknownsPerDoF ) {
54 int points = tarch::la::aPowI(dimensions,dofsPerAxis) * unknownsPerDoF;
55 for (int i=0; i<points; i++) {
56 data[i] = otherData.data[i];
57 }
58}
59
60
62 if ( data!=nullptr ) {
63 delete[] data;
64 data = nullptr;
65 }
66}
A patch is a square or cube in the domain.
Definition PatchData.h:25
PatchData(int dimensions, double *offset_, double *size_, int dofsPerAxis, int unknownsPerDoF, int originTree)
Definition PatchData.cpp:15
void copyData(const PatchData &otherData, int dofsPerAxis, int unknownsPerDoF)
Definition PatchData.cpp:53
bool overlaps(const PatchData &otherPatch)
Definition PatchData.cpp:41
double * data
Mapping from variables onto the actual data.
Definition PatchData.h:54
double offset[MaxDimensions]
Definition PatchData.h:42
void free()
Free internal dynamic data types if there's still data left.
Definition PatchData.cpp:61
double size[MaxDimensions]
size of the patch in each dimension
Definition PatchData.h:47
bool samePatch(const PatchData &otherPatch)
Definition PatchData.cpp:29
static bool smaller(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) InlineMethod
Smaller operator for floating point values.
bool greater(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
bool equals(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares to matrices on equality by means of a numerical accuracy.
int aPowI(int i, int a)
Computes the i-th power of a in integer arithmetic.