CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

How to stop a simulation with a physical criterion (other than time) ?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By oxadampf

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 23, 2019, 06:03
Default How to stop a simulation with a physical criterion (other than time) ?
  #1
Member
 
Mat
Join Date: Jan 2012
Posts: 60
Rep Power: 14
Mat_fr is on a distinguished road
Hi foamers,


Everything's in the title.


I was wondering if there's a way to stop an openfoam simulation with a physical criterion (e.g. average pressure on a wall exceeding a threshold), using the dictionaries. And then to write the results, at this last time step.


Otherwise, I suppose I will have to modify the solver.


Thanks,
Mat
Mat_fr is offline   Reply With Quote

Old   November 7, 2019, 03:55
Default
  #2
New Member
 
Benedikt Scholz
Join Date: Oct 2019
Posts: 2
Rep Power: 0
oxadampf is on a distinguished road
Hi Mat,


were you able to find a solution to your problem?


Thanks,
Ben
oxadampf is offline   Reply With Quote

Old   November 7, 2019, 04:55
Default
  #3
Member
 
Mat
Join Date: Jan 2012
Posts: 60
Rep Power: 14
Mat_fr is on a distinguished road
Hello,


No I didn't.

For the moment, I am recording some physical values and looking for which time my physical criterion is achieved. Then if I need I start again the simulation at a previous saved time step untill the criterion time I just found.



It's a bit anoying and takes a bit of time, but it's okay.


Good luck,
Mat
Mat_fr is offline   Reply With Quote

Old   November 7, 2019, 05:34
Default
  #4
New Member
 
Benedikt Scholz
Join Date: Oct 2019
Posts: 2
Rep Power: 0
oxadampf is on a distinguished road
Hi,

I think I found a solution. Writing a coded functionObject to the controlDict file can help. Something like this:



T__max__sample
{
enabled true;
type coded;
functionObjectLibs ("libutilityFunctionObjects.so");
region sample00;
redirectType T__max__sample;
writeControl timeStep;
writeInterval 1;
log true;

codeExecute
#{
const volScalarField& T = mesh().lookupObject<volScalarField>("T");
if ( max(T).value() < 270 )
{
bool result=const_cast<Time&>(mesh().time()).writeNow() ;
FatalErrorIn("Stopped")
<< "Bla" << endl
<< exit(FatalError);
}
#};
}


It terminates the simulation, if the max temperature in the region called "sample00" falls below 270 with a fatal error message (I know not pretty, but functional). Then, it writes the last timeStep.



This link helped me a lot:

Mixing #codeStream with coded-function-object


I hope this will help you.
Ben
Mat_fr, acgnipper and ancolli like this.
oxadampf is offline   Reply With Quote

Old   November 7, 2019, 08:00
Default
  #5
Member
 
Mat
Join Date: Jan 2012
Posts: 60
Rep Power: 14
Mat_fr is on a distinguished road
That's grand! Thanks for your time, Ben.


I haven't made it to the step of conded function objetc yet, and I should.


Regards,
Mat
Mat_fr is offline   Reply With Quote

Reply


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
[General] Extracting ParaView Data into Python Arrays Jeffzda ParaView 30 November 6, 2023 22:00
Time Step Continuity Errors simpleFoam Dorian1504 OpenFOAM Running, Solving & CFD 1 October 9, 2022 10:23
Unexpected deltaT decrease in pimpleFoam simulation robyTKD OpenFOAM Running, Solving & CFD 9 June 27, 2014 07:52
dynamic Mesh is faster than MRF???? sharonyue OpenFOAM Running, Solving & CFD 14 August 26, 2013 08:47
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 04:34


All times are GMT -4. The time now is 03:57.