From 688877a534e348ef24ac2d79f714f326b7d2f6ff Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Mon, 19 Sep 2022 15:34:01 +0530 Subject: [PATCH 01/17] Updated docs w.r.t. meshing workflow updates --- doc/source/user_guide/meshing_workflows.rst | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index 4721c5a33fcb..5c56b24636d4 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -607,4 +607,29 @@ Switch to solution mode .. code:: python - solver = meshing.switch_to_solver() \ No newline at end of file + solver = meshing.switch_to_solver() + +Sample use of CommandArguments and accessor methods +--------------------------------------------------- +This simple example shows how you use the CommandArgument attributes and explicit attribute accessor methods in a watertight geometry meshing workflow. +Note: CommandArgument attributes are read-only. + +Import geometry +~~~~~~~~~~~~~~~ + +.. code:: python + +import ansys.fluent.core as pyfluent +from ansys.fluent.core import examples + +import_filename = examples.download_file('mixing_elbow.pmdb', 'pyfluent/mixing_elbow') +meshing = pyfluent.launch_fluent(mode="meshing", precision='double', processor_count=2) +w = meshing.workflow +w.InitializeWorkflow(WorkflowType='Watertight Geometry') + +w.task("Import Geometry").CommandArguments() +w.task("Import Geometry").CommandArguments.FileName.is_read_only() +w.task("Import Geometry").CommandArguments.LengthUnit.is_active() +w.task("Import Geometry").CommandArguments.CadImportOptions.OneZonePer.default_value() +w.task("Import Geometry").CommandArguments.CadImportOptions.OneZonePer.allowed_values() +w.task("Import Geometry").CommandArguments.CadImportOptions.FeatureAngle.min() From 88fa2a673c5094f90b75d84ad2e98e8a9b80b29f Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee <109645853+prmukherj@users.noreply.github.com> Date: Tue, 20 Sep 2022 13:16:30 +0530 Subject: [PATCH 02/17] Update doc/source/user_guide/meshing_workflows.rst Co-authored-by: Sean Pearson <93727996+seanpearsonuk@users.noreply.github.com> --- doc/source/user_guide/meshing_workflows.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index 5c56b24636d4..dc698fe173a2 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -609,7 +609,7 @@ Switch to solution mode solver = meshing.switch_to_solver() -Sample use of CommandArguments and accessor methods +Sample use of CommandArguments --------------------------------------------------- This simple example shows how you use the CommandArgument attributes and explicit attribute accessor methods in a watertight geometry meshing workflow. Note: CommandArgument attributes are read-only. From 5594ecdf0b2175b8d3017efe65b289abd85922ce Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee <109645853+prmukherj@users.noreply.github.com> Date: Tue, 20 Sep 2022 13:16:50 +0530 Subject: [PATCH 03/17] Update doc/source/user_guide/meshing_workflows.rst Co-authored-by: Sean Pearson <93727996+seanpearsonuk@users.noreply.github.com> --- doc/source/user_guide/meshing_workflows.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index dc698fe173a2..d9aaab4cfc99 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -611,7 +611,7 @@ Switch to solution mode Sample use of CommandArguments --------------------------------------------------- -This simple example shows how you use the CommandArgument attributes and explicit attribute accessor methods in a watertight geometry meshing workflow. +This simple example shows how you use the CommandArgument attributes and explicit attribute access methods in a watertight geometry meshing workflow. Note: CommandArgument attributes are read-only. Import geometry From b0513632214abb772f7ab55074b01fa390caeae9 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Wed, 21 Sep 2022 20:35:53 +0530 Subject: [PATCH 04/17] Updated the read-only behaviour of CommandArguments --- src/ansys/fluent/core/meshing/workflow.py | 6 +- .../fluent/core/services/datamodel_se.py | 82 +++++++++++-------- tests/test_meshing_workflow.py | 24 +++++- 3 files changed, 73 insertions(+), 39 deletions(-) diff --git a/src/ansys/fluent/core/meshing/workflow.py b/src/ansys/fluent/core/meshing/workflow.py index 7134382f4840..1495181ab0ba 100644 --- a/src/ansys/fluent/core/meshing/workflow.py +++ b/src/ansys/fluent/core/meshing/workflow.py @@ -1,4 +1,4 @@ -from ansys.fluent.core.services.datamodel_se import PyCallableStateObject +from ansys.fluent.core.services.datamodel_se import MakeReadOnly, PyCallableStateObject def _new_command_for_task(task, meshing): @@ -55,8 +55,8 @@ def _refreshed_command(self): task_arg_state = self.Arguments.get_state() cmd = self._command() if task_arg_state: - cmd.update_dict(task_arg_state) - return cmd + cmd.set_state(task_arg_state) + return MakeReadOnly(cmd) def _command(self): if not self._cmd: diff --git a/src/ansys/fluent/core/services/datamodel_se.py b/src/ansys/fluent/core/services/datamodel_se.py index 66c28385f531..5d1ef2f05667 100644 --- a/src/ansys/fluent/core/services/datamodel_se.py +++ b/src/ansys/fluent/core/services/datamodel_se.py @@ -217,7 +217,7 @@ def __call__(self, *args, **kwds) -> Any: return self.get_state() -class PyReadOnlyStateContainer(PyCallableStateObject): +class PyStateContainer(PyCallableStateObject): """Object class using StateEngine based DatamodelService as backend. Use this class instead of directly calling DatamodelService's method. @@ -235,6 +235,12 @@ class PyReadOnlyStateContainer(PyCallableStateObject): getState() Get the state of the current object. (This method is the same as the __call__() method.) + set_state() + Set the state of the current object. (This method is the + same as the __call__() method.) + setState() + Set the state of the current object. (This method is the + same as the __call__() method.) """ def __init__(self, service: DatamodelService, rules: str, path: Path = None): @@ -257,6 +263,17 @@ def get_state(self) -> Any: getState = get_state + def set_state(self, state: Any = None, **kwargs) -> None: + request = DataModelProtoModule.SetStateRequest() + request.rules = self.rules + request.path = _convert_path_to_se_path(self.path) + _convert_value_to_variant( + kwargs, request.state + ) if kwargs else _convert_value_to_variant(state, request.state) + self.service.set_state(request) + + setState = set_state + def get_attrib_value(self, attrib: str) -> Any: """Get attribute value of the current object. @@ -294,24 +311,6 @@ def help(self) -> None: ).common.helpstring print(help_string) - -class PyStateContainer(PyReadOnlyStateContainer): - """Object class using StateEngine based DatamodelService as backend. Use - this class instead of directly calling DatamodelService's method. - - Methods - ------- - get_state() - Get the state of the current object. (This method is the - same as the __call__() method.) - getState() - Get the state of the current object. (This method is the - same as the __call__() method.) - """ - - def __init__(self, service: DatamodelService, rules: str, path: Path = None): - super().__init__(service, rules, path) - def __call__(self, *args, **kwargs): if kwargs: self.set_state(kwargs) @@ -322,17 +321,6 @@ def __call__(self, *args, **kwargs): docstring = None - def set_state(self, state: Any = None, **kwargs) -> None: - request = DataModelProtoModule.SetStateRequest() - request.rules = self.rules - request.path = _convert_path_to_se_path(self.path) - _convert_value_to_variant( - kwargs, request.state - ) if kwargs else _convert_value_to_variant(state, request.state) - self.service.set_state(request) - - setState = set_state - class PyMenu(PyStateContainer): """Object class using StateEngine based DatamodelService as backend. Use @@ -723,7 +711,9 @@ def __getattr__(self, attr): mode = AccessorModes.get_mode(arg.type) py_class = mode.value[1] - return py_class(self, attr, self.service, self.rules, self.path, arg) + return MakeReadOnly( + py_class(self, attr, self.service, self.rules, self.path, arg) + ) def get_state(self) -> Any: parent_state = self.parent.get_state() @@ -744,7 +734,7 @@ def help(self) -> None: pass -class PyCommandArguments(PyReadOnlyStateContainer): +class PyCommandArguments(PyStateContainer): def __init__( self, service: DatamodelService, @@ -778,7 +768,9 @@ def __getattr__(self, attr): if arg.name == attr: mode = AccessorModes.get_mode(arg.type) py_class = mode.value[1] - return py_class(self, attr, self.service, self.rules, self.path, arg) + return MakeReadOnly( + py_class(self, attr, self.service, self.rules, self.path, arg) + ) class PyTextualCommandArgumentsSubItem(PyCommandArgumentsSubItem, PyTextual): @@ -871,6 +863,30 @@ def get_mode(mode: str) -> "AccessorModes": return AccessorModes.GENERIC +class MakeReadOnly: + """Removes 'set_state()' attribute to implement read-only behaviour.""" + + def __init__(self, cmd): + self._cmd = cmd + self._unwanted_attr = ["set_state", "setState"] + + def __getattr__(self, attr): + if attr in self._unwanted_attr: + raise AttributeError("Command Arguments are read-only.") + return getattr(self._cmd, attr) + + def __dir__(self): + returned_list = sorted( + set(list(self.__dict__.keys()) + dir(type(self)) + dir(self._cmd)) + ) + for attr in self._unwanted_attr: + returned_list.remove(attr) + return returned_list + + def __call__(self): + return self._cmd() + + class PyMenuGeneric(PyMenu): attrs = ("service", "rules", "path") diff --git a/tests/test_meshing_workflow.py b/tests/test_meshing_workflow.py index 63cfdc5e1772..f6832d355604 100644 --- a/tests/test_meshing_workflow.py +++ b/tests/test_meshing_workflow.py @@ -293,6 +293,24 @@ def test_accessors_for_argument_sub_items(new_mesh_session): ).CommandArguments.CadImportOptions.FeatureAngle.allowed_values() +@pytest.mark.dev +@pytest.mark.fluent_231 +def test_read_only_behaviour_of_command_arguments(new_mesh_session): + session_new = new_mesh_session + w = session_new.workflow + m = session_new.meshing + w.InitializeWorkflow(WorkflowType="Watertight Geometry") + + assert "set_state" not in dir(w.task("Import Geometry").CommandArguments) + assert "set_state" not in dir(w.task("Import Geometry").CommandArguments.LengthUnit) + + with pytest.raises(AttributeError) as msg: + w.task("Import Geometry").CommandArguments.MeshUnit.set_state("in") + assert msg.value.args[0] == "Command Arguments are read-only." + + assert "set_state" in dir(m.ImportGeometry.new()) + + def test_dummy_journal_data_model_methods(new_mesh_session): session_new = new_mesh_session @@ -303,12 +321,12 @@ def test_dummy_journal_data_model_methods(new_mesh_session): with pytest.raises(AttributeError) as msg: w.task("Import Geometry").delete_child() assert msg.value.args[0] == "This method is yet to be implemented in pyfluent." - with pytest.raises(AttributeError): + with pytest.raises(AttributeError) as msg: w.task("Import Geometry").delete_child_objects() assert msg.value.args[0] == "This method is yet to be implemented in pyfluent." - with pytest.raises(AttributeError): + with pytest.raises(AttributeError) as msg: w.task("Import Geometry").delete_all_child_objects() assert msg.value.args[0] == "This method is yet to be implemented in pyfluent." - with pytest.raises(AttributeError): + with pytest.raises(AttributeError) as msg: w.task("Import Geometry").fix_state() assert msg.value.args[0] == "This method is yet to be implemented in pyfluent." From 05279a5a3d2e73dbedc809f2f8780973747ca178 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Wed, 21 Sep 2022 20:45:30 +0530 Subject: [PATCH 05/17] Test to check a sample use case of CommandArguments --- tests/test_meshing_workflow.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_meshing_workflow.py b/tests/test_meshing_workflow.py index f6832d355604..9b03b2892684 100644 --- a/tests/test_meshing_workflow.py +++ b/tests/test_meshing_workflow.py @@ -1,6 +1,7 @@ from functools import partial import os +os.environ["PYFLUENT_FLUENT_ROOT"] = "C:/ANSYSDev/ANSYSDev/vNNN/fluent/" import pytest from util.meshing_workflow import ( # noqa: F401; model_object_throws_on_invalid_arg, assign_task_arguments, @@ -311,6 +312,27 @@ def test_read_only_behaviour_of_command_arguments(new_mesh_session): assert "set_state" in dir(m.ImportGeometry.new()) +@pytest.mark.dev +@pytest.mark.fluent_231 +def test_sample_use_of_command_arguments(new_mesh_session): + w = new_mesh_session.workflow + + w.InitializeWorkflow(WorkflowType="Watertight Geometry") + + assert w.task("Import Geometry").CommandArguments.LengthUnit.allowed_values() == [ + "m", + "cm", + "mm", + "in", + "ft", + "um", + "nm", + ] + assert w.task("Import Geometry").CommandArguments.LengthUnit.default_value() == "mm" + w.TaskObject["Import Geometry"].Arguments = dict(LengthUnit="in") + assert w.task("Import Geometry").CommandArguments.LengthUnit() == "in" + + def test_dummy_journal_data_model_methods(new_mesh_session): session_new = new_mesh_session From 7886030415a8b4deba35cb1b103824dd57f35ad4 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Wed, 21 Sep 2022 21:17:20 +0530 Subject: [PATCH 06/17] Updated the sample use case --- doc/source/user_guide/meshing_workflows.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index d9aaab4cfc99..e83a8302d5a2 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -611,7 +611,8 @@ Switch to solution mode Sample use of CommandArguments --------------------------------------------------- -This simple example shows how you use the CommandArgument attributes and explicit attribute access methods in a watertight geometry meshing workflow. +This simple example shows how you use the CommandArgument attributes and explicit +attribute access methods in a watertight geometry meshing workflow. Note: CommandArgument attributes are read-only. Import geometry @@ -630,6 +631,8 @@ w.InitializeWorkflow(WorkflowType='Watertight Geometry') w.task("Import Geometry").CommandArguments() w.task("Import Geometry").CommandArguments.FileName.is_read_only() w.task("Import Geometry").CommandArguments.LengthUnit.is_active() -w.task("Import Geometry").CommandArguments.CadImportOptions.OneZonePer.default_value() -w.task("Import Geometry").CommandArguments.CadImportOptions.OneZonePer.allowed_values() +w.task("Import Geometry").CommandArguments.LengthUnit.allowed_values() +w.task("Import Geometry").CommandArguments.LengthUnit.default_value() +w.task("Import Geometry").CommandArguments.LengthUnit() +w.task("Import Geometry").CommandArguments.CadImportOptions.OneZonePer() w.task("Import Geometry").CommandArguments.CadImportOptions.FeatureAngle.min() From 8e5224bb6e10170c9e5e72b9c71bcff45801ddcd Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Wed, 21 Sep 2022 21:23:18 +0530 Subject: [PATCH 07/17] doc style fix --- doc/source/user_guide/meshing_workflows.rst | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index e83a8302d5a2..31faa969b502 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -620,19 +620,19 @@ Import geometry .. code:: python -import ansys.fluent.core as pyfluent -from ansys.fluent.core import examples - -import_filename = examples.download_file('mixing_elbow.pmdb', 'pyfluent/mixing_elbow') -meshing = pyfluent.launch_fluent(mode="meshing", precision='double', processor_count=2) -w = meshing.workflow -w.InitializeWorkflow(WorkflowType='Watertight Geometry') - -w.task("Import Geometry").CommandArguments() -w.task("Import Geometry").CommandArguments.FileName.is_read_only() -w.task("Import Geometry").CommandArguments.LengthUnit.is_active() -w.task("Import Geometry").CommandArguments.LengthUnit.allowed_values() -w.task("Import Geometry").CommandArguments.LengthUnit.default_value() -w.task("Import Geometry").CommandArguments.LengthUnit() -w.task("Import Geometry").CommandArguments.CadImportOptions.OneZonePer() -w.task("Import Geometry").CommandArguments.CadImportOptions.FeatureAngle.min() + import ansys.fluent.core as pyfluent + from ansys.fluent.core import examples + + import_filename = examples.download_file('mixing_elbow.pmdb', 'pyfluent/mixing_elbow') + meshing = pyfluent.launch_fluent(mode="meshing", precision='double', processor_count=2) + w = meshing.workflow + w.InitializeWorkflow(WorkflowType='Watertight Geometry') + + w.task("Import Geometry").CommandArguments() + w.task("Import Geometry").CommandArguments.FileName.is_read_only() + w.task("Import Geometry").CommandArguments.LengthUnit.is_active() + w.task("Import Geometry").CommandArguments.LengthUnit.allowed_values() + w.task("Import Geometry").CommandArguments.LengthUnit.default_value() + w.task("Import Geometry").CommandArguments.LengthUnit() + w.task("Import Geometry").CommandArguments.CadImportOptions.OneZonePer() + w.task("Import Geometry").CommandArguments.CadImportOptions.FeatureAngle.min() From 481ca0eeddd62c2c5ebdd586c3b3fada64b4c871 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee <109645853+prmukherj@users.noreply.github.com> Date: Wed, 21 Sep 2022 21:33:34 +0530 Subject: [PATCH 08/17] Update doc/source/user_guide/meshing_workflows.rst Co-authored-by: Sean Pearson <93727996+seanpearsonuk@users.noreply.github.com> --- doc/source/user_guide/meshing_workflows.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index 31faa969b502..94e75ac26ec9 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -611,7 +611,7 @@ Switch to solution mode Sample use of CommandArguments --------------------------------------------------- -This simple example shows how you use the CommandArgument attributes and explicit +This simple example shows you how to use the CommandArgument attributes and explicit attribute access methods in a watertight geometry meshing workflow. Note: CommandArgument attributes are read-only. From 30e18ebd7022a46a25b5ad7f02fe0f2b7a919dd9 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Wed, 21 Sep 2022 21:34:49 +0530 Subject: [PATCH 09/17] minor style fix --- doc/source/user_guide/meshing_workflows.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index 94e75ac26ec9..6ffca808b068 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -615,9 +615,6 @@ This simple example shows you how to use the CommandArgument attributes and expl attribute access methods in a watertight geometry meshing workflow. Note: CommandArgument attributes are read-only. -Import geometry -~~~~~~~~~~~~~~~ - .. code:: python import ansys.fluent.core as pyfluent From ed41eed3c29155f6c51a8a74c8b17d0aaf0a531d Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Thu, 22 Sep 2022 10:27:33 +0530 Subject: [PATCH 10/17] Updated accessor methods doc for solver settings --- doc/source/user_guide/meshing_workflows.rst | 2 +- doc/source/user_guide/solver_settings.rst | 22 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index 6ffca808b068..44b71324ae6b 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -609,7 +609,7 @@ Switch to solution mode solver = meshing.switch_to_solver() -Sample use of CommandArguments +Sample use of CommandArgumentsshould use sentence-style capitalization --------------------------------------------------- This simple example shows you how to use the CommandArgument attributes and explicit attribute access methods in a watertight geometry meshing workflow. diff --git a/doc/source/user_guide/solver_settings.rst b/doc/source/user_guide/solver_settings.rst index 7203788c5e5a..71c1c702f42e 100644 --- a/doc/source/user_guide/solver_settings.rst +++ b/doc/source/user_guide/solver_settings.rst @@ -69,3 +69,25 @@ Python code for setting the gravitational acceleration. .. code:: python solver.tui.define.operating_conditions.gravity('yes','0','-9.81','0') + +Sample use of accessor methods +------------------------------ +This simple example shows how you use the explicit attribute access methods +in a simple solver session. + +**Python code** + +.. code:: python + +import ansys.fluent.core as pyfluent +from ansys.fluent.core import examples + +import_filename = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow") +solver = pyfluent.launch_fluent(mode="solver") + +solver.setup.models.viscous.is_active() +solver.setup.models.viscous.model.is_read_only() +solver.setup.models.viscous.model.default_value() +solver.setup.models.viscous.model.allowed_values() +solver.setup.models.discrete_phase.tracking.tracking_parameters.max_number_of_steps.min() +solver.setup.models.discrete_phase.tracking.tracking_parameters.max_number_of_steps.max() From a218ce8cfd0031d684e28bb79cdd55a33d7b9a47 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Thu, 22 Sep 2022 10:31:59 +0530 Subject: [PATCH 11/17] style update --- doc/source/user_guide/solver_settings.rst | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/source/user_guide/solver_settings.rst b/doc/source/user_guide/solver_settings.rst index 71c1c702f42e..4cf5b145ddda 100644 --- a/doc/source/user_guide/solver_settings.rst +++ b/doc/source/user_guide/solver_settings.rst @@ -79,15 +79,15 @@ in a simple solver session. .. code:: python -import ansys.fluent.core as pyfluent -from ansys.fluent.core import examples - -import_filename = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow") -solver = pyfluent.launch_fluent(mode="solver") - -solver.setup.models.viscous.is_active() -solver.setup.models.viscous.model.is_read_only() -solver.setup.models.viscous.model.default_value() -solver.setup.models.viscous.model.allowed_values() -solver.setup.models.discrete_phase.tracking.tracking_parameters.max_number_of_steps.min() -solver.setup.models.discrete_phase.tracking.tracking_parameters.max_number_of_steps.max() + import ansys.fluent.core as pyfluent + from ansys.fluent.core import examples + + import_filename = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow") + solver = pyfluent.launch_fluent(mode="solver") + + solver.setup.models.viscous.is_active() + solver.setup.models.viscous.model.is_read_only() + solver.setup.models.viscous.model.default_value() + solver.setup.models.viscous.model.allowed_values() + solver.setup.models.discrete_phase.tracking.tracking_parameters.max_number_of_steps.min() + solver.setup.models.discrete_phase.tracking.tracking_parameters.max_number_of_steps.max() From 2caffd0b4c1381fd68f4ad5ad4af12cfb117fad2 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Thu, 22 Sep 2022 10:35:47 +0530 Subject: [PATCH 12/17] Spelling correction --- doc/source/user_guide/solver_settings.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/user_guide/solver_settings.rst b/doc/source/user_guide/solver_settings.rst index 4cf5b145ddda..cf515db7f959 100644 --- a/doc/source/user_guide/solver_settings.rst +++ b/doc/source/user_guide/solver_settings.rst @@ -70,8 +70,8 @@ Python code for setting the gravitational acceleration. solver.tui.define.operating_conditions.gravity('yes','0','-9.81','0') -Sample use of accessor methods ------------------------------- +Sample use of explicit attribute access methods +----------------------------------------------- This simple example shows how you use the explicit attribute access methods in a simple solver session. From bd3e93cf7bf2fd9bf9b730e4a477be6390ff7703 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Thu, 22 Sep 2022 12:34:45 +0530 Subject: [PATCH 13/17] Include CommandArguments in vale vocab --- doc/.vale.ini | 2 +- doc/source/user_guide/meshing_workflows.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/.vale.ini b/doc/.vale.ini index 344c6c4a70cd..2685ba86590a 100644 --- a/doc/.vale.ini +++ b/doc/.vale.ini @@ -20,7 +20,7 @@ WordTemplate = \b(?:%s)\b Packages = Google # Define the Ansys vocabulary -Vocab = ANSYS +Vocab = ANSYS, CommandArguments, [*.{md,rst}] diff --git a/doc/source/user_guide/meshing_workflows.rst b/doc/source/user_guide/meshing_workflows.rst index 44b71324ae6b..4cd69882ce93 100644 --- a/doc/source/user_guide/meshing_workflows.rst +++ b/doc/source/user_guide/meshing_workflows.rst @@ -609,8 +609,8 @@ Switch to solution mode solver = meshing.switch_to_solver() -Sample use of CommandArgumentsshould use sentence-style capitalization ---------------------------------------------------- +Sample use of CommandArguments +------------------------------ This simple example shows you how to use the CommandArgument attributes and explicit attribute access methods in a watertight geometry meshing workflow. Note: CommandArgument attributes are read-only. From 254e6ebf03b3e8350233888f712016bbbb73efca Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Thu, 22 Sep 2022 12:42:46 +0530 Subject: [PATCH 14/17] Updated vocab --- doc/.vale.ini | 2 +- doc/styles/Vocab/ANSYS/accept.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/.vale.ini b/doc/.vale.ini index 2685ba86590a..344c6c4a70cd 100644 --- a/doc/.vale.ini +++ b/doc/.vale.ini @@ -20,7 +20,7 @@ WordTemplate = \b(?:%s)\b Packages = Google # Define the Ansys vocabulary -Vocab = ANSYS, CommandArguments, +Vocab = ANSYS [*.{md,rst}] diff --git a/doc/styles/Vocab/ANSYS/accept.txt b/doc/styles/Vocab/ANSYS/accept.txt index 0e26bda81311..8cba3358a512 100644 --- a/doc/styles/Vocab/ANSYS/accept.txt +++ b/doc/styles/Vocab/ANSYS/accept.txt @@ -23,4 +23,5 @@ pyvista Pythonic Slurm Univa -sbatch \ No newline at end of file +sbatch +CommandArguments \ No newline at end of file From f4294148329df5ea15c349ea444d12fce1969fa1 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee <109645853+prmukherj@users.noreply.github.com> Date: Thu, 22 Sep 2022 14:45:18 +0530 Subject: [PATCH 15/17] Update src/ansys/fluent/core/services/datamodel_se.py Co-authored-by: Sean Pearson <93727996+seanpearsonuk@users.noreply.github.com> --- src/ansys/fluent/core/services/datamodel_se.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ansys/fluent/core/services/datamodel_se.py b/src/ansys/fluent/core/services/datamodel_se.py index 5d1ef2f05667..d946aa93fd5d 100644 --- a/src/ansys/fluent/core/services/datamodel_se.py +++ b/src/ansys/fluent/core/services/datamodel_se.py @@ -239,8 +239,7 @@ class PyStateContainer(PyCallableStateObject): Set the state of the current object. (This method is the same as the __call__() method.) setState() - Set the state of the current object. (This method is the - same as the __call__() method.) + Deprecated camel case alias of set_state. """ def __init__(self, service: DatamodelService, rules: str, path: Path = None): From a3e9fcc9cf395093765c00005fd9affcef1bbaea Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee <109645853+prmukherj@users.noreply.github.com> Date: Thu, 22 Sep 2022 14:45:33 +0530 Subject: [PATCH 16/17] Update src/ansys/fluent/core/services/datamodel_se.py Co-authored-by: Sean Pearson <93727996+seanpearsonuk@users.noreply.github.com> --- src/ansys/fluent/core/services/datamodel_se.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ansys/fluent/core/services/datamodel_se.py b/src/ansys/fluent/core/services/datamodel_se.py index d946aa93fd5d..15a9e24f728d 100644 --- a/src/ansys/fluent/core/services/datamodel_se.py +++ b/src/ansys/fluent/core/services/datamodel_se.py @@ -233,8 +233,7 @@ class PyStateContainer(PyCallableStateObject): Get the state of the current object. (This method is the same as the __call__() method.) getState() - Get the state of the current object. (This method is the - same as the __call__() method.) + Deprecated camel case alias of get_state. set_state() Set the state of the current object. (This method is the same as the __call__() method.) From 0dc04d2cf1b789596689c25f817a8d098bc60cd5 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Thu, 22 Sep 2022 15:41:25 +0530 Subject: [PATCH 17/17] Re-structuring --- src/ansys/fluent/core/services/datamodel_se.py | 15 ++++++++------- tests/test_meshing_workflow.py | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ansys/fluent/core/services/datamodel_se.py b/src/ansys/fluent/core/services/datamodel_se.py index 15a9e24f728d..290afd516f44 100644 --- a/src/ansys/fluent/core/services/datamodel_se.py +++ b/src/ansys/fluent/core/services/datamodel_se.py @@ -230,15 +230,15 @@ class PyStateContainer(PyCallableStateObject): (This method is the same as the get_attrib_value(attrib) method.) get_state() - Get the state of the current object. (This method is the - same as the __call__() method.) + Get the state of the current object. getState() Deprecated camel case alias of get_state. set_state() - Set the state of the current object. (This method is the - same as the __call__() method.) + Set the state of the current object. setState() Deprecated camel case alias of set_state. + __call__() + Set the state of the current object if state is provided else get its state. """ def __init__(self, service: DatamodelService, rules: str, path: Path = None): @@ -864,12 +864,13 @@ def get_mode(mode: str) -> "AccessorModes": class MakeReadOnly: """Removes 'set_state()' attribute to implement read-only behaviour.""" + _unwanted_attr = ["set_state", "setState"] + def __init__(self, cmd): self._cmd = cmd - self._unwanted_attr = ["set_state", "setState"] def __getattr__(self, attr): - if attr in self._unwanted_attr: + if attr in MakeReadOnly._unwanted_attr: raise AttributeError("Command Arguments are read-only.") return getattr(self._cmd, attr) @@ -877,7 +878,7 @@ def __dir__(self): returned_list = sorted( set(list(self.__dict__.keys()) + dir(type(self)) + dir(self._cmd)) ) - for attr in self._unwanted_attr: + for attr in MakeReadOnly._unwanted_attr: returned_list.remove(attr) return returned_list diff --git a/tests/test_meshing_workflow.py b/tests/test_meshing_workflow.py index 9b03b2892684..9a9908c719d6 100644 --- a/tests/test_meshing_workflow.py +++ b/tests/test_meshing_workflow.py @@ -1,7 +1,6 @@ from functools import partial import os -os.environ["PYFLUENT_FLUENT_ROOT"] = "C:/ANSYSDev/ANSYSDev/vNNN/fluent/" import pytest from util.meshing_workflow import ( # noqa: F401; model_object_throws_on_invalid_arg, assign_task_arguments,