Discussion Forum

Numbering of the boundaries in *.m file

Topics: no topics

Thread index  |  Previous thread  |  Next thread  |  Start a new discussion

RSS FeedRSS feed   |   Email notificationsTurn on email notifications   |   13 Replies   Last post: November 26, 2010 2:44pm UTC
Onur Ilkorur

Onur Ilkorur

August 28, 2009 1:01pm UTC

Numbering of the boundaries in *.m file

Hello all,

I am working on a parametric geometry model and I want to create my geometry/solution fully in script. I have to say that it is a rather complex geometry and till now I took the short and easy way by first creating my geometry in MatLab script with Comsol functions, exporting it to Comsol, doing the necessary subdomain and boundary settings there, exporting the model back to a "*.m" file (letting Comsol deal with the numbering for me) and proceeding with the solution.

Now, the geometry became more complex and the number of boundaries are not constant anymore and I need to understand how Comsol numbers the boundaries so that I can assign the correct boundary conditions without switching between Comsol and MatLab. When I look at bnd.ind=[] and equ.ind=[] there seems to be a logic behind the numbering but I couldn't be able to find any documentation explaining that systematic.

Thanks in advance,
Onur

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Jean Rubiella

Jean Rubiella

September 3, 2009 11:45am UTC in response to Onur Ilkorur

Re: Numbering of the boundaries in *.m file

Hi,
It seems that the index of boundary begins on the left bottom corner of your windows and then increase until the right top corner with priority to the horizontal boundaries.
It's what I noticed. I hope it can help you in your project.

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Yannick fargier

Yannick fargier

September 4, 2009 8:28am UTC in response to Onur Ilkorur

Re: Numbering of the boundaries in *.m file

Hello,

Comsol increment with a sort of triple loop (for x=1:end; for y=1:end; for z=1:end) to find the boundary number.

I have a matlab code which finds a face (or boundary) number (If you know the boundary position (x,y,z)).
the second matlab code finds vertex number.

I hope codes will help you,

Y.

Attachments:   face.m   vertex.m  

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Onur Ilkorur

Onur Ilkorur

September 4, 2009 12:52pm UTC in response to Yannick fargier

Re: Numbering of the boundaries in *.m file

Hello Jean and Yannick,

Thanks to both of you! It seems I am benefiting fully form the experiences of the users who have been there before.

/Onur

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Tom Myers

Tom Myers

November 3, 2009 5:42pm UTC in response to Onur Ilkorur

Re: Numbering of the boundaries in *.m file

Hi,

This is an excellent function! Just should have provided an example of its use.

function result = face(geometry,x,y,z,tol,density)


I would emphasis that the x,y,z co-ordinates are "rubberband" co-ordinates i.e.

face(fem.geom,[3.6e-6 3.8e-6],[4e-6 4.5e-6],[0 40e-6],1e-3,2)

Orginally I entered tol=1 which resulted in all the boundaries in the model being returned, this is because this is the tolerance and 1 = 1m which is larger than my model space.

I am still to work-out what the density is? I have it set to 2 and it is working well!

Good Work!!


Regards,
Tom

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Francis Généreux

Francis Généreux

March 15, 2010 4:04pm UTC in response to Yannick fargier

Re: Numbering of the boundaries in *.m file

Hi,

Thanks for the great functions. I have another problem setting the boundary of a complicated geometry in Matlab that is somewhat related to the above topic. The problem that I am trying to solve is involving more than 400 faces. A lot of them are in contact. I am wondering if there is function or list of commands able to find faces that are in contact.

Regards,

Francis

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Jeremy Teo

Jeremy Teo

April 13, 2010 3:59am UTC in response to Yannick fargier

Re: Numbering of the boundaries in *.m file

Hi Yannick,

This is amazing, but I cannot seem to get it to work in 2D :( can you advise me on how to get it done into2D? and it will give me the index of boundaries if I'm not wrong.

Thanks!

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

MOhmesICx

MOhmesICx

July 26, 2010 3:26pm UTC in response to Jeremy Teo

Re: Numbering of the boundaries in *.m file

In 3.5a I was able to do this using a combination of geomcsg and flgeomnbs. However, I cannot figure out how to do this with version 4.0a? Has anyone figured out how to track the boundaries or more specifically how to determine what boundary numbers are assigned to a specific geometry feature?

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

David Schäfer

David Schäfer

November 25, 2010 11:25am UTC in response to MOhmesICx

Re: Numbering of the boundaries in *.m file

Sorry for bringing up this old Thread, but I still find this an important question. Imho the whole usability of the MATLAB LiveLink depends on this feature, e.g. if you have simulations with geometrie-sweeps.

Edit: Just found this Thread: http://www.comsol.de/community/forums/general/thread/8837/ where the problem seems to be discussed in more detail.

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg
Moderator

November 25, 2010 8:20pm UTC in response to David Schäfer

Re: Numbering of the boundaries in *.m file

Hi

be aware that the numbering methode might well have changed between 3.5a and 4, and could too in the future, from what I have understood, but to be sure ask directly "support" (I'm not COMSOL;)

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

David Schäfer

David Schäfer

November 26, 2010 2:13pm UTC in response to Ivar Kjelberg

Re: Numbering of the boundaries in *.m file

Hi Ivar,

thanks for your reply! I think that's the point: Why does the user have to care about some numbering methods when using the Matlab LiveLink? Why is there no method to reference e.g. all boundarys that belong to a certain 3D-block by the feature-tag of the block? Every COMSOL 4 example that I could find had a hard-coded list like this:

model.geom('geom1').feature.create('blk1', 'Block'); ...
model.selection('sel1').set([1 2 3 4 7 8]); ...

But what I need is something like this:

model.geom('geom1').feature.create('blk1', 'Block'); ...
model.selection('sel1').set(getAllBoundarysFromFeature('blk1')); ...

I often have to make hundreds of simulations with complex geometry variations via script, and there is no way to know the boundary-numbers in advance and code them hard into the script. For 3.5a it was possible to create a reliable workaround to receive the numbers/ids of faces, subdomains etc. corresponding to a certain geometry. It was very extensive to do this and you had to use some creepy, badly documented functions, but it worked. ;) In COMSOL 4.0a there seems to be no way to do this...

I think I'll wait until I get my hands on the 4.1 Version next week and If I don't get it working in 4.1, I contact the support. I don't understand, why there are so few people with the same problem. Is everyone else using the GUI only? ;-)

kind regards
David

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Onur Ilkorur

Onur Ilkorur

November 26, 2010 2:31pm UTC in response to David Schäfer

Re: Numbering of the boundaries in *.m file



... It was very extensive to do this and you had to use some creepy, badly documented functions, but it worked. ;) In COMSOL 4.0a there seems to be no way to do this...

... Is everyone else using the GUI only? ;-)



If a code is working okay, why update it in the first place ;)
/Onur

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg
Moderator

November 26, 2010 2:33pm UTC in response to David Schäfer

Re: Numbering of the boundaries in *.m file

Hi

I agree with you, and I can only suggest that you ask support too, it might already be on their to do list, but will not be there if nobody asks for it ;)

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg
Moderator

November 26, 2010 2:44pm UTC in response to Onur Ilkorur

Re: Numbering of the boundaries in *.m file

Hi

but COMSOL is so complex that there might be other reasons why things change, ... no ?
This does not mean that renumering is not (very) important, I agree, send a suggestion to COMSOL

V4 can do much more than v3.5 so I'm rather happy

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse


Rules and guidelines