|
[Sponsors] |
Java code to get the current time/iteration step |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 26, 2010, 06:40 |
Java code to get the current time/iteration step
|
#1 |
New Member
Varoon
Join Date: Mar 2010
Posts: 6
Rep Power: 16 |
I am writing a macro code to change a parameter value in ccm. I require current iteration no or time step. Is it possible to acess this data in JAVA macro code?
|
|
April 26, 2010, 11:12 |
|
#2 |
Senior Member
Join Date: Mar 2009
Location: Austin, TX
Posts: 160
Rep Power: 18 |
This will return an integer with the current iteration number...
getActiveSimulation().getSimulationIterator().getC urrentIteration() |
|
April 27, 2010, 00:39 |
|
#3 |
New Member
Varoon
Join Date: Mar 2010
Posts: 6
Rep Power: 16 |
Thanks a lot!.. I am trying to update a parameter based on the change in timestep when the simulation is running..
I used simulation_0.getSimulationIterator().run();.. a simple example to my problem is given below: simulation_0.getSimulationIterator().run(); if ( simulation_0.getSimulatorIterator().getCurrentTime step() >2) {vel = 24; } After the entire run is over, it checks the if loop. and not during the run.. Is there any way to change the parameter during the run. I tried recording a macro to see if the change in the value is recorded during the run. It does get recorded only after the simulation_0.getSimulationIterator().run(); Do u have any suggestions? |
|
June 1, 2010, 12:56 |
|
#4 |
New Member
Johannes
Join Date: May 2009
Posts: 16
Rep Power: 17 |
hi!
have you solved your problem? cause i have a quite similar one. int TimeStepNumber = simulation_0.getSimulationIterator().getCurrentTim eLevel() if(TimeStepNumber %3 == 0) { MeshPipelineController meshPipelineController_0 = simulation_0.get(MeshPipelineController.class); meshPipelineController_0.generateVolumeMesh(); } So i wana remesh my mesh every third time-step. but it doesn't work. The simulation is just running without remeshing... thanks a lot! |
|
June 1, 2010, 13:38 |
|
#5 |
Senior Member
Join Date: Mar 2009
Location: Austin, TX
Posts: 160
Rep Power: 18 |
If you want to remesh every 3 timesteps, then do this...
Code:
public void execute() { Simulation sim = getActiveSimulation(); // run three timesteps sim.getSimulationIterator().step(3); // remesh sim.getMeshPipelineController().generateVolumeMesh(); // repeat execute(); } |
|
June 2, 2010, 00:39 |
|
#6 |
New Member
Varoon
Join Date: Mar 2010
Posts: 6
Rep Power: 16 |
yeah.. I used simulation_0.getSimulationIterator().run(1); It stops after every iteration. Then i changed the parameter and ran again.
I think (as stated by Kyle) sim.getSimulationIterator().step(3); must work for you. |
|
June 2, 2010, 10:14 |
|
#7 |
New Member
Johannes
Join Date: May 2009
Posts: 16
Rep Power: 17 |
thanks a lot!
so the simulation is running, but there is no remeshing... in the output window i can read that message: Stopping criterion Maximum Inner Iterations satisfied. Initializing meshing pipeline... No initialization required. Executing surface meshers... Surface remesher up to date, skipping... All volume meshers up to date, skipping... so what's wrong? thank you for your help!! |
|
June 2, 2010, 10:38 |
|
#8 |
Senior Member
Join Date: Mar 2009
Location: Austin, TX
Posts: 160
Rep Power: 18 |
jopawipr, why are you remeshing? If no settings have changed in the mesher, and the input surface has not changed, then the meshers will all skip. There is no reason to mesh when it would just result in the same mesh that you already have!
|
|
June 2, 2010, 10:44 |
|
#9 |
New Member
Johannes
Join Date: May 2009
Posts: 16
Rep Power: 17 |
sorry, my explination was not exact enough...
I've a moving mesh. The simulation is running well until a certain time-step. Than the mesh is to bad and the simulation breaks down. So i thought it's possible to remesh(with the same mesh values) the mesh during the simulation after 5, 10 or maybe 100 time steps, cause the geometry changes during the simulation |
|
June 2, 2010, 10:56 |
|
#10 |
New Member
Eric
Join Date: May 2009
Posts: 6
Rep Power: 17 |
In case you needed to extract the time (instead of the iteration), you could also generate an Expression report with a definition of $Time and then extract this value in your java code, such as:
ExpressionReport expressionReport_0 = ((ExpressionReport) simulation_0.getReportManager().getReport("TimeChe ck")); (my report was named TimeCheck) -Eric |
|
June 21, 2010, 10:09 |
|
#11 |
Member
Ryan Coe
Join Date: Jun 2010
Location: Albuquerque, NM
Posts: 98
Rep Power: 16 |
I had this problem for a while, but seem to have found the solution...
You need to use: simulation_0.getSimulationIterator().run(1, true); This will run the simulation for one time-step (or iteration if you are doing a steady-state), and wait for iterating to complete before attempting to continue the macro. The Boolean "true" forces the macro to wait. If you look in the JAVA API, you'll find an explanation of this, although I must admit as a novice java programmer I find the API pretty cryptic. Hope that helps, Ryan |
|
Tags |
java |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Time step size and max iterations per time step | pUl| | FLUENT | 31 | October 23, 2020 23:50 |
Specfying Turbulent boundary-backward-facing step | Ben Sellars | FLUENT | 1 | December 13, 2006 08:39 |
State of the art in CFD technology | Juan Carlos GARCIA SALAS | Main CFD Forum | 39 | November 1, 1999 15:34 |
public CFD Code development | Heinz Wilkening | Main CFD Forum | 38 | March 5, 1999 12:44 |
What kind of Cmmercial CFD code you feel well? | Lans | Main CFD Forum | 13 | October 27, 1998 11:20 |