OGS
ProcessLib::Reflection::detail Namespace Reference

Classes

struct  GetFlattenedIPDataFromLocAsm
 
struct  is_raw_data
 
struct  is_raw_data< double >
 
struct  is_raw_data< Eigen::Matrix< double, N, 1, Eigen::ColMajor, N, 1 > >
 
struct  is_raw_data< Eigen::Matrix< double, N, M, Eigen::RowMajor, N, M > >
 
struct  NumberOfColumns
 
struct  NumberOfColumns< double >
 
struct  NumberOfColumns< Eigen::Matrix< double, N, 1, Eigen::ColMajor, N, 1 > >
 
struct  NumberOfColumns< Eigen::Matrix< double, N, M, Eigen::RowMajor, N, M > >
 
struct  NumberOfComponents
 
struct  NumberOfRows
 
struct  NumberOfRows< double >
 
struct  NumberOfRows< Eigen::Matrix< double, N, 1, Eigen::ColMajor, N, 1 > >
 
struct  NumberOfRows< Eigen::Matrix< double, N, M, Eigen::RowMajor, N, M > >
 

Functions

template<typename... Ts>
auto reflect (std::type_identity< std::tuple< Ts... > >)
 
template<has_reflect T>
auto reflect (std::type_identity< T >)
 
template<typename T , typename Tag >
auto reflect (std::type_identity< BaseLib::StrongType< T, Tag > >)
 
template<int Dim, typename Accessor_IPDataVecInLocAsm , typename Accessor_CurrentLevelFromIPDataVecElement >
GetFlattenedIPDataFromLocAsm< Dim, std::remove_cvref_t< Accessor_IPDataVecInLocAsm >, std::remove_cvref_t< Accessor_CurrentLevelFromIPDataVecElement > > getFlattenedIPDataFromLocAsm (Accessor_IPDataVecInLocAsm accessor_ip_data_vec_in_loc_asm, Accessor_CurrentLevelFromIPDataVecElement accessor_current_level_from_ip_data_vec_element)
 
template<int Dim, typename Accessor_IPDataVecInLocAsm >
auto getFlattenedIPDataFromLocAsm (Accessor_IPDataVecInLocAsm &&accessor_ip_data_vec_in_loc_asm)
 
template<int Dim, typename Callback , typename ReflectionDataTuple , typename Accessor_IPDataVecInLocAsm , typename Accessor_CurrentLevelFromIPDataVecElement >
void forEachReflectedFlattenedIPDataAccessor (Callback const &callback, ReflectionDataTuple const &reflection_data, Accessor_IPDataVecInLocAsm const &accessor_ip_data_vec_in_loc_asm, Accessor_CurrentLevelFromIPDataVecElement const &accessor_current_level_from_ip_data_vec_element)
 
template<int Dim, typename Callback , typename ReflectionDataTuple , typename Accessor_IPDataVecInLocAsm >
void forEachReflectedFlattenedIPDataAccessor (Callback const &callback, ReflectionDataTuple const &reflection_data, Accessor_IPDataVecInLocAsm const &accessor_ip_data_vec_in_loc_asm)
 
template<int dim, typename IPData , typename Accessor >
void setIPData (double const *values, std::vector< IPData > &ip_data_vector, Accessor const &accessor)
 
template<int dim, typename IPData , typename Accessor_CurrentLevelFromIPData , typename Class , typename Accessor >
bool setIPDataIfNameMatches (std::string_view const name, double const *values, std::vector< IPData > &ip_data_vector, Accessor_CurrentLevelFromIPData const &accessor, ReflectionData< Class, Accessor > const &refl_data)
 
template<int dim, typename IPData , typename Accessor_CurrentLevelFromIPData , typename... Classes, typename... Accessors, std::size_t... Idcs>
bool reflectSetIPData (std::string_view const name, double const *values, std::vector< IPData > &ip_data_vector, Accessor_CurrentLevelFromIPData const &accessor, std::tuple< ReflectionData< Classes, Accessors >... > const &refl_data, std::index_sequence< Idcs... >)
 
