Skip to content

Commit 04442b9

Browse files
authored
add capability to not call result info for solution loading (#49)
1 parent 7209e3a commit 04442b9

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

ansys/dpf/post/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from ansys.dpf.core.common import locations
33
from ansys.dpf.post.post_utility import load_solution, print_available_keywords
44
from ansys import dpf
5-
65
from ansys.dpf.post.misc import Report
6+
import ansys.dpf.core as core
77

88
"""Post-processing module. Using Data Processing Framework.
99
Allow to create a result object, then use it to get wanted results.
@@ -15,5 +15,7 @@
1515
>>> disp = solution.nodal_displacement()
1616
1717
"""
18-
18+
if hasattr(core, "settings") and \
19+
hasattr(core.settings, "set_dynamic_available_results_capability"):
20+
core.settings.set_dynamic_available_results_capability(False)
1921
# dpf.core.start_local_server()

ansys/dpf/post/dpf_solution.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
result introduces an amplitude evaluation.
88
"""
99

10-
10+
import re
1111
from ansys.dpf.core import locations
1212
from ansys.dpf.post.common import _AvailableKeywords
1313
from ansys.dpf.post.displacement import ComplexDisplacement, Displacement
@@ -68,9 +68,10 @@ def _check_nodal_location(self, **kwargs):
6868
raise NodalLocationError()
6969

7070
def __str__(self):
71+
7172
txt = (
72-
"%s solution object."
73-
% self._model.metadata.result_info.analysis_type.capitalize()
73+
"%s object."
74+
% re.sub(r"(?<!^)(?=[A-Z])", " ", type(self).__name__)
7475
+ "\n\n\nData Sources\n------------------------------\n"
7576
)
7677
ds_str = self._data_sources.__str__()

ansys/dpf/post/post_utility.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Module containing the method to instantiate the result
22
object. Initialization of post objects.
33
"""
4+
from builtins import Exception
45

56
from ansys.dpf.core.model import Model
67

@@ -17,7 +18,7 @@
1718
)
1819

1920

20-
def load_solution(data_sources):
21+
def load_solution(data_sources, physics_type=None, analysis_type=None):
2122
"""Return a ``Result`` object which can provide information on a given
2223
set, on a given scoping.
2324
@@ -26,15 +27,40 @@ def load_solution(data_sources):
2627
data_sources : str or dpf.core.DataSources
2728
filepath to the file you want to open, or a dpf.core.DataSources().
2829
30+
physics_type : common._PhysicsType, str, optional
31+
["mecanic", "thermal"] optionally specify the type of physics described in
32+
the ''data_sources''. If nothing is specified, the ''data_sources'' are
33+
read to evaluate the ''physics_type''.
34+
35+
analysis_type : common._AnalysisType, str, optional
36+
["static", "modal", "harmonic", "transient"] optionally specify the type of
37+
analysis described in the ''data_sources''.
38+
If nothing is specified, the ''data_sources'' are read to evaluate
39+
the ''analysis_type''.
40+
2941
Examples
3042
--------
3143
>>> solution = post.solution("file.rst")
3244
"""
3345
_model = Model(data_sources)
3446
data_sources = _model.metadata.data_sources
3547

36-
analysis_type = _model.metadata.result_info.analysis_type
37-
physics_type = _model.metadata.result_info.physics_type
48+
if not physics_type:
49+
try:
50+
physics_type = _model.metadata.result_info.physics_type
51+
except Exception as e:
52+
print("Physics type is taken as mecanic by default, please specify physics_type",
53+
"keyword if it's wrong")
54+
physics_type = _PhysicsType.mecanic
55+
56+
if not analysis_type:
57+
try:
58+
analysis_type = _model.metadata.result_info.analysis_type
59+
except Exception as e:
60+
print("Analysis type is taken as static by default, please specify analysis_type",
61+
"keyword if it's wrong")
62+
analysis_type = _AnalysisType.static
63+
3864
if physics_type == _PhysicsType.thermal:
3965
if analysis_type == _AnalysisType.static:
4066
return ThermalStaticAnalysisSolution(data_sources, _model)

docs/source/getting_started/install.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Once you've installed Ansys 2021R1 or newer, you can install DPF with:
1111
1212
1313
This will install the latest version of ``ansys-dpf-post`` and all the
14-
necessary dependacies.
14+
necessary dependencies.
1515

1616
If you are unable to install the module on the host machine due to
17-
network isolation, download the latest release wheel at `DPF-Post
18-
GitHub <https://https://github.com/pyansys/DPF-Post>`_ or from PyPi at
19-
`DPF-Post PyPi <https://pypi.org/project/ansys-dpf-post/>`_
17+
network isolation, download the latest release wheel at `pydpf-post
18+
GitHub <https://github.com/pyansys/pydpf-post>`_ or from PyPi at
19+
`pydpf-post PyPi <https://pypi.org/project/ansys-dpf-post/>`_
2020

2121

2222
Editable Install (Development Mode)

0 commit comments

Comments
 (0)