-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposition of the mesh_info_provider in Python and output as derived …
…class (#1007) * data sources namespace * fix * add test and docstring * add generic data container api * operator gdc connect & getoutput * exposed get-property * any new_from & cast; gdc set_property * add documentation * add get-property-[names/types] * add missing docstring * fix type reflection * update any ansys release version * fix coding style * fix coding style * remove datasources changes * add server version decorator * fix coding style * fix retro compatibility errors * add server version check in op connect * fix deleter crash * fix get_output * fix deleter crash * fix typo * fix operator gdc test * revert all changes * remove gdc * add back any & gdc * add back operator connect test * revert operators test changes * add back any tests * Exposition of the mesh_info in Python: MeshInfo class and tests * Exposition of the mesh_info in Python * Revert "revert all changes" This reverts commit 2f42b6e. # Conflicts: # src/ansys/dpf/core/__init__.py # src/ansys/dpf/core/common.py # src/ansys/dpf/core/dpf_operator.py * Revert commits "revert all changes" from feat/grpc-api-propagation * Reformat code with pre-commit * Complete the tests and locally correct some issues concerning the GDC (fix in another PR) * mesh_info_provider test with fluent file * Complete mesh_info tests with mesh_info_provider in CFF * Reformat and rename mesh_info * Exposition of the mesh_info_provider Changes in the formating of the operator generation * Fix some issues: naming and argument order, conditionnal derive_class argument. Cleaning the code. * Fix test_mesh_info issues * Pre-commit reformat * Pre commit reformat * Pre commit reformat * Update the PR : expose the output as the derived class. Implementation of the mesh_info in models. * Reformat code * Update the PR : reformat and implement setter/getter for mesh_info * Update the Pr : Reformat code * Update the PR : avoid circular import of the MeshInfo and reformat code * Update the PR : filter the CFF tests for Linux * Update the PR : consistency with DPF side with the use of lower case for derived class name * Update the PR : still skipped Linux for CFF tests in tests_mesh_info * Update mesh_info test * Update the PR : fix retro compatibility issues * Update PR : reformat * Update the PR : retro compatibility * Update the PR : retro compatibility issues * Update Pr : retro compatibility issues * Update the PR : retro compatibility issues * Update the PR : retro compatibility issues * Update PR : Linux issues * Update the PR : call the new API for pins with derived class * Update the PR : reformat code * Update the PR : fix Linux issues * Update the PR : reformat code * test Linux issues : catch if the CFF plugin is loaded * Update the PR : remove Linux test issue * Update the PR : complete mesh_info tests * Update the PR : test fix Linux issues * Revert last commit * Update the PR : fix test_mesh_info issue * Update the PR : test Linux fix * Update the PR : fix Linux issue * Update the PR : complete mesh_info tests with loading cff operator test * Update PR : complete mesh_info tests by adding test concerning the load of CFF operators and model * Update the PR : correct typo * Update the PR : run Linux pipeline testing result_info with fluent model in Grpc * Revert previous test commit * Update the PR : fix conftests issues for CFF fixture fluent_axial_comp * Update the PR : reformat code * Update the PR : add in Process tests in Linux * Update the PR : reformat code * Update the PR : removed Linux skip and update fluent fixture * Update the PR : reformat code * Update the PR : un-unskip Linux test for result_info * Update test_resultinfo.py * Update the PR : reformat code * Update the PR : fix Linux tests for result_info using CFF model * Update the PR : fix issue for Linux test in result_info * Update the PR : un unskip Linux test for result_info * Update the PR : reviews * Update the PR : fix issues concerning deep_copy of the MeshInfo class * Update the PR : satisfy Codacy Static Code Analysis * Update the PR : server consistency * Update the PR : fix server issue --------- Co-authored-by: cbellot <[email protected]> Co-authored-by: Jose A. Henriquez Roa <[email protected]> Co-authored-by: Paul Profizi <[email protected]>
- Loading branch information
1 parent
2b44761
commit bc651fa
Showing
15 changed files
with
898 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
""" | ||
MeshInfo | ||
========== | ||
""" | ||
from ansys.dpf.core import server as server_module | ||
from ansys.dpf.core.generic_data_container import GenericDataContainer | ||
from ansys.dpf.core.scoping import Scoping | ||
from ansys.dpf.core.string_field import StringField | ||
|
||
|
||
class MeshInfo: | ||
"""Hold the information relative to a mesh region. | ||
This class describes the available mesh information. | ||
Parameters | ||
---------- | ||
server : ansys.dpf.core.server, optional | ||
Server with the channel connected to the remote or local instance. | ||
The default is ``None``, in which case an attempt is made to use the | ||
global server. | ||
generic_data_container : ansys.dpf.core.generic_data_container, optional | ||
Generic data container that is wrapped into the mesh info. | ||
mesh_info : optional | ||
Hold the information of the mesh region into a generic data container. | ||
Examples | ||
-------- | ||
Explore the mesh info from the model | ||
>>> from ansys.dpf import core as dpf | ||
>>> from ansys.dpf.core import examples | ||
>>> fluent = examples.fluid_axial_model() | ||
>>> model = dpf.Model(fluent) | ||
>>> mesh_info = model.metadata.mesh_info | ||
""" | ||
|
||
def __init__( | ||
self, | ||
generic_data_container=None, | ||
mesh_info=None, | ||
server=None, | ||
): | ||
"""Initialize with a MeshInfo message""" | ||
# ############################ | ||
# step 1: get server | ||
|
||
if generic_data_container is None and mesh_info is None: | ||
self._server = server_module.get_or_create_server(server) | ||
self._generic_data_container = GenericDataContainer(server=self._server) | ||
elif generic_data_container is not None and mesh_info is None: | ||
self._server = generic_data_container._server | ||
self._generic_data_container = generic_data_container | ||
elif generic_data_container is None and MeshInfo is not None: | ||
self._server = mesh_info.generic_data_container._server | ||
self._generic_data_container = mesh_info.generic_data_container | ||
else: | ||
raise ValueError( | ||
"Arguments generic_data_container and mesh_info are mutually exclusive." | ||
) | ||
|
||
@property | ||
def generic_data_container(self) -> GenericDataContainer: | ||
"""GenericDataContainer wrapped into the MeshInfo | ||
that contains all the relative information of the derived class. | ||
Returns | ||
------- | ||
:class:`ansys.dpf.core.generic_data_container.GenericDataContainer` | ||
""" | ||
|
||
return self._generic_data_container | ||
|
||
@generic_data_container.setter | ||
def generic_data_container(self, value: GenericDataContainer): | ||
"""GenericDataContainer wrapped into the MeshInfo | ||
that contains all the relative information of the derived class. | ||
""" | ||
|
||
if not isinstance(value, GenericDataContainer): | ||
raise ValueError("Input value must be a GenericDataContainer.") | ||
self._generic_data_container = value | ||
self._server = self._generic_data_container._server | ||
|
||
def deep_copy(self, server=None): | ||
"""Create a deep copy of the mesh_info's data on a given server. | ||
This method is useful for passing data from one server instance to another. | ||
Parameters | ||
---------- | ||
server : ansys.dpf.core.server, optional | ||
Server with the channel connected to the remote or local instance. | ||
The default is ``None``, in which case an attempt is made to use the | ||
global server. | ||
Returns | ||
------- | ||
mesh_info_copy : MeshInfo | ||
""" | ||
mesh_info = MeshInfo(server=server) | ||
mesh_info.generic_data_container = self._generic_data_container.deep_copy(server) | ||
return mesh_info | ||
|
||
def get_property(self, property_name, output_type): | ||
"""Get property with given name. | ||
Parameters | ||
---------- | ||
property_name : str | ||
Property name. | ||
output_type : :class:`ansys.dpf.core.common.types` | ||
Returns | ||
------- | ||
type | ||
Property object instance. | ||
""" | ||
return self.generic_data_container.get_property(property_name, output_type) | ||
|
||
def set_property(self, property_name, prop): | ||
"""Register given property with the given name. | ||
Parameters | ||
---------- | ||
property_name : str | ||
Property name. | ||
prop : Int, String, Float, Field, StringField, GenericDataContainer, Scoping | ||
object instance. | ||
""" | ||
|
||
return self.generic_data_container.set_property(property_name, prop) | ||
|
||
@property | ||
def get_number_nodes(self): | ||
""" | ||
Returns | ||
------- | ||
number_nodes : int | ||
Number of nodes of the mesh. | ||
""" | ||
|
||
return self.generic_data_container.get_property("num_nodes", int) | ||
|
||
@property | ||
def get_number_elements(self): | ||
""" | ||
Returns | ||
------- | ||
number_elements : int | ||
Number of elements of the mesh. | ||
""" | ||
|
||
return self.generic_data_container.get_property("num_elements", int) | ||
|
||
@property | ||
def get_splittable_by(self): | ||
""" | ||
Returns | ||
------- | ||
splittable by which entity : StringField | ||
Name of the properties according to which the mesh can be split by. | ||
""" | ||
|
||
return self.generic_data_container.get_property("splittable_by", StringField) | ||
|
||
@property | ||
def get_available_elem_types(self): | ||
""" | ||
Returns | ||
------- | ||
available element types : Scoping | ||
element type available for the mesh. | ||
""" | ||
|
||
return self.generic_data_container.get_property("avalaible_elem_type", Scoping) | ||
|
||
def set_number_nodes(self, number_of_nodes): | ||
"""Set the number of nodes in the mesh""" | ||
|
||
return self.generic_data_container.set_property("num_nodes", number_of_nodes) | ||
|
||
def set_number_elements(self, number_of_elements): | ||
"""Set the number of elements in the mesh""" | ||
|
||
return self.generic_data_container.set_property("num_elements", number_of_elements) | ||
|
||
def set_splittable_by(self, split): | ||
"""Set name of the properties according to which the mesh can be split by""" | ||
|
||
return self.generic_data_container.set_property("splittable_by", split) | ||
|
||
def set_available_elem_types(self, available_elem_types): | ||
"""Set the available element types""" | ||
|
||
return self.generic_data_container.set_property("avalaible_elem_type", available_elem_types) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.