LoAdSG
MatrixVectorMultiplicationPrewavelets.h
1//
2// Created by scherner on 22.04.21.
3//
4
5#ifndef GRUN_MATRIXVECTORMULTIPLICATIONPREWAVELETS_H
6#define GRUN_MATRIXVECTORMULTIPLICATIONPREWAVELETS_H
7
8#include "../../indices/index.h"
9#include "../../sgrid/depth.h"
10#include <cmath>
11#include "../../extemp/vector.h"
12#include "../../extemp/multilevelvector.h"
13#include "../../sgrid/multilevelSparseGrid.h"
14#include "../../mympi.h"
15
16
17#include "../../sgoperation/matrix.h"
18#include "../../BasisTransformations/BasisTransformations_inhomog.h"
19#include "../../BasisTransformations/BasisTransformations.h"
20
21
22
23class CasesIterator {
24public:
25 CasesIterator() { snum = 0; }
26
27 inline bool goon() { return (snum < pow(2, DimensionSparseGrid)); }
28
29 inline void operator++() {
30 snum++;
31 }
32
33
34 inline bool *getcase() {
35 static bool cases[DimensionSparseGrid];
36
37
38 for (int i = 0; i < DimensionSparseGrid; ++i) cases[i] = false;
39
40 for (int i = 0; i < DimensionSparseGrid; ++i) {
41 // the following condition checks
42 // if the ith bit of snum in binary form
43 // is 1 or not
44 if ((snum & (1 << i)) != 0) {
45
46 cases[i] = true;
47 }
48 }
49 return cases;
50 };
51
52 bool *getcase(int snum_);
53
54 int getCaseNumber() { return snum; };
55
56 /* int getCaseNumber(bool* case_){
57 int returnvalue;
58 returnvalue = 0.0;
59 int b = 1;
60 for(int d=DimensionSparseGrid-1; d >=0; d--) {
61 returnvalue = returnvalue + case_[d] * b;
62 b = b * 2;
63 }
64
65 }*/
66
67
68
69
70
71private:
72
73 int snum;
74};
75
76enum StencilType {
77 Stiffness, Mass
78};
79
81void MatrixVectorPrewavelet(VectorSparseG &prew, VectorSparseG &Ax, StencilType type, MultiLevelVector &gM);
82
83//Functionen, die man für MaxtrixVectorPrewavelet braucht
84
85//alte Variante ohne MultigridVector
86/*void PP_Alg(VectorSparseG &prew, VectorSparseG &u, VectorSparseG &Ax, StencilType type, bool *restrictions);*/
87
88
89void MatrixVector_Case(VectorSparseG &prew, VectorSparseG &u, VectorSparseG &Ax, StencilType type, bool *restrictions,
90 VectorSparseG &g, VectorSparseG &z, MultiLevelVector &gM, ListOfDepthOrderedSubgrids &list,
91 MultiLevelVector &nodal);
92
93void ApplyStencil(VectorSparseG &x, VectorSparseG &Ax, Depth &T, StencilType type);
94
95double CalcStencilValue(IndexDimension Index, Depth &T, VectorSparseG &u, StencilType type);
96
97
98IndexDimension GetStencilValueIndex(IndexDimension Index, MultiDimCompass mc, double *stencilvalue, Depth T, int dir,
99 StencilType type);
100
101
102void restriction(VectorSparseG &fine, VectorSparseG &coarse, int t, int d);
103
104void ConvertToPrewavelet(VectorSparseG &Ax_hier, VectorSparseG &Ax, Depth &T, SubgridFixedDepth &subgrid);
105
106void ConvertToPrewavelet2(VectorSparseG &Ax_hier, VectorSparseG &Ax, Depth &T);
107
108void ConvertDualNodalToPrewavelet(VectorSparseG &Ax_hier, VectorSparseG &Ax, Depth &T);
110void MatrixVectorPrewavelet_inhomog(VectorSparseG &prew, VectorSparseG &Ax, StencilType type, MultiLevelVector &gM);
111
112void test_neumann(VectorSparseG &prew, VectorSparseG &Ax, StencilType type, bool *restrictions, MultiLevelVector &gM);
113
114
115class Stencil {
116public:
117 Stencil(Depth T_, StencilType type_);
118
119 double returnValue(MultiDimCompass &mc, IndexDimension Index);
120
121private:
123 StencilType type;
124 Depth T;
125
126};
127
128void ApplyStencil_inhomog(VectorSparseG &x, VectorSparseG &Ax, Depth &T, StencilType type);
129
130double CalcStencilValue_Boundary(IndexDimension Index, Depth &T, VectorSparseG &u, StencilType type, Stencil stencil);
131
132IndexDimension
133GetStencilValueIndex_Boundary(IndexDimension Index, MultiDimCompass mc, double *stencilvalue, Depth T, int dir,
134 StencilType type);
135
136double
137GetStencilValue_Boundary(MultiDimCompass mc, Depth T, int dir,
138 StencilType type);
139
140bool getNextIndex(IndexDimension Index, MultiDimCompass mc, Depth T, IndexDimension &NextIndex );
141
142void restriction_neumann(VectorSparseG &fine, VectorSparseG &coarse, int t, int d);
143
144void ConvertToNeumannPrewavelet(VectorSparseG &Ax_hier, VectorSparseG &Ax, Depth &T);
145
146void ConvertToNeumannPrewavelet2(VectorSparseG &Ax_hier, VectorSparseG &Ax, Depth &T, ListOfDepthOrderedSubgrids &list);
147
149
150void ApplyStencil(VectorSparseG &x, VectorSparseG &Ax, StencilType type);
151
152void restriction_local(VectorSparseG &fine, VectorSparseG &coarse, Depth Tfine, Depth Tcoarse);
153
154void matrixmult_prew_fullgrid(VectorSparseG &x, VectorSparseG &Ax, StencilType type);
155
156
157
158
159
160
162/*void ConvertDualSpace(VectorSparseG &neumann, VectorSparseG &dirichlet);*/
163
164#endif //GRUN_MATRIXVECTORMULTIPLICATIONPREWAVELETS_H
Definition ListOfDepthOrderedGrids.h:115
Definition index.h:209
Definition index.h:356
Definition ListOfDepthOrderedGrids.h:31