Skip to content

Fix bounding box extent #1314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
5 commits merged into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added _unittest/example_models/test_107.aedb/edb.def
Binary file not shown.
14 changes: 14 additions & 0 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pyaedt.edb_core.components import resistor_value_parser
from pyaedt.edb_core.EDB_Data import SimulationConfiguration
from pyaedt.edb_core.EDB_Data import Source
from pyaedt.generic.constants import RadiationBoxType
from pyaedt.generic.constants import SolverType
from pyaedt.generic.constants import SourceType

Expand Down Expand Up @@ -1611,3 +1612,16 @@ def test_Z_build_hfss_project_from_config_file(self):

sim_config = SimulationConfiguration(cfg_file)
assert self.edbapp.build_simulation_project(sim_config)

def test_107_set_bounding_box_extent(self):
source_path = os.path.join(local_path, "example_models", "test_107.aedb")
target_path = os.path.join(self.local_scratch.path, "test_107.aedb")
self.local_scratch.copyfolder(source_path, target_path)
edb = Edb(target_path)
initial_extent_info = edb.active_cell.GetHFSSExtentInfo()
assert initial_extent_info.ExtentType == edb.edb.Utility.HFSSExtentInfoType.Conforming
config = SimulationConfiguration()
config.radiation_box = RadiationBoxType.BoundingBox
assert edb.core_hfss.configure_hfss_extents(config)
final_extent_info = edb.active_cell.GetHFSSExtentInfo()
assert final_extent_info.ExtentType == edb.edb.Utility.HFSSExtentInfoType.BoundingBox
13 changes: 6 additions & 7 deletions pyaedt/edb_core/EDB_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pyaedt.generic.constants import SolverType
from pyaedt.generic.constants import SourceType
from pyaedt.generic.constants import SweepType
from pyaedt.generic.constants import validate_enum_class_value
from pyaedt.generic.general_methods import is_ironpython
from pyaedt.generic.general_methods import pyaedt_function_handler
from pyaedt.modeler.GeometryOperators import GeometryOperators
Expand Down Expand Up @@ -3414,7 +3415,7 @@ def cutout_subdesign_type(self):

@cutout_subdesign_type.setter
def cutout_subdesign_type(self, value): # pragma: no cover
if isinstance(value, CutoutSubdesignType):
if validate_enum_class_value(CutoutSubdesignType, value):
self._cutout_subdesign_type = value

@property
Expand Down Expand Up @@ -3618,8 +3619,8 @@ def radiation_box(self): # pragma: no cover
return self._radiation_box

@radiation_box.setter
def radiation_box(self, value): # pragma: no cover
if isinstance(value, RadiationBoxType):
def radiation_box(self, value):
if validate_enum_class_value(RadiationBoxType, value):
self._radiation_box = value

@property
Expand Down Expand Up @@ -3667,10 +3668,8 @@ def sweep_type(self): # pragma: no cover

@sweep_type.setter
def sweep_type(self, value): # pragma: no cover
if isinstance(value, SweepType):
if validate_enum_class_value(SweepType, value):
self._sweep_type = value
# if isinstance(value, str):
# self._sweep_type = value

@property
def step_freq(self): # pragma: no cover
Expand Down Expand Up @@ -3781,7 +3780,7 @@ def basis_order(self): # pragma: no cover

@basis_order.setter
def basis_order(self, value): # pragma: no cover
if isinstance(value, BasisOrder):
if validate_enum_class_value(BasisOrder, value):
self._basis_order = value

@property
Expand Down
3 changes: 2 additions & 1 deletion pyaedt/edb_core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,8 @@ def configure_hfss_extents(self, simulation_setup=None):
hfss_extent.HonorUserDielectric = simulation_setup.honor_user_dielectric
hfss_extent.TruncateAirBoxAtGround = simulation_setup.truncate_airbox_at_ground
hfss_extent.UseOpenRegion = simulation_setup.use_radiation_boundary
return self._active_layout.GetCell().SetHFSSExtentInfo(hfss_extent)
self._active_layout.GetCell().SetHFSSExtentInfo(hfss_extent) # returns void
return True

@pyaedt_function_handler()
def configure_hfss_analysis_setup(self, simulation_setup=None):
Expand Down
26 changes: 22 additions & 4 deletions pyaedt/generic/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ def scale_units(scale_to_unit):
return sunit


def validate_enum_class_value(cls, value):
"""Return bool whether value is a valid value for enumeration-class cls.

Parameters
----------
cls : class
Enumeration-style class with integer members in range(0, N) where cls.Invalid equals N-1.
value : int
value to check

Returns
-------
bool
Whether value is a valid value for enumeration class cls.
"""
return isinstance(value, int) and value >= 0 and value < cls.Invalid


AEDT_UNITS = {
"AngularSpeed": {
"deg_per_hr": HOUR2SEC * DEG2RAD,
Expand Down Expand Up @@ -528,19 +546,19 @@ class SolverType(object):


class CutoutSubdesignType(object):
(Conformal, BoundingBox) = range(0, 2)
(Conformal, BoundingBox, Invalid) = range(0, 3)


class RadiationBoxType(object):
(Conformal, BoundingBox, ConvexHull) = range(0, 3)
(Conformal, BoundingBox, ConvexHull, Invalid) = range(0, 4)


class SweepType(object):
(Linear, LogCount) = range(0, 2)
(Linear, LogCount, Invalid) = range(0, 3)


class BasisOrder(object):
(Mixed, Zero, single, Double) = range(0, 4)
(Mixed, Zero, single, Double, Invalid) = range(0, 5)


class NodeType(object):
Expand Down