template<int dim, typename IPData , typename Accessor_CurrentLevelFromIPData , typename... Classes, typename... Accessors>
bool reflectSetIPData (std::string_view const name, double const *values, std::vector< IPData > &ip_data_vector, Accessor_CurrentLevelFromIPData const &accessor, std::tuple< ReflectionData< Classes, Accessors >... > const &refl_data)
 

Variables

template<typename T >
constexpr bool is_raw_data_v = is_raw_data<T>::value
 

Function Documentation

◆ forEachReflectedFlattenedIPDataAccessor() [1/2]

template<int Dim, typename Callback , typename ReflectionDataTuple , typename Accessor_IPDataVecInLocAsm >
void ProcessLib::Reflection::detail::forEachReflectedFlattenedIPDataAccessor ( Callback const & callback,
ReflectionDataTuple const & reflection_data,
Accessor_IPDataVecInLocAsm const & accessor_ip_data_vec_in_loc_asm )

Definition at line 432 of file ReflectionIPData.h.

436{
437 forEachReflectedFlattenedIPDataAccessor<Dim>(
438 callback, reflection_data, accessor_ip_data_vec_in_loc_asm,
439 std::identity{});
440}

References forEachReflectedFlattenedIPDataAccessor().

◆ forEachReflectedFlattenedIPDataAccessor() [2/2]

template<int Dim, typename Callback , typename ReflectionDataTuple , typename Accessor_IPDataVecInLocAsm , typename Accessor_CurrentLevelFromIPDataVecElement >
void ProcessLib::Reflection::detail::forEachReflectedFlattenedIPDataAccessor ( Callback const & callback,
ReflectionDataTuple const & reflection_data,
Accessor_IPDataVecInLocAsm const & accessor_ip_data_vec_in_loc_asm,
Accessor_CurrentLevelFromIPDataVecElement const & accessor_current_level_from_ip_data_vec_element )

Calls the given callback for each flattened IP data accessor obtained recursively from the given reflection data.

The callback function must take (i) the name of the IP data (std::string), (ii) their number of components (unsigned) and a flattened IP data accessor of type ProcessLib::Reflection::detail::GetFlattenedIPDataFromLocAsm as arguments.

See also
ProcessLib::Reflection::detail::GetFlattenedIPDataFromLocAsm for details, also on the template parameters.

Definition at line 372 of file ReflectionIPData.h.

377{
379 "The passed reflection data is not a std::tuple.");
380 static_assert(
381 std::is_same_v<ReflectionDataTuple,
382 boost::mp11::mp_rename<ReflectionDataTuple, std::tuple>>,
383 "The passed reflection data is not a std::tuple.");
384
385 boost::mp11::tuple_for_each(
386 reflection_data,
387 [&accessor_ip_data_vec_in_loc_asm,
388 &accessor_current_level_from_ip_data_vec_element,
389 &callback]<typename Class, typename Accessor>(
390 ReflectionData<Class, Accessor> const& refl_data)
391 {
392 using MemberRef = std::invoke_result_t<Accessor, Class const&>;
393 using Member = std::remove_cvref_t<MemberRef>;
394
395 auto accessor_member_from_ip_data_vec_element =
396 [accessor_next_level = refl_data.accessor,
397 accessor_current_level_from_ip_data_vec_element](
398 auto const& ip_data_vec_element) -> Member const&
399 {
400 return accessor_next_level(
401 accessor_current_level_from_ip_data_vec_element(
402 ip_data_vec_element));
403 };
404
405 if constexpr (is_reflectable<Member>)
406 {
407 forEachReflectedFlattenedIPDataAccessor<Dim>(
408 callback, detail::reflect(std::type_identity<Member>{}),
409 accessor_ip_data_vec_in_loc_asm,
410 accessor_member_from_ip_data_vec_element);
411 }
412 else
413 {
414 static_assert(is_raw_data_v<Member>,
415 "The current member is not reflectable, so we "
416 "expect it to be raw data.");
417
418 constexpr unsigned num_comp = NumberOfComponents<Member>::value;
419
420 assert(!refl_data.name.empty());
421 callback(refl_data.name, num_comp,
422 getFlattenedIPDataFromLocAsm<Dim>(
423 accessor_ip_data_vec_in_loc_asm,
424 accessor_member_from_ip_data_vec_element));
425 }
426 });
427}
constexpr bool mp_is_list_v

