Unit tests
I would be curious to see a PR that attempts to create a unit test for a basic MFC subroutine/feature. Some Fortran packages attempt to automate this process:
- https://fortranwiki.org/fortran/show/Unit+testing+frameworks
- https://www.software.ac.uk/blog/2016-09-28-look-fortran-unit-test-frameworks
However I think the easiest solution might be to just write some driver functions/programs that can then call certain subroutines. Some similar arguments are made around the internet, like here:
https://stackoverflow.com/questions/32434904/basic-unit-testing-for-fortran-in-a-locked-down-environment
and
https://groups.google.com/g/comp.lang.fortran/c/CwJdQm1E_iQ
I'm not entirely sure, though, and maybe some package would do the trick.
relevant: https://github.com/trixi-framework/HOHQMesh
Looking at some of these existing tools and knowing how MFC 'works,' I think using an existing package will be challenging. They often have compiler limitations, introduce a more modern Fortran standard, don't support GPU offload, etc.
It seems like the 'best' solution might be to roll our own. We would need some sort of 'constructor' that creates a data field of the appropriate size. This would take the place of the input data, say the conservative variable fields. Then, these can be inputs to various tests. Many of our subroutines take such fields as inputs (rightfully so, in my view), so it seems these need to be generated a priori.
This would be easier - and not require a constructor - if we used more elemental or pure functions, but I find these to be rather slow on GPU when they are being called so many times per time step.
Going to try something here https://github.com/sbryngelson/MFC/tree/unit
Starting working on something along these lines. Was curious what other folks are using for unit tests for finite volume schemes. Did not find many examples (at least open source ones). But did find these:
- https://github.com/thenumbernine/hydro-cl-lua/tree/master/tests
- https://gitlab.lrz.de/nanoshock/ALPACA/
Overall, not too many unit tests seem obvious here. Some examples I noticed or made up myself are:
- uniform field gives zero derivatives
- zero RHS if no source terms and uniform IC
- making sure equation of state is doing the right thing (giving an expected result)
- [wip]
I sort of ran out of ideas for good unit tests for a CFD solver, especially since MFC wasn't built via TDD. Open to suggestions.
No suggestion for this. Closing for now due to inactivity.