You have to install the Salome Meca and the Sovler.The latest meca version is 9.10
go to (Salome Meca root dir)/W64 and copy ASTERSTUDY dir into (Salome root dir)/W64.
Add several codes in (Salome root dir)/salome (it’s a python file without a suffix )
You can find those in (Salome Meca root dir)/salome and copy to (Salome root dir)/salome in same position.
register ASTERSTUDY
context.setVariable(r"SALOME_MODULES", r"SHAPER,SHAPERSTUDY,ASTERSTUDY,GEOM,SMESH,PARAVIS,YACS,JOBMANAGER", overwrite=True)
tell salome where to find ASTERSTUDY and the solver
#[ASTERSTUDY]
context.setVariable(r"ASTERSTUDY_ROOT_DIR", out_dir_Path + r"\W64\ASTERSTUDY", overwrite=True)
context.addToPythonPath(r"%ASTERSTUDY_ROOT_DIR%\%PYTHON_LIBDIR%")
context.addToPythonPath(r"%ASTERSTUDY_ROOT_DIR%\%PYTHON_LIBDIR%\salome")
appendPath(r"SalomeAppConfig", out_dir_Path + r"\W64\ASTERSTUDY\share\salome\resources\asterstudy",separator=";")
#[CODEASTER]
import winreg
try:
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"SOFTWARE\code_aster\v2023") as key:
aster_root_dir = winreg.EnumValue(key, 0)[1]
except:
aster_root_dir = None
if aster_root_dir is None and os.path.exists(out_dir_Path + r"\W64\code_aster"):
# use embeded code_aster
aster_root_dir = out_dir_Path + r"\W64\code_aster\v2023"
if not os.path.exists(aster_root_dir + r"\16.5\lib\aster\aster.pyd"):
# execute post-installation for embeded code_aster
subprocess.run(aster_root_dir + r"\16.5\update_pyd_links.bat")
if aster_root_dir:
context.setVariable(r"ASTER_ROOT_DIR", aster_root_dir, overwrite=True)
#context.setVariable(r"ASTER_OLDSTABLE", r"%ASTER_ROOT_DIR%\15.9", overwrite=True)
context.setVariable(r"ASTER_STABLE", r"%ASTER_ROOT_DIR%\16.5", overwrite=True)
context.addToPath(r"%ASTER_ROOT_DIR%\bin")
context.addToPythonPath(r"%ASTER_ROOT_DIR%\lib\python3.7\site-packages")
else:
print("ERROR : Code_Aster installation not found on this machine. ASTERSTUDY module will not found any Code_Aster version")
print(" You may download and install 'code_aster 2023 msi' package available at code-aster-windows.com/download")
a Salome MECA custom method
# salomeContext only prepend variables, we use our own appendPath when required
def appendPath(name, value, separator=os.pathsep):
if value == '':
return
value = os.path.expandvars(value) # expand environment variables
env = os.getenv(name, None)
if env is None:
os.environ[name] = value
else:
os.environ[name] = env + separator + value
do the same like previous and save. Go to Salome root dir and run run_salome.bat