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
12 changes: 6 additions & 6 deletions doc/source/_static/dpf_operators.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
###############################################################################
# Get the rotation matrix of the LCS ID 12.
# The first 9 values in the ``cs`` output is the rotation matrix.
cs = model.operator(r"mapdl::rst::CS")
cs = dpf.operators.result.coordinate_system()
cs.inputs.data_sources.connect(model)
cs.inputs.cs_id.connect(12)
cs_rot_mat = cs.outputs.field.get_data().data.T[0:9]

Expand Down
75 changes: 68 additions & 7 deletions src/ansys/dpf/core/operators/math/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,27 @@


class scale(Operator):
"""Scales a field by a constant factor.
"""Scales a field by a constant factor. This factor can be a scalar or a
vector, where each value of the vector represents a scaler per
component. Number of the components are corresponding to the input
field dimensionality

Parameters
----------
field : Field or FieldsContainer
Field or fields container with only one field
is expected
ponderation : float or Field
Double/field scoped on overall
Double/field/vector of doubles. when scoped
on overall, same value(s) applied on
all the data, when scoped elsewhere,
corresponding values will be
multiplied due to the scoping
boolean : bool, optional
Default is false. if set to true, output of
scale is made dimensionless
algorithm : int, optional
Default is 0 use mkl. if set to 1, don't


Examples
Expand All @@ -40,20 +49,29 @@ class scale(Operator):
>>> op.inputs.ponderation.connect(my_ponderation)
>>> my_boolean = bool()
>>> op.inputs.boolean.connect(my_boolean)
>>> my_algorithm = int()
>>> op.inputs.algorithm.connect(my_algorithm)

>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.math.scale(
... field=my_field,
... ponderation=my_ponderation,
... boolean=my_boolean,
... algorithm=my_algorithm,
... )

