CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

Java code to get the current time/iteration step

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 26, 2010, 06:40
Default Java code to get the current time/iteration step
  #1
New Member
 
Varoon
Join Date: Mar 2010
Posts: 6
Rep Power: 16
varoon is on a distinguished road
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?
varoon is offline   Reply With Quote

Old   April 26, 2010, 11:12
Default
  #2
Senior Member
 
Join Date: Mar 2009
Location: Austin, TX
Posts: 160
Rep Power: 18
kyle is on a distinguished road
This will return an integer with the current iteration number...

getActiveSimulation().getSimulationIterator().getC urrentIteration()
kyle is offline   Reply With Quote

Old   April 27, 2010, 00:39
Default
  #3
New Member
 
Varoon
Join Date: Mar 2010
Posts: 6
Rep Power: 16
varoon is on a distinguished road
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?
varoon is offline   Reply With Quote

Old   June 1, 2010, 12:56
Default
  #4
New Member
 
Johannes
Join Date: May 2009
Posts: 16
Rep Power: 17
jopawipr is on a distinguished road
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!
jopawipr is offline   Reply With Quote

Old   June 1, 2010, 13:38
Default
  #5
Senior Member
 
Join Date: Mar 2009
Location: Austin, TX
Posts: 160
Rep Power: 18
kyle is on a distinguished road
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();

}
kyle is offline   Reply With Quote

Old   June 2, 2010, 00:39
Default
  #6
New Member
 
Varoon
Join Date: Mar 2010
Posts: 6
Rep Power: 16
varoon is on a distinguished road
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.
varoon is offline   Reply With Quote

Old   June 2, 2010, 10:14
Default
  #7
New Member
 
Johannes
Join Date: May 2009
Posts: 16
Rep Power: 17
jopawipr is on a distinguished road
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!!
jopawipr is offline   Reply With Quote

Old   June 2, 2010, 10:38
Default
  #8
Senior Member
 
Join Date: Mar 2009
Location: Austin, TX
Posts: 160
Rep Power: 18
kyle is on a distinguished road
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!
kyle is offline   Reply With Quote

Old   June 2, 2010, 10:44
Default
  #9
New Member
 
Johannes
Join Date: May 2009
Posts: 16
Rep Power: 17
jopawipr is on a distinguished road
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
jopawipr is offline   Reply With Quote

Old   June 2, 2010, 10:56
Default
  #10
ems
New Member
 
Eric
Join Date: May 2009
Posts: 6
Rep Power: 17
ems is on a distinguished road
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
ems is offline   Reply With Quote

Old   June 21, 2010, 10:09
Default
  #11
Member
 
Ryan Coe
Join Date: Jun 2010
Location: Albuquerque, NM
Posts: 98
Rep Power: 16
ryancoe is on a distinguished road
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
ryancoe is offline   Reply With Quote

Reply

Tags
java


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


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