Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow iterables in mapdl.cmsel #3425

Open
germa89 opened this issue Sep 20, 2024 · 4 comments
Open

Allow iterables in mapdl.cmsel #3425

germa89 opened this issue Sep 20, 2024 · 4 comments

Comments

@germa89
Copy link
Collaborator

germa89 commented Sep 20, 2024

As the title.

@germa89
Copy link
Collaborator Author

germa89 commented Oct 3, 2024

Mmhhh.. Now I think about it... it might not make much sense to have iterables.....

New selection 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.

Reselect 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:

  • select all the elements (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")
  • select all the elements (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.

Add selection 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

Unselect 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")

@germa89
Copy link
Collaborator Author

germa89 commented Oct 3, 2024

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 operator

What 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 operator

But 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 operator

I guess this is easy, it should unselect:

mapdl.select(not cm1)

will be translated to:

mapdl.cmsel("U", "cm1")

Summary

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")

@germa89
Copy link
Collaborator Author

germa89 commented Oct 3, 2024

Pinging @koubaa, @mcMunich, @mikerife and @pthieffry for feedback before considering it for future work.

@pthieffry
Copy link

@germa89 I much prefer the idea of logic operators than iterables. I concur with your assessment on the ambiguity iterables could introduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants