https://github.com/bendudson/pybout
Code generator for BOUT++
https://github.com/bendudson/pybout
Last synced: about 1 month ago
JSON representation
Code generator for BOUT++
- Host: GitHub
- URL: https://github.com/bendudson/pybout
- Owner: bendudson
- Created: 2020-05-05T14:15:40.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-05T14:16:09.000Z (about 6 years ago)
- Last Synced: 2025-02-27T18:31:08.514Z (over 1 year ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* PyBOUT
Code generator for [[https://github.com/boutproject/BOUT-dev/][BOUT++]] in python. Example:
#+BEGIN_SRC python :results output
import pybout
f = pybout.Field("f")
g = pybout.Field("g")
f.ddt = g
g.ddt = -f
model = pybout.PhysicsModel(f, g)
print(str(model)) # Generates C++ code
#+END_SRC
#+RESULTS:
#+begin_example c++
#include "bout/physicsmodel.hxx"
class Model : public PhysicsModel {
private:
// Evolving fields
Field3D f;
Field3D g;
protected:
int init(bool restarting) override {
// Evolving quantities
SOLVE_FOR(f);
SOLVE_FOR(g);
return 0;
}
int rhs(BoutReal time) override {
ddt(f) = g;
ddt(g) = f;
return 0;
}
};
BOUTMAIN(Model);
#+end_example