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

#include <consoleWriter.h>

+ Collaboration diagram for olb::ConsoleWriter< T, D, DATA >:

Public Member Functions

 ConsoleWriter (std::ostream &str, DATA &data)
 
void print ()
 
void adjustSettings (Vector< unsigned, 2 > spacing)
 
template<typename F >
void write (F f, unsigned sliceAxis=2, int slicePosOnAxis=0)
 
template<typename GETABLE >
void writeGetable (GETABLE &getable, unsigned sliceAxis=2, int slicePosOnAxis=0)
 Non-generic common functions.
 
template<typename INDICATOR >
void writeIndicator (INDICATOR &indicator, unsigned sliceAxis=2, int slicePosOnAxis=0)
 
template<typename INDICATOR >
void writeIndicator (BlockGeometry< T, D > &blockGeometry, INDICATOR &indicator, unsigned sliceAxis=2, int slicePosOnAxis=0)
 
template<unsigned DIM, typename FUNCTOR , typename S = T>
void writeFunctor (FUNCTOR &functor, unsigned sliceAxis=2, int slicePosOnAxis=0)
 

Detailed Description

template<typename T, unsigned D, typename DATA>
class olb::ConsoleWriter< T, D, DATA >

Definition at line 33 of file consoleWriter.h.

Constructor & Destructor Documentation

◆ ConsoleWriter()

template<typename T , unsigned D, typename DATA >
olb::ConsoleWriter< T, D, DATA >::ConsoleWriter ( std::ostream & str,
DATA & data )
inline

Definition at line 55 of file consoleWriter.h.

56 : _data(data), os(str)
57 {
58 _extent = data.getExtent();
59 }

Member Function Documentation

◆ adjustSettings()

template<typename T , unsigned D, typename DATA >
void olb::ConsoleWriter< T, D, DATA >::adjustSettings ( Vector< unsigned, 2 > spacing)
inline

Definition at line 67 of file consoleWriter.h.

68 {
69 _spacing = spacing;
70 }

◆ print()

template<typename T , unsigned D, typename DATA >
void olb::ConsoleWriter< T, D, DATA >::print ( )
inline

Definition at line 62 of file consoleWriter.h.

62 {
63 os << "DataType: " << typeid(DATA).name() << std::endl;
64 os << "Extent=" << _extent << std::endl;
65 }
std::string name()
Returns distinct name on GCC, Clang and ICC but may return arbitrary garbage as per the standard.
Definition meta.h:100

◆ write()

template<typename T , unsigned D, typename DATA >
template<typename F >
void olb::ConsoleWriter< T, D, DATA >::write ( F f,
unsigned sliceAxis = 2,
int slicePosOnAxis = 0 )
inline

Definition at line 74 of file consoleWriter.h.

74 {
75 for (loc iY=0; iY < _extent[1]; ++iY) {
76 for (loc iX=0; iX < _extent[0]; ++iX) {
77 if constexpr (D == 3) {
78 int iZ = slicePosOnAxis;
79 loc iXeval;
80 loc iYeval;
81 loc iZeval;
82 if (sliceAxis==0){ //YZ-Slice
83 iXeval = iZ;
84 iYeval = iX;
85 iZeval = _extent[1]-iY-1;
86 } else if (sliceAxis==1){ //XZ-Slice
87 iXeval = iX;
88 iYeval = iZ;
89 iZeval = _extent[1]-iY-1;
90 } else { //XY-Slice
91 iXeval = iX;
92 iYeval = _extent[1]-iY-1;
93 iZeval = iZ;
94 }
95 //Evaluate function f
96 if constexpr (std::is_invocable_v<F, DATA&, LatticeR<D>>) {
97 os << f(_data,{iXeval,iYeval,iZeval}); //Version B: call with braced enclosed dimensions
98 } else {
99 os << f(_data,iXeval,iYeval,iZeval); //Version A: call with dimensions separat
100 }
101 } else {
102 //Project coordinates
103 loc iXeval = iX;
104 loc iYeval = _extent[1]-iY-1;
105 //Evaluate function f
106 if constexpr (std::is_invocable_v<F, DATA&, LatticeR<D>>) {
107 os << f(_data,{iXeval,iYeval}); //Version B: call with braced enclosed dimensions
108 } else {
109 os << f(_data,iXeval,iYeval); //Version A: call with dimensions separat
110 }
111 }
112 os << (iX==_extent[0]-1? "" : sequence(_charEmpty,_spacing[0]));
113 }
114 os << std::endl;
115 //Add _spacing (if needed)
116 if (iY<_extent[1]-1){
117 for (unsigned i=0; i<_spacing[1]; ++i){
118 for (loc iX=0; iX < _extent[0]; ++iX) {
119 os << (iX==_extent[0]-1? _charEmpty : sequence(_charEmpty,_spacing[0]+1));
120 }
121 os << std::endl;
122 }
123 }
124 }
125 }
+ Here is the caller graph for this function:

