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.

Creating selections based on geometric objects

Please login with a confirmed email address before reporting spam

I've got a complicated geometry full of small spheres with a single layer. I made them by editing a .java exported file from a model that I created with some of the spheres so I could get the basic syntax and then just edited to create them on a loop that determines the geometry I need and also create definitions for a local spherical coordinate system for each sphere that I need to define some material expressions.

The geometry creation works fine, what I need is to create selections for the internal and external domains (the innermost sphere, and the external domain that belongs to the layer) of each sphere separately.

I tried to figure this out by myself looking through the Java API documentation, without success.

Is there any way to create what I want?

Thanks in advance.

PS: Here is a simplified piece of code that I use to create the spheres:

int sphIndex = SP_START_INDEX;
int neighbors = NEIGHBORS;
for (int i = -neighbors; i <= neighbors; i++)
{
for (int j = -neighbors; j <= neighbors; j++)
{
for (int k = -neighbors; k <= neighbors; k++)
{
String sphName = "sph" + sphIndex;
model.geom("geom1").feature().create(sphName, "Sphere");
String shpAlias = sphereName(i,j,k); // just create an unique alias
model.geom("geom1").feature(sphName).name(shpAlias);
model.geom("geom1").feature(sphName)
.set("pos", new String[]{String.valueOf(i) + "*Cd", String.valueOf(j) + "*Cd", String.valueOf(k) + "*Cd"}); // Cd is just a constant
model.geom("geom1").feature(sphName).set("axis", "0 0");
model.geom("geom1").feature(sphName)
.set("layername", new String[]{"Layer 1"});
model.geom("geom1").feature(sphName).set("layer", new String[]{"Ct"}); // Ct is another constant
model.geom("geom1").feature(sphName).set("r", "Cr"); // so is Cr

String sysName = "sys" + sphIndex;
model.coordSystem().create(sysName, "geom1", "Spherical");
model.coordSystem(sysName).name(shpAlias + "System");
model.coordSystem(sysName).set("origin", new String[]{String.valueOf(i) + "*Cd",
"0" : String.valueOf(j) + "*Cd", "0" : String.valueOf(k) + "*Cd"});

sphIndex++;
}
}
}

0 Replies Last Post 2013年4月13日 GMT-4 23:18
COMSOL Moderator

Hello Heric Farias

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.

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.