LoAdSG
MassStencil.h
1//
2// Created by to35jepo on 2/16/23.
3//
4
5#ifndef SGRUN_MASSSTENCIL_H
6#define SGRUN_MASSSTENCIL_H
7
8
9#include "../extemp/vector.h"
10#include "../myMath/myMath.h"
11#include "../cells/celldimension.h"
12
13class MassStencil {
14public:
15
16 inline void initialize(Depth &T_) {
17
18 for (int d = 0; d < DimensionSparseGrid; d++) {
19 auto value = double(POW2( T_.at(d)));
20 meshwidth[d] = 1.0 / value;
21 }
22
23 };
24 virtual inline void applyStencilOnCell_MPI_OMP(CellDimension& cell,VectorSparseG& input, VectorSparseG& output) {
25 cout << " MassStencil applyStencilOnCell NOT IMPLEMENTED YET!" << endl;
26 exit(1);
27 }
28 virtual inline void applyStencilOnCell(CellDimension& cell,VectorSparseG& input, VectorSparseG& output){
29 cout << " MassStencil applyStencilOnCell NOT IMPLEMENTED YET!" << endl;
30 exit(1);
31 /* for(CellIndexIterator outerIter(&cell); outerIter.goon(); ++outerIter){
32
33 IndexDimension p = outerIter.getIndex();
34 CellIndexDirection dirP = outerIter.getCellIndexDirection();
35
36
37 for(CellIndexIterator innerIter(outerIter); innerIter.goon(); ++innerIter){
38 IndexDimension q=innerIter.getIndex();
39 CellIndexDirection dirQ = innerIter.getCellIndexDirection();
40 unsigned long k;
41 if(output.getSparseGrid()->occupied(k,q)){
42
43 double val = integration(cell, dirP, dirQ);
44 output.setValue(k,val);
45 }
46
47
48 }
49 }*/
50 }
51
52 inline double returnValue(const IndexDimension &Index, MultiDimCompass &mc) const {
53 double factors[DimensionSparseGrid];
54 for (int j = 0; j < DimensionSparseGrid; ++j) {
55 double h = meshwidth[j];
56 Richtung r = mc.getRichtung(j);
57 factors[j] = (1.0 / 6.0) * h;;
58 if(r == Mitte) {
59 if((!Index.isAtLeftBoundary(j)) && (!Index.isAtRightBoundary(j)))factors[j] *= 4;
60 else factors[j] *= 2;
61 }
62 if(r == Links && Index.isAtLeftBoundary(j)) factors[j]=1.0;
63 if (r == Rechts && Index.isAtRightBoundary(j)) factors[j]=1.0;
64
65 }
66
67
68
69 double prod = 1.0;
70 for (int j = 0; j < DimensionSparseGrid; j++) {
71
72 prod *= factors[j];
73
74
75 }
76
77
78
79
80
81 return prod;
82
83 }
84 // inline double returnValue(IndexDimension &Index, MultiDimCompass &mc) const {
85 // size_t factors[DimensionSparseGrid];
86 // for (int j = 0; j < DimensionSparseGrid; ++j) {
87 // Richtung r = mc.getRichtung(j);
88 // factors[j] = 0;
89 // if(r == Mitte) {
90 // factors[j] += 1;
91 // if((!Index.isAtLeftBoundary(j)) && (!Index.isAtRightBoundary(j)))
92 // factors[j] += 1;
93 // }
94 // }
95
96 // // Stencil == Stiffness
97 // double sum = 0.0;
98 // for (int i = 0; i < DimensionSparseGrid; i++) {
99 // // int du/dxi * dv/dxi d(x1...xd)
100 // double prod = 1.0;
101 // for (int j = 0; j < DimensionSparseGrid; ++j) {
102 // // integral factor in direction j
103
104 // double h = meshwidth[j];
105
106 // if (i == j) {
107 // // factor: int du/dxi * dv/dxi dxi
108 // prod *= (1.0 / h);
109 // if (factors[j] == 0) {
110 // prod *= -1;
111 // } else if(factors[j] == 2){
112 // prod *= 2.0;
113 // }
114 // } else {
115 // // factor int du/dxi*dv/dxi dxj = int u*v*xj
116 // prod *= (1.0 / 6.0) * h;
117 // if (factors[j] == 1) {
118 // prod *= 2.0;
119 // } else if (factors[j] == 2) {
120 // prod *= 4.0;
121 // }
122
123 // }
124 // }
125 // sum += prod;
126 // }
127
128
129 // return sum;
130
131
132 // }
133
134
135private:
136 double meshwidth[DimensionSparseGrid];
137
138};
139
140
141#endif //SGRUN_MASSSTENCIL_H
Definition index.h:356