>>> # Get output data
>>> result_field = op.outputs.field()
"""

def __init__(
self, field=None, ponderation=None, boolean=None, config=None, server=None
self,
field=None,
ponderation=None,
boolean=None,
algorithm=None,
config=None,
server=None,
):
super().__init__(name="scale", config=config, server=server)
self._inputs = InputsScale(self)
Expand All @@ -64,10 +82,15 @@ def __init__(
self.inputs.ponderation.connect(ponderation)
if boolean is not None:
self.inputs.boolean.connect(boolean)
if algorithm is not None:
self.inputs.algorithm.connect(algorithm)

@staticmethod
def _spec():
description = """Scales a field by a constant factor."""
description = """Scales a field by a constant factor. This factor can be a scalar or a
vector, where each value of the vector represents a scaler
per component. Number of the components are corresponding
to the input field dimensionality"""
spec = Specification(
description=description,
map_input_pin_spec={
Expand All @@ -80,9 +103,13 @@ def _spec():
),
1: PinSpecification(
name="ponderation",
type_names=["double", "field"],
type_names=["double", "field", "vector<double>"],
optional=False,
document="""Double/field scoped on overall""",
document="""Double/field/vector of doubles. when scoped
on overall, same value(s) applied on
all the data, when scoped elsewhere,
corresponding values will be
multiplied due to the scoping""",
),
2: PinSpecification(
name="boolean",
Expand All @@ -91,6 +118,12 @@ def _spec():
document="""Default is false. if set to true, output of
scale is made dimensionless""",
),
3: PinSpecification(
name="algorithm",
type_names=["int32"],
optional=True,
document="""Default is 0 use mkl. if set to 1, don't""",
),
},
map_output_pin_spec={
0: PinSpecification(
Expand Down Expand Up @@ -154,6 +187,8 @@ class InputsScale(_Inputs):
>>> op.inputs.ponderation.connect(my_ponderation)
>>> my_boolean = bool()
>>> op.inputs.boolean.connect(my_boolean)
>>> my_algorithm = int()
>>> op.inputs.algorithm.connect(my_algorithm)
"""

def __init__(self, op: Operator):
Expand All @@ -164,6 +199,8 @@ def __init__(self, op: Operator):
self._inputs.append(self._ponderation)
self._boolean = Input(scale._spec().input_pin(2), 2, op, -1)
self._inputs.append(self._boolean)
self._algorithm = Input(scale._spec().input_pin(3), 3, op, -1)
self._inputs.append(self._algorithm)

@property
def field(self):
Expand All @@ -190,7 +227,11 @@ def field(self):
def ponderation(self):
"""Allows to connect ponderation input to the operator.

Double/field scoped on overall
Double/field/vector of doubles. when scoped
on overall, same value(s) applied on
all the data, when scoped elsewhere,
corresponding values will be
multiplied due to the scoping

Parameters
----------
Expand Down Expand Up @@ -227,6 +268,26 @@ def boolean(self):
"""
return self._boolean

@property
def algorithm(self):
"""Allows to connect algorithm input to the operator.

Default is 0 use mkl. if set to 1, don't

Parameters
----------
my_algorithm : int

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.math.scale()
>>> op.inputs.algorithm.connect(my_algorithm)
>>> # or
>>> op.inputs.algorithm(my_algorithm)
"""
return self._algorithm


class OutputsScale(_Outputs):
"""Intermediate class used to get outputs from
Expand Down
90 changes: 76 additions & 14 deletions src/ansys/dpf/core/operators/math/scale_fc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,27 @@


class scale_fc(Operator):
"""Scales a field by a constant factor.
"""Scales a fields container by a constant factor. This factor can be a
scalar, a vector a field, a fields container, where each value of
the vector represents a scaler per component. Number of the
components are corresponding to the input field dimensionality

Parameters
----------
fields_container : FieldsContainer
Field or fields container with only one field
is expected
ponderation : float or Field
Double/field scoped on overall
Fields container to be scaled
ponderation : float or Field or FieldsContainer
Double/vector of
doubles/field/fieldscontainer. when
scoped on overall, same value(s)
applied on all the data, when scoped
elsewhere, corresponding values will
be multiplied due to the scoping
boolean : bool, optional
Default is false. if set to true, output of
scale is made dimensionless
algorithm : int, optional
Default is 0 use mkl. if set to 1, don't


Examples
Expand All @@ -40,12 +49,15 @@ class scale_fc(Operator):
>>> op.inputs.ponderation.connect(my_ponderation)
>>> my_boolean = bool()
>>> op.inputs.boolean.connect(my_boolean)
>>> my_algorithm = int()
>>> op.inputs.algorithm.connect(my_algorithm)

>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.math.scale_fc(
... fields_container=my_fields_container,
... ponderation=my_ponderation,
... boolean=my_boolean,
... algorithm=my_algorithm,
... )

>>> # Get output data
Expand All @@ -57,6 +69,7 @@ def __init__(
fields_container=None,
ponderation=None,
boolean=None,
algorithm=None,
config=None,
server=None,
):
Expand All @@ -69,25 +82,40 @@ def __init__(
self.inputs.ponderation.connect(ponderation)
if boolean is not None:
self.inputs.boolean.connect(boolean)
if algorithm is not None:
self.inputs.algorithm.connect(algorithm)

@staticmethod
def _spec():
description = """Scales a field by a constant factor."""
description = """Scales a fields container by a constant factor. This factor can be a
scalar, a vector a field, a fields container, where each
value of the vector represents a scaler per component.
Number of the components are corresponding to the input
field dimensionality"""
spec = Specification(
description=description,
map_input_pin_spec={
0: PinSpecification(
name="fields_container",
type_names=["fields_container"],
optional=False,
document="""Field or fields container with only one field
is expected""",
document="""Fields container to be scaled""",
),
1: PinSpecification(
name="ponderation",
type_names=["double", "field"],
type_names=[
"double",
"field",
"vector<double>",
"fields_container",
],
optional=False,
document="""Double/field scoped on overall""",
document="""Double/vector of
doubles/field/fieldscontainer. when
scoped on overall, same value(s)
applied on all the data, when scoped
elsewhere, corresponding values will
be multiplied due to the scoping""",
),
2: PinSpecification(
name="boolean",
Expand All @@ -96,6 +124,12 @@ def _spec():
document="""Default is false. if set to true, output of
scale is made dimensionless""",
),
3: PinSpecification(
name="algorithm",
type_names=["int32"],
optional=True,
document="""Default is 0 use mkl. if set to 1, don't""",
),
},
map_output_pin_spec={
0: PinSpecification(
Expand Down Expand Up @@ -159,6 +193,8 @@ class InputsScaleFc(_Inputs):
>>> op.inputs.ponderation.connect(my_ponderation)
>>> my_boolean = bool()
>>> op.inputs.boolean.connect(my_boolean)
>>> my_algorithm = int()
>>> op.inputs.algorithm.connect(my_algorithm)
"""

def __init__(self, op: Operator):
Expand All @@ -169,13 +205,14 @@ def __init__(self, op: Operator):
self._inputs.append(self._ponderation)
self._boolean = Input(scale_fc._spec().input_pin(2), 2, op, -1)
self._inputs.append(self._boolean)
self._algorithm = Input(scale_fc._spec().input_pin(3), 3, op, -1)
self._inputs.append(self._algorithm)

@property
def fields_container(self):
"""Allows to connect fields_container input to the operator.

Field or fields container with only one field
is expected
Fields container to be scaled

Parameters
----------
Expand All @@ -195,11 +232,16 @@ def fields_container(self):
def ponderation(self):
"""Allows to connect ponderation input to the operator.

Double/field scoped on overall
Double/vector of
doubles/field/fieldscontainer. when
scoped on overall, same value(s)
applied on all the data, when scoped
elsewhere, corresponding values will
be multiplied due to the scoping

Parameters
----------
my_ponderation : float or Field
my_ponderation : float or Field or FieldsContainer

Examples
--------
Expand Down Expand Up @@ -232,6 +274,26 @@ def boolean(self):
"""
return self._boolean

@property
def algorithm(self):
"""Allows to connect algorithm input to the operator.

Default is 0 use mkl. if set to 1, don't

Parameters
----------
my_algorithm : int

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.math.scale_fc()
>>> op.inputs.algorithm.connect(my_algorithm)
>>> # or
>>> op.inputs.algorithm(my_algorithm)
"""
return self._algorithm


class OutputsScaleFc(_Outputs):
"""Intermediate class used to get outputs from
Expand Down
8 changes: 4 additions & 4 deletions src/ansys/dpf/core/operators/result/coordinate_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class coordinate_system(Operator):
"""Extracts the Rotation Matrix and Origin of a specific coordinate
system
system.

Parameters
----------
Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(
config=None,
server=None,
):
super().__init__(name="mapdl::rst::CS", config=config, server=server)
super().__init__(name="CS", config=config, server=server)
self._inputs = InputsCoordinateSystem(self)
self._outputs = OutputsCoordinateSystem(self)
if cs_id is not None:
Expand All @@ -69,7 +69,7 @@ def __init__(
@staticmethod
def _spec():
description = """Extracts the Rotation Matrix and Origin of a specific coordinate
system"""
system."""
spec = Specification(
description=description,
map_input_pin_spec={
Expand Down Expand Up @@ -119,7 +119,7 @@ def default_config(server=None):
Server with channel connected to the remote or local instance. When
``None``, attempts to use the global server.
"""
return Operator.default_config(name="mapdl::rst::CS", server=server)
return Operator.default_config(name="CS", server=server)

@property
def inputs(self):
Expand Down
Loading