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.

Geometry present or not depending on a parameter

Please login with a confirmed email address before reporting spam

Hi!

I am trying to create a geometry that will have certain elements appear or disappear depending on a variable. For example: I have a variable "var1" that can take the values of 1 or 2. I have a geometry that hast a plate with a hole in the middle (in 2D, so it would basically look like a rectangle with a circle in the middle). I want to be able to have COMSOL build the geometry with the circle if I input 1 for "var1" and to build the geometry with just the rectangle is I input 2 for "var1"

Thank you very much for your help.

Francesco

1 Reply Last Post 8 févr. 2013, 15:17 UTC−5
Josh Thomas Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 8 févr. 2013, 15:17 UTC−5
Francesco-

First off, be sure to use a Global>Parameter definition and not a variable definition as variables in COMSOL aren't allowed to be used in the Geometry node.

As to parameterizing the existance and non-existance of a hole, I have had success doing this by using the Array function and making the array size a function of a parameter that can be 0 if you don't want the object present.

Be advised, if you are performing a boolean difference operation on the array object you can't completely remove the object or you will get a geometry error. See the attached mph file for a workaround. Set parameter array_x to 1 to have no hole in the square. Set parameter array_x to 2 to have a hole in the square.

Regards,
Josh Thomas
AltaSim Technologies
Francesco- First off, be sure to use a Global>Parameter definition and not a variable definition as variables in COMSOL aren't allowed to be used in the Geometry node. As to parameterizing the existance and non-existance of a hole, I have had success doing this by using the Array function and making the array size a function of a parameter that can be 0 if you don't want the object present. Be advised, if you are performing a boolean difference operation on the array object you can't completely remove the object or you will get a geometry error. See the attached mph file for a workaround. Set parameter array_x to 1 to have no hole in the square. Set parameter array_x to 2 to have a hole in the square. Regards, Josh Thomas AltaSim Technologies

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.