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

#include <reactionPostProcessor3D.h>

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

Public Member Functions

 ReactionPostProcessor3D (int x0, int x1, int y0, int y1, int z0, int z1, std::vector< std::shared_ptr< Rate< T > > > rate, std::shared_ptr< REACTIONS > reactions, std::vector< BlockStructureD< 3 > * > partners)
 
 ReactionPostProcessor3D (std::vector< std::shared_ptr< Rate< T > > > rate, std::shared_ptr< REACTIONS > reactions, std::vector< BlockStructureD< 3 > * > 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, int z0, int z1) override
 Execute post-processing step on a sublattice.
 
- Public Member Functions inherited from olb::PostProcessor3D< T, DESCRIPTOR >
 PostProcessor3D ()
 
virtual ~PostProcessor3D ()
 
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::PostProcessor3D< T, DESCRIPTOR >
int _priority
 

Detailed Description

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

Definition at line 41 of file reactionPostProcessor3D.h.

Constructor & Destructor Documentation

◆ ReactionPostProcessor3D() [1/2]

template<typename T , typename DESCRIPTOR , typename REACTIONS >
olb::ReactionPostProcessor3D< T, DESCRIPTOR, REACTIONS >::ReactionPostProcessor3D ( int x0,
int x1,
int y0,
int y1,
int z0,
int z1,
std::vector< std::shared_ptr< Rate< T > > > rate,
std::shared_ptr< REACTIONS > reactions,
std::vector< BlockStructureD< 3 > * > partners )

Definition at line 36 of file reactionPostProcessor3D.hh.

39 : _x0(x0), _x1(x1), _y0(y0), _y1(y1), _z0(z0), _z1(z1),
40 _rate(rate), _reactions(reactions), _partners(partners)
41{
42 std::size_t iReaction = 0;
43 _sizes = std::vector<std::size_t>(std::tuple_size_v<REACTIONS>);
44 meta::tuple_for_each(*_reactions.get(), [&](auto& line){
45 using line_type = typename std::remove_reference_t<decltype(line)>;
46 _sizes[iReaction++] = std::tuple_size_v<line_type>;
47 });
48 if (std::accumulate(_sizes.begin(), _sizes.end(), std::size_t(0)) != partners.size()) {
49 throw std::invalid_argument("The number of species must equate the number of input lattices.");
50 }
51}
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:

◆ ReactionPostProcessor3D() [2/2]

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

Definition at line 54 of file reactionPostProcessor3D.hh.

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

Member Function Documentation

◆ extent() [1/2]

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

Extent of application area (0 for purely local operations)

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 48 of file reactionPostProcessor3D.h.

49 {
50 return 1;
51 }

◆ extent() [2/2]

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

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

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 52 of file reactionPostProcessor3D.h.

53 {
54 return 1;
55 }

◆ process()

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

Execute post-processing step.

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 76 of file reactionPostProcessor3D.hh.

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

◆ processSubDomain()

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

Execute post-processing step on a sublattice.

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 82 of file reactionPostProcessor3D.hh.

84{
85 int newX0, newX1, newY0, newY1, newZ0, newZ1;
86 if ( util::intersect ( _x0, _x1, _y0, _y1, _z0, _z1,
87 x0, x1, y0, y1, z0, z1,
88 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
89
90 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
91 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
92 for (int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
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, iZ) );
98 elem.resetSource(component, iX, iY, iZ);
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<3>*>> 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, iZ);
116 });
117 }
118 }
119 }
120 }
121}
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: