@@ -47,7 +47,6 @@ def __init__(self, grid, data={}):
4747 }
4848 )
4949
50- self .vol = 1.0 # grid.step_vector[0] * grid.step_vector[1] * \
5150 # grid.step_vector[2]
5251 self .type = InterpolatorType .FINITE_DIFFERENCE
5352
@@ -230,7 +229,7 @@ def add_interface_constraints(self, w=1.0):
230229 interface_A [outside , :],
231230 np .zeros (interface_A [outside , :].shape [0 ]),
232231 interface_idc [outside , :],
233- w = w * self . vol ,
232+ w = w ,
234233 name = "interface_{}" .format (unique_id ),
235234 )
236235
@@ -353,7 +352,12 @@ def add_norm_constraints(self, w=1.0):
353352 self .up_to_date = False
354353
355354 def add_gradient_orthogonal_constraints (
356- self , points : np .ndarray , vectors : np .ndarray , w : float = 1.0 , B : float = 0
355+ self ,
356+ points : np .ndarray ,
357+ vectors : np .ndarray ,
358+ w : float = 1.0 ,
359+ B : float = 0 ,
360+ name = "gradient orthogonal" ,
357361 ):
358362 """
359363 constraints scalar field to be orthogonal to a given vector
@@ -372,6 +376,7 @@ def add_gradient_orthogonal_constraints(
372376
373377 """
374378 if points .shape [0 ] > 0 :
379+
375380 # calculate unit vector for orientation data
376381 node_idx , inside = self .support .position_to_cell_corners (points [:, :3 ])
377382 # calculate unit vector for node gradients
@@ -401,9 +406,7 @@ def add_gradient_orthogonal_constraints(
401406 # dot product of vector and element gradient = 0
402407 A = np .einsum ("ij,ijk->ik" , vectors [inside , :3 ], T )
403408 B = np .zeros (points [inside , :].shape [0 ]) + B
404- self .add_constraints_to_least_squares (
405- A , B , idc [inside , :], w = w * self .vol , name = "gradient orthogonal"
406- )
409+ self .add_constraints_to_least_squares (A , B , idc [inside , :], w = w , name = name )
407410 if np .sum (inside ) <= 0 :
408411 logger .warning (
409412 f"{ np .sum (~ inside )} \
@@ -460,7 +463,7 @@ def assemble_inner(self, operator, w):
460463 a [inside , :],
461464 B [inside ],
462465 idc [inside , :],
463- w = w * self . vol ,
466+ w = w ,
464467 name = "regularisation" ,
465468 )
466469 return
0 commit comments