-
Notifications
You must be signed in to change notification settings - Fork 11
/
getJacobians.py
37 lines (33 loc) · 987 Bytes
/
getJacobians.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'''
Author: Andy Wang
Descriptions: Finds the Jacobians for all the transforms
from the ReferenceElement to normal Elements. Used
to save computational costs.
Important Variables
Jacobians: [J_1, J_2, ... ]
Dilations: [[0, 1, 2, ...]; [3, 4, 5, ...], ...]
'''
from numpy.linalg import det
from copy import deepcopy as COPY
from globalVars import dimension
from readMesh import Nodes, Elements
Jacobians = []
Dilations = []
if dimension == 2:
for element, attribute in Elements:
points = [Nodes[element[i]] for i in range(3)]
b = COPY(points[0])
A = COPY(points[1:])
A = [[node[i] - b[i] for i in range(2)] for node in A]
Dilations.append(A)
Jacobian = det(A)
Jacobians.append(Jacobian)
elif dimension == 3:
for element, attribute in Elements:
points = [Nodes[element[i]] for i in range(4)]
b = COPY(points[0])
A = COPY(points[1:])
A = [[node[i] - b[i] for i in range(3)] for node in A]
Dilations.append(A)
Jacobian = det(A)
Jacobians.append(Jacobian)