# do_while loop for coupling two equations (convergence criteria?)

 Register Blogs Members List Search Today's Posts Mark Forums Read

 February 26, 2011, 12:32 do_while loop for coupling two equations (convergence criteria?) #1 New Member   Muhammad reza hassani Join Date: Apr 2010 Posts: 29 Rep Power: 8 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 volField. 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?

 February 28, 2011, 08:56 #2 Senior Member     Santiago Marquez Damian Join Date: Aug 2009 Location: Santa Fe, Santa Fe, Argentina Posts: 430 Rep Power: 16 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

 February 28, 2011, 12:13 #3 Senior Member     Anton Kidess Join Date: May 2009 Location: Delft, Netherlands Posts: 1,153 Rep Power: 20 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

 February 28, 2011, 12:35 #4 Senior Member     Santiago Marquez Damian Join Date: Aug 2009 Location: Santa Fe, Santa Fe, Argentina Posts: 430 Rep Power: 16 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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post nishant_hull Open Source Meshers: Gmsh, Netgen, CGNS, ... 23 August 5, 2015 02:09 steventay CFX 7 May 14, 2010 12:44 edwin FLUENT 1 February 14, 2008 20:24 Franny Main CFD Forum 13 July 7, 2007 15:57 Shyam Main CFD Forum 0 June 1, 2007 00:47

All times are GMT -4. The time now is 20:49.