diff --git a/ProcessLib/Reflection/ReflectionSetIPData.h b/ProcessLib/Reflection/ReflectionSetIPData.h index 10ee153a55af65c2c8a6e73f567c641d3b6fef90..27f72d470454a3ceaef26df1e6d6954f02c7fbb4 100644 --- a/ProcessLib/Reflection/ReflectionSetIPData.h +++ b/ProcessLib/Reflection/ReflectionSetIPData.h @@ -34,12 +34,11 @@ void setIPData(double const* values, constexpr auto num_comp = NumberOfComponents<AccessorResultStripped>::value; - auto constexpr kv_size = - MathLib::KelvinVector::kelvin_vector_dimensions(dim); auto const num_int_pts = ip_data_vector.size(); if constexpr (num_comp == 1) { + // scalar for (unsigned ip = 0; ip < num_int_pts; ++ip) { accessor(ip_data_vector[ip]) = values[ip]; @@ -47,6 +46,12 @@ void setIPData(double const* values, } else { + constexpr auto num_rows = NumberOfRows<AccessorResultStripped>::value; + constexpr auto num_cols = + NumberOfColumns<AccessorResultStripped>::value; + constexpr auto kv_size = + MathLib::KelvinVector::kelvin_vector_dimensions(dim); + auto const values_mat = Eigen::Map<Eigen::Matrix<double, num_comp, Eigen::Dynamic, Eigen::ColMajor> const>(values, num_comp, @@ -54,18 +59,29 @@ void setIPData(double const* values, for (unsigned ip = 0; ip < num_int_pts; ++ip) { - if constexpr (num_comp == kv_size) + if constexpr (num_cols == 1 || num_rows == 1) { - accessor(ip_data_vector[ip]) = - MathLib::KelvinVector::symmetricTensorToKelvinVector( - values_mat.col(ip)); + // vector + if constexpr (num_comp == kv_size) + { + // Kelvin vector + accessor(ip_data_vector[ip]) = + MathLib::KelvinVector::symmetricTensorToKelvinVector( + values_mat.col(ip)); + } + else + { + // other vector + accessor(ip_data_vector[ip]) = values_mat.col(ip); + } } else { - accessor(ip_data_vector[ip]) = values_mat.col(ip); + // matrix + accessor(ip_data_vector[ip]) = + values_mat.col(ip).template reshaped<Eigen::RowMajor>( + num_rows, num_cols); } - - // TODO input of matrix valued properties } } }