This repository replicates the result of the paper (https://doi.org/10.1016/j.jcp.2023.112100).
The code is structured as follows:
- src: Contains the C++ code that implements the methodology. Note that for the time being we only support fields with one input and one output. Support for multiple outputs will be added in the future.
- examples: Contains the C++ code that implements the paper examples, and the Python scripts that make the plots.
- tests: Contains some unit tests. These may not be up to date.
The code for Examples 1-3 is written in C++. The plotting code is written in Python.
The requirements for the C++ code is:
- YAML-CPP for reading YAML configuration
files. If you are on OS X and you are using
homebrew, then you can simply do:
If you are on a different OS, you are on your own. In any case, once you have YAML-CPP installed, you need to edit the makefile to make the variable
brew install yaml-cpp
YAMLCPP
point to the right folder. - GNU Scientific Library. This is only
used in Example 3b to find eigenvalues of a
symmetric matrix. Again, if you are using on OS X and using
homebrew, then you do:
brew install gsl
To compile the C++ code, simply run:
make all
in the first directory of the problem. This command will compile the following executables:
examples/example01
: Example 1 of the paper.examples/example02a
: Example 2.a of the paper.examples/example02b
: Example 2.b of the paper.examples/example03a
: Example 3.a of the paper.examples/example03b
: Example 3.b of the paper.
The requirements for the Python plotting scripts are (ignoring standard libraries):
- matplotlib
- seaborn
- texlive If you are on OS X and using homebrew,
then run
If for some reason you cannot install texlive, you will need to manually edit the Python plotting scripts and comment out the lines:
brew install texlive
plt.rcParams['text.latex.preamble']=[r"\usepackage{lmodern}"] params = {'text.usetex' : True, 'font.size' : 9, 'font.family' : 'lmodern' }
The code for Example 4 is in a Jupyter notebook. The requirements are:
Follow the links to see how you can reproduce the paper results for each eaxmple:
Note: Because the random seed changes every time your run the code, the figures your produce may be slightly different from the ones found in the paper. We dedided not to fix the random seed to avoid a positive results bias, or ``hero'' runs.