@@ -30,8 +30,6 @@ class BaseRegularization(BaseObjectiveFunction):
30
30
:param weights: Weight multipliers to customize the least-squares function.
31
31
"""
32
32
33
- _model = None
34
-
35
33
def __init__ (
36
34
self ,
37
35
mesh : RegularizationMesh | BaseMesh ,
@@ -51,6 +49,8 @@ def __init__(
51
49
f"Value of type { type (mesh )} provided."
52
50
)
53
51
52
+ self ._model = None
53
+ self ._parent = None
54
54
self ._regularization_mesh = mesh
55
55
self ._weights = {}
56
56
@@ -136,6 +136,23 @@ def mapping(self, mapping: maps.IdentityMap):
136
136
)
137
137
self ._mapping = mapping
138
138
139
+ @property
140
+ def parent (self ):
141
+ """
142
+ The parent objective function
143
+ """
144
+ return self ._parent
145
+
146
+ @parent .setter
147
+ def parent (self , parent ):
148
+ combo_class = ComboObjectiveFunction
149
+ if not isinstance (parent , combo_class ):
150
+ raise TypeError (
151
+ f"Invalid parent of type '{ parent .__class__ .__name__ } '. "
152
+ f"Parent must be a { combo_class .__name__ } ."
153
+ )
154
+ self ._parent = parent
155
+
139
156
@property
140
157
def units (self ) -> str | None :
141
158
"""Specify the model units. Special care given to 'radian' values"""
@@ -555,10 +572,7 @@ def _cell_distances(self):
555
572
"""
556
573
Distances between cell centers for the cell center difference.
557
574
"""
558
- if self .__cell_distances is None :
559
- self .__cell_distances = 1.0 / np .max (self .cell_gradient , axis = 1 ).data
560
-
561
- return self .__cell_distances
575
+ return getattr (self .regularization_mesh , f"cell_distances_{ self .orientation } " )
562
576
563
577
@property
564
578
def orientation (self ):
@@ -784,6 +798,10 @@ def __init__(
784
798
else :
785
799
objfcts = kwargs .pop ("objfcts" )
786
800
super ().__init__ (objfcts = objfcts , ** kwargs )
801
+
802
+ for fun in objfcts :
803
+ fun .parent = self
804
+
787
805
self .mapping = mapping
788
806
self .reference_model = reference_model
789
807
self .reference_model_in_smooth = reference_model_in_smooth
0 commit comments