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.

how to change material properties of a mesh element in a loop

Please login with a confirmed email address before reporting spam

Hi

I am working with livelink to maltab and I have a geometry with three domains assigned with certain material properties. After solving my model for the first iteration, I take the results for each node or element and depenting on the values I get I need to change the material properties of that node or element.

I think that I can't use somehow the command
model.material('<mat tag>').selection.set([<point>]) e.g. for each point node, since the materials are assigned to domains, geometries or boundaries, right?

Do you have any idea about how to make it? For each iteration maybe I have to re-create the geometry including a new domain (even if this is an element) and then assign the domain with the new material properties? how can I create a new domain from matlab?

Thanks


2 Replies Last Post Jan 16, 2015, 11:26 a.m. EST
COMSOL Moderator

Hello Maria Vavva

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 17, 2014, 2:32 a.m. EDT
Hi Maria,

have you found any solution to your problem yet? I have been looking for ages how to do the same thing as you described!

Regards,
Stefan

Hi Maria, have you found any solution to your problem yet? I have been looking for ages how to do the same thing as you described! Regards, Stefan

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jan 16, 2015, 11:26 a.m. EST
Have either of you found a solution? I am trying to change the property values for each individual element. I am currently able to create an interpolation function based on element values and the property I want to assign to individual mesh elements (in my case hydraulic conductivity). This code runs, but the assigned hydraulic conductivities are assigned to different elements than the model I input to the interpolation function.
...

Some sample code:
"model.file.create('res2');
model.func.create('int1', 'Interpolation');
model.func('int1').set('importedname','test_hyd_cond_elems.csv');
model.func('int1').set('modelres', 'res2');
model.func('int1').set('importedstruct', 'Spreadsheet');
model.func('int1').set('importeddim', '1D');
model.func('int1').set('sourcetype', 'model');
model.file('res2').resource('test_hyd_cond_elems.csv');
...
expre = 'int1(meshelement)';
model.physics('dl').feature('smm2').set('K', {expre; '0'; '0'; '0'; expre; '0'; '0'; '0'; expre});"

Thank you in advanced for you help,

Carolyne Bocovich
Have either of you found a solution? I am trying to change the property values for each individual element. I am currently able to create an interpolation function based on element values and the property I want to assign to individual mesh elements (in my case hydraulic conductivity). This code runs, but the assigned hydraulic conductivities are assigned to different elements than the model I input to the interpolation function. ... Some sample code: "model.file.create('res2'); model.func.create('int1', 'Interpolation'); model.func('int1').set('importedname','test_hyd_cond_elems.csv'); model.func('int1').set('modelres', 'res2'); model.func('int1').set('importedstruct', 'Spreadsheet'); model.func('int1').set('importeddim', '1D'); model.func('int1').set('sourcetype', 'model'); model.file('res2').resource('test_hyd_cond_elems.csv'); ... expre = 'int1(meshelement)'; model.physics('dl').feature('smm2').set('K', {expre; '0'; '0'; '0'; expre; '0'; '0'; '0'; expre});" Thank you in advanced for you help, Carolyne Bocovich

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.