MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / Diffusion

Class Diffusion

tests/MMS/diffusion2/diffusion.cxx:8–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <math.h>
7
8class Diffusion : public PhysicsModel {
9 Field3D N;
10
11 BoutReal Dx, Dy, Dz;
12 BoutReal Lx, Ly, Lz;
13
14protected:
15 int init(bool UNUSED(restarting)) override {
16 // Get the options
17 Options* meshoptions = Options::getRoot()->getSection("mesh");
18 Coordinates* coords = mesh->getCoordinates();
19
20 meshoptions->get("Lx", Lx, 1.0);
21 meshoptions->get("Ly", Ly, 1.0);
22
23 /*this assumes equidistant grid*/
24 coords->dx = Lx / (mesh->GlobalNx - 2 * mesh->xstart);
25
26 coords->dy = Ly / (mesh->GlobalNy - 2 * mesh->ystart);
27
28 output.write("SIZES: {:d}, {:d}, {:e}\n", mesh->GlobalNy,
29 (mesh->GlobalNy - 2 * mesh->ystart), coords->dy(0, 0, 0));
30
31 SAVE_ONCE2(Lx, Ly);
32
33 Options* cytooptions = Options::getRoot()->getSection("cyto");
34 OPTION(cytooptions, Dx, 1.0);
35 OPTION(cytooptions, Dy, -1.0);
36 OPTION(cytooptions, Dz, -1.0);
37
38 SAVE_ONCE3(Dx, Dy, Dz);
39
40 // set mesh
41 coords->g11 = 1.0;
42 coords->g22 = 1.0;
43 coords->g33 = 1.0;
44 coords->g12 = 0.0;
45 coords->g13 = 0.0;
46 coords->g23 = 0.0;
47
48 coords->g_11 = 1.0;
49 coords->g_22 = 1.0;
50 coords->g_33 = 1.0;
51 coords->g_12 = 0.0;
52 coords->g_13 = 0.0;
53 coords->g_23 = 0.0;
54 coords->geometry();
55
56 // Tell BOUT++ to solve N
57 SOLVE_FOR(N);
58
59 return 0;
60 }
61
62 int rhs(BoutReal UNUSED(t)) override {
63 mesh->communicate(N); // Communicate guard cells
64
65 ddt(N) = 0.0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected