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

how to determine and prove the order of our cfd code?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree5Likes
  • 3 Post By Eifoehn4
  • 1 Post By LuckyTran
  • 1 Post By sbaffini

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 20, 2022, 13:18
Default how to determine and prove the order of our cfd code?
  #1
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
Theoretically it's possible to prove that our discretization schemes are 2nd order. But during coding, it's possible to introduce errors that make it 1st order.


If possible, I would like to prove for my codes, that they're indeed as accurate as the theoretical calculations say they should be.


Is there any way to do this?
aerosayan is offline   Reply With Quote

Old   May 20, 2022, 13:24
Default
  #2
Senior Member
 
Eifoehn4's Avatar
 
-
Join Date: Jul 2012
Location: Germany
Posts: 184
Rep Power: 13
Eifoehn4 is on a distinguished road
Do you know the "Method of Manufactured Solutions"?

It is quite standard for code verification.

Regards
__________________
Check out my side project:

A multiphysics discontinuous Galerkin framework: Youtube, Gitlab.
Eifoehn4 is offline   Reply With Quote

Old   May 20, 2022, 13:55
Default
  #3
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,665
Rep Power: 65
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
You test it by brute forcing it across several orders of magnitude and observing (i.e. back-calculating) the order of convergence. Some practical issues arise of course... it's really difficult to mesh one computational domain with mesh cells varying by several orders of magnitude and expecting to get "similar" results each time. That's why you prescribe as much as you can an analytical profile. That is, prescribe a velocity field and then use that to test only the discretization of the field. And that is precisely the basis of the method of manufactured solutions already mentioned.
aerosayan likes this.
LuckyTran is offline   Reply With Quote

Old   May 20, 2022, 14:43
Default
  #4
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,764
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by aerosayan View Post
Theoretically it's possible to prove that our discretization schemes are 2nd order. But during coding, it's possible to introduce errors that make it 1st order.


If possible, I would like to prove for my codes, that they're indeed as accurate as the theoretical calculations say they should be.


Is there any way to do this?



I am not sure about the goal of your question ... Are you interested in checking the accuracy order of single part/subroutines of your code or the final global accuracy?
FMDenaro is offline   Reply With Quote

Old   May 20, 2022, 14:58
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 FMDenaro View Post
I am not sure about the goal of your question ... Are you interested in checking the accuracy order of single part/subroutines of your code or the final global accuracy?

Being able to do both would be appreciated. I will look into Method of Manufactured Solutions, as that was recommended before.
aerosayan is offline   Reply With Quote

Old   May 21, 2022, 08:40
Default
  #6
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,152
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
I would first add that most of the times, a coding error is not going to show up as a different accuracy order but either crash your code or just give plainly wrong results (0th order or divergence). That is, it is typically by chance that, for certain tests, an error just gives a lower order, it is more probable that it in certain other tests the code more simply fails.

For the accuracy tests, the step 0, which is a special case of the method of manufactured solutions, is to just pick up know exact solutions to test the code against. The moms is step 1 and generally requires adding source terms to make an ideally arbitrary function a solution to your problem. However, if your code can handle non constant source terms this really is no different from step 0 (but typically requires you to work out a specific solution take derivatives, etc.)

The way both work is that you know that a certain analytical solution holds for a given set of boundary conditions (and possibly source terms for moms) then you just try to solve the given problem with given bc (and possibly source terms) with your code with different grid and/or time steps. As you know the analytical solution, you can then compute the error (which is a vector for each grid) and show that a given norm of this error reduces with respect to the grid and/or time step following the expected accuracy of the method you are using.

The more pieces of your code the analytical solution will test the more you gain confidence on the correctness of the code. You then typically put together as much of them as necessary by the code features.

This way of proceeding is ideal because you work at the whole code level. Still, sometimes you can't simply do that or it is not efficient. Then, at the cost of introducing specific unit tests, you simply apply the same methodology on smaller parts of your code. For example, if you have a runge kutta integration routine, you might want to test it out of your code with simpler ODEs for which you know the analytical solution.
aerosayan likes this.
sbaffini is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 02:06.