@@ -30,8 +30,6 @@ class BaseRegularization(BaseObjectiveFunction):
3030 :param weights: Weight multipliers to customize the least-squares function.
3131 """
3232
33- _model = None
34-
3533 def __init__ (
3634 self ,
3735 mesh : RegularizationMesh | BaseMesh ,
@@ -51,6 +49,8 @@ def __init__(
5149 f"Value of type { type (mesh )} provided."
5250 )
5351
52+ self ._model = None
53+ self ._parent = None
5454 self ._regularization_mesh = mesh
5555 self ._weights = {}
5656
@@ -136,6 +136,23 @@ def mapping(self, mapping: maps.IdentityMap):
136136 )
137137 self ._mapping = mapping
138138
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+
139156 @property
140157 def units (self ) -> str | None :
141158 """Specify the model units. Special care given to 'radian' values"""
@@ -555,10 +572,7 @@ def _cell_distances(self):
555572 """
556573 Distances between cell centers for the cell center difference.
557574 """
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 } " )
562576
563577 @property
564578 def orientation (self ):
@@ -784,6 +798,10 @@ def __init__(
784798 else :
785799 objfcts = kwargs .pop ("objfcts" )
786800 super ().__init__ (objfcts = objfcts , ** kwargs )
801+
802+ for fun in objfcts :
803+ fun .parent = self
804+
787805 self .mapping = mapping
788806 self .reference_model = reference_model
789807 self .reference_model_in_smooth = reference_model_in_smooth
0 commit comments