Skip to content

Commit 3d773c9

Browse files
authored
Remove operator name in result info print (#119)
1 parent 545d664 commit 3d773c9

File tree

8 files changed

+119
-139
lines changed

8 files changed

+119
-139
lines changed

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,20 @@ To open a result file and explore what's inside, do:
6767

6868
DPF Model
6969
------------------------------
70-
DPF Result Info
71-
Analysis: static
72-
Physics Type: mecanic
73-
Unit system: MKS: m, kg, N, s, V, A, degC
74-
Available results:
75-
U Displacement :nodal displacements
76-
ENF Element nodal Forces :element nodal forces
77-
ENG_VOL Volume :element volume
78-
ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix
79-
ENG_AHO Hourglass Energy :artificial hourglass energy
80-
ENG_TH thermal dissipation energy :thermal dissipation energy
81-
ENG_KE Kinetic Energy :kinetic energy
82-
ENG_CO co-energy :co-energy (magnetics)
83-
ENG_INC incremental energy :incremental energy (magnetics)
84-
BFE Temperature :element structural nodal temperatures
70+
Static analysis
71+
Unit system: Metric (m, kg, N, s, V, A)
72+
Physics Type: Mecanic
73+
Available results:
74+
- displacement: Nodal Displacement
75+
- element_nodal_forces: ElementalNodal Element nodal Forces
76+
- elemental_volume: Elemental Volume
77+
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
78+
- artificial_hourglass_energy: Elemental Hourglass Energy
79+
- thermal_dissipation_energy: Elemental thermal dissipation energy
80+
- kinetic_energy: Elemental Kinetic Energy
81+
- co_energy: Elemental co-energy
82+
- incremental_energy: Elemental incremental energy
83+
- structural_temperature: ElementalNodal Temperature
8584
------------------------------
8685
DPF Meshed Region:
8786
3751 nodes
@@ -92,8 +91,8 @@ To open a result file and explore what's inside, do:
9291
DPF Time/Freq Support:
9392
Number of sets: 1
9493
Cumulative Time (s) LoadStep Substep
95-
1 1.000000 1 1
96-
94+
1 1.000000 1 1
95+
9796

9897
```
9998

ansys/dpf/core/available_result.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ def native_scoping_location(self):
134134
else:
135135
return loc
136136

137+
@property
138+
def physical_name(self) -> str:
139+
"""Name of the result with spaces"""
140+
return self._message.physicsname
141+
137142

138143
_result_properties = {
139144
"S": {"location": "ElementalNodal", "scripting_name": "stress"},

ansys/dpf/core/result_info.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,21 @@ def __init__(self, result_info, server=None):
7373
self._message = result_info
7474

7575
def __str__(self):
76-
txt = (
77-
"%s analysis\n" % self.analysis_type.capitalize()
78-
+ "Unit system: %s\n" % self.unit_system
79-
+ "Physics Type: %s\n" % self.physics_type.capitalize()
80-
+ "Available results:\n"
81-
)
82-
for res in self.available_results:
83-
line = ["", "-", res.name]
84-
txt += "{0:^4} {1:^2} {2:<30}".format(*line) + "\n"
85-
86-
return txt
76+
try:
77+
txt = (
78+
"%s analysis\n" % self.analysis_type.capitalize()
79+
+ "Unit system: %s\n" % self.unit_system
80+
+ "Physics Type: %s\n" % self.physics_type.capitalize()
81+
+ "Available results:\n"
82+
)
83+
for res in self.available_results:
84+
line = ["", "-", f'{res.name}: {res.native_location} {res.physical_name}']
85+
txt += "{0:^4} {1:^2} {2:<30}".format(*line) + "\n"
86+
87+
return txt
88+
except:
89+
from ansys.dpf.core.core import _description
90+
return _description(self._message, self._server)
8791

8892
@property
8993
def _names(self):
@@ -308,17 +312,6 @@ def _connect(self):
308312
"""Connect to the gRPC service containing the reader."""
309313
return result_info_pb2_grpc.ResultInfoServiceStub(self._server.channel)
310314

311-
def __str__(self):
312-
"""Describe the entity.
313-
314-
Returns
315-
-------
316-
description : str
317-
"""
318-
from ansys.dpf.core.core import _description
319-
320-
return _description(self._message, self._server)
321-
322315
def __del__(self):
323316
try:
324317
self._stub.Delete(self._message)

docs/source/_static/simple_example.rst

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,31 @@ extracting results from it is easy:
1818
1919
DPF Model
2020
------------------------------
21-
DPF Result Info
22-
Analysis: static
23-
Physics Type: mecanic
24-
Unit system: MKS: m, kg, N, s, V, A, degC
25-
Available results:
26-
U Displacement :nodal displacements
27-
ENF Element nodal Forces :element nodal forces
28-
ENG_VOL Volume :element volume
29-
ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix
30-
ENG_AHO Hourglass Energy :artificial hourglass energy
31-
ENG_TH thermal dissipation energy :thermal dissipation energy
32-
ENG_KE Kinetic Energy :kinetic energy
33-
ENG_CO co-energy :co-energy (magnetics)
34-
ENG_INC incremental energy :incremental energy (magnetics)
35-
BFE Temperature :element structural nodal temperatures
21+
Static analysis
22+
Unit system: Metric (m, kg, N, s, V, A)
23+
Physics Type: Mecanic
24+
Available results:
25+
- displacement: Nodal Displacement
26+
- element_nodal_forces: ElementalNodal Element nodal Forces
27+
- elemental_volume: Elemental Volume
28+
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
29+
- artificial_hourglass_energy: Elemental Hourglass Energy
30+
- thermal_dissipation_energy: Elemental thermal dissipation energy
31+
- kinetic_energy: Elemental Kinetic Energy
32+
- co_energy: Elemental co-energy
33+
- incremental_energy: Elemental incremental energy
34+
- structural_temperature: ElementalNodal Temperature
3635
------------------------------
37-
DPF Meshed Region:
38-
3751 nodes
39-
3000 elements
40-
Unit: m
36+
DPF Meshed Region:
37+
3751 nodes
38+
3000 elements
39+
Unit: m
4140
With solid (3D) elements
4241
------------------------------
43-
DPF Time/Freq Support:
44-
Number of sets: 1
45-
Cumulative Time (s) LoadStep Substep
46-
1 1.000000 1 1
42+
DPF Time/Freq Support:
43+
Number of sets: 1
44+
Cumulative Time (s) LoadStep Substep
45+
1 1.000000 1 1
4746
4847
4948
.. code-block:: default

docs/source/getting_started/index.rst

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,31 @@ For a quick tryout installation, use:
4848
4949
DPF Model
5050
------------------------------
51-
DPF Result Info
52-
Analysis: static
53-
Physics Type: mecanic
54-
Unit system: MKS: m, kg, N, s, V, A, degC
55-
Available results:
56-
U Displacement :nodal displacements
57-
ENF Element nodal Forces :element nodal forces
58-
ENG_VOL Volume :element volume
59-
ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix
60-
ENG_AHO Hourglass Energy :artificial hourglass energy
61-
ENG_TH thermal dissipation energy :thermal dissipation energy
62-
ENG_KE Kinetic Energy :kinetic energy
63-
ENG_CO co-energy :co-energy (magnetics)
64-
ENG_INC incremental energy :incremental energy (magnetics)
65-
BFE Temperature :element structural nodal temperatures
51+
Static analysis
52+
Unit system: Metric (m, kg, N, s, V, A)
53+
Physics Type: Mecanic
54+
Available results:
55+
- displacement: Nodal Displacement
56+
- element_nodal_forces: ElementalNodal Element nodal Forces
57+
- elemental_volume: Elemental Volume
58+
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
59+
- artificial_hourglass_energy: Elemental Hourglass Energy
60+
- thermal_dissipation_energy: Elemental thermal dissipation energy
61+
- kinetic_energy: Elemental Kinetic Energy
62+
- co_energy: Elemental co-energy
63+
- incremental_energy: Elemental incremental energy
64+
- structural_temperature: ElementalNodal Temperature
6665
------------------------------
67-
DPF Meshed Region:
68-
3751 nodes
69-
3000 elements
70-
Unit: m
66+
DPF Meshed Region:
67+
3751 nodes
68+
3000 elements
69+
Unit: m
7170
With solid (3D) elements
7271
------------------------------
73-
DPF Time/Freq Support:
74-
Number of sets: 1
75-
Cumulative Time (s) LoadStep Substep
76-
1 1.000000 1 1
72+
DPF Time/Freq Support:
73+
Number of sets: 1
74+
Cumulative Time (s) LoadStep Substep
75+
1 1.000000 1 1
7776
7877
7978

docs/source/user_guide/model.rst

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,31 @@ To undestand what is available in the result file, you can print the model
3737
3838
DPF Model
3939
------------------------------
40-
DPF Result Info
41-
Analysis: static
42-
Physics Type: mecanic
43-
Unit system: MKS: m, kg, N, s, V, A, degC
44-
Available results:
45-
U Displacement :nodal displacements
46-
ENF Element nodal Forces :element nodal forces
47-
ENG_VOL Volume :element volume
48-
ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix
49-
ENG_AHO Hourglass Energy :artificial hourglass energy
50-
ENG_TH thermal dissipation energy :thermal dissipation energy
51-
ENG_KE Kinetic Energy :kinetic energy
52-
ENG_CO co-energy :co-energy (magnetics)
53-
ENG_INC incremental energy :incremental energy (magnetics)
54-
BFE Temperature :element structural nodal temperatures
40+
Static analysis
41+
Unit system: Metric (m, kg, N, s, V, A)
42+
Physics Type: Mecanic
43+
Available results:
44+
- displacement: Nodal Displacement
45+
- element_nodal_forces: ElementalNodal Element nodal Forces
46+
- elemental_volume: Elemental Volume
47+
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
48+
- artificial_hourglass_energy: Elemental Hourglass Energy
49+
- thermal_dissipation_energy: Elemental thermal dissipation energy
50+
- kinetic_energy: Elemental Kinetic Energy
51+
- co_energy: Elemental co-energy
52+
- incremental_energy: Elemental incremental energy
53+
- structural_temperature: ElementalNodal Temperature
5554
------------------------------
56-
DPF Meshed Region:
57-
3751 nodes
58-
3000 elements
59-
Unit: m
55+
DPF Meshed Region:
56+
3751 nodes
57+
3000 elements
58+
Unit: m
6059
With solid (3D) elements
6160
------------------------------
62-
DPF Time/Freq Support:
63-
Number of sets: 1
64-
Cumulative Time (s) LoadStep Substep
65-
1 1.000000 1 1
61+
DPF Time/Freq Support:
62+
Number of sets: 1
63+
Cumulative Time (s) LoadStep Substep
64+
1 1.000000 1 1
6665
6766
6867
@@ -157,35 +156,21 @@ To view available results, print them:
157156

158157
.. code-block:: none
159158
160-
DPF Result Information
161-
162-
Analysis: static
163-
164-
Physics Type: mecanic
165-
166-
Unit system: MKS: m, kg, N, s, V, A, degC
167-
Available results:
168-
169-
U Displacement :nodal displacements
170-
171-
ENF Element nodal Forces :element nodal forces
172-
173-
ENG_VOL Volume :element volume
174-
175-
ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix
176-
177-
ENG_AHO Hourglass Energy :artificial hourglass energy
178-
179-
ENG_TH thermal dissipation energy :thermal dissipation energy
180-
181-
ENG_KE Kinetic Energy :kinetic energy
182-
183-
ENG_CO co-energy :co-energy (magnetics)
184-
185-
ENG_INC incremental energy :incremental energy (magnetics)
186-
187-
BFE Temperature :element structural nodal temperatures
188-
159+
Static analysis
160+
Unit system: Metric (m, kg, N, s, V, A)
161+
Physics Type: Mecanic
162+
Available results:
163+
- displacement: Nodal Displacement
164+
- element_nodal_forces: ElementalNodal Element nodal Forces
165+
- elemental_volume: Elemental Volume
166+
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
167+
- artificial_hourglass_energy: Elemental Hourglass Energy
168+
- thermal_dissipation_energy: Elemental thermal dissipation energy
169+
- kinetic_energy: Elemental Kinetic Energy
170+
- co_energy: Elemental co-energy
171+
- incremental_energy: Elemental incremental energy
172+
- structural_temperature: ElementalNodal Temperature
173+
189174
190175
.. autoattribute:: ansys.dpf.core.model.Model.results
191176
:noindex:

tests/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_kinetic(static_model):
5757

5858

5959
def test_str_model(static_model):
60-
assert "Physics Type: mecanic" in str(static_model)
60+
assert "Static" in str(static_model)
6161
assert "81" in str(static_model)
6262
assert "Unit: m" in str(static_model)
6363

tests/test_resultinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_get_resultinfo_no_model(velocity_acceleration):
2222

2323
def test_get_resultinfo(model):
2424
res = model.metadata.result_info
25-
assert "Analysis: static" in str(res)
25+
assert "Static analysis" in str(res)
2626
assert res.analysis_type == "static"
2727
assert res.n_results == 14
2828
assert res.unit_system == "Metric (m, kg, N, s, V, A)"

0 commit comments

Comments
 (0)