Skip to content

Commit 07ad3ef

Browse files
author
Daniel Ruprecht
committed
new FD matrix builders
1 parent 36e0071 commit 07ad3ef

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import sys
2+
sys.path.append('../')
3+
import numpy as np
4+
import scipy.sparse as sp
5+
from buildFDMatrix import getMatrix, getHorizontalDx, getBCLeft, getBCRight
6+
7+
def getWave1DMatrix(N, dx, bc_left, bc_right):
8+
9+
Id = sp.eye(2*N)
10+
11+
D_u = getMatrix(N, dx, bc_left[0], bc_right[0])
12+
D_p = getMatrix(N, dx, bc_left[1], bc_right[1])
13+
Zero = np.zeros((N,N))
14+
M1 = sp.hstack((Zero, D_p), format="csc")
15+
M2 = sp.hstack((D_u, Zero), format="csc")
16+
M = sp.vstack((M1, M2), format="csc")
17+
return sp.csc_matrix(Id), sp.csc_matrix(M)
18+
19+
def getWave1DAdvectionMatrix(N, dx, order):
20+
Dx = getHorizontalDx(N, dx, order)
21+
Zero = np.zeros((N,N))
22+
M1 = sp.hstack((Dx, Zero), format="csc")
23+
M2 = sp.hstack((Zero, Dx), format="csc")
24+
M = sp.vstack((M1, M2), format="csc")
25+
return sp.csc_matrix(M)
26+
27+
def getWaveBCLeft(value, N, dx, bc_left):
28+
bu = getBCLeft(value[0], N, dx, bc_left[0])
29+
bp = getBCLeft(value[1], N, dx, bc_left[1])
30+
return np.concatenate((bp, bu))
31+
32+
def getWaveBCRight(value, N, dx, bc_right):
33+
bu = getBCRight(value[0], N, dx, bc_right[0])
34+
bp = getBCRight(value[1], N, dx, bc_right[1])
35+
return np.concatenate((bp, bu))

0 commit comments

Comments
 (0)