You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought we could replicate the MAPDL behaviour accepting arrays as arguments.
For examples, the command D can accept tables for the argument values:
D,Node,TEMP,%tabname%
I think we could wrap every APDL command with something like:
def_allow_array_tables_on_args(self):
def_upload_arg_as_array(arg):
# to be defined# we might need to sanitize the name of the new array from the variable# name.returnarg_name# Array name in MAPDL databasedef_upload_arg_as_table(arg):
# to be defined# we might need to sanitize the name of the new array from the variable# name.returnarg_name# table name in MAPDL databasedef_process_arg(arg):
ifisinstance(each_arg, np.array):
arg=_upload_arg_as_array(arg)
elifisinstance(each_arg, pd.DataFrame):
arg=_upload_arg_as_table(arg)
returnargdefwrap_bc_listing_function(func):
@wraps(func)definner_wrapper(*args, **kwargs):
args_= []
foreach_arginargs:
arg=_process_arg(each_arg)
args_.append(arg)
kwargs_= {}
foreach_key, each_valueinkwargs:
arg=_process_arg(each_value)
args_.append(arg)
returnfunc(*args_, **kwargs)
returninner_wrapperfornameindir(self):
ifname[0:4].upper() inCMD_LISTINGandnameindir(
Commands
): # avoid matching Mapdl properties which starts with same letters as MAPDL commands.func=self.__getattribute__(name)
setattr(self, name, wrap_listing_function(func))
I think it could be useful because then you can do something like:
mytable=pd.Dataframe(index=[1,2,3], data= [[35],[36],[37]])
# apply temperatures 35,36 and 37 to nodes 1,2 and 3 respectivelymapdl.d("all",TEMP, mytable)
Pinging @mikerife, @mcMunich@koubaa and @pmaroneh for feedback. This an idea, I cannot work on it yet, but I'm happy to heard about this.
Same approach could be done for components. If a list/array is used as an argument, create the component with the parameter name and use it. When using an object defined in the same line, for instance:
mapdl.d([1,2,3], Temp, mytable)
we can create a temporary component and use it.
It might be not super obvious to the user though that the component/array/table is being created on the background.
That is a great suggestion. Being able to use lists and/or pandas dataframes to define tabular load value would be so much easier than having to create MAPDL tables.
Writing something somewhere I had an idea.
I thought we could replicate the MAPDL behaviour accepting arrays as arguments.
For examples, the command D can accept tables for the argument
values
:I think we could wrap every APDL command with something like:
I think it could be useful because then you can do something like:
Pinging @mikerife, @mcMunich @koubaa and @pmaroneh for feedback. This an idea, I cannot work on it yet, but I'm happy to heard about this.
References:
pymapdl/src/ansys/mapdl/core/mapdl_core.py
Lines 1215 to 1253 in c551d20
The text was updated successfully, but these errors were encountered: