CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to carry out multiple solving iterations within one time step (https://www.cfd-online.com/Forums/openfoam-programming-development/227686-how-carry-out-multiple-solving-iterations-within-one-time-step.html)

ywem June 6, 2020 09:47

How to carry out multiple solving iterations within one time step
 
Dear Foamers,
I am trying to solve two coupled equations with OpenFOAM. The solutions converge very slowly and I have to make several iterations within one time step. I have used piso corrections in the runTime loop and solving the two equations sequentially in each correction loop. But it seems that the solution of the current correction iteration does not read solutions of the former iteration.
Does anyone has ideas about this problem or any instructions about the solving of coupled equations using OpenFOAM? Thanks in advance.

wangsen992 June 6, 2020 20:27

Dear Wenming,

Quote:

the solution of the current correction iteration does not read solutions of the former iteration
This is probably due to your settings on the IOobject set on your variables. Also please note, the objectRegistry only writes those variables marked with AUTO_WRITE if the current time step is over. So if you are doing iteration within the time step, using the time control loop won't work.

Could you upload your solver (including the createFields.H file). For piso corrections (i haven't looked into the internals), but i suspect it explicitly works with p, U and phi (for optimization), most likely a tmp<type> object is used for storing intermediate geometricField data, or use the prevIter() method from the geometricField.

So in summary it looks like a storage/IO issue, so a test case could be helpful. If not solving fluid motion, i don't recommend using pisoControl directly (a personal preference).

Cheers,
Sen

ywem June 7, 2020 04:54

Dear Sen,
Thank you for your reply.
Yes, you are right. The settings for IOobject such as
volVectorField M
(
IOobject
(
"M",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
dose not work for the iteration within time steps.

Following your advice, I tried to store the intermediate field data by adding a sentence like
M.storePrevIter();
but it does not work either.

I also tried to change the piso correction to the PIMPLE outer correction for the iteration within one time loop. The results were not changed. The problem is also that the previous results of the inner iteration was not read by the current interation.

superkelle June 7, 2020 06:09

won't a simple "for" or "while" loop in your runtime loop work?


Code:




while (runTime.loop())
{   

    runTime++;

   
    for (int i=0; i<nTotalCycles; ++i)
    {
        #include "Eqn1.H"
        #include "Eqn2.H"
    }
    runTime.write();

}

or

Code:

while (runTime.loop())
{   

    runTime++;

    while ( ! convCrit)
    {
        #include "Eqn1.H"       

        #include "Eqn2.H"
        #include "convergenceCriterium.H"


    }
    runTime.write();

}


ywem June 7, 2020 07:35

Dear Alexander,
Thank you for your suggestions. I tried that but it dose not work either. The problem is that the solving of Eqn2 does not read the results of Eqn1 in your reply within one time step.

wangsen992 June 7, 2020 20:08

Hi Wenming,

i am confused about why your Eqn2 is not reading your Eqn1's results. After computation of Eqn1, M should be the updated result which can be directly accessed in Eqn2. Maybe you can check if your scope is set correctly? So for your Eqn1.H, you should not have a set of curly brackets {} surrounding all your code. You can have curly brackets for Eqn2 though.

Sorry since I can't see your code, I can only guess at the possible errors that could happen.

Hope this helps.
Sen

ywem June 9, 2020 03:13

Dear Sen,

Thanks a lot for your suggestions. I checked and found that the curly brackets do not influence the results.

Maybe you are right. Eqn2 should read the results of Eqn1 automatically although its results have not been written out . My problem may come from the fact that

I am solving a steady problem using a transient solver but the convergence of the steady problem is time dependent. So although the Eqn2 and Eqn1 are solved and converged by several innter iterations, the whole problem is not converged because the time dose not evolve.

I have started another thread to talk about this problem.

superkelle June 9, 2020 03:17

Quote:

Originally Posted by ywem (Post 773855)
I have started another thread to talk about this problem.


maybe you post the link here for anyone who has similar issues

ywem June 9, 2020 03:46

Dear Sen,
Please follow the link below

https://www.cfd-online.com/Forums/op...tml#post773860


All times are GMT -4. The time now is 13:43.