Skip to content

Commit 0910032

Browse files
Merge pull request #15 from SeisSol/davschneller/vtk-and-multilinear
Add VTK Matrix/Basis Generators, Multilinear Forms, and High-Order Material Matrices
2 parents 5e75ad0 + 4cddd83 commit 0910032

File tree

10 files changed

+515
-142
lines changed

10 files changed

+515
-142
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
__pycache__
22

3-
*.lock
3+
# don't commit the lock; it may get outdated to quickly
4+
poetry.lock
5+

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,16 @@ If we use basis functions for order $\mathcal{O}$, we have $\frac{1}{6} \times \
2323
| $M_{kl}$ | $\int_T \Psi_k \Psi_l dx$ | `M3` |
2424
| | $\int_T \Phi_k \Phi_l dx$ | `M2` |
2525
| $F_{kl}^{-,j}$ | $\int_T \Psi_k \Psi_l dx$ | `rT` |
26+
27+
## Usage
28+
29+
Use poetry to install or use the package. In particular, consider the commands
30+
31+
```
32+
# install
33+
poetry install
34+
# format files
35+
poetry run black src
36+
# run unit tests
37+
poetry run coverage run -m nose2
38+
```

src/seissol_matrices/base.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import numpy as np
2+
3+
4+
def collocate(basis, points):
5+
# takes a basis object, and a points array
6+
# of the form: npoints × dim
7+
# outputs a collocation matrix of the form
8+
# npoints × nbasis
9+
10+
# as far as the author of these lines is aware,
11+
# this module has no broadcasing functionality yet
12+
# for basis functions. Which is sad.
13+
14+
assert basis.dim() == points.shape[1]
15+
16+
nbasis = basis.number_of_basis_functions()
17+
18+
coll = np.empty((nbasis, points.shape[0]))
19+
for i in range(nbasis):
20+
for j in range(points.shape[0]):
21+
coll[i, j] = basis.eval_basis(points[j, :], i)
22+
return coll

src/seissol_matrices/basis_functions.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def singularity_free_jacobi_polynomial(n, a, b, x, y):
4040

4141
def singularity_free_jacobi_polynomial_and_derivatives(n, a, b, x, y):
4242
if n == 0:
43-
return 1.0, 0.0, 0.0
43+
return np.ones(np.shape(x)), np.zeros(np.shape(x)), np.zeros(np.shape(x))
4444
pm_1 = 1.0
4545
ddx_pm_1 = 0.0
4646
ddy_pm_1 = 0.0
@@ -85,19 +85,25 @@ def eval_diff_basis(self, x, i, k):
8585
def number_of_basis_functions(self, o):
8686
pass
8787

88+
def dim(self):
89+
pass
90+
8891

8992
################################################################################
9093

9194

9295
class BasisFunctionGenerator1D(BasisFunctionGenerator):
96+
def dim(self):
97+
return 1
98+
9399
def eval_basis(self, x, i):
94100
r_num = 2 * x - 1.0
95101
r_den = 1.0
96102
return singularity_free_jacobi_polynomial(i, 0, 0, r_num, r_den)
97103

98104
def eval_diff_basis(self, x, i, k):
99105
if i == 0:
100-
return 0
106+
return np.zeros(x.shape)
101107
else:
102108
r_num = 2 * x - 1.0
103109
r_den = 1.0
@@ -113,6 +119,9 @@ def number_of_basis_functions(self):
113119

114120

115121
class BasisFunctionGenerator2D(BasisFunctionGenerator):
122+
def dim(self):
123+
return 2
124+
116125
def unroll_index(self, i):
117126
n = i[0] + i[1]
118127
tri = 0.5 * n * (n + 1)
@@ -171,6 +180,9 @@ def number_of_basis_functions(self):
171180

172181

173182
class BasisFunctionGenerator3D(BasisFunctionGenerator):
183+
def dim(self):
184+
return 3
185+
174186
def unroll_index(self, i):
175187
n = i[0] + i[1] + i[2]
176188
tet = (n * (n + 1) * (n + 2)) / 6.0

0 commit comments

Comments
 (0)