# Create Iterative Macro

 Register Blogs Members List Search Today's Posts Mark Forums Read

 July 3, 2019, 04:48 Create Iterative Macro #1 New Member   Join Date: Jul 2019 Posts: 3 Rep Power: 3 Hello everyone, I need to write a macro to automate the following procedure: remove cell where velocity magnitude exceed a certain value (say 80 m/s) and re-run the simulation. By now, i create a stopping criteria based on a max value of velocity monitor and every time this criterion is satisfied the simulation stop and save; then I start a macro which remove cells where velocity exceed a chosen value and restart the simulation. Because this limit is reached often I want to automate this procedure whit a cycle based on the stopping criteria which in the case this stopping criteria is satisfied remove cell and run simulation without done manually every time. Hope someone can help me Michele

 July 10, 2019, 20:14 #2 Senior Member   Join Date: Nov 2010 Location: USA Posts: 1,228 Rep Power: 20 Look at the remove invalid cells feature. It has the ability to let you specify a function with which to remove cells from a field function. Record yourself a macro doing just that and you should have everything you need.

July 11, 2019, 05:52
#3
New Member

Join Date: Jul 2019
Posts: 3
Rep Power: 3
Quote:
 Originally Posted by me3840 Look at the remove invalid cells feature. It has the ability to let you specify a function with which to remove cells from a field function. Record yourself a macro doing just that and you should have everything you need.
Thank you for your reply; maybe I bad explained my problem, the issues not how to remove cells that have specific velocity value but to do it for each iteration in case velocity exceed a specific value in an automated way; anyway I've found a solution doing a for cycle with an if condition e give a single step run every time that cycle for runs. Thats the macro:

for (int i=0; i<4000; i++){

simulation_0.getSimulationIterator().run(1);

double a ;
a = maxReport_0.getValue();

if ( a >= 100.0 ) {

Units units_0 =
simulation_0.getUnitsManager().getPreferredUnits(n ew IntVector(new int[] {0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));

Units units_1 =
simulation_0.getUnitsManager().getPreferredUnits(n ew IntVector(new int[] {0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));

Units units_2 =
simulation_0.getUnitsManager().hasPreferredUnits(n ew IntVector(new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));

Units units_3 =
simulation_0.getUnitsManager().hasPreferredUnits(n ew IntVector(new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}));

MeshManager meshManager_0 =
simulation_0.getMeshManager();

Region region_0 =
simulation_0.getRegionManager().getRegion("Region_ 1");

meshManager_0.removeInvalidCells(new NeoObjectVector(new Object[] {region_0}), NeoProperty.fromString("{\'minimumContiguousFaceAr ea\': 0.0, \'minimumCellVolumeEnabled\': true, \'minimumVolumeChangeEnabled\': false, \'functionOperator\': 1, \'minimumContiguousFaceAreaEnabled\': false, \'minimumFaceValidityEnabled\': false, \'functionValue\': 90.0, \'functionEnabled\': true, \'function\': \'VelocityMagnitude\', \'minimumVolumeChange\': 1.0E-10, \'minimumCellVolume\': 0.0, \'minimumCellQualityEnabled\': true, \'minimumCellQuality\': 1.0E-5, \'minimumDiscontiguousCells\': 1, \'minimumDiscontiguousCellsEnabled\': false, \'minimumFaceValidity\': 0.51}"));

}
}

 July 12, 2019, 20:21 #4 Senior Member   Join Date: Nov 2010 Location: USA Posts: 1,228 Rep Power: 20 I really don't suggest doing this every iteration, it's bound to be extremely slow, especially if there's a lot of removals. You're better off creating a damping source term or just improving the mesh if your mesh quality is the problem.

July 15, 2019, 05:19
#5
New Member

Join Date: Jul 2019
Posts: 3
Rep Power: 3
Quote:
 Originally Posted by me3840 I really don't suggest doing this every iteration, it's bound to be extremely slow, especially if there's a lot of removals. You're better off creating a damping source term or just improving the mesh if your mesh quality is the problem.
Sorry for replying too late... how can I create a damping source and what kind of source ? Unfortunately I'm studying a case in which I cannot change the surface tessellation and the solver has to be the coupled implicit. The main problem is that the mesh is highly sensitive to the order of discretization scheme and switching from 1st order to 2nd order generate the high velocity cell..

Thanks for you help

 Tags macro java, star ccm+