25 #include <boost/property_tree/ptree.hpp>
26 #include <unordered_map>
33 ExchangeCoupler::ExchangeCoupler()
37 void ExchangeCoupler::Initialize(
const ptree& params,
42 m_transfer_chemicals = { params.get<
unsigned int>(
"chemical_from"), params.get<
unsigned int>(
"chemical_to")};
44 for (
const auto& transfer_cells : params.get_child(
"transfer_cells_array")) {
45 const auto from = transfer_cells.second.get<
unsigned int>(
"cell_from");
46 const auto to = transfer_cells.second.get<
unsigned int>(
"cell_to");
47 const auto D = transfer_cells.second.get<
double>(
"diffusion");
48 m_transfer_cells.push_back(make_tuple(from, to, D));
52 void ExchangeCoupler::Exec()
54 assert(m_from.m_mesh->GetNumChemicals() >= m_transfer_chemicals.first + 1
55 &&
"Mesh to transfer chemicals from has too few chemicals");
56 assert(m_to.m_mesh->GetNumChemicals() >= m_transfer_chemicals.second + 1
57 &&
"Mesh to transfer chemicals to has too few chemicals");
59 const auto& from_cells = m_from.m_mesh->GetCells();
60 const auto& to_cells = m_to.m_mesh->GetCells();
61 auto& from_map = *m_from.m_coupled_sim_transfer_data;
62 auto& to_map = *m_to.m_coupled_sim_transfer_data;
64 for (
auto c : m_transfer_cells) {
65 assert((from_cells.size() >= get<0>(c) + 1) &&
"No cell with from index");
66 assert((to_cells.size() >= get<1>(c) + 1) &&
"No cell with to index");
68 const Cell& from_cell = *(from_cells[get<0>(c)]);
69 const Cell& to_cell = *(to_cells[get<1>(c)]);
75 value= ( from_cell.GetChemical(m_transfer_chemicals.first) ) / (from_cell.GetArea());
76 to_map[get<1>(c)] = make_tuple (value, get<2>(c));
79 value= ( to_cell.GetChemical(m_transfer_chemicals.second) ) / (to_cell.
GetArea());
81 from_map[get<0>(c)] = make_tuple (value, get<2>(c));
Core data with mesh, parameters, random engine and time data.
A cell contains walls and nodes.
Interface for ExchangeCoupler.
Namespace for the core simulator.
Sim, the actual simulator.
double GetArea() const
Return the area of the cell.