CFD Online Discussion Forums

CFD Online Discussion Forums (
-   STAR-CCM+ (
-   -   Best way to select all region objects in java (

showerlin April 10, 2012 00:52

Best way to select all region objects in java
Dear Experts,

Sorry to bother another pretty dump questions...

I'm writing a simple java script to automate a series of "constrained plane" for the geometry in order to calculate the mass flow for each channels.

it works well when the model only have one region. now the geometry getting more complex and the channels now split into different regions. and the code won't work well.

I can still make it work by manually changing the name in the code to match the region I'm working on. but I'm looking for more generalize solution. is there any clean way to do something like "select-all-regions"? with simple example would be really really appreciated... since I'm still new to CCM...

Many thanks for the great help.


kri321shna April 10, 2012 07:48

u can use collector concept.

frogotron April 10, 2012 08:14


You can use a bit of code like

Simulation sim = getActiveSimulation();

Collection<Region> allReg = sim.getRegionManager().getRegions();

Units units_0 =
((Units) sim.getUnitsManager().getObject("m"));

ConstrainedPlaneSection constrainedPlaneSection_0 =
(ConstrainedPlaneSection) sim.getPartManager().createConstrainedPlaneImplici tPart(new NeoObjectVector(new Object[] {}), new DoubleVector(new double[] {}), units_0);

constrainedPlaneSection_0.getInputParts().setObjec ts(allReg);

You need to be careful if you have deleted regions in your model. If so then you need to make an empty entity and fill it with the appropriate regions eg.

ArrayList<Region> allRegList= new ArrayList<Region>();
for(Region r: sim.getRegionManager().getRegions()){
constrainedPlaneSection_0.getInputParts().setObjec ts(allRegList);

All times are GMT -4. The time now is 18:10.