References ProcessLib::Reflection::ReflectionData< Class, Accessor >::accessor, forEachReflectedFlattenedIPDataAccessor(), getFlattenedIPDataFromLocAsm(), is_raw_data_v, boost::mp11::mp_is_list_v, ProcessLib::Reflection::ReflectionData< Class, Accessor >::name, and reflect().

Referenced by forEachReflectedFlattenedIPDataAccessor(), forEachReflectedFlattenedIPDataAccessor(), and ProcessLib::Reflection::forEachReflectedFlattenedIPDataAccessor().

◆ getFlattenedIPDataFromLocAsm() [1/2]

template<int Dim, typename Accessor_IPDataVecInLocAsm >
auto ProcessLib::Reflection::detail::getFlattenedIPDataFromLocAsm ( Accessor_IPDataVecInLocAsm && accessor_ip_data_vec_in_loc_asm)

Definition at line 350 of file ReflectionIPData.h.

352{
353 return getFlattenedIPDataFromLocAsm<Dim>(
354 std::forward<Accessor_IPDataVecInLocAsm>(
355 accessor_ip_data_vec_in_loc_asm),
356 std::identity{});
357}

References getFlattenedIPDataFromLocAsm().

◆ getFlattenedIPDataFromLocAsm() [2/2]

template<int Dim, typename Accessor_IPDataVecInLocAsm , typename Accessor_CurrentLevelFromIPDataVecElement >
GetFlattenedIPDataFromLocAsm< Dim, std::remove_cvref_t< Accessor_IPDataVecInLocAsm >, std::remove_cvref_t< Accessor_CurrentLevelFromIPDataVecElement > > ProcessLib::Reflection::detail::getFlattenedIPDataFromLocAsm ( Accessor_IPDataVecInLocAsm accessor_ip_data_vec_in_loc_asm,
Accessor_CurrentLevelFromIPDataVecElement accessor_current_level_from_ip_data_vec_element )

Definition at line 335 of file ReflectionIPData.h.

339{
340 return {std::forward<Accessor_IPDataVecInLocAsm>(
341 accessor_ip_data_vec_in_loc_asm),
342 std::forward<Accessor_CurrentLevelFromIPDataVecElement>(
343 accessor_current_level_from_ip_data_vec_element)};
344}

Referenced by forEachReflectedFlattenedIPDataAccessor(), ProcessLib::Reflection::forEachReflectedFlattenedIPDataAccessor(), and getFlattenedIPDataFromLocAsm().

◆ reflect() [1/3]

template<typename T , typename Tag >
auto ProcessLib::Reflection::detail::reflect ( std::type_identity< BaseLib::StrongType< T, Tag > > )

Definition at line 136 of file ReflectionIPData.h.

137{
139
140 auto accessor = [](auto& o) -> auto&
141 {
142 return *o;
143 };
144
145 // Maybe in the future we might want to lift the following two constraints.
146 // But beware: that generalization has to be tested thoroughly such that we
147 // don't accidentally produce I/O data without name and the like.
148 static_assert(
149 has_ioName<Tag>,
150 /* We use ioName(Tag* tag), because it works with an incomplete type
151 * Tag, as opposed to ioName(Tag tag), i.e. declaring
152 * std::string_view ioName(struct SomeTag*);
153 * is possible, whereas
154 * std::string_view ioName(struct SomeTag);
155 * is not.
156 * This choice makes the code for every ioName() definition rather
157 * compact.
158 */
159 "For I/O of StrongType<T, Tag> you have to define an ioName(Tag* tag) "
160 "function returning the name used for I/O.");
161 static_assert(
162 is_raw_data_v<T>,
163 "I/O of StrongTypes is supported only for StrongTypes wrapping 'raw "
164 "data' such as double values, vectors and matrices.");
165
166 return std::tuple{makeReflectionData<ST>(
167 std::string{ioName(static_cast<Tag*>(nullptr))}, std::move(accessor))};
168}

