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.

subdomain number tracking

Please login with a confirmed email address before reporting spam

Dear All,

I am using Matlab interface to draw parameterized geometries and do some post processing after COMSOL solves the magnetostatic problem. The problem I am facing is, when I change the geometry, sometimes the subdomain/boundary/point numbers that COMSOL associates with them changes as well. Then I need to figure out what subdomain numbers COMSOL have given them, and change my physics settings (material definitions etc) accordingly.

I was wondering if you can think of a better way of doing this. For example, is there a function that would give me the subdomain/boundary number of a given geometry?

Thanks!
Arda

8 Replies Last Post Jul 26, 2010, 11:19 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 3, 2009, 7:52 a.m. EST
Dear Arda;
I had a similar problem. I was using a m-file script that automatically generates geometry and do the analysis in for-next loop. But every time i changed a geometry dimension(like scaling), the subdomain IDs were changing.
I solved it by "geomcsg" command.

The syntax of this command is :
[g,st] = geomcsg(sl)
Here, st is the variable that subdomain IDs are stored.
If you use FIND(x) command on that variable, you can get the subdomain IDs that are associated with the geometry ID x.
I hope this will work for you,too..

Oguz
Dear Arda; I had a similar problem. I was using a m-file script that automatically generates geometry and do the analysis in for-next loop. But every time i changed a geometry dimension(like scaling), the subdomain IDs were changing. I solved it by "geomcsg" command. The syntax of this command is : [g,st] = geomcsg(sl) Here, st is the variable that subdomain IDs are stored. If you use FIND(x) command on that variable, you can get the subdomain IDs that are associated with the geometry ID x. I hope this will work for you,too.. Oguz

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 4, 2009, 9:18 a.m. EST
Thank you very much, Oguz.

That solved my problem. Do you know if I can use the same function to track the edges/boundaries in a 2D geometry?

Thank you very much, Oguz. That solved my problem. Do you know if I can use the same function to track the edges/boundaries in a 2D geometry?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 7, 2009, 5:33 p.m. EST
Hi Arda!
I actually didnt try to do it but i think it should work with a little tweak.
There is some information about this command in COMSOL Reference Guide.

" [g,st,ft,ct] = geomcsg(sl,fl,cl,...) additionally returns the curve table, ct, which relates curve objects in cl to edge segments in g. "

I think you should a edge list into the "geomcsg" command. But i'm not sure about it.
If it works, please let me know. I've got a similiar problem that i couldnt find the time to work on..
Hi Arda! I actually didnt try to do it but i think it should work with a little tweak. There is some information about this command in COMSOL Reference Guide. " [g,st,ft,ct] = geomcsg(sl,fl,cl,...) additionally returns the curve table, ct, which relates curve objects in cl to edge segments in g. " I think you should a edge list into the "geomcsg" command. But i'm not sure about it. If it works, please let me know. I've got a similiar problem that i couldnt find the time to work on..

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 8, 2009, 4:45 a.m. EST
Hello!

I tried the following:

ctx = geomcsg(s.obj,'Out','ctx'); % s.obj being the object list

ctx{10}; % gives the edges of 10th object in the object list.

Hope it helps!

Arda
Hello! I tried the following: ctx = geomcsg(s.obj,'Out','ctx'); % s.obj being the object list ctx{10}; % gives the edges of 10th object in the object list. Hope it helps! Arda

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 10, 2009, 1:43 p.m. EST
Hello all,

I have a geometry produced in a m-file. The solid3 object has 7 subdomains, their numbring depends on the length and scaling that is subject to change each round in the for-loop. I used the [g,st] = geomcsg(fem.draw) command. What I am getting is

g =

3D geometry object
subdomains: 7
faces: 36
edges: 60
vertices: 32



st =

(1,1) 1
(2,1) 1
(3,1) 1
(4,1) 1
(5,1) 1
(6,1) 1
(7,1) 1

So, basically, there is no detailed information about the "location" of each subdomain. What I'm exactly looking for is "where" the subdomain X is located, so that I can assign proper settings to that subdomain.
Appreciate any help.

Cheers,
Sattar
Hello all, I have a geometry produced in a m-file. The solid3 object has 7 subdomains, their numbring depends on the length and scaling that is subject to change each round in the for-loop. I used the [g,st] = geomcsg(fem.draw) command. What I am getting is g = 3D geometry object subdomains: 7 faces: 36 edges: 60 vertices: 32 st = (1,1) 1 (2,1) 1 (3,1) 1 (4,1) 1 (5,1) 1 (6,1) 1 (7,1) 1 So, basically, there is no detailed information about the "location" of each subdomain. What I'm exactly looking for is "where" the subdomain X is located, so that I can assign proper settings to that subdomain. Appreciate any help. Cheers, Sattar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 11, 2009, 4:30 a.m. EST
Dear Sattar,

Unfortunately I don't have time to go back to my files and see what I exactly did, but the general idea should be somethiong like the following.

what you get in st variable is the link between your objects and their subdomains. So you don't find the answer to "where is each subdomain" but "which object is assigned what subdomain". In your m-file, if the ordering of your objects are not changing you can use this information to track which object is subdomain X and which one is Y. Then you can do the correct assignments.

Again, this might not be 100% correct, or work in all cases, but what solved my problem has to be something like this.

Hope it helps,
Arda
Dear Sattar, Unfortunately I don't have time to go back to my files and see what I exactly did, but the general idea should be somethiong like the following. what you get in st variable is the link between your objects and their subdomains. So you don't find the answer to "where is each subdomain" but "which object is assigned what subdomain". In your m-file, if the ordering of your objects are not changing you can use this information to track which object is subdomain X and which one is Y. Then you can do the correct assignments. Again, this might not be 100% correct, or work in all cases, but what solved my problem has to be something like this. Hope it helps, Arda

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 21, 2010, 2:28 p.m. EDT
Read the Chapter Postproceaaing and Associativity in the Matlab interface Guide. There You'll find the answer!!!!
And use the function geomanalyze instead of geomcsg so the relationship between names and objects will stay the same.
Read the Chapter Postproceaaing and Associativity in the Matlab interface Guide. There You'll find the answer!!!! And use the function geomanalyze instead of geomcsg so the relationship between names and objects will stay the same.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 26, 2010, 11:19 a.m. EDT
Has anyone figured out how to do this with version 4.0a using the Matlab Live Link?
Has anyone figured out how to do this with version 4.0a using the Matlab Live Link?

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.