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

Class Diffusion

tests/MMS/spatial/diffusion/diffusion.cxx:8–82  ·  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
19 Coordinates* coords = mesh->getCoordinates();
20
21 meshoptions->get("Lx", Lx, 1.0);
22 meshoptions->get("Ly", Ly, 1.0);
23
24 /*this assumes equidistant grid*/
25 coords->dx = Lx / (mesh->GlobalNx - 2 * mesh->xstart);
26
27 coords->dy = Ly / (mesh->GlobalNy - 2 * mesh->ystart);
28
29 output.write("SIZES: {:d}, {:d}, {:e}\n", mesh->GlobalNy,
30 (mesh->GlobalNy - 2 * mesh->ystart), coords->dy(0, 0, 0));
31
32 SAVE_ONCE2(Lx, Ly);
33
34 Options* cytooptions = Options::getRoot()->getSection("cyto");
35 OPTION(cytooptions, Dx, 1.0);
36 OPTION(cytooptions, Dy, -1.0);
37 OPTION(cytooptions, Dz, -1.0);
38
39 SAVE_ONCE3(Dx, Dy, Dz);
40
41 // set mesh
42 coords->g11 = 1.0;
43 coords->g22 = 1.0;
44 coords->g33 = 1.0;
45 coords->g12 = 0.0;
46 coords->g13 = 0.0;
47 coords->g23 = 0.0;
48
49 coords->g_11 = 1.0;
50 coords->g_22 = 1.0;
51 coords->g_33 = 1.0;
52 coords->g_12 = 0.0;
53 coords->g_13 = 0.0;
54 coords->g_23 = 0.0;
55 coords->geometry();
56
57 // Tell BOUT++ to solve N
58 SOLVE_FOR(N);
59
60 return 0;
61 }
62
63 int rhs(BoutReal UNUSED(t)) override {
64 mesh->communicate(N); // Communicate guard cells
65

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected