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

Interface between OF and external linear solvers

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By klausb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 29, 2019, 12:11
Default Interface between OF and external linear solvers
  #1
New Member
 
Davide Cortellessa
Join Date: Jul 2019
Posts: 4
Rep Power: 7
davide.c is on a distinguished road
Dear Foamers,

Currently I知 trying to code an OpenFOAM face-centered finite volume solver. Within this code I知 assembling a big sparse matrix, using the lduMatrix class.

Now, I知 at the point in which I would like to link my code to an external linear solver, since the lduMatrix solvers are not very suitable for my problem.

The ideal library to use would be Mumps, but others like Petsc, Hypre, Pardiso, etc could be fine as well.

I tried to look for an existing interface between OF and one of these libraries, but I couldn稚 find anything. Could you point me in the right direction?

Or this simply does not exist and I need to code one myself?

Thank you very much for your time!

Davide
davide.c is offline   Reply With Quote

Old   November 6, 2019, 02:34
Default
  #2
New Member
 
zizhou huang
Join Date: Jul 2019
Posts: 18
Rep Power: 7
zizhou is on a distinguished road
Hi Davide,

I'm also looking for ways using external linear solvers to substitute the ones in OpenFOAM. I replaced part of codes in PBiCG.C, and I was able to solve equations with Eigen library. I exported the matrix, source, and solution to matlab, and I'm sure the linear solver worked successfully. However, the final result of icoFoam is totally wrong. Are you able to replace the solver now? Thank you!
Attached Files
File Type: c PBiCG.C (7.4 KB, 14 views)

Last edited by zizhou; November 8, 2019 at 00:30.
zizhou is offline   Reply With Quote

Old   November 12, 2019, 07:13
Default
  #3
New Member
 
Davide Cortellessa
Join Date: Jul 2019
Posts: 4
Rep Power: 7
davide.c is on a distinguished road
Hi Zizhou,

Still no unfortunately.

The only thing that I was able to do is to export source, values and addressing to Matlab using OFstream, assemble a Matlab sparse matrix and solve the linear system with backslash.
Of course this is a very "ugly" solution, that I did only to run some tests.

I kept looking but I still wasn't able to find an already existing interface / way of using an external linear solver.

I guess that now I will select, with my PhD supervisors, a suitable library and I will code an interface to that. But I immagine it will take some time.
davide.c is offline   Reply With Quote

Old   November 12, 2019, 22:43
Default
  #4
New Member
 
zizhou huang
Join Date: Jul 2019
Posts: 18
Rep Power: 7
zizhou is on a distinguished road
Hi Davide,

I noticed that openfoam stores the coeffcients from transport equation (in upper, diag, lower), but boundary conditions are not inside. The only way to get the actual matrix is by a function called 'Amul(...)'.

So I can use O(n*n) time to get the actual sparse matrix and solve it with external library. The only problem is that it doubles the time.

I'm wondering if you have any good idea to get the matrix?
zizhou is offline   Reply With Quote

Old   November 13, 2019, 05:41
Default
  #5
New Member
 
Davide Cortellessa
Join Date: Jul 2019
Posts: 4
Rep Power: 7
davide.c is on a distinguished road
Hi Zizhou,

I'm sorry but this is not something I looked much into.

In my application I'm building my own lduMatrix, so boundary contributions are already inside the matrix coeffcients and/or the source term.

Therefore, I am actually caring only for upper lower and diag...

Anyway this "function" that exports a lduMatrix to a different sparse matrix format, compatible with external solver, was precisely that interface I was looking for and I couldn't find.
davide.c is offline   Reply With Quote

Old   March 6, 2020, 15:02
Default
  #6
Senior Member
 
Klaus
Join Date: Mar 2009
Posts: 281
Rep Power: 22
klausb will become famous soon enough
This might help: https://github.com/fppimenta/rheoTool


Maybe you can even use MUMPS through Petsc's interface.


But don't expect miracles!


Klaus
davide.c and KKlee like this.
klausb is offline   Reply With Quote

Reply

Tags
external solver, interface, ldumatrix, linear solvers, mumps


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 18:18.