@@ -42,7 +42,7 @@ def __init__(self, support, data={}, c=None, up_to_date=False):
4242
4343 self .shape = "rectangular"
4444 if self .shape == "square" :
45- self .B = np .zeros (self .nx )
45+ self .B = np .zeros (self .dof )
4646 self .c_ = 0
4747
4848 self .solver = "cg"
@@ -60,7 +60,7 @@ def __init__(self, support, data={}, c=None, up_to_date=False):
6060 self .non_linear_constraints = []
6161 self .constraints = {}
6262 self .interpolation_weights = {}
63- logger .info ("Creating discrete interpolator with {} degrees of freedom" .format (self .nx ))
63+ logger .info ("Creating discrete interpolator with {} degrees of freedom" .format (self .dof ))
6464 self .type = InterpolatorType .BASE_DISCRETE
6565
6666 def set_nelements (self , nelements : int ) -> int :
@@ -78,7 +78,7 @@ def n_elements(self) -> int:
7878 return self .support .n_elements
7979
8080 @property
81- def nx (self ) -> int :
81+ def dof (self ) -> int :
8282 """Number of degrees of freedom for the interpolator
8383
8484 Returns
@@ -125,7 +125,7 @@ def set_region(self, region=None):
125125 # self.region_function = region
126126 logger .info (
127127 "Cannot use region at the moment. Interpolation now uses region and has {} degrees of freedom" .format (
128- self .nx
128+ self .dof
129129 )
130130 )
131131
@@ -175,7 +175,7 @@ def reset(self):
175175 """
176176 self .constraints = {}
177177 self .c_ = 0
178- self .regularisation_scale = np .ones (self .nx )
178+ self .regularisation_scale = np .ones (self .dof )
179179 logger .info ("Resetting interpolation constraints" )
180180
181181 def add_constraints_to_least_squares (self , A , B , idc , w = 1.0 , name = "undefined" ):
@@ -245,7 +245,7 @@ def add_constraints_to_least_squares(self, A, B, idc, w=1.0, name="undefined"):
245245 rows = np .tile (rows , (A .shape [- 1 ], 1 )).T
246246 self .constraints [name ] = {
247247 'matrix' : sparse .coo_matrix (
248- (A .flatten (), (rows .flatten (), idc .flatten ())), shape = (n_rows , self .nx )
248+ (A .flatten (), (rows .flatten (), idc .flatten ())), shape = (n_rows , self .dof )
249249 ).tocsc (),
250250 'b' : B .flatten (),
251251 'w' : w ,
@@ -286,7 +286,7 @@ def add_inequality_constraints_to_matrix(
286286 A : numpy array
287287 matrix of coefficients
288288 bounds : numpy array
289- nx3 lower, upper, 1
289+ n*3 lower, upper, 1
290290 idc : numpy array
291291 index of constraints in the matrix
292292 Returns
@@ -296,14 +296,14 @@ def add_inequality_constraints_to_matrix(
296296 # map from mesh node index to region node index
297297 gi = np .zeros (self .support .n_nodes , dtype = int )
298298 gi [:] = - 1
299- gi [self .region ] = np .arange (0 , self .nx , dtype = int )
299+ gi [self .region ] = np .arange (0 , self .dof , dtype = int )
300300 idc = gi [idc ]
301301 rows = np .arange (0 , idc .shape [0 ])
302302 rows = np .tile (rows , (A .shape [- 1 ], 1 )).T
303303
304304 self .ineq_constraints [name ] = {
305305 'matrix' : sparse .coo_matrix (
306- (A .flatten (), (rows .flatten (), idc .flatten ())), shape = (rows .shape [0 ], self .nx )
306+ (A .flatten (), (rows .flatten (), idc .flatten ())), shape = (rows .shape [0 ], self .dof )
307307 ).tocsc (),
308308 "bounds" : bounds ,
309309 }
@@ -431,7 +431,7 @@ def add_inequality_feature(
431431 np .ones ((value .shape [0 ], 1 )),
432432 l ,
433433 u ,
434- np .arange (0 , self .nx , dtype = int ),
434+ np .arange (0 , self .dof , dtype = int ),
435435 )
436436
437437 def add_equality_constraints (self , node_idx , values , name = "undefined" ):
@@ -454,7 +454,7 @@ def add_equality_constraints(self, node_idx, values, name="undefined"):
454454 # map from mesh node index to region node index
455455 gi = np .zeros (self .support .n_nodes )
456456 gi [:] = - 1
457- gi [self .region ] = np .arange (0 , self .nx )
457+ gi [self .region ] = np .arange (0 , self .dof )
458458 idc = gi [node_idx ]
459459 outside = ~ (idc == - 1 )
460460
@@ -515,7 +515,7 @@ def add_equality_block(self, A, B):
515515 if len (self .equal_constraints ) > 0 :
516516 ATA = A .T .dot (A )
517517 ATB = A .T .dot (B )
518- logger .info (f"Equality block is { self .eq_const_c } x { self .nx } " )
518+ logger .info (f"Equality block is { self .eq_const_c } x { self .dof } " )
519519 # solving constrained least squares using
520520 # | ATA CT | |c| = b
521521 # | C 0 | |y| d
@@ -540,7 +540,7 @@ def add_equality_block(self, A, B):
540540
541541 C = sparse .coo_matrix (
542542 (np .array (a ), (np .array (rows ), cols )),
543- shape = (self .eq_const_c , self .nx ),
543+ shape = (self .eq_const_c , self .dof ),
544544 dtype = float ,
545545 ).tocsr ()
546546
@@ -557,7 +557,7 @@ def build_inequality_matrix(self):
557557 mats .append (c ['matrix' ])
558558 bounds .append (c ['bounds' ])
559559 if len (mats ) == 0 :
560- return sparse .csr_matrix ((0 , self .nx ), dtype = float ), np .zeros ((0 , 3 ))
560+ return sparse .csr_matrix ((0 , self .dof ), dtype = float ), np .zeros ((0 , 3 ))
561561 Q = sparse .vstack (mats )
562562 bounds = np .vstack (bounds )
563563 return Q , bounds
0 commit comments