Changing field mesh scoping

Options

I have created a field in DPF and now I would like to limit to a subset of the mesh on which it was originally created without recomputing it.

I have tried:

ns_scope = dpf.mesh_scoping_factory.named_selection_scoping('BLADE_N', model)

subset_op = dpf.operators.scoping.rescope() # operator instantiation
subset_op.inputs.fields.connect(stress_skin_nodal)
subset_op.inputs.mesh_scoping.connect(ns_scope)
subset_op.inputs.default_value.connect(0.0)
subset_op.eval()

Which generates an error:

--------------------------------------------------------------------------
DPFServerException                        Traceback (most recent call last)
Cell In[160], line 8
      5 subset_op.inputs.mesh_scoping.connect(ns_scope)
      6 subset_op.inputs.default_value.connect(0.0)
----> 8 subset_op.eval()

File c:\users\e092220\.venv\3.9.6\fcdslib-ansys22r2\lib\site-packages\ansys\dpf\core\dpf_operator.py:626, in Operator.eval(self, pin)
    624 if not pin:
    625     if self.outputs != None and len(self.outputs._outputs) > 0:
--> 626         return self.outputs._outputs[0]()
    627     else:
    628         self.run()

File c:\users\e092220\.venv\3.9.6\fcdslib-ansys22r2\lib\site-packages\ansys\dpf\core\outputs.py:58, in Output.__call__(self)
     57 def __call__(self):
---> 58     return self.get_data()

File c:\users\e092220\.venv\3.9.6\fcdslib-ansys22r2\lib\site-packages\ansys\dpf\core\outputs.py:55, in Output.get_data(self)
     52 elif type_output == "streams_container":
     53     type_output = types.streams_container
---> 55 return self._operator.get_output(self._pin, type_output)

File c:\users\e092220\.venv\3.9.6\fcdslib-ansys22r2\lib\site-packages\ansys\dpf\core\dpf_operator.py:455, in Operator.get_output(self, pin, output_type)
    453 if len(type_tuple) >= 3:
    454     if isinstance(type_tuple[2], str):
--> 455         parameters = {type_tuple[2]: type_tuple[1](self, pin)}
    456         out = output_type(**parameters, server=self._server)
    457     else:

File c:\users\e092220\.venv\3.9.6\fcdslib-ansys22r2\lib\site-packages\ansys\dpf\gate\generated\operator_capi.py:377, in OperatorCAPI.operator_getoutput_fields_container(op, iOutput)
    375 res = capi.dll.Operator_getoutput_FieldsContainer(op._internal_obj, utils.to_int32(iOutput), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
    376 if errorSize.value != 0:
--> 377 	raise errors.DPFServerException(sError.value)
    378 return res

DPFServerException: The requested Data format"fields_container" is not valid for this pin

Both the field and new scope are nodal based. Using DPF 0.7.2 and ANSYS 2022R2 on Windows.

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 416
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    edited April 2023
    Options

    Hi @cvaero,

    Based on the error, I suspect the stress_skin_nodal has fields_container as an output. As per the documentation, this shouldn't be an issue with rescope operator but just to be sure, please try using rescope_fcto see if you get the same error.

  • cvaero
    cvaero Member Posts: 8
    Name Dropper First Comment
    Options

    Making the change still results in an error:

    ns_scope = dpf.mesh_scoping_factory.named_selection_scoping('BLADE_N', model)
    
    subset_op = dpf.operators.scoping.rescope_fc() # operator instantiation
    subset_op.inputs.fields_container.connect(stress_skin_nodal)
    subset_op.inputs.mesh_scoping.connect(ns_scope)
    subset_op.inputs.default_value.connect(0.0)
    
    subset_op.eval()
    
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    Cell In[162], line 4
          1 ns_scope = dpf.mesh_scoping_factory.named_selection_scoping('BLADE_N', model)
          3 subset_op = dpf.operators.scoping.rescope_fc() # operator instantiation
    ----> 4 subset_op.inputs.fields_container.connect(stress_skin_nodal)
          5 subset_op.inputs.mesh_scoping.connect(ns_scope)
          6 subset_op.inputs.default_value.connect(0.0)
    
    File c:\users\e092220\.venv\3.9.6\fcdslib-ansys22r2\lib\site-packages\ansys\dpf\core\inputs.py:113, in Input.connect(self, inpt)
        106     err_str = (
        107         f"The input operator for the {self._spec.name} pin must be "
        108         "one of the following types:\n"
        109     )
        110     err_str += "\n".join(
        111         [f"- {py_type}" for py_type in self._python_expected_types]
        112     )
    --> 113     raise TypeError(err_str)
        115 from ansys.dpf.core.results import Result
        117 if isinstance(inpt, _Outputs):
    
    TypeError: The input operator for the fields_container pin must be one of the following types:
    - FieldsContainer
    
    

    Keep in mind that stress_skin_nodal is a field. It is not a fields container and it is not an operator. I have attached the Jupyter notebook that contains the rest of the code if that would be of any help.