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

Solution of a linear system in a semi-implicit method

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 18, 2016, 10:23
Default Solution of a linear system in a semi-implicit method
  #1
New Member
 
Justin Wiegmann
Join Date: Aug 2015
Posts: 20
Rep Power: 10
SirIsaac90 is on a distinguished road
Hello Foamers!

I have again a problem. I think its easy to solve for you guys, but my code can't be correct.
The implicit Euler method shall be implemented. Therefore, I have to solve a linear system Ax = b.

'b' is in this case the velocity vector of the actual time step 'n'. 'Ax' contains everything with respect the new 'U' of time step n+1 that I want to solve this system for.
This part of my code looks as follows:
Code:
        fvVectorMatrix UEqn
        (
            U - (-runTime.deltaT()*fvm::div(phi, U)+
            runTime.deltaT()*nu * fvm::laplacian(U))
        );

        solve (UEqn == U);
Sorry, but I thought nothing else has to be done. In 'fvSolution' I chose the PBiCG with the DILU preconditioner.

Can you tell me how to solve that system to get the new velocity field 'U'.

Thank you and best regards!
SirIsaac90 is offline   Reply With Quote

Old   January 18, 2016, 12:41
Default
  #2
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Hi,

why you don't want to write your matrix as in standard OpenFOAM solver:
Code:
    fvVectorMatrix UEqn
        (
            fvm::ddt(U)
             + fvm::div(phi, U) -
             fvm::laplacian(nu, U))
        );

        UEqn.solve();
But if you want to implement Euler time scheme as you suggested, you need to insert U at 'n+1' slice as implicit source at lhs:
Code:
    volVectorField Uold = U.oldTime()

        fvVectorMatrix UEqn
        (
            fvm::Sp(geometricOneField(),U)
            ==
            runTime.deltaT()*
            (
               -fvm::div(phi, U)
                +
                nu * fvm::laplacian(U))
            )
            +
            Uold
         );
        
         UEqn.solve();
mkraposhin is offline   Reply With Quote

Old   January 19, 2016, 13:19
Default
  #3
New Member
 
Justin Wiegmann
Join Date: Aug 2015
Posts: 20
Rep Power: 10
SirIsaac90 is on a distinguished road
Thank you very much! That helped me a lot. I want to do this, because of a Benchmark of methods based on the projection method in OpenFOAM.

Instead of 'geometricOneField()' I just wrote '1', because an error occured in the compiling process. But in my opinion, it works fine now.

Now, I want to implement a DIRK method, so I have to compute velocity slopes, let's say 'ki'.

Is it possible to use 'UEqn' to solve the linear system for a volVectorField 'ki' somehow? Or can I only do this always with 'U'? Is there a general method to do that with any volVectorFields without writing a completely new code for that? The 'ki's should be stored in the PtrList<volVectorField> ki

It would be nice to define the method for the linear system in fvSolution, too.

Best regards!
SirIsaac90 is offline   Reply With Quote

Old   January 22, 2016, 10:23
Question
  #4
New Member
 
Justin Wiegmann
Join Date: Aug 2015
Posts: 20
Rep Power: 10
SirIsaac90 is on a distinguished road
Okay, maybe the question is too stupid I am a beginner and it is quite difficult to get the knowledge from other sources..

Maybe someone can help me with this:
('lauf3, lauf4' are just running numbers.., 'k' is a volVectorField,
Uold is derived from volVectorField 'U')
I want to solve the system for k
Code:
        fvVectorMatrix kEqn
        (
                fvm::Sp(1, k)
                ==
                - fvm::div
                (phi, Uold + runTime.deltaT()*A[lauf3][lauf4] * k)
                +
                nu * fvm::laplacian
                (Uold + runTime.deltaT()*A[lauf3][lauf4] * k)
        );
        kEqn.solve()
Can someone tell me where is my mistake? Actually, it should be the same as for 'UEqn' from my first post, but the compiling does not work.. The error has to do something with k.

Thanks and best regards!
SirIsaac90 is offline   Reply With Quote

Old   January 25, 2016, 03:25
Default
  #5
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 18
chriss85 will become famous soon enough
You need to only have the field you want to solve for in the second argument of the fvm:: operators, not others. You can put the other fields in the first argument.
chriss85 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
SU2 cfg file and runtime problems hedley SU2 19 January 26, 2016 04:17
Unsteady simulation solution files in parallel gunnersnroses SU2 1 December 15, 2015 13:28
exact meaning of semi implicit in SIMPLE algorithm venkataramana Main CFD Forum 0 April 14, 2011 21:08
Implicit iterative Gauss-Seidel method dearboy Main CFD Forum 5 November 29, 2010 09:18
Philosophy of implicit solution of different regions Louis Le Grange OpenFOAM 0 October 5, 2009 10:53


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