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.
Finding the Domain number/Creating an entity of a feature created with the Comsol Java API
Posted Apr 22, 2013, 9:30 p.m. EDT Version 4.3b 5 Replies
Please login with a confirmed email address before reporting spam
Hi everyone,
I am using the Java API with Comsol and I really like it's abilities overall. I would like to be able to (in a for loop) create a 3D geometrical object (a cylinder) and then make that cylinder into it's own entity. This would be much like if you were to in the GUI create a cylinder, create an Explicit Entity, Change the geometric entity level to "Domain," click on the cylinder, then right click to select that domain, then change Output Entities to Adjacent Boundaries with either Exterior or Interior boundaries selected. Then create a Floating Potential, or really any other Boundary Condition, then set that Boundary Condition to be set to the Entity that was just made.
Here are some lines of the code:
model.geom("geom1").feature().create("cyl1", "Cylinder"); //creates the cylinder
model.geom("geom1").feature("cyl1").set("pos", new String[]{"0", "0", "0"}); // sets position
model.geom("geom1").feature("cyl1").set("h", "length"); // sets the length of the cylinder
model.selection().create("sel1", "Explicit");
model.selection("sel1").geom("geom1", 3, 2, new String[]{"exterior", "interior"});
model.selection("sel1").set(new int[]{5}); // HOW DO YOU FIGURE OUT WHAT DOMAIN TO PUT HERE.
// later in the code:
model.physics("ec").feature().create("fp1", "FloatingPotential", 2);
model.physics("ec").feature("fp1").selection().named("sel1");
Hopefully you got a pretty good idea of what I'm trying to accomplish above. Just trying to be able to find out what domain number "cyl1" is in this case. Eventually, this will be implemented into a code with 100-10000 cylinders and an individual floating potential can be assigned to each cylinder.
Thanks in advance for your help,
John
I am using the Java API with Comsol and I really like it's abilities overall. I would like to be able to (in a for loop) create a 3D geometrical object (a cylinder) and then make that cylinder into it's own entity. This would be much like if you were to in the GUI create a cylinder, create an Explicit Entity, Change the geometric entity level to "Domain," click on the cylinder, then right click to select that domain, then change Output Entities to Adjacent Boundaries with either Exterior or Interior boundaries selected. Then create a Floating Potential, or really any other Boundary Condition, then set that Boundary Condition to be set to the Entity that was just made.
Here are some lines of the code:
model.geom("geom1").feature().create("cyl1", "Cylinder"); //creates the cylinder
model.geom("geom1").feature("cyl1").set("pos", new String[]{"0", "0", "0"}); // sets position
model.geom("geom1").feature("cyl1").set("h", "length"); // sets the length of the cylinder
model.selection().create("sel1", "Explicit");
model.selection("sel1").geom("geom1", 3, 2, new String[]{"exterior", "interior"});
model.selection("sel1").set(new int[]{5}); // HOW DO YOU FIGURE OUT WHAT DOMAIN TO PUT HERE.
// later in the code:
model.physics("ec").feature().create("fp1", "FloatingPotential", 2);
model.physics("ec").feature("fp1").selection().named("sel1");
Hopefully you got a pretty good idea of what I'm trying to accomplish above. Just trying to be able to find out what domain number "cyl1" is in this case. Eventually, this will be implemented into a code with 100-10000 cylinders and an individual floating potential can be assigned to each cylinder.
Thanks in advance for your help,
John
5 Replies Last Post Jun 17, 2015, 1:30 a.m. EDT