References is_raw_data_v, and ProcessLib::Reflection::makeReflectionData().

◆ reflect() [2/3]

template<typename... Ts>
auto ProcessLib::Reflection::detail::reflect ( std::type_identity< std::tuple< Ts... > > )

Definition at line 110 of file ReflectionIPData.h.

111{
112 using namespace boost::mp11;
113
114 // The types Ts... must be unique. Duplicate types are incompatible with the
115 // concept of "reflected" I/O: they would lead to duplicate names for the
116 // I/O data.
117 static_assert(mp_is_set_v<mp_list<Ts...>>);
118
119 return reflectWithoutName<std::tuple<Ts...>>(
120 [](auto& tuple_) -> auto& { return std::get<Ts>(tuple_); }...);
121}
auto reflectWithoutName(Accessors &&... accessors)

References ProcessLib::Reflection::reflectWithoutName().

Referenced by forEachReflectedFlattenedIPDataAccessor(), ProcessLib::Reflection::forEachReflectedFlattenedIPDataAccessor(), ProcessLib::Reflection::reflectSetIPData(), and setIPDataIfNameMatches().

◆ reflect() [3/3]

template<has_reflect T>
auto ProcessLib::Reflection::detail::reflect ( std::type_identity< T > )

Definition at line 124 of file ReflectionIPData.h.

125{
126 return T::reflect();
127}

◆ reflectSetIPData() [1/2]

template<int dim, typename IPData , typename Accessor_CurrentLevelFromIPData , typename... Classes, typename... Accessors>
bool ProcessLib::Reflection::detail::reflectSetIPData ( std::string_view const name,
double const * values,
std::vector< IPData > & ip_data_vector,
Accessor_CurrentLevelFromIPData const & accessor,
std::tuple< ReflectionData< Classes, Accessors >... > const & refl_data )

Definition at line 148 of file ReflectionSetIPData.h.

153{
154 return reflectSetIPData<dim>(
155 name, values, ip_data_vector, accessor, refl_data,
156 std::make_index_sequence<sizeof...(Classes)>{});
157}

References reflectSetIPData().

◆ reflectSetIPData() [2/2]

template<int dim, typename IPData , typename Accessor_CurrentLevelFromIPData , typename... Classes, typename... Accessors, std::size_t... Idcs>
bool ProcessLib::Reflection::detail::reflectSetIPData ( std::string_view const name,
double const * values,
std::vector< IPData > & ip_data_vector,
Accessor_CurrentLevelFromIPData const & accessor,
std::tuple< ReflectionData< Classes, Accessors >... > const & refl_data,
std::index_sequence< Idcs... >  )

Definition at line 132 of file ReflectionSetIPData.h.

138{
139 // uses short-circuit evaluation of the fold || ... to stop after the first
140 // match
141 return ((setIPDataIfNameMatches<dim>(name, values, ip_data_vector, accessor,
142 std::get<Idcs>(refl_data))) ||
143 ...);
144}

References setIPDataIfNameMatches().

Referenced by reflectSetIPData(), ProcessLib::Reflection::reflectSetIPData(), and setIPDataIfNameMatches().

◆ setIPData()

template<int dim, typename IPData , typename Accessor >
void ProcessLib::Reflection::detail::setIPData ( double const * values,
std::vector< IPData > & ip_data_vector,
Accessor const & accessor )

Definition at line 24 of file ReflectionSetIPData.h.

