Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions doc/source/_static/dpf_operators.html

Large diffs are not rendered by default.

39 changes: 27 additions & 12 deletions src/ansys/dpf/core/operators/compression/quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@


class quantization(Operator):
r"""Applies scaling to precision to all the values from field input, then
rounding to the unit.
r"""Scales a field to a given precision threshold, then rounds all the
values to the unit.


Parameters
----------
input_field: Field
Input field
threshold: float
Threshold (precision) desired.
Field to quantize.
threshold: float or Field
Precision threshold desired.
Case double : the threshold is applied on all the input field.
Case field with one value : the threshold is applied on all the input field.
Case field with "numComp" values : each threhsold is applied to the corresponding component of the input field.
Case field with the same number of values than the input field : quantization is performed component-wise.


Returns
-------
Expand Down Expand Up @@ -66,8 +71,8 @@ def __init__(self, input_field=None, threshold=None, config=None, server=None):

@staticmethod
def _spec() -> Specification:
description = r"""Applies scaling to precision to all the values from field input, then
rounding to the unit.
description = r"""Scales a field to a given precision threshold, then rounds all the
values to the unit.
"""
spec = Specification(
description=description,
Expand All @@ -76,13 +81,18 @@ def _spec() -> Specification:
name="input_field",
type_names=["field"],
optional=False,
document=r"""Input field""",
document=r"""Field to quantize.""",
),
1: PinSpecification(
name="threshold",
type_names=["double"],
type_names=["double", "field"],
optional=False,
document=r"""Threshold (precision) desired.""",
document=r"""Precision threshold desired.
Case double : the threshold is applied on all the input field.
Case field with one value : the threshold is applied on all the input field.
Case field with "numComp" values : each threhsold is applied to the corresponding component of the input field.
Case field with the same number of values than the input field : quantization is performed component-wise.
""",
),
},
map_output_pin_spec={
Expand Down Expand Up @@ -165,7 +175,7 @@ def __init__(self, op: Operator):
def input_field(self) -> Input:
r"""Allows to connect input_field input to the operator.

Input field
Field to quantize.

Returns
-------
Expand All @@ -186,7 +196,12 @@ def input_field(self) -> Input:
def threshold(self) -> Input:
r"""Allows to connect threshold input to the operator.

Threshold (precision) desired.
Precision threshold desired.
Case double : the threshold is applied on all the input field.
Case field with one value : the threshold is applied on all the input field.
Case field with "numComp" values : each threhsold is applied to the corresponding component of the input field.
Case field with the same number of values than the input field : quantization is performed component-wise.


Returns
-------
Expand Down
38 changes: 25 additions & 13 deletions src/ansys/dpf/core/operators/compression/quantization_fc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,25 @@


class quantization_fc(Operator):
r"""Applies scaling to precision to all the values from fields container
input, then rounding to the unit.
r"""Scales all the fields of a fields container to a given precision
threshold, then rounds all the values to the unit.


Parameters
----------
input_fc: FieldsContainer
Input fields container
Fields container to be quantized.
threshold: float or Field or FieldsContainer
Threshold (precision) desired.
Precision threshold desired.
Case double : the threshold is applied on all the fields of the input fields container.
Case field with one, numComp or input size values : the threshold is used for each field of the input fields container.
Case fields container : the corresponding threshold field is found by matching label.


Returns
-------
output_fc: FieldsContainer
Scaled and rounded fields container
Quantized fields container.

Examples
--------
Expand Down Expand Up @@ -66,8 +70,8 @@ def __init__(self, input_fc=None, threshold=None, config=None, server=None):

@staticmethod
def _spec() -> Specification:
description = r"""Applies scaling to precision to all the values from fields container
input, then rounding to the unit.
description = r"""Scales all the fields of a fields container to a given precision
threshold, then rounds all the values to the unit.
"""
spec = Specification(
description=description,
Expand All @@ -76,21 +80,25 @@ def _spec() -> Specification:
name="input_fc",
type_names=["fields_container"],
optional=False,
document=r"""Input fields container""",
document=r"""Fields container to be quantized.""",
),
1: PinSpecification(
name="threshold",
type_names=["double", "field", "fields_container"],
optional=False,
document=r"""Threshold (precision) desired.""",
document=r"""Precision threshold desired.
Case double : the threshold is applied on all the fields of the input fields container.
Case field with one, numComp or input size values : the threshold is used for each field of the input fields container.
Case fields container : the corresponding threshold field is found by matching label.
""",
),
},
map_output_pin_spec={
0: PinSpecification(
name="output_fc",
type_names=["fields_container"],
optional=False,
document=r"""Scaled and rounded fields container""",
document=r"""Quantized fields container.""",
),
},
)
Expand Down Expand Up @@ -165,7 +173,7 @@ def __init__(self, op: Operator):
def input_fc(self) -> Input:
r"""Allows to connect input_fc input to the operator.

Input fields container
Fields container to be quantized.

Returns
-------
Expand All @@ -186,7 +194,11 @@ def input_fc(self) -> Input:
def threshold(self) -> Input:
r"""Allows to connect threshold input to the operator.

