OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS > Class Template Reference

#include <reactionPostProcessor2D.h>

+ Inheritance diagram for olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >:
+ Collaboration diagram for olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >:

Public Member Functions

 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)
 
 ReactionPostProcessor2D (std::vector< std::shared_ptr< Rate< T > > > rate, std::shared_ptr< REACTIONS > reactions, std::vector< BlockStructureD< 2 > * > partners)
 
int extent () const override
 Extent of application area (0 for purely local operations)
 
int extent (int whichDirection) const override
 Extent of application area along a direction (0 or 1)
 
void process (BlockLattice< T, DESCRIPTOR > &blockLattice) override
 Execute post-processing step.
 
void processSubDomain (BlockLattice< T, DESCRIPTOR > &blockLattice, int x0, int x1, int y0, int y1) override
 Execute post-processing step on a sublattice.
 
- Public Member Functions inherited from olb::PostProcessor2D< T, DESCRIPTOR >
 PostProcessor2D ()
 
virtual ~PostProcessor2D ()
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
int getPriority () const
 read only access to priority
 

Additional Inherited Members

- Protected Attributes inherited from olb::PostProcessor2D< T, DESCRIPTOR >
int _priority
 

Detailed Description

template<typename T, typename DESCRIPTOR, typename REACTIONS>
class olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >

Definition at line 41 of file reactionPostProcessor2D.h.

Constructor & Destructor Documentation

◆ ReactionPostProcessor2D() [1/2]

template<typename T , typename DESCRIPTOR , typename REACTIONS >
olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >::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 )

Definition at line 37 of file reactionPostProcessor2D.hh.

40 : _x0(x0), _x1(x1), _y0(y0), _y1(y1),
41 _rate(rate), _reactions(reactions), _partners(partners)
42{
43 std::size_t iReaction = 0;
44 _sizes = std::vector<std::size_t>(std::tuple_size_v<REACTIONS>);
45 meta::tuple_for_each(*_reactions.get(), [&](auto& line){
46 using line_type = typename std::remove_reference_t<decltype(line)>;
47 _sizes[iReaction++] = std::tuple_size_v<line_type>;
48 });
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.");
51 }
52}
void tuple_for_each(TUPLE &tuple, F &&f)
Apply F to each element of TUPLE.
Definition meta.h:369

References olb::meta::tuple_for_each().

+ Here is the call graph for this function:

◆ ReactionPostProcessor2D() [2/2]

template<typename T , typename DESCRIPTOR , typename REACTIONS >
olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >::ReactionPostProcessor2D ( std::vector< std::shared_ptr< Rate< T > > > rate,
std::shared_ptr< REACTIONS > reactions,
std::vector< BlockStructureD< 2 > * > partners )

Definition at line 55 of file reactionPostProcessor2D.hh.

58 : ReactionPostProcessor2D<T,DESCRIPTOR,REACTIONS>(0,0,0,0,rate,reactions,partners)
59{}

Member Function Documentation

◆ extent() [1/2]

template<typename T , typename DESCRIPTOR , typename REACTIONS >
int olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >::extent ( ) const
inlineoverridevirtual

Extent of application area (0 for purely local operations)

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 48 of file reactionPostProcessor2D.h.

49 {
50 return 1;
51 }

◆ extent() [2/2]

template<typename T , typename DESCRIPTOR , typename REACTIONS >
int olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >::extent ( int direction) const
inlineoverridevirtual

Extent of application area along a direction (0 or 1)

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 52 of file reactionPostProcessor2D.h.

53 {
54 return 1;
55 }

◆ process()

template<typename T , typename DESCRIPTOR , typename REACTIONS >
void olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >::process ( BlockLattice< T, DESCRIPTOR > & blockLattice)
overridevirtual

Execute post-processing step.

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 77 of file reactionPostProcessor2D.hh.

78{
79 processSubDomain(blockLattice, _x0, _x1, _y0, _y1);
80}
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0, int x1, int y0, int y1) override
Execute post-processing step on a sublattice.

◆ processSubDomain()

template<typename T , typename DESCRIPTOR , typename REACTIONS >
void olb::ReactionPostProcessor2D< T, DESCRIPTOR, REACTIONS >::processSubDomain ( BlockLattice< T, DESCRIPTOR > & blockLattice,
int x0_,
int x1_,
int y0_,
int y1_ )
overridevirtual

Execute post-processing step on a sublattice.

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 83 of file reactionPostProcessor2D.hh.

85{
86 int newX0, newX1, newY0, newY1;
87 if ( util::intersect ( _x0, _x1, _y0, _y1,
88 x0, x1, y0, y1,
89 newX0, newX1, newY0, newY1 ) ) {
90
91 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
92 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
93
94 // storing the old values of the local field from the partner lattices & resetting the sources
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);
99 });
100
101 // computing the rates from the old values of the local fields as per rate's own law
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++]));
110 }
111 }
112
113 // updating local field in the partner lattice: source = sum_i rate_i*coeff
114 functOverReactions(ratePartner, [&](auto& elem, auto& component){
115 elem.incrementSource(std::get<1>(component), std::get<0>(component) * elem.getStoichioCoeff(), iX, iY);
116 });
117 }
118 }
119 }
120}
bool intersect(int x0, int x1, int y0, int y1, int x0_, int x1_, int y0_, int y1_, int &newX0, int &newX1, int &newY0, int &newY1)
Definition util.h:89

The documentation for this class was generated from the following files: