From 9b2828d794f3f283b17361c8a12284424b1efb90 Mon Sep 17 00:00:00 2001 From: adimaria Date: Tue, 9 Jul 2024 16:36:58 +0200 Subject: [PATCH] replaced argument output_dir with output_file for mrthod export_field_file --- _unittest/test_27_Maxwell2D.py | 2 +- _unittest_solvers/test_00_analyze.py | 18 +++++++++--------- pyaedt/modules/PostProcessor.py | 24 ++++++++++++------------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/_unittest/test_27_Maxwell2D.py b/_unittest/test_27_Maxwell2D.py index 1c25f7594ac..28baf00ab85 100644 --- a/_unittest/test_27_Maxwell2D.py +++ b/_unittest/test_27_Maxwell2D.py @@ -596,6 +596,6 @@ def test_37_boundaries_by_type(self): def test_38_export_fields_calc(self): output_file = os.path.join(self.local_scratch.path, "e_tang_field.fld") assert self.m2d_field_export.post.export_field_file( - quantity="E_Line", output_dir=output_file, assignment="Poly1", objects_type="Line" + quantity="E_Line", output_file=output_file, assignment="Poly1", objects_type="Line" ) assert os.path.exists(output_file) diff --git a/_unittest_solvers/test_00_analyze.py b/_unittest_solvers/test_00_analyze.py index b1606b1e9a1..eec974cc0e1 100644 --- a/_unittest_solvers/test_00_analyze.py +++ b/_unittest_solvers/test_00_analyze.py @@ -192,11 +192,11 @@ def test_02_hfss_export_results(self, hfss_app): assert len(exported_files) > 0 fld_file1 = os.path.join(self.local_scratch.path, "test_fld_hfss1.fld") - assert hfss_app.post.export_field_file(quantity="Mag_E", output_dir=fld_file1, assignment="Box1", + assert hfss_app.post.export_field_file(quantity="Mag_E", output_file=fld_file1, assignment="Box1", intrinsics="1GHz", phase="5deg") assert os.path.exists(fld_file1) fld_file2 = os.path.join(self.local_scratch.path, "test_fld_hfss2.fld") - assert hfss_app.post.export_field_file(quantity="Mag_E", output_dir=fld_file2, assignment="Box1", + assert hfss_app.post.export_field_file(quantity="Mag_E", output_file=fld_file2, assignment="Box1", intrinsics="1GHz") assert os.path.exists(fld_file2) @@ -298,26 +298,26 @@ def test_03d_icepak_eval_tempc(self): def test_03e_icepak_ExportFLDFil(self): fld_file = os.path.join(self.local_scratch.path, "test_fld.fld") self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, variations={}, - output_dir=fld_file, assignment="box") + output_file=fld_file, assignment="box") assert os.path.exists(fld_file) fld_file_1 = os.path.join(self.local_scratch.path, "test_fld_1.fld") sample_points_file = os.path.join(local_path, "example_models", test_subfolder, "temp_points.pts") self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, variations=self.icepak_app.available_variations.nominal_w_values_dict, - output_dir=fld_file_1, assignment="box", + output_file=fld_file_1, assignment="box", sample_points_file=sample_points_file) assert os.path.exists(fld_file_1) fld_file_2 = os.path.join(self.local_scratch.path, "test_fld_2.fld") self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, variations=self.icepak_app.available_variations.nominal_w_values_dict, - output_dir=fld_file_2, assignment="box", + output_file=fld_file_2, assignment="box", sample_points=[[0, 0, 0], [3, 6, 8], [4, 7, 9]]) assert os.path.exists(fld_file_2) cs = self.icepak_app.modeler.create_coordinate_system() fld_file_3 = os.path.join(self.local_scratch.path, "test_fld_3.fld") self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, variations=self.icepak_app.available_variations.nominal_w_values_dict, - output_dir=fld_file_3, assignment="box", + output_file=fld_file_3, assignment="box", sample_points=[[0, 0, 0], [3, 6, 8], [4, 7, 9]], reference_coordinate_system=cs.name, export_in_si_system=False, export_field_in_reference=False) @@ -422,17 +422,17 @@ def test_07_export_maxwell_fields(self, m3dtransient): m3dtransient.analyze(m3dtransient.active_setup, cores=4, use_auto_settings=False) fld_file_3 = os.path.join(self.local_scratch.path, "test_fld_3.fld") assert m3dtransient.post.export_field_file(quantity="Mag_B", solution=m3dtransient.nominal_sweep, variations={}, - output_dir=fld_file_3, assignment="Coil_A2", objects_type="Surf", + output_file=fld_file_3, assignment="Coil_A2", objects_type="Surf", intrinsics="10ms") assert os.path.exists(fld_file_3) fld_file_4 = os.path.join(self.local_scratch.path, "test_fld_4.fld") assert not m3dtransient.post.export_field_file(quantity="Mag_B", solution=m3dtransient.nominal_sweep, variations=m3dtransient.available_variations.nominal_w_values_dict, - output_dir=fld_file_4, assignment="Coil_A2", + output_file=fld_file_4, assignment="Coil_A2", objects_type="invalid") setup = m3dtransient.setups[0] m3dtransient.setups[0].delete() - assert not m3dtransient.post.export_field_file(quantity="Mag_B", variations={}, output_dir=fld_file_4, + assert not m3dtransient.post.export_field_file(quantity="Mag_B", variations={}, output_file=fld_file_4, assignment="Coil_A2") new_setup = m3dtransient.create_setup(name=setup.name, setup_type=setup.setuptype) diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index e32a6179530..dba153fa0cc 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -2907,7 +2907,7 @@ def export_field_file_on_grid( @pyaedt_function_handler( quantity_name="quantity", variation_dict="variations", - filename="output_dir", + filename="output_file", obj_list="assignment", obj_type="objects_type", sample_points_lists="sample_points", @@ -2917,7 +2917,7 @@ def export_field_file( quantity, solution=None, variations=None, - output_dir=None, + output_file=None, assignment="AllObjects", objects_type="Vol", intrinsics=None, @@ -2941,9 +2941,9 @@ def export_field_file( variations : dict, optional Dictionary of all variation variables with their values. The default is ``None``. - output_dir : str, optional + output_file : str, optional Full path and name to save the file to. - The default is ``None`` which export file in working_directory. + The default is ``None`` which export a file named ``".fld"`` in working_directory. assignment : str, optional List of objects to export. The default is ``"AllObjects"``. objects_type : str, optional @@ -2994,12 +2994,12 @@ def export_field_file( self.logger.error("There are no existing sweeps.") return False solution = self._app.existing_analysis_sweeps[0] - if not output_dir: + if not output_file: appendix = "" ext = ".fld" - output_dir = os.path.join(self._app.working_directory, solution.replace(" : ", "_") + appendix + ext) + output_file = os.path.join(self._app.working_directory, solution.replace(" : ", "_") + appendix + ext) else: - output_dir = output_dir.replace("//", "/").replace("\\", "/") + output_file = output_file.replace("//", "/").replace("\\", "/") self.ofieldsreporter.CalcStack("clear") try: self.ofieldsreporter.EnterQty(quantity) @@ -3042,7 +3042,7 @@ def export_field_file( args = ["Solution:=", solution, "Geometry:=", assignment, "GeometryType:=", objects_type] else: args = ["Solution:=", solution] - self.ofieldsreporter.CalculatorWrite(output_dir, args, variation) + self.ofieldsreporter.CalculatorWrite(output_file, args, variation) elif sample_points_file: export_options = [ "NAME:ExportOption", @@ -3056,7 +3056,7 @@ def export_field_file( export_field_in_reference, ] self.ofieldsreporter.ExportToFile( - output_dir, + output_file, sample_points_file, solution, variation, @@ -3080,15 +3080,15 @@ def export_field_file( export_field_in_reference, ] self.ofieldsreporter.ExportToFile( - output_dir, + output_file, sample_points_file, solution, variation, export_options, ) - if os.path.exists(output_dir): - return output_dir + if os.path.exists(output_file): + return output_file return False # pragma: no cover @pyaedt_function_handler(plotname="plot_name", filepath="output_dir", filename="file_name")