11"""Module containing the method to instantiate the result
22object. Initialization of post objects.
33"""
4+ from builtins import Exception
45
56from ansys .dpf .core .model import Model
67
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 )
0 commit comments