Peano
Loading...
Searching...
No Matches
FD4Kernels.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3
4
61
62
63def rightHandSideWithFD42D(patchData: "::exahype2::CellData<double, double>&") -> "void":
64 N = Integer("patchData.numberOfCells")
65 t = DataBlock([[0, N]], "patchData.t", "double")
66 dt = DataBlock([[0, N]], "patchData.dt", "double")
67 h = DataBlock([[0, N]], "patchData.cellSize", "tarch::la::Vector<2, double>")
68 x = DataBlock([[0, N]], "patchData.cellCentre", "tarch::la::Vector<2, double>")
69
70 input = DataBlock([[0, NumberOfUnknowns + NumberOfAuxiliaryVariables], [-H, NC + H], [-H, NC + H], [0, N]], "patchData.QIn")
71 output = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, N]], "patchData.QOut")
72 output = 0.0 * input[0:NumberOfUnknowns, 0:NC, 0:NC]
73
74 if volumetricSource:
75 source = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, N]], eval("volumetricSource", input[:, 0:NC, 0:NC], x, t))
76 output = output + source
77
78 if flux:
79 flux_x = DataBlock([[0, NumberOfUnknowns], [-2, NC + 2], [0, NC], [0, N]], eval("flux", input[:, -2:NC+2, 0:NC], x, 0))
80 flux_y = DataBlock([[0, NumberOfUnknowns], [0, NC], [-2, NC + 2], [0, N]], eval("flux", input[:, 0:NC, -2:NC+2], x, 1))
81 output = output - (1.0 / 12.0) * NC / h(0) * (flux_x[:, -2:NC-2, 0:NC] - 8.0 * flux_x[:, -1:NC-1, 0:NC] + 8.0 * flux_x[:, 1:NC+1, 0:NC] - flux_x[:, 2:NC+2, 0:NC])
82 output = output - (1.0 / 12.0) * NC / h(1) * (flux_y[:, 0:NC, -2:NC-2] - 8.0 * flux_y[:, 0:NC, -1:NC-1] + 8.0 * flux_y[:, 0:NC, 1:NC+1] - flux_y[:, 0:NC, 2:NC+2])
83
84 if nonconservativeProduct:
85 delta_x = (1.0 / 12.0) * (input[:, -2:NC-2, 0:NC] - 8.0 * input[:, -1:NC-1, 0:NC] + 8.0 * input[:, 1:NC+1, 0:NC] - input[:, 2:NC+2, 0:NC])
86 ncp_x = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, N]], eval("nonconservativeProduct", input[:, 0:NC, 0:NC], delta_x, x, h, t, dt, 0))
87 output = output - NC / h(0) * ncp_x
88
89 delta_y = (1.0 / 12.0) * (input[:, 0:NC, -2:NC-2] - 8.0 * input[:, 0:NC, -1:NC-1] + 8.0 * input[:, 0:NC, 1:NC+1] - input[:, 0:NC, 2:NC+2])
90 ncp_y = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, N]], eval("nonconservativeProduct", input[:, 0:NC, 0:NC], delta_y, x, h, t, dt, 1))
91 output = output - NC / h(1) * ncp_y
92
93
94def rightHandSideWithFD43D(patchData: "::exahype2::CellData<double, double>&") -> "void":
95 N = Integer("patchData.numberOfCells")
96 t = DataBlock([[0, N]], "patchData.t", "double")
97 dt = DataBlock([[0, N]], "patchData.dt", "double")
98 h = DataBlock([[0, N]], "patchData.cellSize", "tarch::la::Vector<3, double>")
99 x = DataBlock([[0, N]], "patchData.cellCentre", "tarch::la::Vector<3, double>")
100
101 input = DataBlock([[0, NumberOfUnknowns + NumberOfAuxiliaryVariables], [-H, NC + H], [-H, NC + H], [-H, NC + H], [0, N]], "patchData.QIn")
102 output = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, NC], [0, N]], "patchData.QOut")
103 output = 0.0 * input[0:NumberOfUnknowns, 0:NC, 0:NC, 0:NC]
104
105 if volumetricSource:
106 source = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, NC], [0, N]], eval("volumetricSource", input[:, 0:NC, 0:NC, 0:NC], x, t))
107 output = output + source
108
109 if flux:
110 flux_x = DataBlock([[0, NumberOfUnknowns], [-2, NC + 2], [0, NC], [0, NC], [0, N]], eval("flux", input[:, -2:NC+2, 0:NC, 0:NC], x, 0))
111 flux_y = DataBlock([[0, NumberOfUnknowns], [0, NC], [-2, NC + 2], [0, NC], [0, N]], eval("flux", input[:, 0:NC, -2:NC+2, 0:NC], x, 1))
112 flux_z = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [-2, NC + 2], [0, N]], eval("flux", input[:, 0:NC, 0:NC, -2:NC+2], x, 2))
113 output = output - (1.0 / 12.0) * NC / h(0) * (flux_x[:, -2:NC-2, 0:NC, 0:NC] - 8.0 * flux_x[:, -1:NC-1, 0:NC, 0:NC] + 8.0 * flux_x[:, 1:NC+1, 0:NC, 0:NC] - flux_x[:, 2:NC+2, 0:NC, 0:NC])
114 output = output - (1.0 / 12.0) * NC / h(1) * (flux_y[:, 0:NC, -2:NC-2, 0:NC] - 8.0 * flux_y[:, 0:NC, -1:NC-1, 0:NC] + 8.0 * flux_y[:, 0:NC, 1:NC+1, 0:NC] - flux_y[:, 0:NC, 2:NC+2, 0:NC])
115 output = output - (1.0 / 12.0) * NC / h(2) * (flux_z[:, 0:NC, 0:NC, -2:NC-2] - 8.0 * flux_z[:, 0:NC, 0:NC, -1:NC-1] + 8.0 * flux_z[:, 0:NC, 0:NC, 1:NC+1] - flux_z[:, 0:NC, 0:NC, 2:NC+2])
116
117 if nonconservativeProduct:
118 delta_x = (1.0 / 12.0) * (input[:, -2:NC-2, 0:NC, 0:NC] - 8.0 * input[:, -1:NC-1, 0:NC, 0:NC] + 8.0 * input[:, 1:NC+1, 0:NC, 0:NC] - input[:, 2:NC+2, 0:NC, 0:NC])
119 ncp_x = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, NC], [0, N]], eval("nonconservativeProduct", input[:, 0:NC, 0:NC, 0:NC], delta_x, x, h, t, dt, 0))
120 output = output - NC / h(0) * ncp_x
121
122 delta_y = (1.0 / 12.0) * (input[:, 0:NC, -2:NC-2, 0:NC] - 8.0 * input[:, 0:NC, -1:NC-1, 0:NC] + 8.0 * input[:, 0:NC, 1:NC+1, 0:NC] - input[:, 0:NC, 2:NC+2, 0:NC])
123 ncp_y = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, NC], [0, N]], eval("nonconservativeProduct", input[:, 0:NC, 0:NC, 0:NC], delta_y, x, h, t, dt, 1))
124 output = output - NC / h(1) * ncp_y
125
126 delta_z = (1.0 / 12.0) * (input[:, 0:NC, 0:NC, -2:NC-2] - 8.0 * input[:, 0:NC, 0:NC, -1:NC-1] + 8.0 * input[:, 0:NC, 0:NC, 1:NC+1] - input[:, 0:NC, 0:NC, 2:NC+2])
127 ncp_z = DataBlock([[0, NumberOfUnknowns], [0, NC], [0, NC], [0, NC], [0, N]], eval("nonconservativeProduct", input[:, 0:NC, 0:NC, 0:NC], delta_z, x, h, t, dt, 2))
128 output = output - NC / h(2) * ncp_z
129
130
131def maxEigenvalueOverPatch2D(patchData: "::exahype2::CellData<double, double>&") -> "void":
132 N = Integer("patchData.numberOfCells")
133 x = DataBlock([[0, N]], "patchData.cellCentre", "tarch::la::Vector<2, double>")
134 maxEigenvalues = DataBlock([[0, N]], "patchData.maxEigenvalue", "double")
135 input = DataBlock([[0, NumberOfUnknowns + NumberOfAuxiliaryVariables], [0, NC], [0, NC], [0, N]], "patchData.QIn")
136
137 if maxEigenvalue:
138 eigenvalues_x = DataBlock([[0, 1], [0, NC], [0, NC], [0, N]], eval("maxEigenvalue", input, x, 0))
139 eigenvalues_y = DataBlock([[0, 1], [0, NC], [0, NC], [0, N]], eval("maxEigenvalue", input, x, 1))
140 eigenvaluesPerGridCell = max(eigenvalues_x, eigenvalues_y)
141 maxEigenvalues = max(eigenvaluesPerGridCell)
142
143
144def maxEigenvalueOverPatch3D(patchData: "::exahype2::CellData<double, double>&") -> "void":
145 N = Integer("patchData.numberOfCells")
146 x = DataBlock([[0, N]], "patchData.cellCentre", "tarch::la::Vector<3, double>")
147 maxEigenvalues = DataBlock([[0, N]], "patchData.maxEigenvalue", "double")
148 input = DataBlock([[0, NumberOfUnknowns + NumberOfAuxiliaryVariables], [0, NC], [0, NC], [0, NC], [0, N]], "patchData.QIn")
149
150 if maxEigenvalue:
151 eigenvalues_x = DataBlock([[0, 1], [0, NC], [0, NC], [0, NC], [0, N]], eval("maxEigenvalue", input, x, 0))
152 eigenvalues_y = DataBlock([[0, 1], [0, NC], [0, NC], [0, NC], [0, N]], eval("maxEigenvalue", input, x, 1))
153 eigenvalues_z = DataBlock([[0, 1], [0, NC], [0, NC], [0, NC], [0, N]], eval("maxEigenvalue", input, x, 2))
154 eigenvaluesXY = max(eigenvalues_x, eigenvalues_y)
155 eigenvaluesPerGridCell = max(eigenvaluesXY, eigenvalues_z)
156 maxEigenvalues = max(eigenvaluesPerGridCell)
"void" maxEigenvalueOverPatch2D("::exahype2::CellData<double, double>&" patchData)
"void" maxEigenvalueOverPatch3D("::exahype2::CellData<double, double>&" patchData)
"void" rightHandSideWithFD42D("::exahype2::CellData<double, double>&" patchData)
DSLHyPE kernels of the fourth-order Finite Differences.
Definition FD4Kernels.py:63
"void" rightHandSideWithFD43D("::exahype2::CellData<double, double>&" patchData)
Definition FD4Kernels.py:94