Skip to content

Commit

Permalink
fix icepak tests in COM mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzovecchietti committed Nov 23, 2023
1 parent f87d5c4 commit 7c5f987
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 72 deletions.
2 changes: 1 addition & 1 deletion pyaedt/generic/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ def _export_general(self, dict_out):
dict_out["general"]["date"] = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
dict_out["general"]["object_mapping"] = {}
dict_out["general"]["output_variables"] = {}
if self._app.output_variables:
if list(self._app.output_variables):
oo_out = os.path.join(tempfile.gettempdir(), generate_unique_name("oo") + ".txt")
self._app.ooutput_variable.ExportOutputVariables(oo_out)
with open(oo_out, "r") as f:
Expand Down
83 changes: 12 additions & 71 deletions pyaedt/icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from pyaedt.modules.Boundary import BoundaryObject
from pyaedt.modules.Boundary import NativeComponentObject
from pyaedt.modules.Boundary import NetworkObject
from pyaedt.modules.Boundary import _create_boundary
from pyaedt.modules.monitor_icepak import Monitor


Expand Down Expand Up @@ -630,14 +631,7 @@ def create_conduting_plate(
)
props["Shell Conduction"] = shell_conduction
bound = BoundaryObject(self, bc_name, props, "Conducting Plate")
try:
if bound.create():
self._boundaries[bound.name] = bound
return bound
else: # pragma : no cover
raise SystemExit
except (GrpcApiError, SystemExit):
return None
return _create_boundary(bound)

