Go to the documentation of this file.
18 #ifndef FIELD_MODEL_HH_
19 #define FIELD_MODEL_HH_
27 #include <type_traits>
53 #define wrap_overload(func) [](auto&&... ps){ return func( std::forward<decltype(ps)>(ps)... ); }
62 template<
typename CALLABLE,
typename FIELD_TUPLE,
int INDEX >
63 struct model_cache_item
65 template<
typename... Vs >
66 static auto eval(
int i_cache, CALLABLE f, FIELD_TUPLE fields, Vs&&... args) -> decltype(
auto) {
67 const auto &single_field =
std::get < INDEX - 1 > (std::forward<decltype(fields)>(fields));
69 i_cache, f, std::forward<decltype(fields)>(fields),
70 single_field[i_cache], std::forward<Vs>(args)...);
76 template<
typename CALLABLE,
typename FIELD_TUPLE >
79 template<
typename... Vs >
82 return f(std::forward<Vs>(args)...);
92 template<
typename FIELD_TUPLE,
int INDEX >
95 const auto &single_field =
std::get < INDEX - 1 > (std::forward<decltype(fields)>(fields));
96 uint n_comp_new = single_field.n_comp();
100 ASSERT(n_comp == n_comp_new);
106 template<
typename FIELD_TUPLE>
131 template<
int spacedim,
class Value>
141 template<
int spacedim,
class Value>
152 template<
typename FIELD_TUPLE,
int INDEX>
154 static auto eval(FIELD_TUPLE fields,
uint i_comp) -> decltype(
auto)
156 const auto &single_field =
std::get < INDEX - 1 > (std::forward<decltype(fields)>(fields));
157 return std::tuple_cat(
159 std::forward<decltype(fields)>(fields), i_comp),
165 template<
typename FIELD_TUPLE>
169 return std::forward_as_tuple<>();
179 template<
typename FIELD_TUPLE,
int INDEX >
182 const auto &single_field =
std::get < INDEX - 1 > (std::forward<decltype(fields)>(fields));
184 vec.push_back(&single_field);
189 template<
typename FIELD_TUPLE>
199 template<
typename Function,
typename Tuple>
246 template<
int spacedim,
class Value,
typename Fn,
class ... InputFields>
274 for(
unsigned int i_cache=reg_chunk_begin; i_cache<reg_chunk_end; ++i_cache) {
275 data_cache.
set(i_cache) =
290 template<
int spacedim,
class Value>
299 template<
typename Fn,
class ... InputFields>
301 static auto create(Fn fn, InputFields&&... inputs) -> decltype(
auto)
303 return std::make_shared<
FieldModel<spacedim,
Value, Fn, InputFields...>>(fn, std::forward<InputFields>(inputs)...);
308 template<
typename Function,
typename Tuple,
size_t ... I>
309 static auto call_create(Function f, Tuple t, std::index_sequence<I ...>)
311 return create(f, std::get<I>(t) ...);
317 template<
typename Fn,
class ... InputFields>
319 static auto create_multi(Fn fn, InputFields&&... inputs) -> decltype(
auto)
321 typedef std::tuple<InputFields...> FieldTuple;
322 FieldTuple field_tuple = std::forward_as_tuple((inputs)...);
323 constexpr
uint n_inputs =
sizeof...(InputFields);
327 for(
uint i=0; i<n_comp; i++) {
333 result_components.push_back(component_field);
336 return result_components;
base case for building up arguments for the function call
static auto eval(FMT_UNUSED int i_cache, CALLABLE f, FMT_UNUSED FIELD_TUPLE fields, Vs &&... args) -> decltype(auto)
auto field_component(const MultiField< spacedim, Value > &f, uint i_comp) -> decltype(auto)
Directing class of FieldValueCache.
auto call(Function f, Tuple t)
static constexpr bool value
std::tuple< InputFields... > FieldsTuple
Space< spacedim >::Point Point
static uint eval(FMT_UNUSED FIELD_TUPLE fields, uint n_comp)
FieldAlgorithmBase< spacedim, Value >::Point Point
static auto create_multi(Fn fn, InputFields &&... inputs) -> decltype(auto)
unsigned int region_chunk_end(unsigned int region_patch_idx) const
Return end position of region chunk in FieldValueCache.
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Container for various descendants of FieldCommonBase.
ArrayMatSet set(uint index)
std::shared_ptr< FieldBaseType > FieldBasePtr
void cache_update(FieldValueCache< typename Value::element_type > &data_cache, ElementCacheMap &cache_map, unsigned int region_patch_idx) override
Implements FieldAlgoBase::cache_update.
unsigned int region_chunk_begin(unsigned int region_patch_idx) const
Return begin position of region chunk in FieldValueCache.
static std::vector< const FieldCommon * > eval(FIELD_TUPLE fields)
Class for representation of a vector of fields of the same physical quantity.
static std::vector< const FieldCommon * > eval(FMT_UNUSED FIELD_TUPLE fields)
FieldModel(Fn func, InputFields... args)
static auto eval(FMT_UNUSED FIELD_TUPLE fields, FMT_UNUSED uint n_comp) -> decltype(auto)
static uint eval(FIELD_TUPLE fields, uint n_comp)
static auto call_create(Function f, Tuple t, std::index_sequence< I ... >)
static auto create(Fn fn, InputFields &&... inputs) -> decltype(auto)
static auto eval(FIELD_TUPLE fields, uint i_comp) -> decltype(auto)
Class template representing a field with values dependent on: point, element, and region.
std::vector< const FieldCommon * > set_dependency(FMT_UNUSED FieldSet &field_set)
Implements FieldAlgoBase::set_dependency.
FieldAlgorithmBase< spacedim, Value > FieldBaseType
static auto eval(int i_cache, CALLABLE f, FIELD_TUPLE fields, Vs &&... args) -> decltype(auto)