@@ -903,6 +903,54 @@ def add_mesh_link(
903
903
self .auto_update = auto_update
904
904
return False
905
905
906
+ def _parse_link_parameters (self , map_variables_by_name , parameters ):
907
+ # parameters
908
+ params = OrderedDict ({})
909
+ if map_variables_by_name :
910
+ parameters = self .p_app .available_variations .nominal_w_values_dict
911
+ for k , v in parameters .items ():
912
+ params [k ] = k
913
+ elif parameters is None :
914
+ parameters = self .p_app .available_variations .nominal_w_values_dict
915
+ for k , v in parameters .items ():
916
+ params [k ] = v
917
+ else :
918
+ for k , v in parameters .items ():
919
+ if k in list (self ._app .available_variations .nominal_w_values_dict .keys ()):
920
+ params [k ] = v
921
+ else :
922
+ params [k ] = parameters [v ]
923
+ return params
924
+
925
+ def _parse_link_solution (self , project , design , solution ):
926
+ prev_solution = OrderedDict ({})
927
+
928
+ # project name
929
+ if project != "This Project*" :
930
+ if os .path .exists (project ):
931
+ prev_solution ["Project" ] = project
932
+ self .props ["PathRelativeTo" ] = "SourceProduct"
933
+ else :
934
+ raise ValueError ("Project file path provided does not exist." )
935
+ else :
936
+ prev_solution ["Project" ] = project
937
+ self .props ["PathRelativeTo" ] = "TargetProject"
938
+
939
+ # design name
940
+ if not design or design is None :
941
+ raise ValueError ("Provide design name to add mesh link to." )
942
+ elif design not in self .p_app .design_list :
943
+ raise ValueError ("Design does not exist in current project." )
944
+ else :
945
+ prev_solution ["Design" ] = design
946
+
947
+ # solution name
948
+ if solution :
949
+ prev_solution ["Soln" ] = solution
950
+ else :
951
+ raise ValueError ("Provide a valid solution name." )
952
+ return prev_solution
953
+
906
954
@pyaedt_function_handler (
907
955
design_name = "design" , solution_name = "solution" , parameters_dict = "parameters" , project_name = "project"
908
956
)
@@ -922,7 +970,7 @@ def start_continue_from_previous_setup(
922
970
----------
923
971
design : str
924
972
Name of the design.
925
- solution : str, optional
973
+ solution : str
926
974
Name of the solution in the format ``"name : solution_name"``.
927
975
For example, ``"Setup1 : Transient", "MySetup : LastAdaptive"``.
928
976
map_variables_by_name : bool, optional
@@ -962,49 +1010,9 @@ def start_continue_from_previous_setup(
962
1010
try :
963
1011
self .auto_update = False
964
1012
965
- # parameters
966
- params = OrderedDict ({})
967
- if map_variables_by_name :
968
- parameters = self .p_app .available_variations .nominal_w_values_dict
969
- for k , v in parameters .items ():
970
- params [k ] = k
971
- elif parameters is None :
972
- parameters = self .p_app .available_variations .nominal_w_values_dict
973
- for k , v in parameters .items ():
974
- params [k ] = v
975
- else :
976
- for k , v in parameters .items ():
977
- if k in list (self ._app .available_variations .nominal_w_values_dict .keys ()):
978
- params [k ] = v
979
- else :
980
- params [k ] = parameters [v ]
981
-
982
- prev_solution = OrderedDict ({})
983
-
984
- # project name
985
- if project != "This Project*" :
986
- if os .path .exists (project ):
987
- prev_solution ["Project" ] = project
988
- self .props ["PathRelativeTo" ] = "SourceProduct"
989
- else :
990
- raise ValueError ("Project file path provided does not exist." )
991
- else :
992
- prev_solution ["Project" ] = project
993
- self .props ["PathRelativeTo" ] = "TargetProject"
994
-
995
- # design name
996
- if not design or design is None :
997
- raise ValueError ("Provide design name to add mesh link to." )
998
- elif design not in self .p_app .design_list :
999
- raise ValueError ("Design does not exist in current project." )
1000
- else :
1001
- prev_solution ["Design" ] = design
1013
+ params = self ._parse_link_parameters (map_variables_by_name , parameters )
1002
1014
1003
- # solution name
1004
- if solution :
1005
- prev_solution ["Soln" ] = solution
1006
- else :
1007
- raise ValueError ("Provide a valid solution name." )
1015
+ prev_solution = self ._parse_link_solution (project , design , solution )
1008
1016
1009
1017
self .props ["PrevSoln" ] = prev_solution
1010
1018
@@ -3883,3 +3891,85 @@ def update(self, properties=None):
3883
3891
3884
3892
self .omodule .EditSetup (self .name , arg )
3885
3893
return True
3894
+
3895
+
3896
+ class SetupIcepak (Setup , object ):
3897
+ def __init__ (self , app , solution_type , setup_name , is_new_setup = True ):
3898
+ Setup .__init__ (self , app , solution_type , setup_name , is_new_setup )
3899
+
3900
+ def start_continue_from_previous_setup (
3901
+ self ,
3902
+ design ,
3903
+ solution ,
3904
+ map_variables_by_name = True ,
3905
+ parameters = None ,
3906
+ project = "This Project*" ,
3907
+ force_source_to_solve = True ,
3908
+ preserve_partner_solution = True ,
3909
+ frozen_flow = False ,
3910
+ ):
3911
+ """Start or continue from a previously solved setup.
3912
+
3913
+ Parameters
3914
+ ----------
3915
+ design : str
3916
+ Name of the design.
3917
+ solution : str
3918
+ Name of the solution in the format ``"name : solution_name"``.
3919
+ For example, ``"Setup1 : Transient"``, ``"Setup1 : SteadyState"``.
3920
+ map_variables_by_name : bool, optional
3921
+ Whether variables are mapped by name from the source design. The default is
3922
+ ``True``.
3923
+ parameters : dict, optional
3924
+ Dictionary of the parameters. This argument is not considered if
3925
+ ``map_variables_by_name=True``. If ``None``, the default is
3926
+ ``appname.available_variations.nominal_w_values_dict``.
3927
+ project : str, optional
3928
+ Name of the project with the design. The default is ``"This Project*"``.
3929
+ However, you can supply the full path and name to another project.
3930
+ force_source_to_solve : bool, optional
3931
+ The default is ``True``.
3932
+ preserve_partner_solution : bool, optional
3933
+ The default is ``True``.
3934
+ frozen_flow : bool, optional
3935
+ Whether to freeze the flow to the previous solution. The default is ``False``.
3936
+
3937
+ Returns
3938
+ -------
3939
+ bool
3940
+ ``True`` when successful, ``False`` when failed.
3941
+
3942
+ References
3943
+ ----------
3944
+
3945
+ >>> oModule.EditSetup
3946
+
3947
+ Examples
3948
+ --------
3949
+ >>> ipk = pyaedt.Icepak()
3950
+ >>> setup = ipk.get_setup("Setup1")
3951
+ >>> setup.start_continue_from_previous_setup(design="IcepakDesign1",solution="Setup1 : SteadyState")
3952
+
3953
+ """
3954
+
3955
+ auto_update = self .auto_update
3956
+ try :
3957
+ self .auto_update = False
3958
+
3959
+ params = self ._parse_link_parameters (map_variables_by_name , parameters )
3960
+
3961
+ prev_solution = self ._parse_link_solution (project , design , solution )
3962
+
3963
+ self .props ["RestartSoln" ] = prev_solution
3964
+
3965
+ self .props ["RestartSoln" ]["Params" ] = params
3966
+ self .props ["RestartSoln" ]["ForceSourceToSolve" ] = force_source_to_solve
3967
+ self .props ["RestartSoln" ]["PreservePartnerSoln" ] = preserve_partner_solution
3968
+ self .props ["Frozen Flow Simulation" ] = frozen_flow
3969
+
3970
+ self .update ()
3971
+ self .auto_update = auto_update
3972
+ return True
3973
+ except Exception :
3974
+ self .auto_update = auto_update
3975
+ return False
0 commit comments