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

re-evaluate source term during each linear solver iteration

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 27, 2020, 12:35
Default re-evaluate source term during each linear solver iteration
  #1
Senior Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 211
Rep Power: 16
t.teschner is on a distinguished road
I am trying to add a source term to the momentum equation which is depending on the velocity vector, i.e. S(\mathbf{U}). Let's assume I have the momentum equation in the following form (no pressure gradient):

Code:
fvVectorMatrix UEqn
(
    fvm::ddt(U)
  + fvm::div(phi, U)
  - fvm::laplacian(nu, U)
  + turbulence->divDevReff(U)
);
solve(UEqn == - source.evaluate());
Here, source is an object which has access to the velocity vector (specifically a const reference, i.e. it is defined as const volVectorField &U;) and appropriately initialised in the constructor.

I want source.evaluate() to be executed for each iteration in the linear solver, i.e. if I have 5 iterations using a GaussSeidel solver, I want this function to be executed 5 times (and since U is changing during each iteration, the velocity vector dependend sourceterm should change for each iteration as well).

Testing the above, it seems that source.evaluate() is only executed once at the beginning of the iteration but never called for subsequent iterations. It doesn't matter if it is directly included in the UEqn or in the solve() method.

The source term is explicit and does not contribute to the coefficient matrix.

Are there any suggestions how to achieve that?
t.teschner is offline   Reply With Quote

Old   August 30, 2020, 13:02
Default
  #2
Senior Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 211
Rep Power: 16
t.teschner is on a distinguished road
I managed to fix my problem, in case someone stumbles upon this in the future, the trick is to add the contribution of the source (depending on the variable that is being solved for) as an implicit source term (either fvm::Sp() or fvm::SuSp). The book of Moukalled et al. (The finite volume Method in Computational Fluid Dynamics, Chapter 14.1 and 14.5.2) is particularly helpful.
t.teschner is offline   Reply With Quote

Old   August 30, 2020, 14:42
Default
  #3
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 798
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Hmm, are you sure about change the right-hand side vector b while solving the linear system A u = b ?
dlahaye is offline   Reply With Quote

Old   August 30, 2020, 16:37
Default
  #4
Senior Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 211
Rep Power: 16
t.teschner is on a distinguished road
Quote:
Originally Posted by dlahaye View Post
Hmm, are you sure about change the right-hand side vector b while solving the linear system A u = b ?
Yes, as explained in the opening post, the source term is depending on the variable that is being solved for (here the velocity vector U) so it needs to be added implicitly. The contribution will be added to the coefficient matrix A using fvm::Sp(). Actually the full story is a bit more complicated in my case (there are some explicit contributions as well, which are just added to the right hand side vector b) but with this change I got it to work (validated against analytic data)
__________________
cfd.university
t.teschner 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
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 17:02
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 11:59
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 06:18
lid-driven cavity in matlab using BiCGStab Don456 Main CFD Forum 1 January 19, 2012 16:00
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 18:51


All times are GMT -4. The time now is 06:32.