[docs]@register_api_implementation(core_class=MechanicalOutputCase)classMechanicalOutputCaseSetup(OutputCaseSetupPipeline,DataTableDependentOutputsHandlerApiMixin):""" The API handler for mechanical output cases The following example shows how to create a mechanical output case using the API, it is assumed that these steps were performed in each of the examples for other methods in this class. .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> simulation_setup = api.create_simulation_setup() >>> occ_setup = simulation_setup.create_output_case_container_setup().set_name(name='Example OCC') >>> output_case_setup = occ_setup.create_output_case_setup(oc_type='Mechanical output case').set_name(name='Example OC') .. >>> isinstance(output_case_setup, MechanicalOutputCaseSetup) True >>> isinstance(output_case_setup._output_case, MechanicalOutputCase) True The next example shows how to get an API object for an already existing output case. .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> simulation_setup = api.create_simulation_setup() >>> occ_setup = simulation_setup.create_output_case_container_setup().set_name(name='Example OCC') .. >>> _output_case_setup = occ_setup.create_output_case_setup(oc_type='Mechanical output case').set_name(name='Example OC') >>> output_case_setup = occ_setup.get_output_case_setup(name='Example OC') # The output case must already exist .. >>> isinstance(output_case_setup, MechanicalOutputCaseSetup) True >>> isinstance(output_case_setup._output_case, MechanicalOutputCase) True """def__init__(self,item:MechanicalOutputCase):super().__init__(item)self._output_case=item# Backwards compatibilityself.output_case=itemself._data_table_dependent_outputs_handler_api=DataTableDependentOutputsHandlerAPI(data_table_dependent_outputs_handler=self._output_case.data_table_dependent_outputs_handler)
[docs]defget_name(self)->str:""" Returns the name of the output case .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> output_case_setup = _mechanical_output_case_api_setup(api=api) >>> output_case_setup.set_name(name='new_name') <more...> >>> output_case_setup.get_name() 'new_name' Returns ------- name: str The name of the output case """returnself._output_case.name
[docs]defset_name(self,name:str,resolve_duplicate_name:bool=False)->'MechanicalOutputCaseSetup':""" Sets the name of the output case See example at the top to see how to create a MechanicalOutputCaseSetup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> occ = api.create_simulation_setup().create_output_case_container_setup() >>> output_case_setup = occ.create_output_case_setup(oc_type='Mechanical output case') >>> second_output_case_setup = occ.create_output_case_setup(oc_type='Mechanical output case') >>> output_case_setup.set_name(name='new_name') <more...> >>> second_output_case_setup.set_name(name='new_name', resolve_duplicate_name=True).get_name() 'new_name 1' .. >>> output_case_setup._output_case.name 'new_name' Trying to set the name to a non-string value >>> output_case_setup.set_name(name=None) Traceback (most recent call last): ... TypeError: ... Setting a non-unique name >>> output_case_setup.set_name('new_name') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotUniqueError: ... Parameters ---------- name : str The new name for the output case resolve_duplicate_name: bool Whether to automatically assign a new name when the chosen one is already taken Returns ------- self: MechanicalOutputCaseSetup Raises ------ NameNotUniqueError Raised if the given name is not unique TypeError Raised if the given name is not a string """ifnotisinstance(name,str):raiseTypeError('The given name must be of type string, but a: \"{}\" was given'.format(type(name)))created_names=[oc.nameforocinself._output_case.parent.elements]ifnameincreated_names:ifnotresolve_duplicate_name:raiseNameNotUniqueError(f'The given name: \"{name}\" is already given in the list: \"{created_names}\"')else:name=change_duplicate_name(name=name,names_list=created_names)self._output_case.name=namereturnself
[docs]defget_output_setup(self,index:int)->OutputSetup:""" Gets a output setup object for an existing output .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> output_case_setup = _mechanical_output_case_api_setup(api=api) >>> _output_setup_1 = output_case_setup.create_output_setup(output_type='Link displacement') >>> _output_setup_2 = output_case_setup.create_output_setup(output_type='Link displacement') >>> output_setup = output_case_setup.get_output_setup(index=1) # Two outputs must already exist .. >>> _output_setup_2._output == output_setup._output True >>> len(output_case_setup._output_case.data_table_dependent_outputs_handler.outputs_container.elements) 2 >>> output_case_setup._output_case.data_table_dependent_outputs_handler.outputs_container.elements[1] == output_setup._output True >>> output_case_setup.get_output_setup(index=None) Traceback (most recent call last): ... TypeError: ... Parameters ---------- index : int The index of the output in the output table Returns ------- OutputSetup: OutputSetup Raises ------ TypeError Raised if the index is not an integer """returnself._data_table_dependent_outputs_handler_api.get_output_setup(index=index)
[docs]defcreate_output_setup(self,output_type:str)->OutputSetup:""" Creates a output of a specified type .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> output_case_setup = _mechanical_output_case_api_setup(api=api) >>> link_output_setup = output_case_setup.create_output_setup(output_type='Link displacement') >>> control_module_output_setup = output_case_setup.create_output_setup(output_type='Control module output') .. >>> len(output_case_setup._output_case.data_table_dependent_outputs_handler.outputs_container.elements) 2 >>> output_case_setup._output_case.data_table_dependent_outputs_handler.outputs_container.elements[1] == control_module_output_setup._output True >>> output_case_setup._output_case.data_table_dependent_outputs_handler.outputs_container.elements[0] == link_output_setup._output True >>> output_case_setup.create_output_setup(output_type='Non existent output type') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... >>> output_case_setup.create_output_setup(output_type='Interface temperature') Traceback (most recent call last): ... more.api.exceptions.api_exception.NotCompatibleError: ... Parameters ---------- index : int The index of the output in the output table Returns ------- OutputSetup: OutputSetup Raises ------ NameNotFoundError Raised if not output with the specified type was found NotCompatibleError Raised if the specified output type exists, but is not compatible with this output case """returnself._data_table_dependent_outputs_handler_api.create_output_setup(output_type=output_type)
[docs]defremove_output_setup(self,index:int)->'MechanicalOutputCaseSetup':""" Removes the output under the specified index .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> output_case_setup = _mechanical_output_case_api_setup(api=api) >>> _output_setup_1 = output_case_setup.create_output_setup(output_type='Link displacement') >>> _output_setup_2 = output_case_setup.create_output_setup(output_type='Link displacement') >>> output_case_setup = output_case_setup.remove_output_setup(index=1) # Two outputs must already exist .. >>> len(output_case_setup._output_case.data_table_dependent_outputs_handler.outputs_container.elements) 1 >>> output_case_setup._output_case.data_table_dependent_outputs_handler.outputs_container.elements[0] == _output_setup_1._output True >>> output_case_setup.remove_output_setup(index=None) Traceback (most recent call last): ... TypeError: ... Parameters ---------- index : int The index of the output in the output table Returns ------- MechanicalOutputCaseSetup: MechanicalOutputCaseSetup Raises ------ TypeError Raised if the index is not an integer """self._data_table_dependent_outputs_handler_api.remove_output_setup(index=index)returnself
[docs]defset_time_dependent_data_bool(self,value:bool)->'MechanicalOutputCaseSetup':""" Sets whether data table data should be used in the output case .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> output_case_setup = _mechanical_output_case_api_setup(api=api) >>> output_case_setup = output_case_setup.set_time_dependent_data_bool(value=True) .. >>> output_case_setup._output_case.data_table_dependent_outputs_handler.table_dependent_data.time_dependent_data == True True >>> output_case_setup = output_case_setup.set_time_dependent_data_bool(value=False) >>> output_case_setup._output_case.data_table_dependent_outputs_handler.table_dependent_data.time_dependent_data == False True Parameters ---------- value : bool A boolean value specifying whether data table dependence should be used Returns ------- MechanicalOutputCaseSetup: MechanicalOutputCaseSetup """self._data_table_dependent_outputs_handler_api.set_time_dependent_data_bool(value=value)returnself
[docs]defset_data_table_by_name(self,data_table_name:str)->'MechanicalOutputCaseSetup':"""Sets the data table to be used in this output case .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> output_case_setup = _mechanical_output_case_api_setup(api=api) >>> data_table_setup = api.create_simulation_setup() \\ ... .create_data_table_setup(data_table_type_name='Transient data table') \\ ... .set_name(name='data_table_name') >>> print("Available data tables: {}".format(output_case_setup.available_data_table_names)) # To check which data tables are available Available data tables: ... >>> output_case_setup = output_case_setup.set_data_table_by_name(data_table_name='data_table_name') .. >>> output_case_setup._output_case.data_table_dependent_outputs_handler.table_dependent_data.single_data_table_choice == data_table_setup._data_table True >>> output_case_setup.set_data_table_by_name(data_table_name='Non-existent data table') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Parameters ---------- data_table_name: str The name of the data table to set Returns ------- self: MechanicalOutputCaseSetup Raises ------ NameNotFoundError Raised if the data table was not found """self._data_table_dependent_outputs_handler_api.set_data_table_by_name(data_table_name=data_table_name)returnself
[docs]defget_data_table_query_config(self):""" Returns the api object for setting up the data table query for this output case .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> output_case_setup = _mechanical_output_case_api_setup(api=api) >>> data_table_setup = api.create_simulation_setup() \\ ... .create_data_table_setup(data_table_type_name='Transient data table') \\ ... .set_name(name='data_table_name') >>> print("Available data tables: {}".format(output_case_setup.available_data_table_names)) # To check which data tables are available Available data tables: ... >>> output_case_setup = output_case_setup \\ ... .set_data_table_by_name(data_table_name='data_table_name') \\ ... .set_time_dependent_data_bool(value=True) >>> query_config = output_case_setup.get_data_table_query_config() .. >>> query_config._initial_partial_find_creator.data_table == data_table_setup._data_table True >>> _ = output_case_setup.set_time_dependent_data_bool(value=False) >>> output_case_setup.get_data_table_query_config() Traceback (most recent call last): ... more.api.exceptions.api_exception.NotCompatibleError: The current load case setup is not compatible with a data table query config, most probably the time dependency was set to false Returns ------- Query config An object for configuring the data table querying in the output case Raises ------ NotCompatibleError Raised if the current output case configuration is not compatible with a query config object """returnself._data_table_dependent_outputs_handler_api.get_data_table_query_config()
[docs]defset_time_dependent_data_column_index(self,index:int)->'MechanicalOutputCaseSetup':""" Deprecated method .. admonition:: Deprecated :class: warning `set_time_dependent_data_column_index` will be removed in a future MORe release, it is replaced by the more general :meth:`~.get_data_table_query_config` """logger.warning('Deprecation: \"set_time_dependent_data_column_index\" will be removed in a future MORe release, it is replaced by \"get_data_table_query_config\"')self._data_table_dependent_outputs_handler_api.set_time_dependent_data_column_index(index=index)returnself
[docs]defset_time_dependent_data_table_by_name(self,data_table_name:str)->'MechanicalOutputCaseSetup':""" Deprecated method .. admonition:: Deprecated :class: warning `set_time_dependent_data_table_by_name` will be removed in a future MORe release, it is replaced by :meth:`~.set_data_table_by_name` """logger.warning('Deprecation: \"set_time_dependent_data_table_by_name\" will be removed in a future MORe release, it is replaced by \"set_data_table_by_name\"')returnself.set_data_table_by_name(data_table_name=data_table_name)
@propertydefavailable_data_table_names(self)->typing.List[str]:""" Returns the names of compatible data tables .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> output_case_setup = _mechanical_output_case_api_setup(api=api) >>> data_table_setup = api.create_simulation_setup() \\ ... .create_data_table_setup(data_table_type_name='Transient data table') \\ ... .set_name(name='data_table_name') >>> print("Available data tables: {}".format(output_case_setup.available_data_table_names)) # To check which data tables are available Available data tables: ... .. >>> len(output_case_setup.available_data_table_names) == 1 True Returns ------ available_data_tables: Dict(str, str) A list with the names of compatible data tables """returnself._data_table_dependent_outputs_handler_api.available_data_table_names@propertydefavailable_data_tables_dict(self)->typing.Dict[str,str]:""" Deprecated method .. admonition:: Deprecated :class: warning `available_data_tables_dict` will be removed in a future MORe release, it is replaced by :meth:`~.available_data_table_names` """logger.warning('Deprecation: \"available_data_tables_dict\" will be removed in a future MORe release, it is replaced by \"available_data_table_names\"')returnself._data_table_dependent_outputs_handler_api.available_data_tables_dict