27{
28 using AccessorResult = std::invoke_result_t<Accessor, IPData&>;
29 using AccessorResultStripped = std::remove_cvref_t<AccessorResult>;
30
31 static_assert(is_raw_data_v<AccessorResultStripped>,
32 "This method only deals with raw data. The given "
33 "AccessorResultStripped is not raw data.");
34
36
37 auto const num_int_pts = ip_data_vector.size();
38
39 if constexpr (num_comp == 1)
40 {
41 // scalar
42 for (unsigned ip = 0; ip < num_int_pts; ++ip)
43 {
44 accessor(ip_data_vector[ip]) = values[ip];
45 }
46 }
47 else
48 {
49 constexpr auto num_rows = NumberOfRows<AccessorResultStripped>::value;
50 constexpr auto num_cols =
51 NumberOfColumns<AccessorResultStripped>::value;
52 constexpr auto kv_size =
54
55 auto const values_mat =
56 Eigen::Map<Eigen::Matrix<double, num_comp, Eigen::Dynamic,
57 Eigen::ColMajor> const>(values, num_comp,
58 num_int_pts);
59
60 for (unsigned ip = 0; ip < num_int_pts; ++ip)
61 {
62 if constexpr (num_cols == 1 || num_rows == 1)
63 {
64 // vector
65 if constexpr (num_comp == kv_size)
66 {
67 // Kelvin vector
68 accessor(ip_data_vector[ip]) =
70 values_mat.col(ip));
71 }
72 else
73 {
74 // other vector
75 accessor(ip_data_vector[ip]) = values_mat.col(ip);
76 }
77 }
78 else
79 {
80 // matrix
81 accessor(ip_data_vector[ip]) =
82 values_mat.col(ip).template reshaped<Eigen::RowMajor>(
83 num_rows, num_cols);
84 }
85 }
86 }
87}
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
Eigen::Matrix< double, Eigen::MatrixBase< Derived >::RowsAtCompileTime, 1 > symmetricTensorToKelvinVector(Eigen::MatrixBase< Derived > const &v)

References is_raw_data_v, MathLib::KelvinVector::kelvin_vector_dimensions(), and MathLib::KelvinVector::symmetricTensorToKelvinVector().

Referenced by setIPDataIfNameMatches().

◆ setIPDataIfNameMatches()

template<int dim, typename IPData , typename Accessor_CurrentLevelFromIPData , typename Class , typename Accessor >
bool ProcessLib::Reflection::detail::setIPDataIfNameMatches ( std::string_view const name,
double const * values,
std::vector< IPData > & ip_data_vector,
Accessor_CurrentLevelFromIPData const & accessor,
ReflectionData< Class, Accessor > const & refl_data )

Definition at line 93 of file ReflectionSetIPData.h.

97{
98 auto const accessor_next_level = refl_data.accessor;
99
100 using MemberRef = std::invoke_result_t<Accessor, Class&>;
101 using Member = std::remove_cvref_t<MemberRef>;
102
103 auto const accessor_field_from_ip_data =
104 [accessor, accessor_next_level](IPData& ip_data) -> Member&
105 { return accessor_next_level(accessor(ip_data)); };
106
107 if constexpr (detail::is_reflectable<Member>)
108 {
109 return reflectSetIPData<dim>(
110 name, values, ip_data_vector, accessor_field_from_ip_data,
111 detail::reflect(std::type_identity<Member>{}));
112 }
113 else
114 {
115 static_assert(detail::is_raw_data_v<Member>,
116 "The current member is not reflectable, so we "
117 "expect it to be raw data.");
118
119 if (refl_data.name != name)
120 {
121 return false;
122 }
123
124 setIPData<dim>(values, ip_data_vector, accessor_field_from_ip_data);
125
126 return true;
127 }
128}

References ProcessLib::Reflection::ReflectionData< Class, Accessor >::accessor, is_raw_data_v, ProcessLib::Reflection::ReflectionData< Class, Accessor >::name, reflect(), reflectSetIPData(), and setIPData().

Referenced by reflectSetIPData().

Variable Documentation

◆ is_raw_data_v

template<typename T >
bool ProcessLib::Reflection::detail::is_raw_data_v = is_raw_data<T>::value
constexpr