Flow123d
JS_before_hm-1879-g0c4ed93bc
|
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();
106 template<
typename FIELD_TUPLE>
131 template<
int spacedim,
class Value>
134 ASSERT(f.is_multifield());
141 template<
int spacedim,
class Value>
144 ASSERT(!f.is_multifield());
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>
200 template<
typename Function,
typename Tuple>
247 template<
int spacedim,
class Value,
typename Fn,
class ... InputFields>
275 for(
unsigned int i_cache=reg_chunk_begin; i_cache<reg_chunk_end; ++i_cache) {
276 data_cache.
set(i_cache) =
287 ASSERT(
false).error(
"Forbidden method!\n");
294 ASSERT(
false).error(
"Forbidden method!\n");
303 template<
int spacedim,
class Value>
312 template<
typename Fn,
class ... InputFields>
314 static auto create(Fn fn, InputFields&&... inputs) -> decltype(
auto)
316 return std::make_shared<
FieldModel<spacedim,
Value, Fn, InputFields...>>(fn, std::forward<InputFields>(inputs)...);
321 template<
typename Function,
typename Tuple,
size_t ... I>
322 static auto call_create(Function f, Tuple t, std::index_sequence<I ...>)
324 return create(f, std::get<I>(t) ...);
330 template<
typename Fn,
class ... InputFields>
332 static auto create_multi(Fn fn, InputFields&&... inputs) -> decltype(
auto)
334 typedef std::tuple<InputFields...> FieldTuple;
335 FieldTuple field_tuple = std::forward_as_tuple((inputs)...);
336 constexpr
uint n_inputs =
sizeof...(InputFields);
340 for(
uint i=0; i<n_comp; i++) {
346 result_components.push_back(component_field);
349 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)
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
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.
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)
const Value::return_type & value(FMT_UNUSED const Point &p, FMT_UNUSED const ElementAccessor< spacedim > &elm) override
Implementation of virtual method.
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 ... >)
Value::return_type r_value_
static auto create(Fn fn, InputFields &&... inputs) -> decltype(auto)
void value_list(FMT_UNUSED const Armor::array &point_list, FMT_UNUSED const ElementAccessor< spacedim > &elm, FMT_UNUSED std::vector< typename Value::return_type > &value_list) override
Implementation of virtual method.
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)