Commit f0c4fc8f authored by Olivier Lantsoght's avatar Olivier Lantsoght
Browse files

[Ctypes] MBsysPy, python side

parent 772cda3e
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
Creation : 2019 by O. Lantsoght
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
"""
from .mbs_sensor import *
from .mbs_data import *
from .mbs_part import *
from .mbs_dirdyn import *
\ No newline at end of file
This diff is collapsed.
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
Creation : 2019 by O. Lantsoght
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
Define the class MbsDirdyn based on the MbsDirdyn structure of MBsysC.
This class has the functions required to manipulate the direct dynamic module.
This include setting the options, running an (or multiple) analysis and freeing
the memory.
"""
import os
import imp
import numpy as np
# importing MbsysPy classes
# importing libraries
from ..mbsysc_loader.loadlibs import libmodules
# importing wrapping function
from ..mbsysc_loader.callback import user_cons_hJ_wrap
from ..mbsysc_loader.callback import user_cons_jdqd_wrap
from ..mbsysc_loader.callback import user_dirdyn_init_wrap
from ..mbsysc_loader.callback import user_dirdyn_loop_wrap
from ..mbsysc_loader.callback import user_dirdyn_finish_wrap
from ..mbsysc_loader.callback import mbs_cons_hJ_wrap
from ..mbsysc_loader.callback import mbs_cons_jdqd_wrap
from ..mbsysc_loader.callback import mbs_invdyna_wrap
from ..mbsysc_loader.callback import mbs_dirdyna_wrap
#==============================================================================
# Global parameter of the current module
#==============================================================================
__DEBUG__ = True
__MODULE_DIR__ = os.path.dirname(os.path.abspath(__file__))
#==============================================================================
# Defining Python MbsDirdyn class
#==============================================================================
class MbsDirdyn(object):
def __init__(self, mbs, user_path=None, symbolic_path=None):
if __DEBUG__ : print( "DEBUG>> Creating MbsDirdyn struct for "+mbs.mbs_name+"' MBS.")
self.mbs_dirdyn_ptr = libmodules.mbs_new_dirdyn(mbs.mbs_data_ptr)
if __DEBUG__ : print( "DEBUG>> MbsDirdyn structure loaded")
self.mbs = mbs
#Test
if __DEBUG__ :
print( "DEBUG>> MbsDirdyn created.")
print( " >> options->tf (5.0): ", self.mbs_dirdyn_ptr.contents.options.contents.tf)
print( " >> options->dt_max (1e-3): ", self.mbs_dirdyn_ptr.contents.options.contents.dt_max)
print( " >> mbs_aux->NRerr (-): ", self.mbs_dirdyn_ptr.contents.mbs_aux.contents.NRerr)
print( " >> mbs_aux->nquc (-): ", self.mbs_dirdyn_ptr.contents.mbs_aux.contents.nquc)
print( " >> mbs_aux->M[1:3][1:3]: ",
self.mbs_dirdyn_ptr.contents.mbs_aux.contents.M[1][1],
self.mbs_dirdyn_ptr.contents.mbs_aux.contents.M[1][2],
self.mbs_dirdyn_ptr.contents.mbs_aux.contents.M[2][1],
self.mbs_dirdyn_ptr.contents.mbs_aux.contents.M[2][2])
# Path to user function used by partitionning modue
self.user_path = self.mbs.user_path
if not (user_path==None):
project_path = (self.mbs.project_path).decode("utf-8")
user_path = os.path.join(project_path, user_path)
# Error handeling
if not os.path.isdir(user_path):
print ('The user function directory for direct dynamic module does not exist: "'+ user_path+'"')
print ('The current root folder is: "'+os.getcwd()+'"')
print ('The following directory is used instead: "'+self.user_path+'".')
else:
self.user_path = user_path
# Path to user function used by partitionning modue
self.symbolic_path = self.mbs.symbolic_path
if not (user_path==None):
project_path = (self.mbs.project_path).decode("utf-8")
symbolic_path = os.path.join(project_path, symbolic_path)
# Error handeling
if not os.path.isdir(symbolic_path):
print ('Thesymbolic function directory for direct dynamic module does not exist: "'+ symbolic_path+'"')
print ('The current root folder is: "'+os.getcwd()+'"')
print ('The following directory is used instead: "'+self.symbolic_path+'".')
else:
self.symbolic_path = symbolic_path
# pointers list to avoid garbage collecting
self.ptrs_to_fcts = []
# [0]: user_cons_hJ
# [1]: user_cons_jdqd
# [2]: user_dirdyn_init
# [3]: user_dirdyn_loop
# [4]: user_dirdyn_finish
# [5]: mbs_cons_hJ
# [6]: mbs_cons_jdqd
# [6]: mbs_invdyna
# [6]: mbs_dirdyna
# Storing project function pointer
self.user_cons_hJ = None
self.user_cons_jdqd = None
self.user_dirdyn_init = None
self.user_dirdyn_loop = None
self.user_dirdyn_finish = None
self.mbs_cons_hJ = None
self.mbs_cons_jdqd = None
self.mbs_invdyna = None
self.mbs_dirdyna = None
# Exposing some memory
if __DEBUG__ : print( "DEBUG>> Exposing MbsDirdyn fields")
# Constraints
self._h = self._Jac = self._jdqd = None
if self.mbs.Ncons>0:
self._h = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.h, (self.mbs.Ncons+1,))
self._Jac = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.Jac[0], (self.mbs.Ncons+1,self.mbs.njoint+1))
self._jdqd = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.jdqd, (self.mbs.Ncons+1,))
self._huserc = self._Juserc = self._jdqduserc = None
if self.mbs.Nuserc>0:
self._huserc = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.huserc, (self.mbs.Nuserc+1,))
self._Juserc = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.Juserc[0], (self.mbs.Nuserc+1,self.mbs.njoint+1))
self._jdqduserc = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.jdqduserc, (self.mbs.Nuserc+1,))
# Fields from equation of motion
self._M = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.M[0], (self.mbs.njoint+1,self.mbs.njoint+1))
self._c = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.c, (self.mbs.njoint+1,))
self._F = np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.mbs_aux.contents.F, (self.mbs.njoint+1,))
# Loading user function
if __DEBUG__ : print( "DEBUG>> Loading user functions")
self.__load_user_fct__(self.user_path)
# Loading symbolic function
if __DEBUG__ : print( "DEBUG>> Loading symbolic functions")
self.__load_symbolic_fct__(self.symbolic_path)
def __str__(self):
if __DEBUG__ : print( "DEBUG>> start of __str")
return "MbsDirdyn instance has nothing to be printed from C library!"
def __load_user_fct__(self, user_path):
"""
Load user function where some args depend on MbsDirdyn module.
Load the user functions in which some of the arguments are
dependent of MbsDirdyn module instance. The functions will be
assigned to the MbsData instance when the 'run' functions is called
and unassigned at the end.
The loader user functions are :
- user_cons_hJ (from cons_hJ.py)
- user_cons_jdqd (from cons_hJ.py)
- user_dirdyn_init (from user_dirdyn.py)
- user_dirdyn_loop (from user_dirdyn.py)
- user_dirdyn_finish (from user_dirdyn.py)
"""
# cons_hJ
user_file = "cons_hJ.py"
path = os.path.abspath(os.path.join(user_path, user_file))
if os.path.isfile(path):
module = imp.load_source(user_file[:-3], path)
self.user_cons_hJ = module.user_cons_hJ
self.ptrs_to_fcts.append(user_cons_hJ_wrap(lambda h,Jac,mbs,tsim : self.user_cons_hJ(self._huserc, self._Juserc, self.mbs, tsim)))
else:
if __DEBUG__ : print( "DEBUG>> file '"+user_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(user_cons_hJ_wrap(lambda h,Jac,mbs,tsim : None))
self.user_cons_hJ = lambda *args: None
# cons_jdqd
user_file = "cons_jdqd.py"
path = os.path.abspath(os.path.join(user_path, user_file))
if os.path.isfile(path):
module = imp.load_source(user_file[:-3], path)
self.user_cons_jdqd = module.user_cons_jdqd
self.ptrs_to_fcts.append(user_cons_jdqd_wrap(lambda h,Jac,mbs,tsim : self.user_cons_jdqd(self._jdqduserc, self.mbs, tsim)))
else:
if __DEBUG__ : print( "DEBUG>> file '"+user_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(user_cons_jdqd_wrap(lambda h,Jac,mbs,tsim : None))
self.user_cons_jdqd = lambda *args: None
# user_dirdyn
user_file = "user_dirdyn.py"
path = os.path.abspath(os.path.join(user_path, user_file))
if os.path.isfile(path):
if __DEBUG__ : print( "DEBUG>> loading file '"+user_file+"' in folder '"+os.path.dirname(path))
module = imp.load_source(user_file[:-3], path)
self.user_dirdyn_init = module.user_dirdyn_init
self.user_dirdyn_loop = module.user_dirdyn_loop
self.user_dirdyn_finish = module.user_dirdyn_finish
self.ptrs_to_fcts.append(user_dirdyn_init_wrap(lambda mbs, dd : self.mbs.user_dirdyn_init(self.mbs, self)))
self.ptrs_to_fcts.append(user_dirdyn_loop_wrap(lambda mbs, dd : self.mbs.user_dirdyn_loop(self.mbs, self)))
self.ptrs_to_fcts.append(user_dirdyn_finish_wrap(lambda mbs, dd : self.mbs.user_dirdyn_finish(self.mbs, self)))
else:
print ("file '"+user_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(user_dirdyn_init_wrap(lambda mbs, dd : None))
self.ptrs_to_fcts.append(user_dirdyn_loop_wrap(lambda mbs, dd : None))
self.ptrs_to_fcts.append(user_dirdyn_finish_wrap(lambda mbs, dd : None))
self.mbs.user_dirdyn_init = lambda *args: None
self.mbs.user_dirdyn_loop = lambda *args: None
self.mbs.user_dirdyn_finish = lambda *args: None
return
def __load_symbolic_fct__(self, symbolic_path):
"""
Load symbolic function where some args depend on MbsDirdyn module.
Load the symb functions in which some of the arguments are
dependent of MbsDirdyn module instance. The functions will be
assigned to the MbsData instance when the 'run' functions is called
and unassigned at the end.
The loader user functions are :
- cons_hJ (from mbs_cons_hJ_MBSNAME.py)
- cons_jdqd (from mbs_cons_jdqd_MBSNAME.py)
- dirdyna (from mbs_dirdyna_MBSNAME.py)
- invdyna (from mbs_invdyna_MBSNAME.py)
"""
mbs_name = self.mbs.mbs_name
# mbs_cons_hJ
symb_file = "mbs_cons_hJ_"+mbs_name+".py"
path = os.path.abspath(os.path.join(symbolic_path, symb_file))
if os.path.isfile(path):
module = imp.load_source(symb_file[:-3], path)
self.mbs_cons_hJ = module.cons_hJ
self.ptrs_to_fcts.append(mbs_cons_hJ_wrap(lambda h,Jac,mbs,tsim : self.mbs_cons_hJ(self._h, self._Jac, self.mbs)))
else:
if __DEBUG__ : print( "DEBUG>> file '"+symb_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(mbs_cons_hJ_wrap(lambda h,Jac,mbs,tsim : None))
self.mbs_cons_hJ = lambda *args: None
# mbs_cons_jdqd
symb_file = "mbs_cons_jdqd_"+mbs_name+".py"
path = os.path.abspath(os.path.join(symbolic_path, symb_file))
if os.path.isfile(path):
module = imp.load_source(symb_file[:-3], path)
self.mbs_cons_jdqd = module.cons_jdqd
self.ptrs_to_fcts.append(mbs_cons_jdqd_wrap(lambda jdqd,mbs,tsim : self.mbs_cons_jdqd(self._jdqd, self.mbs)))
else:
if __DEBUG__ : print( "DEBUG>> file '"+symb_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(mbs_cons_jdqd_wrap(lambda jdqd,mbs,tsim : None))
self.mbs_cons_jdqd = lambda *args: None
# invdyna
symb_file = "mbs_invdyna_"+mbs_name+".py"
path = os.path.abspath(os.path.join(symbolic_path, symb_file))
if os.path.isfile(path):
module = imp.load_source(symb_file[:-3], path)
self.mbs_invdyna = module.invdyna
self.ptrs_to_fcts.append(mbs_invdyna_wrap(lambda Q,mbs,tsim : self.mbs_invdyna(self.mbs, tsim, None)))
else:
if __DEBUG__ : print( "DEBUG>> file '"+symb_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(mbs_invdyna_wrap(lambda Q,mbs,tsim : None))
self.mbs_invdyna = lambda *args: None
# dirdyna
symb_file = "mbs_dirdyna_"+mbs_name+".py"
path = os.path.abspath(os.path.join(symbolic_path, symb_file))
if os.path.isfile(path):
module = imp.load_source(symb_file[:-3], path)
self.mbs_dirdyna = module.dirdyna
self.ptrs_to_fcts.append(mbs_dirdyna_wrap(lambda M,c,mbs,tsim : self.mbs_dirdyna(self._M, self._c, self.mbs, tsim)))
else:
if __DEBUG__ : print( "DEBUG>> file '"+symb_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(mbs_dirdyna_wrap(lambda M,c,mbs,tsim : None))
self.mbs_dirdyna = lambda *args: None
return
def run(self):
# [0]: user_cons_hJ
# [1]: user_cons_jdqd
# [2]: user_dirdyn_init
# [3]: user_dirdyn_loop
# [4]: user_dirdyn_finish
# [5]: mbs_cons_hJ
# [6]: mbs_cons_jdqd
# [6]: mbs_invdyna
# [6]: mbs_dirdyna
# Assing required user functions
self.mbs.user_cons_hJ = self.user_cons_hJ
self.mbs.mbs_data_ptr.contents.user_cons_hJ = self.ptrs_to_fcts[0]
self.mbs.user_cons_jdqd = self.user_cons_jdqd
self.mbs.mbs_data_ptr.contents.user_cons_jdqd = self.ptrs_to_fcts[1]
self.mbs.user_dirdyn_init = self.user_dirdyn_init
self.mbs.mbs_data_ptr.contents.user_dirdyn_init = self.ptrs_to_fcts[2]
self.mbs.user_dirdyn_loop = self.user_dirdyn_loop
self.mbs.mbs_data_ptr.contents.user_dirdyn_loop = self.ptrs_to_fcts[3]
self.mbs.user_dirdyn_finish = self.user_dirdyn_finish
self.mbs.mbs_data_ptr.contents.user_dirdyn_finish = self.ptrs_to_fcts[4]
# Assing required symbolic functions
self.mbs.mbs_cons_hJ = self.mbs_cons_hJ
self.mbs.mbs_data_ptr.contents.mbs_cons_hJ = self.ptrs_to_fcts[5]
self.mbs.mbs_cons_jdqd = self.mbs_cons_jdqd
self.mbs.mbs_data_ptr.contents.mbs_cons_jdqd = self.ptrs_to_fcts[6]
self.mbs.mbs_invdyna = self.mbs_invdyna
self.mbs.mbs_data_ptr.contents.mbs_invdyna = self.ptrs_to_fcts[7]
self.mbs.mbs_dirdyna = self.mbs_dirdyna
self.mbs.mbs_data_ptr.contents.mbs_dirdyna = self.ptrs_to_fcts[8]
libmodules.mbs_run_dirdyn(self.mbs_dirdyn_ptr, self.mbs.mbs_data_ptr)
#==========================================================================
# Defining properties
#==========================================================================
@property
def mbs_filename(self):
return self.mbs.mbs_filename
@property
def project_path(self):
return self.mbs.project_path
@property
def mbs_name(self):
return self.mbs.mbs_name
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
Creation : 2019 by O. Lantsoght
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
Define the class MbsPart based on the MbsPart structure of MBsysC.
This class has the functions required to manipulate the coordinate
partitionning module (options, run, delete)
"""
import os
import imp
import numpy as np
# importing MbsysPy classes
# importing libraries
from ..mbsysc_loader.loadlibs import libmodules
# importing wrapping function
from ..mbsysc_loader.callback import user_cons_hJ_wrap
from ..mbsysc_loader.callback import mbs_cons_hJ_wrap
#==============================================================================
# Global parameter of the current module
#==============================================================================
__DEBUG__ = True
__MODULE_DIR__ = os.path.dirname(os.path.abspath(__file__))
#==============================================================================
# Defining Python MbsPart class
#==============================================================================
class MbsPart(object):
def __init__(self, mbs, user_path=None, symbolic_path=None):
if __DEBUG__ : print( "DEBUG>> Creating MbsPart struct for "+mbs.mbs_name+"' MBS.")
self.mbs_part_ptr = libmodules.mbs_new_part(mbs.mbs_data_ptr)
if __DEBUG__ : print( "DEBUG>> MbsPartmbs_ structure loaded")
self.mbs = mbs
# Path to user function used by partitionning modue
self.user_path = self.mbs.user_path
if not (user_path==None):
project_path = (self.mbs.project_path).decode("utf-8")
user_path = os.path.join(project_path, user_path)
# Error handeling
if not os.path.isdir(user_path):
print ('The partitionning user function directory does not exist: "'+ user_path+'"')
print ('The current root folder is: "'+os.getcwd()+'"')
print ('The following directory is used instead: "'+self.user_path+'".')
else:
self.user_path = user_path
# Path to user function used by partitionning modue
self.symbolic_path = self.mbs.symbolic_path
if not (user_path==None):
project_path = (self.mbs.project_path).decode("utf-8")
symbolic_path = os.path.join(project_path, symbolic_path)
# Error handeling
if not os.path.isdir(symbolic_path):
print ('The partitionning symbolic function directory does not exist: "'+ symbolic_path+'"')
print ('The current root folder is: "'+os.getcwd()+'"')
print ('The following directory is used instead: "'+self.symbolic_path+'".')
else:
self.symbolic_path = symbolic_path
# pointers list to avoid garbage collecting
self.ptrs_to_fcts = []
# [0]: user_cons_hJ
# [1]: mbs_cons_hJ
# Storing project function pointer
self.user_cons_hJ = None
self.mbs_cons_hJ = None
# Exposing some memory
if __DEBUG__ : print( "DEBUG>> Exposing MbsPart fields")
self.__q_closed = np.ctypeslib.as_array(self.mbs_part_ptr.contents.q_closed, (self.mbs.njoint,))
# Loading user function
if __DEBUG__ : print( "DEBUG>> Loading user functions")
self.__load_user_fct__(self.user_path)
# Loading symbolic function
if __DEBUG__ : print( "DEBUG>> Loading symbolic functions")
self.__load_symbolic_fct__(self.symbolic_path)
def __str__(self):
if __DEBUG__ : print( "DEBUG>> start of __str")
return "MbsPart instance has nothing to be printed from C library!"
def __load_user_fct__(self, user_path):
"""
Load user function where some args depend on MbsPart module.
Load the user functions in which some of the arguments are
dependent of MbsPart module instance. The functions will be
assigned to the MbsData instance when the 'run' functions is called
and unassigned at the end.
The loader user functions are :
- user_cons_hJ (from cons_hJ.py)
"""
# cons_hJ
user_file = "cons_hJ.py"
path = os.path.abspath(os.path.join(user_path, user_file))
if os.path.isfile(path):
module = imp.load_source(user_file[:-3], path)
self.user_cons_hJ = module.user_cons_hJ
self.ptrs_to_fcts.append(user_cons_hJ_wrap(lambda h,Jac,mbs,tsim : self.__callback_user_cons_hJ(self.user_cons_hJ,h,Jac,tsim)))
else:
if __DEBUG__ : print( "DEBUG>> file '"+user_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(user_cons_hJ_wrap(lambda h,Jac,mbs,tsim : None))
self.user_cons_hJ = None
return
def __load_symbolic_fct__(self, symbolic_path):
"""
Load symbolic function where some args depend on MbsPart module.
Load the symb functions in which some of the arguments are
dependent of MbsPart module instance. The functions will be
assigned to the MbsData instance when the 'run' functions is called
and unassigned at the end.
The loader user functions are :
- cons_hJ (from mbs_cons_hJ_MBSNAME.py)
"""
mbs_name = self.mbs.mbs_name
# mbs_cons_hJ
symb_file = "mbs_cons_hJ_"+mbs_name+".py"
path = os.path.abspath(os.path.join(symbolic_path, symb_file))
if os.path.isfile(path):
module = imp.load_source(symb_file[:-3], path)
self.mbs_cons_hJ = module.cons_hJ
self.ptrs_to_fcts.append(mbs_cons_hJ_wrap(lambda h,Jac,mbs,tsim : self.__callback_mbs_cons_hJ(self.mbs_cons_hJ,h,Jac)))
else:
if __DEBUG__ : print( "DEBUG>> file '"+symb_file+"' not found in folder '"+os.path.dirname(path))
self.ptrs_to_fcts.append(mbs_cons_hJ_wrap(lambda h,Jac,mbs,tsim : None))
self.mbs_cons_hJ = None
return
# Callback function for function with advanced arguments
def __callback_user_cons_hJ(self, fun, h, Jac, tsim):
__h = np.ctypeslib.as_array(h, (self.mbs.Nuserc+1,))
__Jac = np.ctypeslib.as_array(Jac[0], (self.mbs.Nuserc+1,self.mbs.njoint+1))
fun(__h,__Jac,self.mbs,tsim)
def __callback_mbs_cons_hJ(self, fun, h, Jac):
if __DEBUG__ : print( "DEBUG>> callback_mbs_cons_hJ")
__h = np.ctypeslib.as_array(h, (self.mbs.Ncons+1,))
__Jac = np.ctypeslib.as_array(Jac[0], (self.mbs.Ncons+1,self.mbs.njoint+1))
fun(__h,__Jac,self.mbs)
def run(self):
# Assing required user functions
self.mbs.user_cons_hJ = self.user_cons_hJ
self.mbs.mbs_data_ptr.contents.user_cons_hJ = self.ptrs_to_fcts[0]
# Assing required symbolic functions
self.mbs.mbs_cons_hJ = self.mbs_cons_hJ
self.mbs.mbs_data_ptr.contents.mbs_cons_hJ = self.ptrs_to_fcts[1]
libmodules.mbs_run_part(self.mbs_part_ptr, self.mbs.mbs_data_ptr)
# Anassign functions
self.mbs.user_cons_hJ = None
self.mbs.mbs_data_ptr.user_cons_hJ = None
# Assing required symbolic functions
self.mbs.mbs_cons_hJ = None
self.mbs.mbs_data_ptr.user_cons_hJ = None
def set_options(self, **kwargs):
for key, value in kwargs.items():
if key == "rowperm":
self.mbs_part_ptr.contents.options.contents.rowperm = value
elif key == "visualise":
self.mbs_part_ptr.contents.options.contents.visualise = value
elif key == "drivers":
self.mbs_part_ptr.contents.options.contents.drivers = value
elif key == "verbose":
self.mbs_part_ptr.contents.options.contents.verbose = value
elif key == "clearmbsglobal":
self.mbs_part_ptr.contents.options.contents.clearmbsglobal = value
else:
print(">>PART>> The option "+key+ " is not defined in this module")
def get_options(self, *args):
options = []
for key in args:
if key == "rowperm":
options.append(self.mbs_part_ptr.contents.options.contents.rowperm)
elif key == "visualise":
options.append(self.mbs_part_ptr.contents.options.contents.visualise)
elif key == "drivers":
options.append(self.mbs_part_ptr.contents.options.contents.drivers)
elif key == "verbose":
options.append(self.mbs_part_ptr.contents.options.contents.verbose)
elif key == "clearmbsglobal":
options.append(self.mbs_part_ptr.contents.options.contents.clearmbsglobal)
else:
print(">>PART>> The option "+key+ " is not defined in this module")
if len(options) == 0:
return
return tuple(options)
#==========================================================================
# Defining properties
#==========================================================================
@property
def n_qu(self):
return self.mbs_part_ptr.contents.n_qu
@property