OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::FieldTypePromise< T, DESCRIPTOR > Class Template Reference

Helper for conveying the ability for operations on FIELD_TYPE. More...

#include <data.h>

+ Collaboration diagram for olb::FieldTypePromise< T, DESCRIPTOR >:

Public Member Functions

template<typename FIELD_TYPE >
 FieldTypePromise (meta::id< FIELD_TYPE >)
 
std::string name () const
 
std::optional< unsigned > dimension () const
 
void ensureAvailabilityIn (BlockLattice< T, DESCRIPTOR > &block)
 
void ensureAvailabilityIn (BlockD< T, DESCRIPTOR > &block)
 
void setPlaceholderExpression (Cell< Expr, DESCRIPTOR > &cell, std::vector< Expr > &expr)
 
std::vector< Expr > getPlaceholderExpression (Cell< Expr, DESCRIPTOR > &cell)
 
bool operator< (const FieldTypePromise< T, DESCRIPTOR > &rhs) const
 

Detailed Description

template<typename T, typename DESCRIPTOR>
class olb::FieldTypePromise< T, DESCRIPTOR >

Helper for conveying the ability for operations on FIELD_TYPE.

e.g. enable field allocation and communication setup without exposing the concrete field type (which would necessitate templatization)

c.f. DynamicsPromise and PostProcessorPromise

Definition at line 95 of file data.h.

Constructor & Destructor Documentation

◆ FieldTypePromise()

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE >
olb::FieldTypePromise< T, DESCRIPTOR >::FieldTypePromise ( meta::id< FIELD_TYPE > )
inline

Definition at line 113 of file data.h.

113 :
115 _allocateInLattice([](BlockLattice<T,DESCRIPTOR>& block) {
116 if constexpr (concepts::LatticeDescriptor<DESCRIPTOR>) {
117 block.template getData<FIELD_TYPE>();
118 }
119 }),
120 _allocateInBlockD([](BlockD<T,DESCRIPTOR>& block) {
121 block.template getData<FIELD_TYPE>();
122 }),
123 _setPlaceholderExpr([](Cell<Expr,DESCRIPTOR>& cell, std::vector<Expr>& expr) {
124 if constexpr (concepts::LatticeDescriptor<DESCRIPTOR>) {
125 if constexpr (fields::isArray<FIELD_TYPE>()) {
126 if constexpr (std::is_same_v<Expr, typename FieldD<Expr,DESCRIPTOR,typename FIELD_TYPE::field_t>::value_t>) {
128 for (unsigned iD=0; iD < placeholder.d; ++iD) {
129 placeholder[iD] = expr[iD];
130 }
131 cell.template setField<typename FIELD_TYPE::field_t>(placeholder);
132 } else {
133 throw std::runtime_error("Can not set placeholder for non-T types");
134 }
135 } else {
136 throw std::runtime_error("Can not set placeholder for non-FieldArray types");
137 }
138 }
139 }),
140 _getPlaceholderExpr([](Cell<Expr,DESCRIPTOR>& cell) {
141 std::vector<Expr> expressions;
142 if constexpr (concepts::LatticeDescriptor<DESCRIPTOR>) {
143 if constexpr (fields::isArray<FIELD_TYPE>()) {
144 if constexpr (std::is_same_v<Expr, typename FieldD<Expr,DESCRIPTOR,typename FIELD_TYPE::field_t>::value_t>) {
146 placeholder = cell.template getFieldPointer<typename FIELD_TYPE::field_t>();
147 for (unsigned iD=0; iD < placeholder.d; ++iD) {
148 expressions.push_back(placeholder[iD]);
149 }
150 } else {
151 throw std::runtime_error("Can not get placeholder for non-T types");
152 }
153 } else {
154 throw std::runtime_error("Can not get placeholder for non-FieldArray types");
155 }
156 }
157 return expressions;
158 })
159 {
160 if constexpr (fields::isArray<FIELD_TYPE>()) {
161 _dim = std::optional<unsigned>{DESCRIPTOR::template size<typename FIELD_TYPE::field_t>()};
162 }
163 }
std::string name()
Returns name of FIELD for human consumption.
Definition fields.h:49
constexpr bool isArray()
Helper to determine if FIELD contains FieldArray.
Definition data.h:81
Vector< typename FIELD::template value_type< T >, DESCRIPTOR::template size< FIELD >() > FieldD
Vector storing a single field instance.
Definition vector.h:480

Member Function Documentation

◆ dimension()

template<typename T , typename DESCRIPTOR >
std::optional< unsigned > olb::FieldTypePromise< T, DESCRIPTOR >::dimension ( ) const
inline

Definition at line 169 of file data.h.

169 {
170 return _dim;
171 }

◆ ensureAvailabilityIn() [1/2]

template<typename T , typename DESCRIPTOR >
void olb::FieldTypePromise< T, DESCRIPTOR >::ensureAvailabilityIn ( BlockD< T, DESCRIPTOR > & block)
inline

Definition at line 177 of file data.h.

177 {
178 _allocateInBlockD(block);
179 }

◆ ensureAvailabilityIn() [2/2]

template<typename T , typename DESCRIPTOR >
void olb::FieldTypePromise< T, DESCRIPTOR >::ensureAvailabilityIn ( BlockLattice< T, DESCRIPTOR > & block)
inline

Definition at line 173 of file data.h.

173 {
174 _allocateInLattice(block);
175 }

◆ getPlaceholderExpression()

template<typename T , typename DESCRIPTOR >
std::vector< Expr > olb::FieldTypePromise< T, DESCRIPTOR >::getPlaceholderExpression ( Cell< Expr, DESCRIPTOR > & cell)
inline

Definition at line 185 of file data.h.

185 {
186 return _getPlaceholderExpr(cell);
187 }

◆ name()

template<typename T , typename DESCRIPTOR >
std::string olb::FieldTypePromise< T, DESCRIPTOR >::name ( ) const
inline

Definition at line 165 of file data.h.

165 {
166 return _name;
167 }
+ Here is the caller graph for this function:

◆ operator<()

template<typename T , typename DESCRIPTOR >
bool olb::FieldTypePromise< T, DESCRIPTOR >::operator< ( const FieldTypePromise< T, DESCRIPTOR > & rhs) const
inline

Definition at line 189 of file data.h.

189 {
190 return name() < rhs.name();
191 }
std::string name() const
Definition data.h:165

References olb::FieldTypePromise< T, DESCRIPTOR >::name().

+ Here is the call graph for this function:

◆ setPlaceholderExpression()

template<typename T , typename DESCRIPTOR >
void olb::FieldTypePromise< T, DESCRIPTOR >::setPlaceholderExpression ( Cell< Expr, DESCRIPTOR > & cell,
std::vector< Expr > & expr )
inline

Definition at line 181 of file data.h.

181 {
182 _setPlaceholderExpr(cell, expr);
183 }

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