@@ -46,6 +46,10 @@ class compute_residual_and_error(Operator):
4646 pin2 selection
4747 1 for l1, ie sum(abs(xi)),
4848 2 for l2, ie sqrt(sum((xi^2))
49+ field_reference : int, optional
50+ Field reference for the normalization step,
51+ default: 0 for entry 1, 1 for
52+ residuals - optional
4953 field_or_fields_container2 : Field or FieldsContainer, optional
5054 Field or fields container of same
5155 dimensionality as entry 1 - optional
@@ -65,6 +69,8 @@ class compute_residual_and_error(Operator):
6569 >>> op.inputs.normalization_type.connect(my_normalization_type)
6670 >>> my_norm_calculation_type = int()
6771 >>> op.inputs.norm_calculation_type.connect(my_norm_calculation_type)
72+ >>> my_field_reference = int()
73+ >>> op.inputs.field_reference.connect(my_field_reference)
6874 >>> my_field_or_fields_container2 = dpf.Field()
6975 >>> op.inputs.field_or_fields_container2.connect(my_field_or_fields_container2)
7076
@@ -73,19 +79,23 @@ class compute_residual_and_error(Operator):
7379 ... field_or_fields_container1=my_field_or_fields_container1,
7480 ... normalization_type=my_normalization_type,
7581 ... norm_calculation_type=my_norm_calculation_type,
82+ ... field_reference=my_field_reference,
7683 ... field_or_fields_container2=my_field_or_fields_container2,
7784 ... )
7885
7986 >>> # Get output data
8087 >>> result_residuals = op.outputs.residuals()
8188 >>> result_error = op.outputs.error()
89+ >>> result_residuals_normalization_factor = op.outputs.residuals_normalization_factor()
90+ >>> result_error_normalization_factor = op.outputs.error_normalization_factor()
8291 """
8392
8493 def __init__ (
8594 self ,
8695 field_or_fields_container1 = None ,
8796 normalization_type = None ,
8897 norm_calculation_type = None ,
98+ field_reference = None ,
8999 field_or_fields_container2 = None ,
90100 config = None ,
91101 server = None ,
@@ -99,6 +109,8 @@ def __init__(
99109 self .inputs .normalization_type .connect (normalization_type )
100110 if norm_calculation_type is not None :
101111 self .inputs .norm_calculation_type .connect (norm_calculation_type )
112+ if field_reference is not None :
113+ self .inputs .field_reference .connect (field_reference )
102114 if field_or_fields_container2 is not None :
103115 self .inputs .field_or_fields_container2 .connect (field_or_fields_container2 )
104116
@@ -151,6 +163,14 @@ def _spec():
151163 2 for l2, ie sqrt(sum((xi^2))""" ,
152164 ),
153165 3 : PinSpecification (
166+ name = "field_reference" ,
167+ type_names = ["int32" ],
168+ optional = True ,
169+ document = """Field reference for the normalization step,
170+ default: 0 for entry 1, 1 for
171+ residuals - optional""" ,
172+ ),
173+ 4 : PinSpecification (
154174 name = "field_or_fields_container2" ,
155175 type_names = ["field" , "fields_container" ],
156176 optional = True ,
@@ -175,6 +195,18 @@ def _spec():
175195 document = """1: error as a field or a field container
176196 depending on the entry's type.""" ,
177197 ),
198+ 2 : PinSpecification (
199+ name = "residuals_normalization_factor" ,
200+ type_names = ["field" , "fields_container" ],
201+ optional = False ,
202+ document = """2: factor used for residual normalization""" ,
203+ ),
204+ 3 : PinSpecification (
205+ name = "error_normalization_factor" ,
206+ type_names = ["field" , "fields_container" ],
207+ optional = False ,
208+ document = """3: factor used for error norm normalization""" ,
209+ ),
178210 },
179211 )
180212 return spec
@@ -230,6 +262,8 @@ class InputsComputeResidualAndError(_Inputs):
230262 >>> op.inputs.normalization_type.connect(my_normalization_type)
231263 >>> my_norm_calculation_type = int()
232264 >>> op.inputs.norm_calculation_type.connect(my_norm_calculation_type)
265+ >>> my_field_reference = int()
266+ >>> op.inputs.field_reference.connect(my_field_reference)
233267 >>> my_field_or_fields_container2 = dpf.Field()
234268 >>> op.inputs.field_or_fields_container2.connect(my_field_or_fields_container2)
235269 """
@@ -248,9 +282,13 @@ def __init__(self, op: Operator):
248282 compute_residual_and_error ._spec ().input_pin (2 ), 2 , op , - 1
249283 )
250284 self ._inputs .append (self ._norm_calculation_type )
251- self ._field_or_fields_container2 = Input (
285+ self ._field_reference = Input (
252286 compute_residual_and_error ._spec ().input_pin (3 ), 3 , op , - 1
253287 )
288+ self ._inputs .append (self ._field_reference )
289+ self ._field_or_fields_container2 = Input (
290+ compute_residual_and_error ._spec ().input_pin (4 ), 4 , op , - 1
291+ )
254292 self ._inputs .append (self ._field_or_fields_container2 )
255293
256294 @property
@@ -326,6 +364,28 @@ def norm_calculation_type(self):
326364 """
327365 return self ._norm_calculation_type
328366
367+ @property
368+ def field_reference (self ):
369+ """Allows to connect field_reference input to the operator.
370+
371+ Field reference for the normalization step,
372+ default: 0 for entry 1, 1 for
373+ residuals - optional
374+
375+ Parameters
376+ ----------
377+ my_field_reference : int
378+
379+ Examples
380+ --------
381+ >>> from ansys.dpf import core as dpf
382+ >>> op = dpf.operators.math.compute_residual_and_error()
383+ >>> op.inputs.field_reference.connect(my_field_reference)
384+ >>> # or
385+ >>> op.inputs.field_reference(my_field_reference)
386+ """
387+ return self ._field_reference
388+
329389 @property
330390 def field_or_fields_container2 (self ):
331391 """Allows to connect field_or_fields_container2 input to the operator.
@@ -359,6 +419,8 @@ class OutputsComputeResidualAndError(_Outputs):
359419 >>> # Connect inputs : op.inputs. ...
360420 >>> result_residuals = op.outputs.residuals()
361421 >>> result_error = op.outputs.error()
422+ >>> result_residuals_normalization_factor = op.outputs.residuals_normalization_factor()
423+ >>> result_error_normalization_factor = op.outputs.error_normalization_factor()
362424 """
363425
364426 def __init__ (self , op : Operator ):
@@ -395,3 +457,35 @@ def __init__(self, op: Operator):
395457 op ,
396458 )
397459 self ._outputs .append (self .error_as_fields_container )
460+ self .residuals_normalization_factor_as_field = Output (
461+ _modify_output_spec_with_one_type (
462+ compute_residual_and_error ._spec ().output_pin (2 ), "field"
463+ ),
464+ 2 ,
465+ op ,
466+ )
467+ self ._outputs .append (self .residuals_normalization_factor_as_field )
468+ self .residuals_normalization_factor_as_fields_container = Output (
469+ _modify_output_spec_with_one_type (
470+ compute_residual_and_error ._spec ().output_pin (2 ), "fields_container"
471+ ),
472+ 2 ,
473+ op ,
474+ )
475+ self ._outputs .append (self .residuals_normalization_factor_as_fields_container )
476+ self .error_normalization_factor_as_field = Output (
477+ _modify_output_spec_with_one_type (
478+ compute_residual_and_error ._spec ().output_pin (3 ), "field"
479+ ),
480+ 3 ,
481+ op ,
482+ )
483+ self ._outputs .append (self .error_normalization_factor_as_field )
484+ self .error_normalization_factor_as_fields_container = Output (
485+ _modify_output_spec_with_one_type (
486+ compute_residual_and_error ._spec ().output_pin (3 ), "fields_container"
487+ ),
488+ 3 ,
489+ op ,
490+ )
491+ self ._outputs .append (self .error_normalization_factor_as_fields_container )
0 commit comments