Skip to content

Commit 3bf9947

Browse files
committed
misc changes
1 parent 2e1b008 commit 3bf9947

File tree

4 files changed

+118
-119
lines changed

4 files changed

+118
-119
lines changed

LoopStructural/interpolators/_p2interpolator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def minimise_edge_jumps(
244244
const_cp = np.hstack([const_t_cp, const_n_cp])
245245
tri_cp = np.hstack([self.support.elements[cp_tri1], self.support.elements[cp_tri2]])
246246
wt = np.zeros(tri_cp.shape[0])
247-
wt[:] = w
247+
wt[:] = w * weight[:, i]
248248
if wtfunc:
249249
wt = wtfunc(tri_cp)
250250
self.add_constraints_to_least_squares(

LoopStructural/interpolators/supports/_2d_p2_unstructured.py

Lines changed: 117 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -41,130 +41,130 @@ def evaluate_d2_shape(self, indexes):
4141
)
4242
jac = np.linalg.inv(jac)
4343
dxy = (
44-
self.H[None, 0, 1, :] * jac[:, 0, 0] * jac[:, 1, 1]
45-
+ self.H[None, 0, 1, :] * jac[:, 1, 0] * jac[:, 0, 1]
46-
+ self.H[None, 0, 0, :] * jac[:, 0, 0] * jac[:, 0, 1]
47-
+ self.H[None, 1, 1, :] * jac[:, 1, 0] * jac[:, 1, 1]
44+
self.hessian[None, 0, 1, :] * jac[:, 0, 0] * jac[:, 1, 1]
45+
+ self.hessian[None, 0, 1, :] * jac[:, 1, 0] * jac[:, 0, 1]
46+
+ self.hessian[None, 0, 0, :] * jac[:, 0, 0] * jac[:, 0, 1]
47+
+ self.hessian[None, 1, 1, :] * jac[:, 1, 0] * jac[:, 1, 1]
4848
)
4949
dxx = (
50-
self.H[None, 0, 0, :] * jac[:, 0, 0] * jac[:, 0, 0]
51-
+ jac[:, 0, 0] * jac[:, 1, 0] * self.H[None, 0, 1, :]
52-
+ jac[:, 1, 0] * jac[:, 1, 0] * self.H[None, 1, 1]
50+
self.hessian[None, 0, 0, :] * jac[:, 0, 0] * jac[:, 0, 0]
51+
+ jac[:, 0, 0] * jac[:, 1, 0] * self.hessian[None, 0, 1, :]
52+
+ jac[:, 1, 0] * jac[:, 1, 0] * self.hessian[None, 1, 1]
5353
)
5454
dyy = (
55-
self.H[None, 0, 0, :] * jac[:, 1, 0] * jac[:, 1, 0]
56-
+ jac[:, 1, 0] * jac[:, 1, 1] * self.H[None, 0, 1, :]
57-
+ jac[:, 1, 1] * jac[:, 1, 1] * self.H[None, 1, 1]
55+
self.hessian[None, 0, 0, :] * jac[:, 1, 0] * jac[:, 1, 0]
56+
+ jac[:, 1, 0] * jac[:, 1, 1] * self.hessian[None, 0, 1, :]
57+
+ jac[:, 1, 1] * jac[:, 1, 1] * self.hessian[None, 1, 1]
5858
)
5959
return dxx, dyy, dxy
6060

61-
# vertices = np.zeros((3,2))
62-
# vertices[0,:] = [M[0,1],M[0,2]]
63-
# vertices[1,:] = [M[1,1],M[1,2]]
64-
# vertices[2,:] = [M[2,1],M[2,2]]
65-
# jac = np.array([[(vertices[1,0]-vertices[0,0]),(vertices[1,1]-vertices[0,1])],
66-
# [vertices[2,0]-vertices[0,0],vertices[2,1]-vertices[0,1]]])
67-
# Nst_coeff = jac[0,0]*jac[1,1]+jac[0,1]*jac[1,0]
68-
69-
# #N_st
70-
# Nst = np.zeros(6)
71-
# Nst[0] = 4
72-
# Nst[1] = 0
73-
# Nst[2] = 0
74-
# Nst[3] = 4
75-
# Nst[4] = -4
76-
# Nst[5] = -4
77-
78-
# hN = np.zeros((2,6))
79-
80-
# #N_ss
81-
# hN[0,0] = 4
82-
# hN[0,1] = 4
83-
# hN[0,2] = 0
84-
# hN[0,3] = 0
85-
# hN[0,4] = 0
86-
# hN[0,5] = -8
87-
88-
# #N_tt
89-
# hN[1,0] = 4
90-
# hN[1,1] = 0
91-
# hN[1,2] = 4
92-
# hN[1,3] = 0
93-
# hN[1,4] = -8
94-
# hN[1,5] = 0
95-
96-
# xyConst = Nst*Nst_coeff + hN[0] * jac[0,0]*jac[1,0] + hN[1] * jac[1,0]*jac[1,1]
97-
# jac = np.linalg.inv(jac)
98-
# jac = jac*jac
99-
100-
# d2_prod = np.dot(jac,hN)
101-
# d2Const = d2_prod[0] + d2_prod[1]
102-
# xxConst = d2_prod[0]
103-
# yyConst = d2_prod[1]
104-
105-
# return xxConst,yyConst,xyConstz
106-
# def evaluate_mixed_derivative(self, indexes):
107-
# """
108-
# evaluate partial of N with respect to st (to set u_xy=0)
109-
# """
110-
111-
# vertices = self.nodes[self.elements[indexes], :]
112-
# jac = np.array(
113-
# [
114-
# [
115-
# (vertices[:, 1, 0] - vertices[:, 0, 0]),
116-
# (vertices[:, 1, 1] - vertices[:, 0, 1]),
117-
# ],
118-
# [
119-
# vertices[:, 2, 0] - vertices[:, 0, 0],
120-
# vertices[:, 2, 1] - vertices[:, 0, 1],
121-
# ],
122-
# ]
123-
# ).T
124-
# Nst_coeff = jac[:, 0, 0] * jac[:, 1, 1] + jac[:, 0, 1] * jac[:, 1, 0]
125-
126-
# Nst = self.Nst[None, :] * Nst_coeff[:, None]
127-
# return (
128-
# Nst
129-
# + self.hN[None, 0, :] * (jac[:, 0, 0] * jac[:, 1, 0])[:, None]
130-
# + self.hN[None, 1, :] * (jac[:, 1, 0] * jac[:, 1, 1])[:, None]
131-
# )
132-
133-
# def evaluate_shape_d2(self, indexes):
134-
# """evaluate second derivatives of shape functions in s and t
135-
136-
# Parameters
137-
# ----------
138-
# M : [type]
139-
# [description]
140-
141-
# Returns
142-
# -------
143-
# [type]
144-
# [description]
145-
# """
146-
147-
# vertices = self.nodes[self.elements[indexes], :]
148-
149-
# jac = np.array(
150-
# [
151-
# [
152-
# (vertices[:, 1, 0] - vertices[:, 0, 0]),
153-
# (vertices[:, 1, 1] - vertices[:, 0, 1]),
154-
# ],
155-
# [
156-
# vertices[:, 2, 0] - vertices[:, 0, 0],
157-
# vertices[:, 2, 1] - vertices[:, 0, 1],
158-
# ],
159-
# ]
160-
# ).T
161-
# jac = np.linalg.inv(jac)
162-
# jac = jac * jac
163-
164-
# d2_prod = np.einsum("lij,ik->lik", jac, self.hN)
165-
# d2Const = d2_prod[:, 0, :] + d2_prod[:, 1, :]
166-
# xxConst = d2_prod[:, 0, :]
167-
# yyConst = d2_prod[:, 1, :]
61+
# vertices = np.zeros((3,2))
62+
# vertices[0,:] = [M[0,1],M[0,2]]
63+
# vertices[1,:] = [M[1,1],M[1,2]]
64+
# vertices[2,:] = [M[2,1],M[2,2]]
65+
# jac = np.array([[(vertices[1,0]-vertices[0,0]),(vertices[1,1]-vertices[0,1])],
66+
# [vertices[2,0]-vertices[0,0],vertices[2,1]-vertices[0,1]]])
67+
# Nst_coeff = jac[0,0]*jac[1,1]+jac[0,1]*jac[1,0]
68+
69+
# #N_st
70+
# Nst = np.zeros(6)
71+
# Nst[0] = 4
72+
# Nst[1] = 0
73+
# Nst[2] = 0
74+
# Nst[3] = 4
75+
# Nst[4] = -4
76+
# Nst[5] = -4
77+
78+
# hN = np.zeros((2,6))
79+
80+
# #N_ss
81+
# hN[0,0] = 4
82+
# hN[0,1] = 4
83+
# hN[0,2] = 0
84+
# hN[0,3] = 0
85+
# hN[0,4] = 0
86+
# hN[0,5] = -8
87+
88+
# #N_tt
89+
# hN[1,0] = 4
90+
# hN[1,1] = 0
91+
# hN[1,2] = 4
92+
# hN[1,3] = 0
93+
# hN[1,4] = -8
94+
# hN[1,5] = 0
95+
96+
# xyConst = Nst*Nst_coeff + hN[0] * jac[0,0]*jac[1,0] + hN[1] * jac[1,0]*jac[1,1]
97+
# jac = np.linalg.inv(jac)
98+
# jac = jac*jac
99+
100+
# d2_prod = np.dot(jac,hN)
101+
# d2Const = d2_prod[0] + d2_prod[1]
102+
# xxConst = d2_prod[0]
103+
# yyConst = d2_prod[1]
104+
105+
# return xxConst,yyConst,xyConstz
106+
# def evaluate_mixed_derivative(self, indexes):
107+
# """
108+
# evaluate partial of N with respect to st (to set u_xy=0)
109+
# """
110+
111+
# vertices = self.nodes[self.elements[indexes], :]
112+
# jac = np.array(
113+
# [
114+
# [
115+
# (vertices[:, 1, 0] - vertices[:, 0, 0]),
116+
# (vertices[:, 1, 1] - vertices[:, 0, 1]),
117+
# ],
118+
# [
119+
# vertices[:, 2, 0] - vertices[:, 0, 0],
120+
# vertices[:, 2, 1] - vertices[:, 0, 1],
121+
# ],
122+
# ]
123+
# ).T
124+
# Nst_coeff = jac[:, 0, 0] * jac[:, 1, 1] + jac[:, 0, 1] * jac[:, 1, 0]
125+
126+
# Nst = self.Nst[None, :] * Nst_coeff[:, None]
127+
# return (
128+
# Nst
129+
# + self.hN[None, 0, :] * (jac[:, 0, 0] * jac[:, 1, 0])[:, None]
130+
# + self.hN[None, 1, :] * (jac[:, 1, 0] * jac[:, 1, 1])[:, None]
131+
# )
132+
133+
# def evaluate_shape_d2(self, indexes):
134+
# """evaluate second derivatives of shape functions in s and t
135+
136+
# Parameters
137+
# ----------
138+
# M : [type]
139+
# [description]
140+
141+
# Returns
142+
# -------
143+
# [type]
144+
# [description]
145+
# """
146+
147+
# vertices = self.nodes[self.elements[indexes], :]
148+
149+
# jac = np.array(
150+
# [
151+
# [
152+
# (vertices[:, 1, 0] - vertices[:, 0, 0]),
153+
# (vertices[:, 1, 1] - vertices[:, 0, 1]),
154+
# ],
155+
# [
156+
# vertices[:, 2, 0] - vertices[:, 0, 0],
157+
# vertices[:, 2, 1] - vertices[:, 0, 1],
158+
# ],
159+
# ]
160+
# ).T
161+
# jac = np.linalg.inv(jac)
162+
# jac = jac * jac
163+
164+
d2_prod = np.einsum("lij,ik->lik", jac, self.hessian)
165+
# d2Const = d2_prod[:, 0, :] + d2_prod[:, 1, :]
166+
xxConst = d2_prod[:, 0, :]
167+
yyConst = d2_prod[:, 1, :]
168168

169169
# return xxConst, yyConst
170170

LoopStructural/interpolators/supports/_2d_structured_tetra.py

Whitespace-only changes.

tests/unit/interpolator/test_discrete_interpolator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def test_region(interpolator, data, region_func):
1212
interpolator.setup_interpolator()
1313
interpolator.set_region(region_func)
1414
# assert np.all(interpolator.region == region_func(interpolator.support.nodes))
15-
print(np.sum(interpolator.region))
1615
interpolator.solve_system()
1716

1817

0 commit comments

Comments
 (0)