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.

Domain number Assignment

Please login with a confirmed email address before reporting spam

Dear All,
I wrote a code for my comsol multiphysics problem using comsol livelink matlab. The code is working and producing desired geometry but there is problem regarding domain number as comsol assign domain number itself .

Is there any way to assign domain number of one's need while working in comsol livelink matlab .

Please suggest some solution.

-----------------------
Asha Sharma


4 Replies Last Post 22.08.2017, 07:04 GMT-4
Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 18.08.2017, 15:33 GMT-4
Hello Asha,

See www.comsol.com/blogs/manually-work-entity-numbers-selections/

Best,
Jeff
Hello Asha, See https://www.comsol.com/blogs/manually-work-entity-numbers-selections/ Best, Jeff

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 18.08.2017, 16:24 GMT-4
Hello Jeff,
Thank you for valuable suggestion.

But in my geometry, i am having 200 circles and can't let the material property to get changed within each domain. So i used 'for' loop while using 'ballselection' for 200circles as below:
numpart=200
for j=1:numpart
selball=(j);
ballsel1=strcat('c',selball)
partno=j;
ctxname=(ctx(partno));
ctyname=(cty(partno));
model.geom('geom1').create(ballsel1, 'BallSelection');
model.geom('geom1').feature(ballsel1).set('r', [radpart]);
model.geom('geom1').feature(ballsel1).set('posx', [ctxname]);
model.geom('geom1').feature(ballsel1).set('posy', [ctyname]);
model.geom('geom1').feature(ballsel1).set('condition', 'allvertices');
end
model.geom('geom1').run;

But its producing following error:
Error using PermittThreeCirc (line 46)
Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: An object with the given name
already exists
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
An object with the given name already exists

An object with the given name already exists

An object with the given name already exists.
- Tag: ballsel1

Please suggest solution.
Hello Jeff, Thank you for valuable suggestion. But in my geometry, i am having 200 circles and can't let the material property to get changed within each domain. So i used 'for' loop while using 'ballselection' for 200circles as below: numpart=200 for j=1:numpart selball=(j); ballsel1=strcat('c',selball) partno=j; ctxname=(ctx(partno)); ctyname=(cty(partno)); model.geom('geom1').create(ballsel1, 'BallSelection'); model.geom('geom1').feature(ballsel1).set('r', [radpart]); model.geom('geom1').feature(ballsel1).set('posx', [ctxname]); model.geom('geom1').feature(ballsel1).set('posy', [ctyname]); model.geom('geom1').feature(ballsel1).set('condition', 'allvertices'); end model.geom('geom1').run; But its producing following error: Error using PermittThreeCirc (line 46) Java exception occurred: Exception: com.comsol.util.exceptions.FlException: An object with the given name already exists (rethrown as com.comsol.util.exceptions.FlException) (rethrown as com.comsol.util.exceptions.FlException) Messages: An object with the given name already exists An object with the given name already exists An object with the given name already exists. - Tag: ballsel1 Please suggest solution.

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 22.08.2017, 06:54 GMT-4
Hi

I can't see why your code should result in the error message you see. Can you send your model and script to support?

What type of variation of material parameters do you wish to have for each circle? Are all the parameters different or can you group the material settings?

You can either use different materials for different selections or you can define Variables (Component->Definitions->Variables) that use different expressions in different domains.

I would use the function mphselectcoords for finding the entity numbers. It works similarly to a BallSelection, but doesn't add selections to the model. You can then use the returned entity numbers when setting up your model.

--
Lars Gregersen
Comsol Denmark
Hi I can't see why your code should result in the error message you see. Can you send your model and script to support? What type of variation of material parameters do you wish to have for each circle? Are all the parameters different or can you group the material settings? You can either use different materials for different selections or you can define Variables (Component->Definitions->Variables) that use different expressions in different domains. I would use the function mphselectcoords for finding the entity numbers. It works similarly to a BallSelection, but doesn't add selections to the model. You can then use the returned entity numbers when setting up your model. -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 22.08.2017, 07:04 GMT-4
Hello Lars,
Thank you for your valuable suggestion.
This link www.comsol.com/blogs/manually-...ork-entity-numbers-selections/ worked for me.

Actually i was writing code like
model.geom('geom1').create(ballsel1, 'BallSelection');
Instead of
tag=model.geom('geom1').feature.uniquetag('ballsel');
model.geom('geom1').feature.create(tag, 'BallSelection');

------------------
Asha Sharma
Hello Lars, Thank you for your valuable suggestion. This link www.comsol.com/blogs/manually-...ork-entity-numbers-selections/ worked for me. Actually i was writing code like model.geom('geom1').create(ballsel1, 'BallSelection'); Instead of tag=model.geom('geom1').feature.uniquetag('ballsel'); model.geom('geom1').feature.create(tag, 'BallSelection'); ------------------ Asha Sharma

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.