12 template <
typename Description,
int dim,
typename Number>
25 static void check(
const std::vector<std::string> &selected)
27 const auto search = [&](
const auto entry,
const auto &names) {
28 const auto pos = std::find(std::begin(names), std::end(names), entry);
29 return pos != std::end(names);
32 for (
const auto &entry : selected) {
33 const auto found = search(entry, View::component_names) ||
34 search(entry, View::primitive_component_names) ||
35 search(entry, View::precomputed_names) ||
36 search(entry, View::initial_precomputed_names) ||
41 "Invalid component name: \"" + entry +
42 "\" is not a valid conserved/primitive/precomputed/initial "
47 static std::vector<ScalarVector>
52 const std::vector<std::string> &selected)
60 std::vector<std::tuple<std::size_t, std::size_t>> conserved_indices;
61 std::vector<std::tuple<std::size_t, std::size_t>> primitive_indices;
62 std::vector<std::tuple<std::size_t, std::size_t>> precomputed_indices;
63 std::vector<std::tuple<std::size_t, std::size_t>> initial_indices;
64 std::vector<std::size_t> alpha_indices;
66 for (std::size_t i = 0;
const auto &entry : selected) {
67 const auto search = [&](
const auto &names,
auto &indices) {
68 const auto pos = std::find(std::begin(names), std::end(names), entry);
69 if (pos != std::end(names)) {
70 const auto index = std::distance(std::begin(names), pos);
71 indices.push_back({i++, index});
77 if (search(View::component_names, conserved_indices))
79 else if (search(View::primitive_component_names, primitive_indices))
81 else if (search(View::precomputed_names, precomputed_indices))
83 else if (search(View::initial_precomputed_names, initial_indices))
85 else if (entry ==
"alpha")
86 alpha_indices.push_back(i++);
88 AssertThrow(
false, dealii::ExcInternalError());
91 std::vector<ScalarVector> extracted_components(selected.size());
92 const auto &scalar_partitioner = alpha.get_partitioner();
93 for (
auto &it : extracted_components)
94 it.reinit(scalar_partitioner);
96 for (
const auto &[i, k] : conserved_indices) {
97 const auto &U = std::get<0>(state_vector);
98 U.extract_component(extracted_components[i], k);
101 if (!primitive_indices.empty()) {
102 const auto &U = std::get<0>(state_vector);
103 const unsigned int n_owned = scalar_partitioner->locally_owned_size();
104 const auto view = hyperbolic_system.template view<dim, Number>();
105 for (
unsigned int i = 0; i < n_owned; ++i) {
106 const auto U_i = U.get_tensor(i);
107 const auto PU_i = view.to_primitive_state(U_i);
108 for (
const auto &[j, k] : primitive_indices)
109 extracted_components[j].local_element(i) = PU_i[k];
113 for (
const auto &[i, k] : precomputed_indices) {
114 const auto &prec = std::get<1>(state_vector);
115 prec.extract_component(extracted_components[i], k);
118 for (
const auto &[i, k] : initial_indices) {
119 initial_precomputed.extract_component(extracted_components[i], k);
122 for (
const auto &i : alpha_indices)
123 extracted_components[i] = alpha;
125 return extracted_components;
dealii::LinearAlgebra::distributed::Vector< Number > ScalarVector
std::tuple< MultiComponentVector< Number, problem_dim >, MultiComponentVector< Number, prec_dim >, BlockVector< Number > > StateVector
Euler::HyperbolicSystem HyperbolicSystem