CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Applying AMG to explicit CFD solvers by solving in Ax=b form

Register Blogs Community New Posts Updated Threads Search

Like Tree11Likes
  • 1 Post By LuckyTran
  • 1 Post By arjun
  • 1 Post By sbaffini
  • 1 Post By sbaffini
  • 2 Post By arjun
  • 1 Post By arjun
  • 1 Post By arjun
  • 1 Post By arjun
  • 2 Post By arjun

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 24, 2022, 20:11
Default Applying AMG to explicit CFD solvers by solving in Ax=b form
  #1
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
Hello everyone,

I'm realizing that developing GMG methods for explicit solvers on unstructured grids might be a lot of work. I'm wondering if it's possible to use AMG methods instead.

Converting the equations to a sparse Ax=b form, then applying AMG to solve this, just might be possible.

Since explicit equations are easy to parallelize, I'm wondering if it's possible to do the same to the matrix A i.e domain decompose across all processors, and apply AMG on the matrix's "block" locally on each processor.

Benefit of the method, if possible, would be that it might work for explicit solvers on all kinds of grids. Tri, Quad, Hex, Prism, Tetra, i.e in both 2D and 3D, and we save time on development.
aerosayan is offline   Reply With Quote

Old   August 25, 2022, 00:37
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,747
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
The AMG approach is used in just about every commercial cfd software unless I missed something about why AMG can't be done for your case.
aerosayan likes this.
LuckyTran is offline   Reply With Quote

Old   August 25, 2022, 01:42
Default
  #3
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by aerosayan View Post
Hello everyone,

I'm realizing that developing GMG methods for explicit solvers on unstructured grids might be a lot of work. I'm wondering if it's possible to use AMG methods instead.

Converting the equations to a sparse Ax=b form, then applying AMG to solve this, just might be possible.

Since explicit equations are easy to parallelize, I'm wondering if it's possible to do the same to the matrix A i.e domain decompose across all processors, and apply AMG on the matrix's "block" locally on each processor.

Benefit of the method, if possible, would be that it might work for explicit solvers on all kinds of grids. Tri, Quad, Hex, Prism, Tetra, i.e in both 2D and 3D, and we save time on development.

As it is mentioned AMG methods are pretty much default in all commercial softwares. Writing a good parallel AMG could be time consuming so you can try libs like hypre etc.
aerosayan likes this.
arjun is offline   Reply With Quote

Old   August 25, 2022, 05:07
Default
  #4
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,190
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
If I understand you correctly, you mean something like an algebraic FAS.

This, or a similar question, already popped up here some time ago. I now miss the several reasons against this, but for sure there is one, the highest difficulty in AMG (at least in its common FV implementation as additive correction) is building the matrix in parallel at the coarse levels (the serial version is pretty much trivial). Once you have that, using it explicitly makes no sense.

Which recalls me of another fundamental reason, the fact that the power of AMG is indeed in the implicit realm. In the explicit case FAS is much less effective in accelerating the solution, whose advancement speed is mostly governed by the time step.
aerosayan likes this.
sbaffini is offline   Reply With Quote

Old   August 25, 2022, 07:48
Default
  #5
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
If I understand you correctly, you mean something like an algebraic FAS.

This, or a similar question, already popped up here some time ago. I now miss the several reasons against this, but for sure there is one, the highest difficulty in AMG (at least in its common FV implementation as additive correction) is building the matrix in parallel at the coarse levels (the serial version is pretty much trivial). Once you have that, using it explicitly makes no sense.

Which recalls me of another fundamental reason, the fact that the power of AMG is indeed in the implicit realm. In the explicit case FAS is much less effective in accelerating the solution, whose advancement speed is mostly governed by the time step.
Yeah, true. Implicit is better.

If my code is explicit, it will be far too slow for most people's use.

Luckily, I now have enough brain cells to understand implicit codes and am slowly moving away from explicit ones.
aerosayan is offline   Reply With Quote

Old   August 25, 2022, 07:59
Default
  #6
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,190
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Quote:
Originally Posted by aerosayan View Post
Yeah, true. Implicit is better.

If my code is explicit, it will be far too slow for most people's use.

Luckily, I now have enough brain cells to understand implicit codes and am slowly moving away from explicit ones.
Ok, now that I read again your post, I might have misunderstood, at least partially ,what you meant.

In this case, what Luckytran and Arjun wrote applies, using AMG for linearized systems of equations arising from implicit discretizations is, indeed, the norm in most commercial solvers out there.

As I already wrote, doing it in serial is trivial, at least for the common additive correction multigrid in use in most FV solvers.

The difficult part is the parallel, it has costs at each iteration and there is no definitive guide out there on how to implement it, nor the matter is such that some specific way would appear obvious from the context. There are some papers out there, from Maximillian Emans, former AVL developer, that give some context and clue. Some others from the Moukalled
and Darwish group, but that's it. Most of the remaining stuff is focused on more complex AMG flavors, mostly for math oriented people (who like a lot to complicate stuff).

Note, however, that the system solver is not a difficult part, in general, for the implicit approach. A LU-SGS is just a couple of loops on the cells, where you update the system unknowns. Most Krylov methods add some matrix-vector products, which again are the same kind of loop. AMG is the kind of the exception here, because you need to update the matrix at each level in parallel. For tall the others, you just need a sparse-matrix data structure and you're done, the parallel exchange is not different fromother variables. The difficult part is the book-keeping one, which sign does this element have, which matrix element does this term goes, etc.

Explicit has his use cases, but that is in the unsteady realm with no doubt.
aerosayan likes this.
sbaffini is offline   Reply With Quote

Old   August 25, 2022, 16:40
Default
  #7
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Why not just use BiCGStab or GMRES etc. They are not tough to write and in compressible solver the linear system is easier to solve compared to incompressible case (hyperbolic vs elliptic system).
sbaffini and aerosayan like this.
arjun is offline   Reply With Quote

Old   August 25, 2022, 16:54
Default
  #8
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
Quote:
Originally Posted by arjun View Post
Why not just use BiCGStab or GMRES etc. They are not tough to write and in compressible solver the linear system is easier to solve compared to incompressible case (hyperbolic vs elliptic system).
Thanks Arjun! I will most likely use LU-SGS or BiCGStab or GMRES. Which one is the easiest?
aerosayan is offline   Reply With Quote

Old   August 25, 2022, 16:56
Default
  #9
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by aerosayan View Post
Thanks Arjun! I will most likely use LU-SGS or BiCGStab or GMRES. Which one is the easiest?


Try BiCGStab even though the LU-SGS will be faster but BiCG will be more robust. If you want parallel consistency then use polynomial methods are preconditioner for BiCGStab.
aerosayan likes this.
arjun is offline   Reply With Quote

Old   August 26, 2022, 17:56
Default
  #10
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
Quote:
Originally Posted by arjun View Post
Try BiCGStab even though the LU-SGS will be faster but BiCG will be more robust. If you want parallel consistency then use polynomial methods are preconditioner for BiCGStab.

BiCGStab seems to be the combination of BiCG, and GMRES. Su2 uses FGMRES by default. I think it might be easier for me to implement and use FGMRES first, then move on to BiCGStab.
aerosayan is offline   Reply With Quote

Old   August 27, 2022, 01:58
Default
  #11
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by aerosayan View Post
BiCGStab seems to be the combination of BiCG, and GMRES. Su2 uses FGMRES by default. I think it might be easier for me to implement and use FGMRES first, then move on to BiCGStab.
I believe the F in FGMRES here stands for Flex and it stands for Flexible preconditioners in same GMRES. This I believe could be more efficient but not neccessarily easier to implement compared to BiCGStab.


However please check out PyAMG library. There you can learn how to implement BiCGStab or GMRES or even FGMRES if I remember correctly . They are at github too.
aerosayan likes this.
arjun is offline   Reply With Quote

Old   August 27, 2022, 04:36
Default
  #12
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
Quote:
Originally Posted by arjun View Post
I believe the F in FGMRES here stands for Flex and it stands for Flexible preconditioners in same GMRES. This I believe could be more efficient but not neccessarily easier to implement compared to BiCGStab.


However please check out PyAMG library. There you can learn how to implement BiCGStab or GMRES or even FGMRES if I remember correctly . They are at github too.
Oh okay thanks. GMRES looked easy, and if FGMRES is more difficult, I'll see GMRES first. I want to use BiCGStab, but have reliable but slow fallback code too. GMRES seemed like the best option since it's required in BiCGStab, and I'll have to understand and develop it anyway.
aerosayan is offline   Reply With Quote

Old   August 27, 2022, 04:37
Default
  #13
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by aerosayan View Post
Oh okay thanks. GMRES looked easy, and if FGMRES is more difficult, I'll see GMRES first. I want to use BiCGStab, but have reliable but slow fallback code too. GMRES seemed like the best option since it's required in BiCGStab, and I'll have to understand and develop it anyway.


