Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
07.02.2013, 11:19 GMT-5
Hi Daniel,
I'm not sure if I understood correctly your question, but I believe there are many different ways of doing that.
You may uses this line:
mphgeom(model,'geom1','Edgelabels','on')
to have a plot of the geometry with the numbering used by comsol.
Then with a simple 'input' matlab command you can specify which edge (or boundary) should have a determined boundary condition.
The mphgeom helps if your geometry changes within your applications. However, if that is not the case you better define selections to identify which edge has a particular set of boundary conditions.
Hope it helps,
Mattia
Hi Daniel,
I'm not sure if I understood correctly your question, but I believe there are many different ways of doing that.
You may uses this line:
mphgeom(model,'geom1','Edgelabels','on')
to have a plot of the geometry with the numbering used by comsol.
Then with a simple 'input' matlab command you can specify which edge (or boundary) should have a determined boundary condition.
The mphgeom helps if your geometry changes within your applications. However, if that is not the case you better define selections to identify which edge has a particular set of boundary conditions.
Hope it helps,
Mattia
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
07.02.2013, 14:17 GMT-5
The mphgeom helps if your geometry changes within your applications. However, if that is not the case you better define selections to identify which edge has a particular set of boundary conditions.
Yes this is the case. I am developing a pipeline where a text file with randomly generated coordinates is pulled up by matlab and used to define the geometry. There are over 100 objects whose boundary conditions need to be set. I know which objects need what boundary conditions based on draw order and I want to be able to automatically step through the objects and set boundary conditions without the user having to do it manually. However, I am not clear on how to associate the boundary/face numbers with a given object. They seem to be based on relative position within the geometry but I haven't been able to figure it out.
[QUOTE]
The mphgeom helps if your geometry changes within your applications. However, if that is not the case you better define selections to identify which edge has a particular set of boundary conditions.
[/QUOTE]
Yes this is the case. I am developing a pipeline where a text file with randomly generated coordinates is pulled up by matlab and used to define the geometry. There are over 100 objects whose boundary conditions need to be set. I know which objects need what boundary conditions based on draw order and I want to be able to automatically step through the objects and set boundary conditions without the user having to do it manually. However, I am not clear on how to associate the boundary/face numbers with a given object. They seem to be based on relative position within the geometry but I haven't been able to figure it out.
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
07.02.2013, 17:43 GMT-5
Was able to figure out a round-about way of doing this for my particular geometry. Seems like comsol sets face numbers by stepping through the geometry starting in the lower left and proceeding through y, then taking one step in x, and proceeding through y again, etc. Once I've separated out the faces by which object they belong to, I can find out which object is which and what faces are associated with it, based on where it is in my model
oNames = model.geom('geom1').objectNames();
upDown = model.geom('geom1').getUpDown;
upDown = int32(upDown');
domain = cell(1,length(upDown));
for i = 1:length(domain)
domain{upDown(i,2)} = cat(2,domain{upDown(i,2)},i);
end
% posloc contains the x-y position data for objects on my plane of interest and cellpos is my 'odd man out'
% feature that needs a different BC. It's x position is at 75 with a radius of 7.5 so I can find the other features
% relative to it and less in x-value. Since the objects are added to my domain cell-array based on the same x-y
% position logic, I know which object is which.
cellpos = 75;
cellr = 7.5;
sortpos = sortrows(posloc);
xlessrows = find((sortpos(:,1)-r)<cellpos-cellr);
bndset = [];
for i = 2:(max(xlessrows)+1);
bndset = cat(2,bndset,domain{i});
end
for i = (max(xlessrows)+3):length(domain);
bndset = cat(2,bndset,domain{i});
end
Was able to figure out a round-about way of doing this for my particular geometry. Seems like comsol sets face numbers by stepping through the geometry starting in the lower left and proceeding through y, then taking one step in x, and proceeding through y again, etc. Once I've separated out the faces by which object they belong to, I can find out which object is which and what faces are associated with it, based on where it is in my model
oNames = model.geom('geom1').objectNames();
upDown = model.geom('geom1').getUpDown;
upDown = int32(upDown');
domain = cell(1,length(upDown));
for i = 1:length(domain)
domain{upDown(i,2)} = cat(2,domain{upDown(i,2)},i);
end
% posloc contains the x-y position data for objects on my plane of interest and cellpos is my 'odd man out'
% feature that needs a different BC. It's x position is at 75 with a radius of 7.5 so I can find the other features
% relative to it and less in x-value. Since the objects are added to my domain cell-array based on the same x-y
% position logic, I know which object is which.
cellpos = 75;
cellr = 7.5;
sortpos = sortrows(posloc);
xlessrows = find((sortpos(:,1)-r)
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
08.02.2013, 02:49 GMT-5
Hi Daniel,
my suggestion is to play more with comsol's command than with Matlab to identify these things. The API manual is a quite good reference (also the only one we have ;-) ).
Personally I'm using comsol 4,3, but you may find what you look for using:
model.mesh( 'mesh1' ).getElemEntity( 'edg' )
model.mesh( 'mesh1' ).getElem('edg' ) + 1
With these 2 lines you should be able to relate the boundaries of the geometry to the boundaries of the mesh.
While if you look for coordinates of any entity, than you shuold use the command xmeshinfo.
Another option might be to define selections while drawing your pipe. This shuold allow you to "keep track" of you 100 parameters!
Hope it helps,
Mattia
Hi Daniel,
my suggestion is to play more with comsol's command than with Matlab to identify these things. The API manual is a quite good reference (also the only one we have ;-) ).
Personally I'm using comsol 4,3, but you may find what you look for using:
model.mesh( 'mesh1' ).getElemEntity( 'edg' )
model.mesh( 'mesh1' ).getElem('edg' ) + 1
With these 2 lines you should be able to relate the boundaries of the geometry to the boundaries of the mesh.
While if you look for coordinates of any entity, than you shuold use the command xmeshinfo.
Another option might be to define selections while drawing your pipe. This shuold allow you to "keep track" of you 100 parameters!
Hope it helps,
Mattia
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
13.08.2016, 11:12 GMT-4
Hello,
I have a similar problem when using Comsol with Matlab.
I would like to export only the nodes associated with selected boundaries, that I know in the Comsol server.
The problem is that when I use "mphxmeshinfo" and "info.elements.edg.nodes" I get a different order of the boundaries with respect what I get by using "mphmesh(model,'mesh1','edgelabels','on')".
Is there any easy way to make the correct order?
Thanks in advance,
Simonetta
Hello,
I have a similar problem when using Comsol with Matlab.
I would like to export only the nodes associated with selected boundaries, that I know in the Comsol server.
The problem is that when I use "mphxmeshinfo" and "info.elements.edg.nodes" I get a different order of the boundaries with respect what I get by using "mphmesh(model,'mesh1','edgelabels','on')".
Is there any easy way to make the correct order?
Thanks in advance,
Simonetta