Skip to content

Commit 61bac69

Browse files
committed
scale by element size
1 parent 66eb035 commit 61bac69

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

LoopStructural/interpolators/_discrete_interpolator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def add_constraints_to_least_squares(self, A, B, idc, w=1.0, name="undefined"):
219219
# normalise by rows of A
220220
# Should this be done? It should make the solution more stable
221221
length = np.linalg.norm(A, axis=1)
222+
# length[length>0] = 1.
222223
B[length > 0] /= length[length > 0]
223224
# going to assume if any are nan they are all nan
224225
mask = np.any(np.isnan(A), axis=1)

LoopStructural/interpolators/_p1interpolator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_norm_constraints(self, w=1.0):
4545
points = self.get_norm_constraints()
4646
if points.shape[0] > 0:
4747
grad, elements, inside = self.support.evaluate_shape_derivatives(points[:, :3])
48-
size = self.support.element_size[elements[inside]]
48+
size = self.support.element_scale[elements[inside]]
4949
wt = np.ones(size.shape[0])
5050
wt *= w # s* size
5151
elements = np.tile(self.support.elements[elements[inside]], (3, 1, 1))
@@ -70,6 +70,7 @@ def add_value_constraints(self, w=1.0):
7070
if points.shape[0] > 1:
7171
N, elements, inside = self.support.evaluate_shape(points[:, :3])
7272
size = self.support.element_size[elements[inside]]
73+
7374
wt = np.ones(size.shape[0])
7475
wt *= w # * size
7576
self.add_constraints_to_least_squares(
@@ -110,13 +111,16 @@ def minimise_edge_jumps(self, w=0.1, vector_func=None, vector=None, name="edge j
110111
const_n = -np.einsum("ij,ijk->ik", norm, Dn)
111112
# const_t_cp2 = np.einsum('ij,ikj->ik',normal,cp2_Dt)
112113
# const_n_cp2 = -np.einsum('ij,ikj->ik',normal,cp2_Dn)
113-
114+
# shared_element_size = self.support.shared_element_size
115+
# const_t /= shared_element_size[:, None] # normalise by element size
116+
# const_n /= shared_element_size[:, None] # normalise by element size
114117
const = np.hstack([const_t, const_n])
115118

116119
# get vertex indexes
117120
tri_cp1 = np.hstack([self.support.elements[tri1], self.support.elements[tri2]])
118121
# tri_cp2 = np.hstack([self.support.elements[cp2_tri1],self.support.elements[tri2]])
119122
# add cp1 and cp2 to the least squares system
123+
120124
self.add_constraints_to_least_squares(
121125
const,
122126
np.zeros(const.shape[0]),

LoopStructural/interpolators/supports/_3d_structured_tetra.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ def element_size(self):
8585
)
8686

8787
return np.abs(np.linalg.det(vecs)) / 6
88-
88+
8989
@property
9090
def element_scale(self):
91-
return self.element_size / np.mean(self.element_size)
91+
size = self.element_size
92+
size-= np.min(size)
93+
size/= np.max(size)
94+
size+=1.
95+
return size
9296

9397
@property
9498
def barycentre(self) -> np.ndarray:
@@ -189,7 +193,7 @@ def shared_element_size(self):
189193
"""
190194
norm = self.shared_element_norm
191195
return 0.5 * np.linalg.norm(norm, axis=1)
192-
196+
193197
@property
194198
def shared_element_scale(self):
195199
return self.shared_element_size / np.mean(self.shared_element_size)

0 commit comments

Comments
 (0)