Open germa89 opened 1 month ago
Mmhhh.. Now I think about it... it might not make much sense to have iterables.....
S
mapdl.cmsel("s", ['cm1', 'cm2'])
you cannot have:
mapdl.cmsel( "s", cm1)
mapdl.cmsel( "s", cm2)
Because the last command overwrites all the previous selections (that's the point of S
)
However, you could have:
mapdl.cmsel("s", cm1)
mapdl.cmsel("a", cm2)
Which is more useful.
R
The behaviour of multiple arguments here is a bit complicated.
In the case we can have multiple R
, I would expect that
mapdl.allsel()
mapdl.cmsel("R", ["cm1", "cm2"])
will mean something like either:
allsel
), and from them select the ones contained in "cm1" AND "cm2". In my opinion the most logical one. Equivalent to:
mapdl.allsel()
mapdl.cmsel("R", "cm1")
mapdl.cmsel("R", "cm2")
allsel
), and from them select the ones contained in "cm1" OR "cm2" Equivalent to:
mapdl.allsel()
# something to save all the selections for KP, L, A, V, N and ELEM in ``temp_sel_0``.
mapdl.cmsel("S", "cm1")
mapdl.cmsel("A", "cm2")
# something to save all the selections for KP, L, A, V, N and ELEM in ``temp_sel_1``.
# restore ``S``, ``temp_sel_0``
# restore ``R``, ``temp_sel_1``
we could hook the mapdl.save_selection
context manager to do that... but it seems quite expensive in terms of operations.
We could also extract the entities inside the components and do the matematical operations on our side, and not touch the selections... so we would avoid many calls to gRPC, but we might need to transfer a lot of ids.
Anyways, I'm not too fond of this ambiguity.
A
I think this is quite easy, because mapdl.cmsel("a", ["cm1", "cm2"])
should mean:
# whatever selection you might have
mapdl.cmsel("a", "cm1")
mapdl.cmsel("a", "cm2")
Easy
U
I think this is quite easy as well, because mapdl.cmsel("U", ["cm1", "cm2"])
should mean:
# whatever selection you might have
mapdl.cmsel("u", "cm1")
mapdl.cmsel("u", "cm2")
I am wondering if makes sense to overload the math operators for selections. Given:
# node selection 1
cm1 = mapdl.cm("cm1", "nodes") # current implementation does not return anything
# node selection 2
cm2 = mapdl.cm("cm2", "nodes")
mapdl.select # imaginary function to select components
What the following operation will mean:
AND
operatorWhat the following statement should mean:
mapdl.select(cm1 and cm2)
I guess it should mean to select both:
mapdl.cmsel("s", "cm1")
mapdl.cmsel("a", "cm2")
However, using R
could make sense also:
mapdl.cmsel("s", "cm1")
mapdl.cmsel("R", "cm2")
OR
operatorBut then what about the or
operator?
mapdl.select(cm1 or cm2)
probably here the only reasonable option will be to use A
:
mapdl.cmsel("s", "cm1")
mapdl.cmsel("a", "cm2")
NOT
operatorI guess this is easy, it should unselect:
mapdl.select(not cm1)
will be translated to:
mapdl.cmsel("U", "cm1")
So...
Python operator | MAPDL operation | Python example | PyMAPDL command |
---|---|---|---|
and | Reselect R | mapdl.select(cm1 and cm2) | mapdl.cmsel("S", "cm1");mapdl.cmsel("R", "cm2") |
|||
or | Add A | mapdl.select(cm1 or cm2) | mapdl.cmsel("S", "cm1");mapdl.cmsel("A", "cm2") |
|||
not | Unselect U | mapdl.select(not cm1) | mapdl.cmsel("U", "cm1") |
Pinging @koubaa, @mcMunich, @mikerife and @pthieffry for feedback before considering it for future work.
@germa89 I much prefer the idea of logic operators than iterables. I concur with your assessment on the ambiguity iterables could introduce.
As the title.