@pyaedt_function_handler()
def create_source_power(
Expand Down Expand Up @@ -727,14 +721,7 @@ def create_source_power(
props["Temperature"] = temperature
props["Radiation"] = OrderedDict({"Radiate": radiate})
bound = BoundaryObject(self, source_name, props, "SourceIcepak")
try:
if bound.create():
self._boundaries[bound.name] = bound
return bound
else: # pragma : no cover
raise SystemExit
except (GrpcApiError, SystemExit):
return None
return _create_boundary(bound)

@pyaedt_function_handler()
def create_network_block(
Expand Down Expand Up @@ -3486,14 +3473,7 @@ def assign_stationary_wall(
props["External Radiation Reference Temperature"] = ext_surf_rad_ref_temp
props["External Radiation View Factor"] = ext_surf_rad_view_factor
bound = BoundaryObject(self, name, props, "Stationary Wall")
try:
if bound.create():
self._boundaries[bound.name] = bound
return bound
else: # pragma : no cover
raise SystemExit
except (GrpcApiError, SystemExit):
return None
return _create_boundary(bound)

@pyaedt_function_handler()
def assign_stationary_wall_with_heat_flux(
Expand Down Expand Up @@ -4200,14 +4180,7 @@ def assign_solid_block(
boundary_name = generate_unique_name("Block")

bound = BoundaryObject(self, boundary_name, props, "Block")
try:
if bound.create():
self._boundaries[bound.name] = bound
return bound
else: # pragma : no cover
raise SystemExit
except (GrpcApiError, SystemExit):
return None
return _create_boundary(bound)

@pyaedt_function_handler
def assign_hollow_block(
Expand Down Expand Up @@ -4335,14 +4308,7 @@ def assign_hollow_block(
boundary_name = generate_unique_name("Block")

bound = BoundaryObject(self, boundary_name, props, "Block")
try:
if bound.create():
self._boundaries[bound.name] = bound
return bound
else: # pragma : no cover
raise SystemExit
except (GrpcApiError, SystemExit):
return None
return _create_boundary(bound)

@pyaedt_function_handler()
def get_fans_operating_point(self, export_file=None, setup_name=None, timestep=None, design_variation=None):
Expand Down Expand Up @@ -4827,11 +4793,7 @@ def assign_mass_flow_free_opening(
)

@pyaedt_function_handler()
def assign_symmetry_wall(
self,
geometry,
boundary_name=None,
):
def assign_symmetry_wall(self, geometry, boundary_name=None):
"""Assign symmetry wall boundary condition.
Parameters
Expand Down Expand Up @@ -4864,14 +4826,7 @@ def assign_symmetry_wall(
props["Objects"] = geometry

bound = BoundaryObject(self, boundary_name, props, "Symmetry Wall")
try:
if bound.create():
self._boundaries[bound.name] = bound
return bound
else: # pragma : no cover
raise SystemExit
except (GrpcApiError, SystemExit):
return None
return _create_boundary(bound)

@pyaedt_function_handler()
def assign_adiabatic_plate(self, assignment, high_radiation_dict=None, low_radiation_dict=None, boundary_name=None):
Expand Down Expand Up @@ -5044,11 +4999,11 @@ def assign_recirculation_opening(self, face_list, extract_face, thermal_specific
if not len(face_list) == 2:
self.logger.error("Recirculation boundary condition must be assigned to two faces.")
return False
if conductance_external_temperature is not None and thermal_specification is not "Conductance":
if conductance_external_temperature is not None and thermal_specification != "Conductance":
self.logger.warning(
'``conductance_external_temperature`` does not have any effect unless the ``thermal_specification`` '
'is ``"Conductance"``.')
if conductance_external_temperature is not None and thermal_specification is not "Conductance":
if conductance_external_temperature is not None and thermal_specification != "Conductance":
self.logger.warning(
'``conductance_external_temperature`` must be specified when ``thermal_specification`` '
'is ``"Conductance"``. Setting ``conductance_external_temperature`` to ``"AmbientTemp"``.')
Expand Down Expand Up @@ -5122,14 +5077,7 @@ def assign_recirculation_opening(self, face_list, extract_face, thermal_specific
boundary_name = generate_unique_name("Recirculating")

bound = BoundaryObject(self, boundary_name, props, "Recirculating")
try:
if bound.create():
self._boundaries[bound.name] = bound
return bound
else: # pragma: no cover
raise SystemExit
except (GrpcApiError, SystemExit): # pragma : no cover
return None
return _create_boundary(bound)

@pyaedt_function_handler()
def assign_blower_type1(self, faces, inlet_face, fan_curve_pressure, fan_curve_flow, blower_power="0W", blade_rpm=0,
Expand Down Expand Up @@ -5281,11 +5229,4 @@ def _assign_blower(self, props, faces, inlet_face, fan_curve_flow_unit, fan_curv
if not boundary_name:
boundary_name = generate_unique_name("Blower")
bound = BoundaryObject(self, boundary_name, props, "Blower")
try:
if bound.create():
self._boundaries[bound.name] = bound
return bound
else: # pragma : no cover
raise SystemExit
except (GrpcApiError, SystemExit): # pragma: no cover
return None
return _create_boundary(bound)
14 changes: 14 additions & 0 deletions pyaedt/modules/Boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import copy
import re

import pywintypes

from pyaedt.application.Variables import decompose_variable_value
from pyaedt.generic.DataHandlers import _dict2arg
from pyaedt.generic.DataHandlers import random_string
from pyaedt.generic.constants import CATEGORIESQ3D
from pyaedt.generic.general_methods import GrpcApiError
from pyaedt.generic.general_methods import PropsManager
from pyaedt.generic.general_methods import _dim_arg
from pyaedt.generic.general_methods import filter_tuple
Expand Down Expand Up @@ -4506,3 +4509,14 @@ def _create_node_dict(self, default_dict):
node_args[k] = val

return node_args


def _create_boundary(bound):
try:
if bound.create():
bound._app._boundaries[bound.name] = bound
return bound
else: # pragma : no cover
raise SystemExit
except (GrpcApiError, SystemExit, pywintypes.com_error): # pragma: no cover
return None

0 comments on commit 7c5f987

Please sign in to comment.