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

Stoping criterion

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Jerryfan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 24, 2016, 11:49
Default Stoping criterion
  #1
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Hi All,

I want to stop my simulation when C < tolerance_Value or C < 0 at any grid point. I don't know, how to write the condition in while loop? I need your help, code is given below.

Code:
while (????)    
   {        
         Info<< "Time = " << runTime.timeName() << nl << endl;               

         forAll(CX, cellI) 
            {   
                   CX[cellI] = alpha.value()*C[cellI]*C[cellI];            
            }                          

         solve(fvm::ddt(C) == fvm::laplacian(DT, C) - k*CX*C);   

         runTime.write();  
    }

Last edited by cute; July 24, 2016 at 20:00.
cute is offline   Reply With Quote

Old   July 25, 2016, 11:35
Default
  #2
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18
anishtain4 is on a distinguished road
You can use panicDump during the run rather than putting it in the solver.
anishtain4 is offline   Reply With Quote

Old   July 25, 2016, 15:10
Default
  #3
Member
 
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 12
Jerryfan is on a distinguished road
Hi cute,


You can simply add a line that gives the maximum of C, and then determine based on this maximum value.


Quote:
while (maxC > tolerance_value)
{
Info<< "Time = " << runTime.timeName() << nl << endl;

forAll(CX, cellI)
{
CX[cellI] = alpha.value()*C[cellI]*C[cellI];
}

dimensioned<Type> maxC = max(C); //Type depends on the Type of variable in field C.

solve(fvm::ddt(C) == fvm::laplacian(DT, C) - k*CX*C);

runTime.write();
}
LogiDF likes this.
Jerryfan is offline   Reply With Quote

Old   July 25, 2016, 20:30
Default
  #4
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Thanks for the input.
I defined C as volScalarField, is my Type equals volScalarField?

dimensioned<volScalarField> maxC = max(C);

But all the values in C are floating point numbers, I am confused what to write?
cute is offline   Reply With Quote

Old   July 25, 2016, 20:34
Default
  #5
Member
 
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 12
Jerryfan is on a distinguished road
What I mean is Type of variable in field C, not the Type of field C itself. In this case, you should use
Quote:
dimensioned<scalar>
.
Jerryfan is offline   Reply With Quote

Old   July 25, 2016, 20:35
Default
  #6
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Thanks for a quick response.
cute is offline   Reply With Quote

Old   July 31, 2016, 12:26
Default
  #7
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
I am using the following code as suggested, but I am getting error:

CODE:
Code:
dimensioned<scalar> maxC = max(C);
dimensioned<scalar> minC = min(C);
    
    while (maxC > 1E-6 && minC > 0.0)
    { -------------------- }
ERROR:

Code:
 error: no match for ‘operator>’ (operand types are ‘Foam::dimensioned<double>’ and ‘double’)
     while (maxC > 1E-6 && minC > 0.0)
cute is offline   Reply With Quote

Old   July 31, 2016, 12:52
Default
  #8
Member
 
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 12
Jerryfan is on a distinguished road
Quote:
I am using the following code as suggested, but I am getting error:

CODE:
Code:
dimensioned<scalar> maxC = max(C);
dimensioned<scalar> minC = min(C);

while (maxC > 1E-6 && minC > 0.0)
{ -------------------- }
ERROR:

Code:
error: no match for ‘operator>’ (operand types are ‘Foam::dimensioned<double>’ and ‘double’)
while (maxC > 1E-6 && minC > 0.0)

You can try to get the value out from the dimensionedType variable by:


while (maxC.value() > 1E-6 && minC.value() > 0.0)
Jerryfan is offline   Reply With Quote

Old   July 31, 2016, 14:27
Default
  #9
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Thanks, it works.
cute 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
problem with Min/max rho tH3f0rC3 OpenFOAM 8 July 31, 2019 09:48
Is convergence criterion (residual value) related with grid size? rdeepakkumar FLUENT 2 November 9, 2014 01:19
Asymptotic stopping criterion is not working rob50904 STAR-CCM+ 2 January 28, 2013 08:25
question to courant criterion tH3f0rC3 OpenFOAM 6 May 16, 2011 04:32
convergence criterion Dominique FLUENT 5 November 24, 2006 02:36


All times are GMT -4. The time now is 00:35.