Skip to content

Commit 420c882

Browse files
authored
fix create_fieldplot_surface (#4191)
1 parent 0032bb4 commit 420c882

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

_unittest/test_12_1_PostProcessing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ def test_01B_Field_Plot(self):
7878
assert self.aedtapp.post.field_plots[plot1.name].IsoVal == "Tone"
7979
assert plot1.change_plot_scale(min_value, "30000")
8080
assert self.aedtapp.post.create_fieldplot_volume("inner", "Vector_E", setup_name, intrinsic)
81-
8281
assert self.aedtapp.post.create_fieldplot_surface(
8382
self.aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic
8483
)
8584
assert self.aedtapp.post.create_fieldplot_surface(self.aedtapp.modeler["outer"], "Mag_E", setup_name, intrinsic)
8685
assert self.aedtapp.post.create_fieldplot_surface(
8786
self.aedtapp.modeler["outer"].faces, "Mag_E", setup_name, intrinsic
8887
)
88+
assert not self.aedtapp.post.create_fieldplot_surface(123123123, "Mag_E", setup_name, intrinsic)
8989
assert len(self.aedtapp.setups[0].sweeps[0].frequencies) > 0
9090
assert isinstance(self.aedtapp.setups[0].sweeps[0].basis_frequencies, list)
9191
assert len(self.aedtapp.setups[0].sweeps[1].basis_frequencies) == 2

examples/03-Maxwell/Maxwell2D_NissanLeaf.py

+20-11
Original file line numberDiff line numberDiff line change
@@ -708,25 +708,34 @@ def create_cs_magnets(pm_id, cs_name, point_direction):
708708
# report_category=None, plot_type="Rectangular Plot", context=None, subdesign_id=None,
709709
# polyline_points=1001, plotname=v)
710710

711+
712+
##########################################################
713+
# Analyze and save project
714+
# ~~~~~~~~~~~~~~~~~~~~~~~~
715+
# Analyze and save the project.
716+
717+
M2D.save_project()
718+
M2D.analyze_setup(sName, use_auto_settings=False)
719+
711720
##########################################################
712721
# Create flux lines plot on region
713722
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
714723
# Create a flux lines plot on a region. The ``object_list`` is
715724
# formerly created when the section is applied.
716725

717726
faces_reg = mod2D.get_object_faces(object_list[1].name) # Region
718-
# Maxwell Transient needs time specified in a dictionary
719-
# "IntrinsicVar:=" , "Time=\'0\'",
720-
M2D.post.create_fieldplot_surface(objlist=faces_reg, quantityName='Flux_Lines', intrinsincDict={"Time": "0.000"},
721-
plot_name="Flux_Lines")
727+
plot1 = M2D.post.create_fieldplot_surface(objlist=faces_reg,
728+
quantityName='Flux_Lines',
729+
intrinsincDict={
730+
"Time": M2D.variable_manager.variables["StopTime"].evaluated_value},
731+
plot_name="Flux_Lines")
722732

723733
##########################################################
724-
# Analyze and save project
725-
# ~~~~~~~~~~~~~~~~~~~~~~~~
726-
# Analyze and save the project.
734+
# Export a field plot to an image file
735+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
736+
# Export the flux lines plot to an image file using Python PyVista.
727737

728-
M2D.save_project()
729-
M2D.analyze_setup(sName, use_auto_settings=False)
738+
M2D.post.plot_field_from_fieldplot(plot1.name, show=False)
730739

731740
###############################################
732741
# Get solution data
@@ -736,15 +745,15 @@ def create_cs_magnets(pm_id, cs_name, point_direction):
736745

737746
solutions = M2D.post.get_solution_data(expressions="Moving1.Torque",
738747
primary_sweep_variable="Time")
739-
solutions.plot()
748+
#solutions.plot()
740749

741750
###############################################
742751
# Retrieve the data magnitude of an expression
743752
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
744753
# List of shaft torque points and compute average.
745754

746755
mag = solutions.data_magnitude()
747-
avg = sum(mag)/len(mag)
756+
avg = sum(mag) / len(mag)
748757

749758
###############################################
750759
# Export a report to a file

examples/06-Multiphysics/Hfss_Icepak_Coupling.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
view="isometric",
260260
show=False,
261261
plot_cad_objs=False,
262-
log_scale = False,
262+
log_scale=False,
263263
)
264264

265265
################################################################################
@@ -329,13 +329,13 @@
329329
# Generate pdf report
330330
# ~~~~~~~~~~~~~~~~~~~
331331
# Generate a pdf report with output of simultion.
332-
report = AnsysReport(project_name=aedtapp.project_name, design_name=aedtapp.design_name,version=desktopVersion)
332+
report = AnsysReport(project_name=aedtapp.project_name, design_name=aedtapp.design_name, version=desktopVersion)
333333
report.create()
334334
report.add_section()
335335
report.add_chapter("Hfss Results")
336336
report.add_sub_chapter("Field Plot")
337337
report.add_text("This section contains Field plots of Hfss Coaxial.")
338-
report.add_image(os.path.join(results_folder, plot1.name+".jpg"), "Coaxial Cable")
338+
report.add_image(os.path.join(results_folder, plot1.name + ".jpg"), "Coaxial Cable")
339339
report.add_page_break()
340340
report.add_sub_chapter("S Parameters")
341341
report.add_chart(my_data.intrinsics["Freq"], my_data.data_db20(), "Freq", trace_names[0], "S-Parameters")
@@ -345,11 +345,9 @@
345345
report.add_sub_chapter("Temperature Plot")
346346
report.add_text("This section contains Multiphysics temperature plot.")
347347
report.add_toc()
348-
#report.add_image(os.path.join(results_folder, plot5.name+".jpg"), "Coaxial Cable Temperatures")
348+
# report.add_image(os.path.join(results_folder, plot5.name+".jpg"), "Coaxial Cable Temperatures")
349349
report.save_pdf(results_folder, "AEDT_Results.pdf")
350350

351-
352-
353351
################################################################################
354352
# Close project and release AEDT
355353
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pyaedt/modules/PostProcessor.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from pyaedt.generic.general_methods import open_file
2323
from pyaedt.generic.general_methods import pyaedt_function_handler
2424
from pyaedt.generic.settings import settings
25+
from pyaedt.modeler.cad.elements3d import FacePrimitive
2526
import pyaedt.modules.report_templates as rt
2627
from pyaedt.modules.solutions import FieldPlot
2728
from pyaedt.modules.solutions import SolutionData
@@ -3226,11 +3227,11 @@ def create_fieldplot_surface(
32263227
if not isinstance(objlist, (list, tuple)):
32273228
objlist = [objlist]
32283229
new_obj_list = []
3229-
for objs in objlist:
3230-
if self._app.modeler[objs]:
3231-
new_obj_list.extend([i.id for i in self._app.modeler[objs].faces])
3232-
else:
3233-
new_obj_list.append(objs)
3230+
for obj in objlist:
3231+
if isinstance(obj, (int, FacePrimitive)):
3232+
new_obj_list.append(obj)
3233+
elif self._app.modeler[obj]:
3234+
new_obj_list.extend([face for face in self._app.modeler[obj].faces if face.id not in new_obj_list])
32343235
return self._create_fieldplot(
32353236
new_obj_list, quantityName, setup_name, intrinsincDict, "FacesList", plot_name, field_type=field_type
32363237
)

0 commit comments

Comments
 (0)