Langevin C++ source

Loading...
Searching...
No Matches
langevin_construct_grid1d.cpp
Go to the documentation of this file.
1
5
6#include "langevin_types.hpp"
7#include "langevin_base.hpp"
8
10 bool BaseLangevin::construct_1D_grid(const Parameters p)
11{
12 const auto n_x = p.n_x;
13 grid_wiring = grid_wiring_t(n_x, neighborhood_t(2));
14
15 // Everywhere except the grid ends
16 for (auto i=1; i<n_x-1; i++)
17 {
18 // Each cell has a L and R neighbor whose indexes are specified here
19 grid_wiring[i][0] = i-1;
20 grid_wiring[i][1] = i+1;
21 }
22
23 // Grid ends
24 switch (p.grid_topologies.at(0))
25 {
26 case GridTopology::PERIODIC:
27 // Each end cell neighbor is the other end cell, so wrap the indexes
28 grid_wiring[0][0] = n_x-1; // left-end left
29 grid_wiring[0][1] = 1; // left-end right
30 grid_wiring[n_x-1][0] = n_x-2; // right-end left VMB: [n_x-1][0] = n_x-2;
31 grid_wiring[n_x-1][1] = 0; // right-end right
32 return true;
33
34 case GridTopology::BOUNDED:
35 // Link each end cell to its adjacent cell only
36 grid_wiring[0] = neighborhood_t(1, 1);
37 grid_wiring[n_x-1] = neighborhood_t(1, n_x-2);
38 return true;
39
40 default:
41 return false;
42 }
43}
BaseLangevin::grid_wiring
grid_wiring_t grid_wiring
Neighorhood topology for all grid cells.
Definition langevin_base.hpp:23
BaseLangevin::construct_1D_grid
bool construct_1D_grid(const Parameters parameters)
Build 1d Langevin density field grid & topology.
Definition langevin_construct_grid1d.cpp:10
langevin_base.hpp
Base class for Langevin equation integrator.
langevin_types.hpp
Type definitions for BaseLangevin integrator.
neighborhood_t
std::vector< int > neighborhood_t
Type for density grid wiring.
Definition langevin_types.hpp:28
grid_wiring_t
std::vector< neighborhood_t > grid_wiring_t
Type for grid-cell neighborhood connections.
Definition langevin_types.hpp:30
Parameters
Container for BaseLangevin integrator parameters.
Definition langevin_parameters.hpp:21