Skip to content

Conversation

@PProfizi
Copy link
Contributor

@PProfizi PProfizi commented Nov 8, 2023

Closes #1255

Working locally, apart from the mesh_scoping section commented-out

TODO:

  • upload a nicer example file to the example files repo, use it
  • improve explanations, add sections, review...
  • showcase using streams instead of datasources

@PProfizi PProfizi added the examples Related to PyDPF-Core examples label Nov 8, 2023
@PProfizi PProfizi requested a review from rafacanton November 8, 2023 14:13
@PProfizi PProfizi self-assigned this Nov 8, 2023
@PProfizi
Copy link
Contributor Author

PProfizi commented Nov 8, 2023

@rajesh1359 FYI
Would you have result files for a nice-looking model for this example? IP-free

@PProfizi PProfizi changed the title Add a Modal Superposition Transient Analysis example Add a Mode-Superposition Transient Analysis example Nov 8, 2023
@codecov
Copy link

codecov bot commented Nov 8, 2023

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
28165 1 28164 3757
View the top 1 failed test(s) by shortest run time
test_entry.py::test_apply_context_remote[gRPC CLayer]
Stack Traces | 26.4s run time
remote_config_server_type = <ansys.dpf.core.server_factory.ServerConfig object at 0x000001A2843D7B80>

    @pytest.mark.order(4)
    @pytest.mark.skipif(
        not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, reason="not supported"
    )
    @conftest.raises_for_servers_version_under("6.0")
    def test_apply_context_remote(remote_config_server_type):
        dpf.server.shutdown_all_session_servers()
        dpf.SERVER_CONFIGURATION = remote_config_server_type
        field = dpf.Field()
        field.append([0.0], 1)
        if conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_6_0:
            if conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_6_1:
                with pytest.raises(errors.DPFServerException):
                    op = dpf.Operator("core::field::high_pass")
                    op.connect(0, field)
                    op.connect(1, 0.0)
                    op.eval()
            else:
                with pytest.raises(errors.DPFServerException):
                    _ = dpf.Operator("core::field::high_pass")
                with pytest.raises(errors.DPFServerException):
                    if dpf.SERVER.os == "nt":
                        dpf.load_library("Ans.Dpf.Math.dll", "math_operators")
                    else:
                        dpf.load_library("libAns.Dpf.Math.so", "math_operators")
            assert dpf.SERVER.context == dpf.AvailableServerContexts.entry
        else:
            dpf.start_local_server()
    
        dpf.SERVER.apply_context(dpf.AvailableServerContexts.premium)
        op = dpf.Operator("core::field::high_pass")
        op.connect(0, field)
        op.connect(1, 0.0)
        op.eval()
        field = None
        assert dpf.SERVER.context == dpf.AvailableServerContexts.premium
        dpf.server.shutdown_all_session_servers()
>       field = dpf.Field()

tests\entry\test_entry.py:121: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\field.py:213: in __init__
    super().__init__(
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\field_base.py:53: in __init__
    self._server = server_module.get_or_create_server(
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\server.py:413: in get_or_create_server
    return _global_server()
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\server.py:98: in _global_server
    start_local_server(as_global=True)
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\server.py:255: in start_local_server
    server = server_type(
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\server_types.py:852: in __init__
    self._check_first_call(timeout=timeout - (time.time() - start_time))  # Pass remaining time
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\server_types.py:871: in _check_first_call
    raise e
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\server_types.py:865: in _check_first_call
    _ = self.version
.tox\test-api_entry\lib\site-packages\ansys\dpf\core\server_types.py:888: in version
    api.data_processing_get_server_version_on_client(self.client, major, minor)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

client = <ansys.dpf.core.server_types.GrpcClient object at 0x000001A284488E50>
major = <ansys.dpf.gate.integral_types.MutableInt32 object at 0x000001A2860C1210>
minor = <ansys.dpf.gate.integral_types.MutableInt32 object at 0x000001A2860C1BD0>

    @staticmethod
    def data_processing_get_server_version_on_client(client, major, minor):
    	errorSize = ctypes.c_int(0)
    	sError = ctypes.c_wchar_p()
    	res = capi.dll.DataProcessing_getServerVersion_on_client(client._internal_obj if client is not None else None, ctypes.byref(utils.to_int32(major)), ctypes.byref(utils.to_int32(minor)), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
    	if errorSize.value != 0:
>   		raise errors.DPFServerException(sError.value)
E     ansys.dpf.gate.errors.DPFServerException: a 'cancelled' error occurred: CANCELLED

.tox\test-api_entry\lib\site-packages\ansys\dpf\gate\generated\data_processing_capi.py:498: DPFServerException

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

mode_scoping = dpf.Scoping(ids=list(range(1, 3))) # Modes of interest
displacement_fc = dpf.operators.scoping.rescope_fc(
fields_container=displacement_fc,
mesh_scoping=mode_scoping, # Input here the modes of interest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you input this to the mesh_scoping, it is understood as a Nodal scoping. Is this what you mean?

Copy link
Contributor Author

@PProfizi PProfizi Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafacanton no, interestingly enough, this displacement_fc contains fields located at Modal, which is unexpected but actually logical when using an rdsp file as input, hence the rescope on a generic Scoping (tried instantiating a Scoping as Modal but it does not work):

DPF  Fields Container
  with 21 field(s)
  defined on labels: time 

  with:
  - field 0 {time:  1} with Modal location, 1 components and 6 entities.
  - field 1 {time:  2} with Modal location, 1 components and 6 entities.
  - field 2 {time:  3} with Modal location, 1 components and 6 entities.
  - field 3 {time:  4} with Modal location, 1 components and 6 entities.
  - field 4 {time:  5} with Modal location, 1 components and 6 entities.
  - field 5 {time:  6} with Modal location, 1 components and 6 entities.
  - field 6 {time:  7} with Modal location, 1 components and 6 entities.
  - field 7 {time:  8} with Modal location, 1 components and 6 entities.
  - field 8 {time:  9} with Modal location, 1 components and 6 entities.
  - field 9 {time:  10} with Modal location, 1 components and 6 entities.
  - field 10 {time:  11} with Modal location, 1 components and 6 entities.
  - field 11 {time:  12} with Modal location, 1 components and 6 entities.
  - field 12 {time:  13} with Modal location, 1 components and 6 entities.
  - field 13 {time:  14} with Modal location, 1 components and 6 entities.
  - field 14 {time:  15} with Modal location, 1 components and 6 entities.
  - field 15 {time:  16} with Modal location, 1 components and 6 entities.
  - field 16 {time:  17} with Modal location, 1 components and 6 entities.
  - field 17 {time:  18} with Modal location, 1 components and 6 entities.
  - field 18 {time:  19} with Modal location, 1 components and 6 entities.
  - field 19 {time:  20} with Modal location, 1 components and 6 entities.
  - field 20 {time:  21} with Modal location, 1 components and 6 entities.

While trying out different combinations, I realized that this is really not straightforward with the API currently in place. For example, the Modal scoping seems to exist server-side but is impossible to build client-side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conclusion: this example is useful to showcase how to do this, but really we lack helpers regarding mode manipulation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a bit confusing, I think it's worth adding a comment to explain

@PProfizi PProfizi requested a review from cbellot000 December 15, 2023 13:47
mode_scoping = dpf.Scoping(ids=list(range(1, 3))) # Modes of interest
displacement_fc = dpf.operators.scoping.rescope_fc(
fields_container=displacement_fc,
mesh_scoping=mode_scoping, # Input here the modes of interest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a bit confusing, I think it's worth adding a comment to explain

@PProfizi PProfizi changed the base branch from master to main July 28, 2025 09:56
@pyansys-automation
Copy link
Contributor

Hello @PProfizi!
This issue has been open for over a year and has had no updates in the past 8 months. If it is still relevant, please provide an update. Otherwise, consider closing it to help keep the issue tracker clean.

If this issue needs to remain open, please comment below with @pyansys-automation never close issue to prevent it from being automatically closed.

If you want this repository to be excluded from this automated maintenance process, please let us know by filling in the opt-out request form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Related to PyDPF-Core examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mode-superposition transient analysis, with mode selection for expansion

5 participants