Skip to content

Commit

Permalink
FIX: Use "lite" CLR host on windows for 251+ (#920)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohamed Koubaa <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: pyansys-ci-bot <[email protected]>
  • Loading branch information
4 people authored Sep 27, 2024
1 parent f51a086 commit 498e216
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/920.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use "lite" CLR host on windows for 251+
6 changes: 0 additions & 6 deletions src/ansys/mechanical/core/embedding/addins.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,3 @@ def addin_configuration(self) -> str:
@addin_configuration.setter
def addin_configuration(self, value: str):
self._addin_configuration = value


def configure(configuration: AddinConfiguration):
"""Apply the given configuration."""
if configuration.no_act_addins:
os.environ["ANSYS_MECHANICAL_STANDALONE_NO_ACT_EXTENSIONS"] = "1"
18 changes: 16 additions & 2 deletions src/ansys/mechanical/core/embedding/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,24 @@ def _get_default_version() -> int:
return int_version


def __check_python_interpreter_architecture():
def __check_python_interpreter_architecture() -> None:
"""Embedding support only 64 bit architecture."""
if platform.architecture()[0] != "64bit":
raise Exception("Mechanical Embedding requires a 64-bit Python environment.")


def __set_environment(version: int) -> None:
"""Set environment variables to configure embedding."""
if os.name == "nt": # pragma: no cover
if version < 251:
os.environ["MECHANICAL_STARTUP_UNOPTIMIZED"] = "1"

# TODO - use this on linux as well
if version >= 251:
if "PYMECHANICAL_NO_CLR_HOST_LITE" not in os.environ:
os.environ["ANSYS_MECHANICAL_EMBEDDING_CLR_HOST"] = "1"


def __check_for_mechanical_env():
"""Embedding in linux platform must use mechanical-env."""
if platform.system() == "Linux" and os.environ.get("PYMECHANICAL_EMBEDDING") != "TRUE":
Expand Down Expand Up @@ -157,7 +169,9 @@ def initialize(version: int = None):

INITIALIZED_VERSION = version

__check_loaded_libs(version) # pragma: no cover
__set_environment(version)

__check_loaded_libs(version)

__workaround_material_server(version)

Expand Down
4 changes: 4 additions & 0 deletions tests/embedding/test_dyna.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def test_lsdyna(printer, embedded_app, assets):
Runs only in Windows environment. This test involves
a simple geometry with high velocity
hitting on rigid wall.
Note - In order for standalone Mechanical to use LS-DYNA,
the lsdyna license needs to be at the top of the list.
Use the license preferences in Mechanical to set this up.
"""
embedded_app.update_globals(globals())
printer("Setting up test - LSDyna system")
Expand Down

0 comments on commit 498e216

Please sign in to comment.