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

do_while loop for coupling two equations (convergence criteria?)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 26, 2011, 12:32
Default do_while loop for coupling two equations (convergence criteria?)
  #1
New Member
 
Muhammad reza hassani
Join Date: Apr 2010
Posts: 29
Rep Power: 16
mhassani is on a distinguished road
hi
I have a question regarding coupling two scalar transport equations. the equations are coupled through their source term.

from the programmer's guide, source term can explicitly be added to the equation: solve(fvm::laplacian(phi) == f), f being a vol<type>Field.

I want to solve them sequentially and constructing a loop to reach to converge iteratively. in order to see the convergence, I have one problem, how I can save the previous iteration result and subtract them to see if it meets the convergence tolerance.
do{
solve(equation of C1, with a source term of C2)
solve (equation of C2, with a source term of C1)
error1=C1(n-1)-C1; //n-1 represent previous iteration results
error2=C2(n-1)-C2;//n-1 represent previous iteration results
}while(error1<0.001 && error2<0.001) //0.001 is the convergence tolerance
if you can help me, it means a lot. thanks in forward.
p.s. I have declare the errors as volScalarField and I don't know is it ok, and I have faced errors using declaration of this errors and using relational operators (>=). any suggestion?
mhassani is offline   Reply With Quote

Old   February 28, 2011, 08:56
Default
  #2
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 24
santiagomarquezd will become famous soon enough
Muhammad, error1 and error2 will be fields and comparing them with scalar is inappropriate, I think. May be you can take the average of error1 and errors absolute values in order to have only on scalar, then compare it with your error criterion.

volScalarField C1nminus1=C1;

solve(equation of C1, with a source term of C2)
error1=Foam::average(Foam::mag(C1nminus1-C1)); //n-1 represent previous iteration results

Or something like this.


Regards
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   February 28, 2011, 12:13
Default
  #3
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Why not use the residual as done in simpleFoam? Something like:

Code:
    eqnResidual = solve
    (
        CEqn()
    ).initialResidual();

    maxResidual = max(eqnResidual, maxResidual);
Edit: Thinking about it a bit more this might just give r = Ax - b, which wouldn't really help you.

Last edited by akidess; February 28, 2011 at 12:17. Reason: Probably won't work after all, sorry
akidess is offline   Reply With Quote

Old   February 28, 2011, 12:35
Default
  #4
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 24
santiagomarquezd will become famous soon enough
Yes, I thought in the same thing, but it supposes you're judging convergence based on residuals. Which I can understand at all is the purpose of this loop, Is this a sort of outer loop in order to better couple the solution in each time-step?

Regards.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd 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
[Gmsh] Problem with Gmsh nishant_hull OpenFOAM Meshing & Mesh Conversion 23 August 5, 2015 03:09
What value shall I set for the Convergence criteria? steventay CFX 7 May 14, 2010 13:44
Convergence Criteria edwin FLUENT 1 February 14, 2008 20:24
NACA0012 geometry/design software needed Franny Main CFD Forum 13 July 7, 2007 16:57
convergence of Euler Equations with WENO Shyam Main CFD Forum 0 June 1, 2007 01:47


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