Skip to content
Snippets Groups Projects
Commit 00f3e84f authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[PL/Refl] Extract common code

parent 74a7fb21
No related branches found
No related tags found
No related merge requests found
...@@ -120,44 +120,27 @@ struct GetFlattenedIPDataFromLocAsm ...@@ -120,44 +120,27 @@ struct GetFlattenedIPDataFromLocAsm
IPDataVectorElement const&>>; IPDataVectorElement const&>>;
constexpr unsigned num_comp = NumberOfComponents<ConcreteIPData>::value; constexpr unsigned num_comp = NumberOfComponents<ConcreteIPData>::value;
auto const& ip_data_vector = accessor_ip_data_vec_in_loc_asm(loc_asm);
auto const num_ips = ip_data_vector.size();
if constexpr (num_comp == 1) std::vector<double> result(num_comp * num_ips);
{
auto const& ip_data_vector =
accessor_ip_data_vec_in_loc_asm(loc_asm);
auto const num_ips = ip_data_vector.size();
std::vector<double> result(num_ips); for (std::size_t ip = 0; ip < num_ips; ++ip)
{
auto const& ip_data_vector_element = ip_data_vector[ip];
auto const& ip_data =
accessor_current_level_from_ip_data_vec_element(
ip_data_vector_element);
// TODO optimization if nothing needs to be copied? if constexpr (num_comp == 1)
for (std::size_t ip = 0; ip < num_ips; ++ip)
{ {
auto const& ip_data_vector_element = ip_data_vector[ip]; // TODO optimization if nothing needs to be copied?
auto const& ip_data =
accessor_current_level_from_ip_data_vec_element(
ip_data_vector_element);
result[ip] = ip_data; result[ip] = ip_data;
} }
else if constexpr (num_comp ==
return result; MathLib::KelvinVector::kelvin_vector_dimensions(
} Dim))
else if constexpr (num_comp ==
MathLib::KelvinVector::kelvin_vector_dimensions(Dim))
{
auto const& ip_data_vector =
accessor_ip_data_vec_in_loc_asm(loc_asm);
auto const num_ips = ip_data_vector.size();
std::vector<double> result(num_comp * num_ips);
for (std::size_t ip = 0; ip < num_ips; ++ip)
{ {
auto const& ip_data_vector_element = ip_data_vector[ip];
auto const& ip_data =
accessor_current_level_from_ip_data_vec_element(
ip_data_vector_element);
auto const converted = auto const converted =
MathLib::KelvinVector::kelvinVectorToSymmetricTensor( MathLib::KelvinVector::kelvinVectorToSymmetricTensor(
ip_data); ip_data);
...@@ -167,32 +150,15 @@ struct GetFlattenedIPDataFromLocAsm ...@@ -167,32 +150,15 @@ struct GetFlattenedIPDataFromLocAsm
result[ip * num_comp + comp] = converted[comp]; result[ip * num_comp + comp] = converted[comp];
} }
} }
else
return result;
}
else
{
auto const& ip_data_vector =
accessor_ip_data_vec_in_loc_asm(loc_asm);
auto const num_ips = ip_data_vector.size();
std::vector<double> result(num_comp * num_ips);
for (std::size_t ip = 0; ip < num_ips; ++ip)
{ {
auto const& ip_data_vector_element = ip_data_vector[ip];
auto const& ip_data =
accessor_current_level_from_ip_data_vec_element(
ip_data_vector_element);
for (unsigned comp = 0; comp < num_comp; ++comp) for (unsigned comp = 0; comp < num_comp; ++comp)
{ {
result[ip * num_comp + comp] = ip_data[comp]; result[ip * num_comp + comp] = ip_data[comp];
} }
} }
return result;
} }
return result;
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment