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

What's your philosophy on using third-party numerical libraries?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By naffrancois
  • 1 Post By sbaffini

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 24, 2022, 11:17
Default What's your philosophy on using third-party numerical libraries?
  #1
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
Many developers seem to accept using third-party libraries like BLAS, LAPACK, METIS, ParMETIS, Eigen 3 (C++ vector algebra library) etc. It makes sense for some teams, because it helps them reduce development time and cost.

I understand there's possibly no right or wrong answer, as every dev's requirement and philosophy will be different. What's your take on the issue?

Have you observed better results, by writing your own code? I remember once paolo said that one of his procedures was performing and scaling better than a commercial CFD code. Have you experienced such improvements in your own code?

edit : removed rant about intel mkl
aerosayan is offline   Reply With Quote

Old   May 24, 2022, 12:33
Default
  #2
Senior Member
 
Join Date: Oct 2011
Posts: 239
Rep Power: 16
naffrancois is on a distinguished road
It is always good whenever you can to develop your own routines, reinvent the wheel at first and eventually maybe do better. This may be good on the long run and helps you understand deeper what is behind a package.

But time is the ennemy and you usually need to prioritize things. I'd like to write my own thermo-chemical solver to fit my equations of state and not rely on one I don't control all the details. Same happens with linear solver, efficient parallel I/O, efficient domain decomposition load-balancing, dynamic meshing etc etc. But in the end, my client need my model to match some experimental results on a difficult flow configuration. Whether the code is fast or slow comes always second. Then I focus my work on the model.
aerosayan likes this.
naffrancois is offline   Reply With Quote

Old   May 26, 2022, 12:39
Default
  #3
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
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
Many developers seem to accept using third-party libraries like BLAS, LAPACK, METIS, ParMETIS, Eigen 3 (C++ vector algebra library) etc. It makes sense for some teams, because it helps them reduce development time and cost.

I understand there's possibly no right or wrong answer, as every dev's requirement and philosophy will be different. What's your take on the issue?

Have you observed better results, by writing your own code? I remember once paolo said that one of his procedures was performing and scaling better than a commercial CFD code. Have you experienced such improvements in your own code?

edit : removed rant about intel mkl
Assuming paolo is me, I don't remember the exact circumstances leading to that statement, so let me digress to clarify my point of view.

In general, I don't think there is anything wrong in using a library, especially if you're not on par with the required complexity, robustness, speed, etc. This might be in relation with the developer actual capability and understanding of the matter or just in relation to the required time to reach certain goals.

I also think that in academic settings (or similar ones) this pretty much sounds always as the right thing to do, considering the typical limited scope of the program as a whole. For example, if I want to test my new convective scheme, it totally makes sense that I just try it in OpenFOAM, not that I develop a full CFD code from scratch just to test the scheme.

Also, I claim that any scripted language is, in fact, just that, using someone else library for anything, limiting yourself to the glue code.

But, if we look at the business side of the thing, I think there are several cases where developing your own solution is the best or the only actual option in the end. From one side, I think that if your core business depends on a certain code, you must both know enough of that to be able to implement it in full autonomy and also need to in order to have control on your product.

Let's take the linear algebra case, to stay close to your example. Am I able to develop a similarly equipped algebraic solver for my code as, say, PETSc? Hell no, and I will probably never be, that's why I use PETSc in my code, but I still have a backup internal LU-SGS solution in case people at PETSc, say, simply change their licence or get mad or whatever. I only have two parts of my code that have no backup solution, xml file processing and the SVD from lapack. In both cases, the standard I required for their implementation was clearly out of my league. I will probably try to have backup solution for them in time, but it's not a priority now. This, I think, pretty much clarify what I think about using a library in general.

Let's get now to the point. There is no guarantee that any piece of software, just because the author felt confident enought to put it in an open source library, is actually well tought or even reasonable. It might or not. For me, whoever wrote and/or maintains Lapack is better than me at the SVD, so I don't need to investigate further. But there are things for which I couldn't find a decent implementation and I decided to go on my own.

Sometimes, even if you can't do better, you might just need a very limited subset of a feature that using a full library might be an overkill or just kill performances because the library does too little in the end (besides making maintainability more complex). Do I need a library to sort and search, numerically integrate, find a root? Not me, I can delve deep enough in my problems to be able to come up with a solution that, in the end, is always the better for me. Let me highlight it again, better for me. And I always quantify this before making any decision. That's how I typically build unit tests, investigating the options out there.

If you want, in the end, it is (or should be) always like that: you need something, you see what you got and test it, you take the better one. Sometimes it is clear that you are going to write something better and, simply enough, you do it. So, there is really not a recipe, just common sense.
aerosayan likes this.

Last edited by sbaffini; May 26, 2022 at 13:44.
sbaffini 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] difficulties installing swak4foam newbie29 OpenFOAM Community Contributions 120 October 21, 2022 04:01
compiling libraries - LIBBIN and USER_LIBBIN grjmell OpenFOAM Programming & Development 4 June 17, 2022 22:06
How to Install Numerical Wave and Pressure Gauges in the Numerical Wave Tank? mushtak Main CFD Forum 0 November 2, 2020 02:34
[PyFoam] path problems for shared libraries after Qt update klausb OpenFOAM Community Contributions 0 May 20, 2016 07:39
New Books and Numerical Software Eleuterio TORO Main CFD Forum 0 December 18, 1998 12:41


All times are GMT -4. The time now is 21:29.