38 std::vector<std::shared_ptr<
Rate<T>>> rate, std::shared_ptr<REACTIONS> reactions,
40 : _x0(x0), _x1(x1), _y0(y0), _y1(y1),
41 _rate(rate), _reactions(reactions), _partners(partners)
43 std::size_t iReaction = 0;
44 _sizes = std::vector<std::size_t>(std::tuple_size_v<REACTIONS>);
46 using line_type = typename std::remove_reference_t<decltype(line)>;
47 _sizes[iReaction++] = std::tuple_size_v<line_type>;
49 if (std::accumulate(_sizes.begin(), _sizes.end(), std::size_t(0)) != partners.size()) {
50 throw std::invalid_argument(
"The number of species must equate the number of input lattices.");
70 f(elem, vect[std::accumulate(_sizes.begin(), _sizes.begin()+iReaction, 0) + (iReagent++)]);
84 int x0,
int x1,
int y0,
int y1 )
86 int newX0, newX1, newY0, newY1;
87 if ( util::intersect ( _x0, _x1, _y0, _y1,
89 newX0, newX1, newY0, newY1 ) ) {
91 for (
int iX=newX0-1; iX<=newX1+1; ++iX) {
92 for (
int iY=newY0-1; iY<=newY1+1; ++iY) {
95 std::vector<T> fields_asSingleVector;
96 functOverReactions(_partners, [&](
auto& elem,
auto& component){
97 fields_asSingleVector.push_back( elem.getField(component, iX, iY) );
98 elem.resetSource(component, iX, iY);
102 std::size_t iPartner = 0;
103 std::vector<std::tuple<T,BlockStructureD<2>*>> ratePartner;
104 for (std::size_t iReaction=0; iReaction<_sizes.size(); ++iReaction) {
105 auto reagents_begin = fields_asSingleVector.begin() + std::accumulate(_sizes.begin(), _sizes.begin()+iReaction, 0);
106 std::vector<T> reagents = { reagents_begin, reagents_begin + _sizes[iReaction] };
107 T rate_thisReaction = _rate[iReaction]->compute(reagents);
108 for (std::size_t iReagent=0; iReagent<_sizes[iReaction]; ++iReagent) {
109 ratePartner.push_back(std::make_tuple(rate_thisReaction, _partners[iPartner++]));
114 functOverReactions(ratePartner, [&](
auto& elem,
auto& component){
115 elem.incrementSource(std::get<1>(component), std::get<0>(component) * elem.getStoichioCoeff(), iX, iY);
Interface of 2D post-processing steps.
ReactionPostProcessor2D(int x0, int x1, int y0, int y1, std::vector< std::shared_ptr< Rate< T > > > rate, std::shared_ptr< REACTIONS > reactions, std::vector< BlockStructureD< 2 > * > partners)