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

Solving eqation and poor convergence problem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 19, 2017, 14:09
Default Solving eqation and poor convergence problem
  #1
Member
 
behzad Ghasemi
Join Date: Sep 2013
Location: Iran
Posts: 56
Rep Power: 12
behzad-cfd is on a distinguished road
Hi dear foamers,

I want to solve magnetic potential equation.
\nabla\cdot(\mu\nabla \phi)=0
I defined this equation like this:
Code:
fvScalarMatrix ksiEqn
(
    fvm::laplacian(interfacePsi.muM() ,ksi)
);
ksiEqn.solve();
Boundary conditions for achieving the uniform vertical magnetic field is:
Code:
inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            zeroGradient;
    }

    up
    {
        type            fixedGradient;
        gradient       uniform -1234;
    }

    down
    {
        type            fixedGradient;
        gradient       uniform 1234;
    }

    frontAndBack
    {
        type            empty;
    }
fvSolution dictionary for ksi equation is:
Code:
ksi
    {
        solver           smoothSolver;
        smoother      DICGaussSeidel; //DIC-FDIC-GAMG-diagonal-none
        tolerance      1e-6;
        relTol            0;
    }
When i choose any solver except selected one (smoothSolver) after some time steps courant number rises dramatically and solver diverges. also with mentioned fvSolution setup, solving process is very slow and ksi equtaion iterates 1000 times in every time step!
The log file is attached.
Any suggestion is appreciated.

Thanks in advance,
Behzad
Attached Files
File Type: txt log.txt (153.3 KB, 3 views)
behzad-cfd is offline   Reply With Quote

Old   December 20, 2017, 03:43
Default Solved
  #2
Member
 
behzad Ghasemi
Join Date: Sep 2013
Location: Iran
Posts: 56
Rep Power: 12
behzad-cfd is on a distinguished road
Hi,

I solved this problem by adding equation in a simple loop. If there is a better solution I'm very glad to know.

Regards,

Behzad
behzad-cfd is offline   Reply With Quote

Old   December 22, 2017, 12:25
Default
  #3
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
What kind of loop did you add? Could you please post the peace of code which solved your problem.
Zeppo is offline   Reply With Quote

Old   December 22, 2017, 15:09
Default
  #4
Member
 
behzad Ghasemi
Join Date: Sep 2013
Location: Iran
Posts: 56
Rep Power: 12
behzad-cfd is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
What kind of loop did you add? Could you please post the peace of code which solved your problem.
Hi Sergei,

1- In your solver *.C file include "simpleControl.H".
2- Then create an object from simpleControl class like this:
Code:
simpleControl simple(mesh);
3- Put your equation in simple loop:
Code:
while (simple.correctNonOrthogonal())
{
        yourEqn.solve();
}
Don't forget to add simple control parameters in fvSolution.
Code:
SIMPLE
{
    nNonOrthogonalCorrectors 1; //or whatever number of correctors you set
}
I hope this could be helpful.
behzad-cfd is offline   Reply With Quote

Old   January 6, 2018, 15:39
Default
  #5
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
You are right. There should be 2 loops. The outer one to advance over time and the inner one to deal with mesh nonorthogonality which strongly affects laplacian discretisation. For the nonorthogolal correction loop to work don't forget to specify in fvSchemes dictionary:
Code:
gradSchemes 
{ 
    default         Gauss linear; 
} 
laplacianSchemes 
{ 
    default         Gauss linear corrected; 
}
Zeppo is offline   Reply With Quote

Old   January 6, 2018, 15:56
Default
  #6
Member
 
behzad Ghasemi
Join Date: Sep 2013
Location: Iran
Posts: 56
Rep Power: 12
behzad-cfd is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
You are right. There should be 2 loops. The outer one to advance over time and the inner one to deal with mesh nonorthogonality which strongly affects laplacian discretisation. For the nonorthogolal correction loop to work don't forget to specify in fvSchemes dictionary:
Code:
gradSchemes 
{ 
    default         Gauss linear; 
} 
laplacianSchemes 
{ 
    default         Gauss linear corrected; 
}
Thanks for confirming. And yes I've set the laplacianSchemes as Gauss linear corrected.
Rgards,
Behzad
behzad-cfd 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



All times are GMT -4. The time now is 12:36.