diff --git a/examples/00-basic/10-math_operations.py b/examples/00-basic/10-math_operations.py index d7bd09599da..8e65fa9face 100644 --- a/examples/00-basic/10-math_operations.py +++ b/examples/00-basic/10-math_operations.py @@ -105,15 +105,15 @@ # ~~~~~~~~~~ # First we define fields. By default, fields represent 3D vectors # so one elementary data is a 3D vector. -# The optional ponderation field is a field which takes one value per entity, +# The optional weights field is a field which takes one value per entity, # so we need to change its dimensionality (1D). num_entities = 3 input_field = dpf.Field(nentities=num_entities) -ponderation_field = dpf.Field(num_entities) -ponderation_field.dimensionality = dpf.Dimensionality([1]) +weights_field = dpf.Field(num_entities) +weights_field.dimensionality = dpf.Dimensionality([1]) input_field.scoping.ids = range(num_entities) -ponderation_field.scoping.ids = range(num_entities) +weights_field.scoping.ids = range(num_entities) ############################################################################### # Fill fields with data. @@ -121,11 +121,11 @@ input_field.data = [-2.0, 2.0, 4.0, -5.0, 0.5, 1.0, 7.0, 3.0, -3.0] ############################################################################### # Three weights, one per entity. -ponderation_field.data = [0.5, 2.0, 0.5] +weights_field.data = [0.5, 2.0, 0.5] ############################################################################### # Retrieve the result. -acc = dpf.operators.math.accumulate(fieldA=input_field, ponderation=ponderation_field) +acc = dpf.operators.math.accumulate(fieldA=input_field, weights=weights_field) output_field = acc.outputs.field() # (-2.0 * 0.5) + (-5.0 * 2.0) + (7.0 * 0.5) = -7.5 diff --git a/examples/01-mathematical-operations/matrix-operations.py b/examples/01-mathematical-operations/matrix-operations.py index 0c0127a2c37..c4afab6a7f5 100644 --- a/examples/01-mathematical-operations/matrix-operations.py +++ b/examples/01-mathematical-operations/matrix-operations.py @@ -94,11 +94,11 @@ # Add a constant # Add 2 to each value in the field -stress_2 = maths.add_constant_fc(fields_container=stress_2, ponderation=2.0).eval() +stress_2 = maths.add_constant_fc(fields_container=stress_2, weights=2.0).eval() # Multiply by a constant # Multiply each value in the field by 3 -stress_3 = maths.scale_fc(fields_container=stress_3, ponderation=3.0).eval() +stress_3 = maths.scale_fc(fields_container=stress_3, weights=3.0).eval() # Add fields containers # Each value of each field is added by the correspondent component of the others fields diff --git a/examples/04-advanced/04-extrapolation_stress_3d.py b/examples/04-advanced/04-extrapolation_stress_3d.py index a61ca2f36b5..9037199643f 100644 --- a/examples/04-advanced/04-extrapolation_stress_3d.py +++ b/examples/04-advanced/04-extrapolation_stress_3d.py @@ -177,7 +177,7 @@ divide.inputs.fieldB.connect(stress_ref_nodal_op) rel_error = dpf.operators.math.scale() rel_error.inputs.field.connect(divide) -rel_error.inputs.ponderation.connect(1.0) +rel_error.inputs.weights.connect(1.0) ############################################################################### # Plot absolute and relative errors. diff --git a/examples/04-advanced/05-extrapolation_strain_2d.py b/examples/04-advanced/05-extrapolation_strain_2d.py index cb83609539f..4f7aa7afd44 100644 --- a/examples/04-advanced/05-extrapolation_strain_2d.py +++ b/examples/04-advanced/05-extrapolation_strain_2d.py @@ -167,7 +167,7 @@ divide.inputs.fieldB.connect(strain_ref_nodal_op) rel_error = dpf.operators.math.scale() rel_error.inputs.field.connect(divide) -rel_error.inputs.ponderation.connect(1.0) +rel_error.inputs.weights.connect(1.0) ############################################################################### # Plot absolute and relative errors. diff --git a/examples/04-advanced/06-stress_gradient_path.py b/examples/04-advanced/06-stress_gradient_path.py index f39ebd718fa..30cde84e76b 100644 --- a/examples/04-advanced/06-stress_gradient_path.py +++ b/examples/04-advanced/06-stress_gradient_path.py @@ -110,7 +110,7 @@ # using :class:`scale ` operator # inwards in the geometry, to get the path direction. # -normal_vec_in_field = ops.math.scale(field=normal_vec_out_field, ponderation=-1.0) +normal_vec_in_field = ops.math.scale(field=normal_vec_out_field, weights=-1.0) normal_vec_in = normal_vec_in_field.outputs.field.get_data().data[0] ############################################################################### # Get nodal coordinates, they serve as the first point on the line. diff --git a/examples/04-advanced/10-asme_secviii_divtwo.py b/examples/04-advanced/10-asme_secviii_divtwo.py index c6628832f0f..ff3897ed22c 100644 --- a/examples/04-advanced/10-asme_secviii_divtwo.py +++ b/examples/04-advanced/10-asme_secviii_divtwo.py @@ -114,7 +114,7 @@ poisson_ratio_correction = 1.3 / 1.5 eppleqvmech_op = dpf.operators.math.scale_fc( - fields_container=eppleqv, ponderation=poisson_ratio_correction + fields_container=eppleqv, weights=poisson_ratio_correction ) eppleqvmech = eppleqvmech_op.outputs.fields_container() @@ -134,23 +134,23 @@ s123 = s123_op.outputs.fields_container() # SVM_scale=SVM*3 ratio = 3.0 -seqvs_op = dpf.operators.math.scale_fc(fields_container=seqv, ponderation=ratio) +seqvs_op = dpf.operators.math.scale_fc(fields_container=seqv, weights=ratio) seqvs = seqvs_op.outputs.fields_container() # S123/SVM*3 sratio_op = dpf.operators.math.component_wise_divide(fieldA=s123, fieldB=seqvs) sratio = sratio_op.outputs.field() # S123/SVM*3-0.33 -sterm_op = dpf.operators.math.add_constant(field=sratio, ponderation=-1 / 3) +sterm_op = dpf.operators.math.add_constant(field=sratio, weights=-1 / 3) sterm = sterm_op.outputs.field() # -alfasl/(1+m2)*stressterm ratio2 = -alfasl / (1 + m2) -expt_op = dpf.operators.math.scale(field=sterm, ponderation=ratio2) +expt_op = dpf.operators.math.scale(field=sterm, weights=ratio2) expt = expt_op.outputs.field() # exp(-alfasl/(1+m2)*stressterm) exp_op = dpf.operators.math.exponential(field=expt) exp = exp_op.outputs.field() # elu*exp(-alfasl/(1+m2)*stressterm) -strainlimit_op = dpf.operators.math.scale(field=exp, ponderation=m2) +strainlimit_op = dpf.operators.math.scale(field=exp, weights=m2) strainlimit = strainlimit_op.outputs.field() ############################################################################### diff --git a/examples/04-advanced/13-manage_licensing.py b/examples/04-advanced/13-manage_licensing.py index a339a04644d..602592abcdc 100644 --- a/examples/04-advanced/13-manage_licensing.py +++ b/examples/04-advanced/13-manage_licensing.py @@ -68,7 +68,7 @@ print(field) # Instantiate an Entry (not licensed) DPF operator -op_entry = dpf.operators.math.add_constant(field=field, ponderation=2.0, server=server) +op_entry = dpf.operators.math.add_constant(field=field, weights=2.0, server=server) # Instantiate a Premium (licensed) DPF operator op_premium = dpf.operators.filter.field_high_pass(field=field, threshold=0.0, server=server) diff --git a/examples/05-file-IO/04-basic-load-file.py b/examples/05-file-IO/04-basic-load-file.py index 77aa2aece24..add1880f434 100644 --- a/examples/05-file-IO/04-basic-load-file.py +++ b/examples/05-file-IO/04-basic-load-file.py @@ -120,7 +120,7 @@ divide.inputs.fieldB.connect(fc_out) scale = dpf.operators.math.scale() scale.inputs.field.connect(divide) -scale.inputs.ponderation.connect(100.0) +scale.inputs.weights.connect(100.0) rel_error = scale.eval() ############################################################################### diff --git a/examples/06-plotting/02-solution_combination.py b/examples/06-plotting/02-solution_combination.py index f849df07437..9837e32a0aa 100644 --- a/examples/06-plotting/02-solution_combination.py +++ b/examples/06-plotting/02-solution_combination.py @@ -74,7 +74,7 @@ field_lc2 = stress_tensor.outputs.fields_container()[1] # Scale LC2 to -1. -stress_tensor_lc2_sc = dpf.operators.math.scale(field=field_lc2, ponderation=-1.0) +stress_tensor_lc2_sc = dpf.operators.math.scale(field=field_lc2, weights=-1.0) ############################################################################### # Add load cases. diff --git a/examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py b/examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py index db13a8ac9d4..f7ddf086331 100644 --- a/examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py +++ b/examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py @@ -86,9 +86,9 @@ ############################################################################### # Transform rotated nodal coordinates field along rotated position vector # ``pos_vec_rot``: -pos_vec_rot_neg_f = dpf.operators.math.scale(field=pos_vec_rot, ponderation=-1.0) +pos_vec_rot_neg_f = dpf.operators.math.scale(field=pos_vec_rot, weights=-1.0) pos_vec_rot_neg = pos_vec_rot_neg_f.outputs.field.get_data().data_as_list -ncoord_translate = dpf.operators.math.add_constant(field=ncoord_rot_f, ponderation=pos_vec_rot_neg) +ncoord_translate = dpf.operators.math.add_constant(field=ncoord_rot_f, weights=pos_vec_rot_neg) ############################################################################### # Get the nodal coordinates field ``ncoord_lcs_f`` in LCS: ncoord_lcs_f = ncoord_translate.outputs.field.get_data() diff --git a/examples/16-maths-ops/01-matrix-operations.py b/examples/16-maths-ops/01-matrix-operations.py index 0c0127a2c37..c4afab6a7f5 100644 --- a/examples/16-maths-ops/01-matrix-operations.py +++ b/examples/16-maths-ops/01-matrix-operations.py @@ -94,11 +94,11 @@ # Add a constant # Add 2 to each value in the field -stress_2 = maths.add_constant_fc(fields_container=stress_2, ponderation=2.0).eval() +stress_2 = maths.add_constant_fc(fields_container=stress_2, weights=2.0).eval() # Multiply by a constant # Multiply each value in the field by 3 -stress_3 = maths.scale_fc(fields_container=stress_3, ponderation=3.0).eval() +stress_3 = maths.scale_fc(fields_container=stress_3, weights=3.0).eval() # Add fields containers # Each value of each field is added by the correspondent component of the others fields diff --git a/src/ansys/dpf/core/animation.py b/src/ansys/dpf/core/animation.py index 3739245fa03..3ba200c5438 100644 --- a/src/ansys/dpf/core/animation.py +++ b/src/ansys/dpf/core/animation.py @@ -118,14 +118,14 @@ def animate_mode( scaling_op.inputs.field.connect(field_mode) wf.add_operators([scaling_op]) - wf.set_input_name("ponderation", scaling_op.inputs.ponderation) + wf.set_input_name("weights", scaling_op.inputs.weights) wf.set_output_name("field", scaling_op.outputs.field) anim = Animator(workflow=wf, **kwargs) return anim.animate( loop_over=loop_over, - input_name="ponderation", + input_name="weights", output_name="field", save_as=save_as, mode_number=mode_number, diff --git a/src/ansys/dpf/core/meshed_region.py b/src/ansys/dpf/core/meshed_region.py index 193798edc69..80ba95ad61e 100644 --- a/src/ansys/dpf/core/meshed_region.py +++ b/src/ansys/dpf/core/meshed_region.py @@ -493,7 +493,7 @@ def deform_by(self, deform_by, scale_factor=1.0): deform_by = deform_by[0] if deform_by.unit != self.unit: unit_convert(deform_by, self.unit) - scale_op = scale(field=deform_by, ponderation=scale_factor) + scale_op = scale(field=deform_by, weights=scale_factor) return add(fieldA=self.nodes.coordinates_field, fieldB=scale_op.outputs.field).eval() def _as_vtk(self, coordinates=None, as_linear=True, include_ids=False): diff --git a/src/ansys/dpf/core/operators/translator.py b/src/ansys/dpf/core/operators/translator.py new file mode 100644 index 00000000000..afdfeb00d37 --- /dev/null +++ b/src/ansys/dpf/core/operators/translator.py @@ -0,0 +1,45 @@ +# Copyright (C) 2020 - 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +class Markdown2RstTranslator: + """A translator class for Markdown to RST text conversion.""" + def __init__(self): + import pypandoc + + self._convert = pypandoc.convert_text + + # import mistune + # from mistune.renderers.rst import RSTRenderer + # + # md2rst_converter = mistune.create_markdown(renderer=RSTRenderer()) + + def convert(self, text:str) -> str: + """Convert the Markdown text in input to RST.""" + return self._convert( + source=text, + to="rst", + format="md", + verify_format=False, # Improves performance but does not check validity of format + extra_args=["--eol=lf"], + ) + # return md2rst_converter(specification.description) diff --git a/tests/test_animation.py b/tests/test_animation.py index 4c95f8c71f4..9db70b56074 100644 --- a/tests/test_animation.py +++ b/tests/test_animation.py @@ -27,6 +27,10 @@ from ansys.dpf import core as dpf from ansys.dpf.core import animation, examples, misc +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0 + +if not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0: + pytest.skip("skipping retro temporarily", allow_module_level=True) if misc.module_exists("pyvista"): HAS_PYVISTA = True diff --git a/tests/test_animator.py b/tests/test_animator.py index 402e4f66176..b0fedf5e198 100644 --- a/tests/test_animator.py +++ b/tests/test_animator.py @@ -27,6 +27,10 @@ from ansys.dpf import core as dpf from ansys.dpf.core import Workflow, examples, misc +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0 + +if not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0: + pytest.skip("skipping retro temporarily", allow_module_level=True) if misc.module_exists("pyvista"): HAS_PYVISTA = True