Thats why suggested PyAMG. You can see the python code for them and it makes it easier to learn.
aerosayan likes this.
arjun is offline   Reply With Quote

Old   October 20, 2023, 03:57
Smile
  #14
New Member
 
Join Date: Oct 2023
Location: CN
Posts: 6
Rep Power: 3
luckyXing is on a distinguished road
Quote:
Originally Posted by arjun View Post
Thats why suggested PyAMG. You can see the python code for them and it makes it easier to learn.
I have a qustion, is the GMERS,LU-SGS,BiCG methods used as smoother in AMG? as i know, AMG has Pre-smoothing, Coarse-grid correction and Post-smoothing; all the methods before used as Coarse-grid correction?
luckyXing is offline   Reply With Quote

Old   October 20, 2023, 09:40
Default
  #15
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by luckyXing View Post
I have a qustion, is the GMERS,LU-SGS,BiCG methods used as smoother in AMG? as i know, AMG has Pre-smoothing, Coarse-grid correction and Post-smoothing; all the methods before used as Coarse-grid correction?
even though the post is bot generated. I think (need to double check) only CFX has AMG that uses BiCG as smoother.
arjun is offline   Reply With Quote

Old   October 21, 2023, 03:30
Default
  #16
New Member
 
Join Date: Oct 2023
Location: CN
Posts: 6
Rep Power: 3
luckyXing is on a distinguished road
Quote:
Originally Posted by arjun View Post
even though the post is bot generated. I think (need to double check) only CFX has AMG that uses BiCG as smoother.
Yeah, but in fluent, there are G-S/ILU used as smoother, so the BiCGSTAB/RPM/GMERS which can choose at Stabilization Method means iteration for Coarse-grid?
luckyXing is offline   Reply With Quote

Old   October 21, 2023, 05:18
Default
  #17
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by luckyXing View Post
Yeah, but in fluent, there are G-S/ILU used as smoother, so the BiCGSTAB/RPM/GMERS which can choose at Stabilization Method means iteration for Coarse-grid?

?????????

I mean what??????
arjun is offline   Reply With Quote

Old   October 21, 2023, 05:37
Default
  #18
New Member
 
Join Date: Oct 2023
Location: CN
Posts: 6
Rep Power: 3
luckyXing is on a distinguished road
Quote:
Originally Posted by arjun View Post
?????????

I mean what??????
sorry, maybe i didn't get you, i wonder just like in the Fluent, i can use G-S/ILU as pre/post-smoothing, but what is the iterarion method for coarse-mesh? direct iteration or use these methods 'GMERS'/'BiCGSTAB'; I just learn AMG method recently and i confused is the 'GMERS'/'BiCGSTAB' methods used as iteration in solve Coarse-grid or AMG is a preconditioner before we use the'GMERS'.

anyway, thank you for your response.
luckyXing is offline   Reply With Quote

Old   October 21, 2023, 10:22
Default
  #19
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by luckyXing View Post
sorry, maybe i didn't get you, i wonder just like in the Fluent, i can use G-S/ILU as pre/post-smoothing, but what is the iterarion method for coarse-mesh? direct iteration or use these methods 'GMERS'/'BiCGSTAB'; I just learn AMG method recently and i confused is the 'GMERS'/'BiCGSTAB' methods used as iteration in solve Coarse-grid or AMG is a preconditioner before we use the'GMERS'.

anyway, thank you for your response.

Yes you can use G-S and ILU as smoother. These are the most popular options.

AMG can be used as stand alone linear system solver.

AMG can also be used as precoditioner to GMRES, BiCongujate etc solvers.


Rarely BiConjugate and GMRES are used as smoothers because they are expensive or they take more time.
aerosayan and luckyXing like this.
arjun 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
chtMultiRegionSimpleFoam: maximum number of iterations excedeed. Nkl OpenFOAM Running, Solving & CFD 19 October 10, 2019 03:42
Suppress twoPhaseEulerFoam energy AlmostSurelyRob OpenFOAM Running, Solving & CFD 33 September 25, 2018 18:45
HeatSource BC to the whole region in chtMultiRegionHeater xsa OpenFOAM Running, Solving & CFD 3 November 7, 2016 06:07
Compressor Simulation using rhoPimpleDyMFoam Jetfire OpenFOAM Running, Solving & CFD 107 December 9, 2014 14:38
calculation stops after few time steps sivakumar OpenFOAM Running, Solving & CFD 7 March 17, 2013 07:37


All times are GMT -4. The time now is 03:51.