Coverage for pySDC/implementations/problem_classes/acoustic_helpers/buildWave1DMatrix.py: 79%
28 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
1import numpy as np
2import scipy.sparse as sp
4from pySDC.implementations.problem_classes.acoustic_helpers.buildFDMatrix import (
5 getMatrix,
6 getHorizontalDx,
7 getBCLeft,
8 getBCRight,
9)
11wave_order = 6
14def getWave1DMatrix(N, dx, bc_left, bc_right):
15 Id = sp.eye(2 * N)
17 D_u = getMatrix(N, dx, bc_left[0], bc_right[0], wave_order)
18 D_p = getMatrix(N, dx, bc_left[1], bc_right[1], wave_order)
19 Zero = np.zeros((N, N))
20 M1 = sp.hstack((Zero, D_p), format="csc")
21 M2 = sp.hstack((D_u, Zero), format="csc")
22 M = sp.vstack((M1, M2), format="csc")
23 return sp.csc_matrix(Id), sp.csc_matrix(M)
26def getWave1DAdvectionMatrix(N, dx, order):
27 Dx = getHorizontalDx(N, dx, order)
28 Zero = np.zeros((N, N))
29 M1 = sp.hstack((Dx, Zero), format="csc")
30 M2 = sp.hstack((Zero, Dx), format="csc")
31 M = sp.vstack((M1, M2), format="csc")
32 return sp.csc_matrix(M)
35def getWaveBCLeft(value, N, dx, bc_left):
36 bu = getBCLeft(value[0], N, dx, bc_left[0], wave_order)
37 bp = getBCLeft(value[1], N, dx, bc_left[1], wave_order)
38 return np.concatenate((bp, bu))
41def getWaveBCRight(value, N, dx, bc_right):
42 bu = getBCRight(value[0], N, dx, bc_right[0], wave_order)
43 bp = getBCRight(value[1], N, dx, bc_right[1], wave_order)
44 return np.concatenate((bp, bu))