Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

How to make reliable domain selections in a parametric model?

Please login with a confirmed email address before reporting spam

Hello,
I have created a model using the JAVA API. The whole model is fully parametric. If the parameters are changed reasonably, the topology does not change. The model contains named selections to set up the electrostatic boundary problems, and to interface with a particle tracing code.
Unfortunately, the selections change dramatically if I make a very tiny change to the parameters.
1) compile the attached code and run it as it is. The named selections "Attractive electrode domain" and "Frame domain" are set up correctly
2) Change the value of the parameter 'bending_angle' to '46[deg]'. This is a minor change from 45[deg], and does not change the topology of the model. Run the .class file now. The above-mentioned selections are messed up.
Why does it happen, and how can I make an algorithmic selection of domains or boundaries in a parametric model? I created the model interactively in the GUI, and created the explicit selections also interactively, hoping that the internal numbering of the domains does not change if the topology of the model does not change. This doesn't seem to be the case. Did I mess up something?
I could of course use the Box selection method for example, figuring out the bounding boxes of my sub-domains, but this is a bit cumbersome. Is there no simpler way? Even a "Find domain containing the point (x,y,z)" function would be simpler than the Box selection.

The java file can be downloaded from here:
drive.google.com/file/d/0B32t7G3WoSUtZERNaFRJdmRlQzQ/edit?usp=sharing

Thank you
Daniel

2 Replies Last Post 5 févr. 2014, 09:19 UTC−5
Lorant Olasz COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 4 févr. 2014, 06:07 UTC−5
Hi Daniel,

If I understand it correctly you are trying to run the code (including the set-up of explicit selections) for different parameter values. This cannot work because you do not know before hand how the entities will be numbered as the geometry is changing. Domain numbering can and in many cases will change even if the topology stays the same.

I suggest that you set up the selections only once in your code. A subsequent modification of a parameter does not require the explicit selections to be redefined. They will be automatically updated as soon as the geometry sequence is run. This is the same when working in the GUI or with the API in java. You can even save the base configuration of your mph file, and load it in your code before changing parameters and solving.

You could also try to avoid explicit selections by using selections with geometry operations. In your example just select (I refer to the GUI now, but the API also allows this) the Create selection option on the Revolve and Revolve 4 operations to get the two explicit domain selections you refer to in point 1 of your post.

I hope this helps.
Lorant
Hi Daniel, If I understand it correctly you are trying to run the code (including the set-up of explicit selections) for different parameter values. This cannot work because you do not know before hand how the entities will be numbered as the geometry is changing. Domain numbering can and in many cases will change even if the topology stays the same. I suggest that you set up the selections only once in your code. A subsequent modification of a parameter does not require the explicit selections to be redefined. They will be automatically updated as soon as the geometry sequence is run. This is the same when working in the GUI or with the API in java. You can even save the base configuration of your mph file, and load it in your code before changing parameters and solving. You could also try to avoid explicit selections by using selections with geometry operations. In your example just select (I refer to the GUI now, but the API also allows this) the Create selection option on the Revolve and Revolve 4 operations to get the two explicit domain selections you refer to in point 1 of your post. I hope this helps. Lorant

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 5 févr. 2014, 09:19 UTC−5

I suggest that you set up the selections only once in your code. A subsequent modification of a parameter does not require the explicit selections to be redefined. They will be automatically updated as soon as the geometry sequence is run. This is the same when working in the GUI or with the API in java. You can even save the base configuration of your mph file, and load it in your code before changing parameters and solving.


Yes indeed, I also observed that changing the parameters *after* I create the selections keeps the selections unchanged.


You could also try to avoid explicit selections by using selections with geometry operations. In your example just select (I refer to the GUI now, but the API also allows this) the Create selection option on the Revolve and Revolve 4 operations to get the two explicit domain selections you refer to in point 1 of your post.


Thank you, this is surely the most robust solution, allowing to change the parameters before or after the selections are created. I will adopt this approach.

Daniel
[QUOTE] I suggest that you set up the selections only once in your code. A subsequent modification of a parameter does not require the explicit selections to be redefined. They will be automatically updated as soon as the geometry sequence is run. This is the same when working in the GUI or with the API in java. You can even save the base configuration of your mph file, and load it in your code before changing parameters and solving. [/QUOTE] Yes indeed, I also observed that changing the parameters *after* I create the selections keeps the selections unchanged. [QUOTE] You could also try to avoid explicit selections by using selections with geometry operations. In your example just select (I refer to the GUI now, but the API also allows this) the Create selection option on the Revolve and Revolve 4 operations to get the two explicit domain selections you refer to in point 1 of your post. [/QUOTE] Thank you, this is surely the most robust solution, allowing to change the parameters before or after the selections are created. I will adopt this approach. Daniel

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.