Peano
Loading...
Searching...
No Matches
CellIntegral2D.py
Go to the documentation of this file.
1def cellIntegral(patchData: "CellData<double, double>&") -> "void":
2 N = Integer("patchData.numberOfCells")
3 t = DataBlock([[0, N]], "patchData.t", "double")
4 dt = DataBlock([[0, N]], "patchData.dt", "double")
5 h = DataBlock([[0, N]], "patchData.cellSize", "tarch::la::Vector<2, double>")
6 x = DataBlock([[0, N]], "patchData.cellCentre", "tarch::la::Vector<2, double>")
7
8 input = DataBlock([[0, NumberOfUnknowns + NumberOfAuxiliaryVariables], [0, DGOrder + 1], [0, DGOrder + 1], [0, N]], "patchData.QIn")
9 output = DataBlock([[0, NumberOfUnknowns + NumberOfAuxiliaryVariables], [0, DGOrder + 1], [0, DGOrder + 1], [0, N]], "patchData.QOut")
10
11 output = 0.0
12 mass_matrix_1d = DiagonalMatrix(DGOrder + 1, "SolverType::MassMatrixDiagonal1d")
13 mass_matrix_2d = kroneckerProduct(mass_matrix_1d, mass_matrix_1d)
14 identity_matrix = DiagonalMatrix(DGOrder + 1, 1.0)
15 quadrature_positions = DataBlock([[0, 1], [0, DGOrder + 1], [0, DGOrder + 1], [0, N]], eval("getQuadraturePoint", index, x, h, DGOrder, "SolverType::QuadraturePoints1d"), "tarch::la::Vector<2, double>")
16
17 if EvaluateSource:
18 source = DataBlock([[0, NumberOfUnknowns], [0, DGOrder + 1], [0, DGOrder + 1], [0, N]], eval("sourceTerm", input, quadrature_positions, t, dt))
19 output = output + h(0) * h(1) * mass_matrix_2d * source
20
21 if EvaluateFlux:
22 flux_x = DataBlock([[0, NumberOfUnknowns], [0, DGOrder + 1], [0, DGOrder + 1], [0, N]], eval("flux", input, quadrature_positions, t, dt, 0))
23 flux_y = DataBlock([[0, NumberOfUnknowns], [0, DGOrder + 1], [0, DGOrder + 1], [0, N]], eval("flux", input, quadrature_positions, t, dt, 1))
24
25 mass_matrix_x = kroneckerProduct(mass_matrix_1d, identity_matrix)
26 mass_matrix_y = kroneckerProduct(identity_matrix, mass_matrix_1d)
27
28 stiffness_matrix_1d = Matrix(DGOrder + 1, DGOrder + 1, "SolverType::StiffnessOperator1d")
29 stiffness_matrix_x = kroneckerProduct(identity_matrix, stiffness_matrix_1d)
30 stiffness_matrix_y = kroneckerProduct(stiffness_matrix_1d, identity_matrix)
31
32 matrixVectorProduct(stiffness_matrix_x, flux_x, flux_x_contribution)
33 matrixVectorProduct(stiffness_matrix_y, flux_y, flux_y_contribution)
34
35 flux_x_contribution = h(0) * mass_matrix_x * flux_x_contribution
36 flux_y_contribution = h(1) * mass_matrix_y * flux_y_contribution
37
38 output[0:NumberOfUnknowns, :, :] = output[0:NumberOfUnknowns, :, :] + flux_x_contribution + flux_y_contribution
39
40 if EvaluateNonconservativeProduct:
41 derivative_matrix_1d = Matrix(DGOrder + 1, DGOrder + 1, "SolverType::DerivativeOperator1d")
42 derivative_matrix_x = kroneckerProduct(identity_matrix, derivative_matrix_1d)
43 derivative_matrix_y = kroneckerProduct(derivative_matrix_1d, identity_matrix)
44
45 matrixVectorProduct(derivative_matrix_x, input, gradient_x)
46 matrixVectorProduct(derivative_matrix_y, input, gradient_y)
47 gradient_x = gradient_x / h(0)
48 gradient_y = gradient_y / h(1)
49
50 nonconservative_product_x = DataBlock([[0, NumberOfUnknowns], [0, DGOrder + 1], [0, DGOrder + 1], [0, N]], eval("nonconservativeProduct", input, gradient_x, quadrature_positions, t, dt, 0))
51 nonconservative_product_y = DataBlock([[0, NumberOfUnknowns], [0, DGOrder + 1], [0, DGOrder + 1], [0, N]], eval("nonconservativeProduct", input, gradient_y, quadrature_positions, t, dt, 1))
52
53 output[0:NumberOfUnknowns, :, :] = output[0:NumberOfUnknowns, :, :] - h(0) * h(1) * mass_matrix_2d * (nonconservative_product_x + nonconservative_product_y)
tarch::la::DynamicMatrix kroneckerProduct(const tarch::la::DynamicMatrix &lhs, const tarch::la::DynamicMatrix &rhs)
Wrapper around static routine, so I don't have to use full-qualified name.