◆ writeFunctor()

template<typename T , unsigned D, typename DATA >
template<unsigned DIM, typename FUNCTOR , typename S = T>
void olb::ConsoleWriter< T, D, DATA >::writeFunctor ( FUNCTOR & functor,
unsigned sliceAxis = 2,
int slicePosOnAxis = 0 )
inline

Definition at line 162 of file consoleWriter.h.

162 {
163 write([&](auto& data, LatticeR<D> pos){
164 Vector<S,DIM> out;
165 functor( out.data(), pos.data() );
166 if constexpr (DIM==1){
167 return out[0];
168 } else {
169 return out;
170 }
171 });
172 }
void write(F f, unsigned sliceAxis=2, int slicePosOnAxis=0)

References olb::Vector< T, D >::data(), and olb::ConsoleWriter< T, D, DATA >::write().

+ Here is the call graph for this function:

◆ writeGetable()

template<typename T , unsigned D, typename DATA >
template<typename GETABLE >
void olb::ConsoleWriter< T, D, DATA >::writeGetable ( GETABLE & getable,
unsigned sliceAxis = 2,
int slicePosOnAxis = 0 )
inline

Non-generic common functions.

Definition at line 131 of file consoleWriter.h.

131 {
132 write([&](auto& data, LatticeR<D> pos){
133 auto res = getable.get(pos);
134 return res;
135 });
136 }

References olb::ConsoleWriter< T, D, DATA >::write().

+ Here is the call graph for this function:

◆ writeIndicator() [1/2]

template<typename T , unsigned D, typename DATA >
template<typename INDICATOR >
void olb::ConsoleWriter< T, D, DATA >::writeIndicator ( BlockGeometry< T, D > & blockGeometry,
INDICATOR & indicator,
unsigned sliceAxis = 2,
int slicePosOnAxis = 0 )
inline

Definition at line 150 of file consoleWriter.h.

150 {
151 write([&](auto& data, LatticeR<D> pos){
152 bool out[1];
153 Vector<T,D> physPos;
154 blockGeometry.getPhysR( physPos.data(), pos );
155 indicator( out, physPos.data() );
156 return out[0];
157 });
158 }

References olb::Vector< T, D >::data(), olb::BlockGeometry< T, D >::getPhysR(), and olb::ConsoleWriter< T, D, DATA >::write().

+ Here is the call graph for this function:

◆ writeIndicator() [2/2]

template<typename T , unsigned D, typename DATA >
template<typename INDICATOR >
void olb::ConsoleWriter< T, D, DATA >::writeIndicator ( INDICATOR & indicator,
unsigned sliceAxis = 2,
int slicePosOnAxis = 0 )
inline

Definition at line 140 of file consoleWriter.h.

140 {
141 write([&](auto& data, LatticeR<D> pos){
142 bool out[1];
143 indicator( out, pos.data() );
144 return out[0];
145 });
146 }

References olb::Vector< T, D >::data(), and olb::ConsoleWriter< T, D, DATA >::write().

+ Here is the call graph for this function:

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