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.

Difficulties with mphselectcoords

Please login with a confirmed email address before reporting spam

Hi everybody, it’s me again asking help with API command:
I have a geometry where I need to retrieve face’s number under a given XYZ point: mphselectcoords is the perfect tool for this task and work most of the time.

Here is a situation, as with some other models that I have, where it does not work at all.
See the .m attached -> you will probably need to change the path at line #39 in order to convert it into mph.
With an another model, I found out that mphselectcoords was also sensible to the radius imposed.

Why is this not working?

I have a whole code, 2 months of work, based on this tool and this really slow me down, since I have to define manually faces in my code for each model.

Regards,
Gabriel.



P.S.: This could be part of my own ‘Comsol user story' working with API commands.
www.comsol.com/community/forums/general/thread/16199/
www.comsol.com/community/forums/general/thread/18623/


4 Replies Last Post 7 sept. 2012, 16:19 UTC−4
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 8 juin 2011, 08:48 UTC−4
Hi

Just a teaser for those of you who haven't received Comsol 4.2 yet: Comsol 4.2 has a totally new set of coordinate based selection methods built-in. This means that these new selection methods can be used both from the Comsol Desktop and when using Matlab.

Both for Comsol 4.1 and Comsol 4.2 there are sometimes a need for low level functions such as mphselectcoords. The important thing to notice is that the function is entirely based on the coordinates of the vertices of the boundaries you are trying to identify.

E.g. instead of specifying a coordinate on the middle of your boundary like this:

mphselectcoords(model,'geom1',[0.25,1,0.7],'boundary','radius',0.001)

you could do

mphselectcoords(model,'geom1',[0 1 0.5;0.5 1 1]','boundary')

I.e. by picking opposite coordinates of vertices on the boundary you can uniquely identify the boundary.


You can also use mphselectbox instead:

mphselectbox(model,'geom1',[-0.1 0.9 0.4;0.6 1.1 1.1]','boundary')

where the third argument is used to define a box that is slightly larger than the boundary you are trying to identify. mphselectbox is usually easier to understand and easier to work with than mphselectcoords - as long as you are working with geometries that fit nicely within boxes.


Lars Gregersen
Comsol Denmark
Hi Just a teaser for those of you who haven't received Comsol 4.2 yet: Comsol 4.2 has a totally new set of coordinate based selection methods built-in. This means that these new selection methods can be used both from the Comsol Desktop and when using Matlab. Both for Comsol 4.1 and Comsol 4.2 there are sometimes a need for low level functions such as mphselectcoords. The important thing to notice is that the function is entirely based on the coordinates of the vertices of the boundaries you are trying to identify. E.g. instead of specifying a coordinate on the middle of your boundary like this: mphselectcoords(model,'geom1',[0.25,1,0.7],'boundary','radius',0.001) you could do mphselectcoords(model,'geom1',[0 1 0.5;0.5 1 1]','boundary') I.e. by picking opposite coordinates of vertices on the boundary you can uniquely identify the boundary. You can also use mphselectbox instead: mphselectbox(model,'geom1',[-0.1 0.9 0.4;0.6 1.1 1.1]','boundary') where the third argument is used to define a box that is slightly larger than the boundary you are trying to identify. mphselectbox is usually easier to understand and easier to work with than mphselectcoords - as long as you are working with geometries that fit nicely within boxes. Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 8 juin 2011, 10:20 UTC−4
Hi,

thank you for the explanation on how mphselectcoords manages the vertices. I'll work on it -> the difficulty is that I have only coordinate for a single measure point. I'll work on it.


I look forward to version 4.2 :)



Regards,
Gabriel
Hi, thank you for the explanation on how mphselectcoords manages the vertices. I'll work on it -> the difficulty is that I have only coordinate for a single measure point. I'll work on it. I look forward to version 4.2 :) Regards, Gabriel

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 8 juin 2011, 10:21 UTC−4
Hi,

thank you for the explanation on how mphselectcoords manages the vertices. I'll work on it -> the difficulty is that I have only coordinate for a single measure point. I'll work on it.


I look forward to version 4.2 :)



Regards,
Gabriel
Hi, thank you for the explanation on how mphselectcoords manages the vertices. I'll work on it -> the difficulty is that I have only coordinate for a single measure point. I'll work on it. I look forward to version 4.2 :) Regards, Gabriel

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 7 sept. 2012, 16:19 UTC−4
I am having difficulty in getting the top, bottom faces/boundaries of a cylinder.

Lets say the cylinder is positioned at (x,y,z) and has radius=r and height=h.

I tried to use following command:

bottom = mphselectcoords(model, 'geom1', [x-r, x+r; y-r, y+r; z , z], 'boundary')

But, it didn't work. Similarly, I couldn't get the top and side faces too.

Also, how do we get the domain number for a cylindrical domain, (say for above-mentioned example)?

Thanks,
Kapil



I am having difficulty in getting the top, bottom faces/boundaries of a cylinder. Lets say the cylinder is positioned at (x,y,z) and has radius=r and height=h. I tried to use following command: bottom = mphselectcoords(model, 'geom1', [x-r, x+r; y-r, y+r; z , z], 'boundary') But, it didn't work. Similarly, I couldn't get the top and side faces too. Also, how do we get the domain number for a cylindrical domain, (say for above-mentioned example)? Thanks, Kapil

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.