Threshold (precision) desired.
Precision threshold desired.
Case double : the threshold is applied on all the fields of the input fields container.
Case field with one, numComp or input size values : the threshold is used for each field of the input fields container.
Case fields container : the corresponding threshold field is found by matching label.


Returns
-------
Expand Down Expand Up @@ -225,7 +237,7 @@ def __init__(self, op: Operator):
def output_fc(self) -> Output:
r"""Allows to get output_fc output of the operator

Scaled and rounded fields container
Quantized fields container.

Returns
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class compute_invariant_terms_motion(Operator):
field_coordinates: Field
coordinates of all nodes
nod:
phi_ortho: FieldsContainer, optional
Orthonormalizated modes transformation

Returns
-------
Expand Down Expand Up @@ -78,6 +80,8 @@ class compute_invariant_terms_motion(Operator):
>>> op.inputs.field_coordinates.connect(my_field_coordinates)
>>> my_nod = dpf.()
>>> op.inputs.nod.connect(my_nod)
>>> my_phi_ortho = dpf.FieldsContainer()
>>> op.inputs.phi_ortho.connect(my_phi_ortho)

>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.result.compute_invariant_terms_motion(
Expand All @@ -87,6 +91,7 @@ class compute_invariant_terms_motion(Operator):
... model_data=my_model_data,
... field_coordinates=my_field_coordinates,
... nod=my_nod,
... phi_ortho=my_phi_ortho,
... )

>>> # Get output data
Expand Down Expand Up @@ -117,6 +122,7 @@ def __init__(
model_data=None,
field_coordinates=None,
nod=None,
phi_ortho=None,
config=None,
server=None,
):
Expand All @@ -137,6 +143,8 @@ def __init__(
self.inputs.field_coordinates.connect(field_coordinates)
if nod is not None:
self.inputs.nod.connect(nod)
if phi_ortho is not None:
self.inputs.phi_ortho.connect(phi_ortho)

@staticmethod
def _spec() -> Specification:
Expand Down Expand Up @@ -182,6 +190,12 @@ def _spec() -> Specification:
optional=False,
document=r"""""",
),
6: PinSpecification(
name="phi_ortho",
type_names=["fields_container"],
optional=True,
document=r"""Orthonormalizated modes transformation""",
),
},
map_output_pin_spec={
0: PinSpecification(
Expand Down Expand Up @@ -356,6 +370,8 @@ class InputsComputeInvariantTermsMotion(_Inputs):
>>> op.inputs.field_coordinates.connect(my_field_coordinates)
>>> my_nod = dpf.()
>>> op.inputs.nod.connect(my_nod)
>>> my_phi_ortho = dpf.FieldsContainer()
>>> op.inputs.phi_ortho.connect(my_phi_ortho)
"""

