23template <
int dim,
typename IPData,
typename Accessor>
25 std::vector<IPData>& ip_data_vector,
26 Accessor
const& accessor)
28 using AccessorResult = std::invoke_result_t<Accessor, IPData&>;
29 using AccessorResultStripped = std::remove_cvref_t<AccessorResult>;
31 static_assert(is_raw_data_v<AccessorResultStripped>,
32 "This method only deals with raw data. The given "
33 "AccessorResultStripped is not raw data.");
37 auto const num_int_pts = ip_data_vector.size();
39 if constexpr (num_comp == 1)
42 for (
unsigned ip = 0; ip < num_int_pts; ++ip)
44 accessor(ip_data_vector[ip]) = values[ip];
50 constexpr auto num_cols =
52 constexpr auto kv_size =
55 auto const values_mat =
56 Eigen::Map<Eigen::Matrix<double, num_comp, Eigen::Dynamic,
57 Eigen::ColMajor>
const>(values, num_comp,
60 for (
unsigned ip = 0; ip < num_int_pts; ++ip)
62 if constexpr (num_cols == 1 || num_rows == 1)
65 if constexpr (num_comp == kv_size)
68 accessor(ip_data_vector[ip]) =
75 accessor(ip_data_vector[ip]) = values_mat.col(ip);
81 accessor(ip_data_vector[ip]) =
82 values_mat.col(ip).template reshaped<Eigen::RowMajor>(
91template <
int dim,
typename IPData,
typename Accessor_CurrentLevelFromIPData,
92 typename Class,
typename Accessor>
94 std::vector<IPData>& ip_data_vector,
95 Accessor_CurrentLevelFromIPData
const& accessor,
98 auto const accessor_next_level = refl_data.
accessor;
100 using MemberRef = std::invoke_result_t<Accessor, Class&>;
101 using Member = std::remove_cvref_t<MemberRef>;
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)); };
109 return reflectSetIPData<dim>(
110 name, values, ip_data_vector, accessor_field_from_ip_data,
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.");
119 if (refl_data.
name != name)
124 setIPData<dim>(values, ip_data_vector, accessor_field_from_ip_data);
130template <
int dim,
typename IPData,
typename Accessor_CurrentLevelFromIPData,
131 typename... Classes,
typename... Accessors, std::size_t... Idcs>
133 std::string_view
const name,
double const* values,
134 std::vector<IPData>& ip_data_vector,
135 Accessor_CurrentLevelFromIPData
const& accessor,
137 std::index_sequence<Idcs...>)
141 return ((setIPDataIfNameMatches<dim>(name, values, ip_data_vector, accessor,
142 std::get<Idcs>(refl_data))) ||
146template <
int dim,
typename IPData,
typename Accessor_CurrentLevelFromIPData,
147 typename... Classes,
typename... Accessors>
149 std::string_view
const name,
double const* values,
150 std::vector<IPData>& ip_data_vector,
151 Accessor_CurrentLevelFromIPData
const& accessor,
154 return reflectSetIPData<dim>(
155 name, values, ip_data_vector, accessor, refl_data,
156 std::make_index_sequence<
sizeof...(Classes)>{});
169template <
int dim,
typename IPData>
171 std::vector<IPData>& ip_data_vector)
173 detail::reflectSetIPData<dim>(
174 name, values, ip_data_vector, std::identity{},
177 return ip_data_vector.size();
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)
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)
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... >)
void setIPData(double const *values, std::vector< IPData > &ip_data_vector, Accessor const &accessor)
auto reflect(std::type_identity< std::tuple< Ts... > >)
std::size_t reflectSetIPData(std::string_view const name, double const *values, std::vector< IPData > &ip_data_vector)