ConditionExtensiveUpdater.cpp
1 #include "ConditionExtensiveUpdater.hpp"
2 #include "../../misc/utils.hpp"
3 #include <iostream>
4 namespace
5 {
6  bool bracketed(int low, int arg, int high)
7  {
8  return arg >= low && high>arg;
9  }
10 }
11 
12 ConditionExtensiveUpdater::Condition::~Condition() {}
13 
14 ConditionExtensiveUpdater::Action::~Action() {}
15 
16 ConditionExtensiveUpdater::~ConditionExtensiveUpdater() {}
17 
18 ConditionExtensiveUpdater::ConditionExtensiveUpdater(const vector<pair<const Condition*, const Action*> >& sequence) :
19  sequence_(sequence) {}
20 
21 void ConditionExtensiveUpdater::operator()(const vector<Extensive>& fluxes,
22  const PhysicalGeometry& pg,
23  const Tessellation& tess,
24  const double dt,
25  const CacheData& cd,
26  const vector<ComputationalCell>& cells,
27  vector<Extensive>& extensives,
28  double time,
29  TracerStickerNames const& tracerstickernames) const
30 {
31  const vector<Edge>& edge_list = tess.getAllEdges();
32  Extensive delta(extensives[0]);
33  for (size_t i = 0; i<edge_list.size(); ++i)
34  {
35  const Edge& edge = edge_list[i];
36  ReplaceExtensive(delta, fluxes[i]);
37  delta *= dt*cd.areas[i];
38  if (bracketed(0, edge.neighbors.first, tess.GetPointNo()))
39  extensives[static_cast<size_t>(edge.neighbors.first)] -= delta;
40  if (bracketed(0, edge.neighbors.second, tess.GetPointNo()))
41  extensives[static_cast<size_t>(edge.neighbors.second)] += delta;
42  }
43  size_t n = static_cast<size_t>(tess.GetPointNo());
44  for (size_t i = 0; i < n; ++i)
45  {
46  for (size_t j = 0; j < sequence_.size(); ++j)
47  {
48  if (sequence_[j].first->operator()(i, tess, cells, time, tracerstickernames))
49  {
50  sequence_[j].second->operator()(fluxes, pg, tess, dt, cd, cells, extensives[i], i, time, tracerstickernames);
51  break;
52  }
53  }
54  }
55 }
56 
57 
Extensive variables.
Definition: extensive.hpp:18
Abstract class for tessellation.
virtual int GetPointNo(void) const =0
Get Total number of mesh generating points.
Interface between two cells.
Definition: Edge.hpp:13
const CachedLazyList< double > areas
List of areas of interfaces.
Definition: cache_data.hpp:84
virtual const vector< Edge > & getAllEdges(void) const =0
Returns reference to the list of all edges.
void ReplaceExtensive(Extensive &toreplace, Extensive const &other)
Replaces the data in the extensive. The tracers should already be allocated.
Definition: extensive.cpp:47
Container for cache data.
Definition: cache_data.hpp:14
void operator()(const vector< Extensive > &fluxes, const PhysicalGeometry &pg, const Tessellation &tess, const double dt, const CacheData &cd, const vector< ComputationalCell > &cells, vector< Extensive > &extensives, double time, TracerStickerNames const &tracerstickernames) const
Updates the extensive variables.
Class for keeping the names of the tracers and stickers.
std::pair< int, int > neighbors
Neighboring cells.
Definition: Edge.hpp:21
Base class for physical geometry.
ConditionExtensiveUpdater(const vector< pair< const Condition *, const Action *> > &sequence)
Class constructor.