def __init__(self, op: Operator):
Expand Down Expand Up @@ -384,6 +400,10 @@ def __init__(self, op: Operator):
compute_invariant_terms_motion._spec().input_pin(5), 5, op, -1
)
self._inputs.append(self._nod)
self._phi_ortho = Input(
compute_invariant_terms_motion._spec().input_pin(6), 6, op, -1
)
self._inputs.append(self._phi_ortho)

@property
def rom_matrices(self) -> Input:
Expand Down Expand Up @@ -509,6 +529,27 @@ def nod(self) -> Input:
"""
return self._nod

@property
def phi_ortho(self) -> Input:
r"""Allows to connect phi_ortho input to the operator.

Orthonormalizated modes transformation

Returns
-------
input:
An Input instance for this pin.

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.result.compute_invariant_terms_motion()
>>> op.inputs.phi_ortho.connect(my_phi_ortho)
>>> # or
>>> op.inputs.phi_ortho(my_phi_ortho)
"""
return self._phi_ortho


class OutputsComputeInvariantTermsMotion(_Outputs):
"""Intermediate class used to get outputs from
Expand Down
32 changes: 32 additions & 0 deletions src/ansys/dpf/core/operators/result/rom_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class rom_data_provider(Operator):
ids of master nodes
meshed_region: MeshedRegion
expanded meshed region.
phi_ortho: FieldsContainer, optional
Orthonormalized mode shape transformation

Examples
--------
Expand Down Expand Up @@ -108,6 +110,7 @@ class rom_data_provider(Operator):
>>> result_field_coordinates_and_euler_angles = op.outputs.field_coordinates_and_euler_angles()
>>> result_nod = op.outputs.nod()
>>> result_meshed_region = op.outputs.meshed_region()
>>> result_phi_ortho = op.outputs.phi_ortho()
"""

def __init__(
Expand Down Expand Up @@ -261,6 +264,12 @@ def _spec() -> Specification:
optional=False,
document=r"""expanded meshed region.""",
),
10: PinSpecification(
name="phi_ortho",
type_names=["fields_container"],
optional=True,
document=r"""Orthonormalized mode shape transformation""",
),
},
)
return spec
Expand Down Expand Up @@ -550,6 +559,7 @@ class OutputsRomDataProvider(_Outputs):
>>> result_field_coordinates_and_euler_angles = op.outputs.field_coordinates_and_euler_angles()
>>> result_nod = op.outputs.nod()
>>> result_meshed_region = op.outputs.meshed_region()
>>> result_phi_ortho = op.outputs.phi_ortho()
"""

def __init__(self, op: Operator):
Expand All @@ -576,6 +586,8 @@ def __init__(self, op: Operator):
self._outputs.append(self._nod)
self._meshed_region = Output(rom_data_provider._spec().output_pin(9), 9, op)
self._outputs.append(self._meshed_region)
self._phi_ortho = Output(rom_data_provider._spec().output_pin(10), 10, op)
self._outputs.append(self._phi_ortho)

@property
def rom_matrices(self) -> Output:
Expand Down Expand Up @@ -774,3 +786,23 @@ def meshed_region(self) -> Output:
>>> result_meshed_region = op.outputs.meshed_region()
"""
return self._meshed_region

@property
def phi_ortho(self) -> Output:
r"""Allows to get phi_ortho output of the operator

Orthonormalized mode shape transformation

Returns
-------
output:
An Output instance for this pin.

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.result.rom_data_provider()
>>> # Get the output from op.outputs. ...
>>> result_phi_ortho = op.outputs.phi_ortho()
"""
return self._phi_ortho
Binary file modified src/ansys/dpf/gatebin/Ans.Dpf.GrpcClient.dll
Binary file not shown.
Binary file modified src/ansys/dpf/gatebin/DPFClientAPI.dll
Binary file not shown.
Loading