21 namespace ShallowWater
26 using namespace dealii;
28 template <
typename Description,
int dim,
typename Number>
31 std::map<std::string, dealii::Timer> &computing_timer,
35 const std::string &subsection )
36 : ParameterAcceptor(subsection)
38 , indicator_parameters_(subsection +
"/indicator")
39 , limiter_parameters_(subsection +
"/limiter")
40 , riemann_solver_parameters_(subsection +
"/riemann solver")
41 , mpi_ensemble_(mpi_ensemble)
42 , computing_timer_(computing_timer)
43 , offline_data_(&offline_data)
44 , hyperbolic_system_(&hyperbolic_system)
45 , initial_values_(&initial_values)
53 template <
typename Description,
int dim,
typename Number>
57 std::cout <<
"HyperbolicModule<Description, dim, Number>::prepare()"
61 AssertThrow(limiter_parameters_.iterations() <= 2,
63 "The number of limiter iterations must be between [0,2]"));
67 const auto &scalar_partitioner = offline_data_->scalar_partitioner();
68 alpha_.reinit(scalar_partitioner);
69 bounds_.reinit_with_scalar_partitioner(scalar_partitioner);
71 r_.reinit(offline_data_->hyperbolic_vector_partitioner());
77 const auto &sparsity_simd = offline_data_->sparsity_pattern_simd();
78 dij_matrix_.reinit(sparsity_simd);
79 lij_matrix_.reinit(sparsity_simd);
80 lij_matrix_next_.reinit(sparsity_simd);
81 pij_matrix_.reinit(sparsity_simd);
85 initial_precomputed_ =
86 initial_values_->interpolate_initial_precomputed_vector();
97 template <
typename Description,
int dim,
typename Number>
102 std::cout <<
"HyperbolicModule<Description, dim, "
103 "Number>::prepare_state_vector()"
107 auto &U = std::get<0>(state_vector);
108 auto &precomputed = std::get<1>(state_vector);
110 const unsigned int n_export_indices = offline_data_->n_export_indices();
111 const unsigned int n_internal = offline_data_->n_locally_internal();
112 const unsigned int n_owned = offline_data_->n_locally_owned();
113 const auto &sparsity_simd = offline_data_->sparsity_pattern_simd();
114 const auto &boundary_map = offline_data_->boundary_map();
115 unsigned int channel = 10;
116 using VA = VectorizedArray<Number>;
118 Scope scope(computing_timer_,
119 "time step [H] 1 - update boundary values, precompute values");
124 for (
const auto &entry : boundary_map) {
125 const auto &[i, normal, normal_mass, boundary_mass, id, position] = entry;
135 auto U_i = U.get_tensor(i);
138 auto get_dirichlet_data = [position = position, t = t,
this]() {
139 return initial_values_->initial_state(position, t);
142 const auto view = hyperbolic_system_->template view<dim, Number>();
143 U_i = view.apply_boundary_conditions(
id, U_i, normal, get_dirichlet_data);
144 U.write_tensor(U_i, i);
149 U.update_ghost_values();
155 if constexpr (n_precomputation_cycles != 0) {
156 for (
unsigned int cycle = 0; cycle < n_precomputation_cycles; ++cycle) {
159 precomputed.update_ghost_values_start(channel++);
160 precomputed.update_ghost_values_finish();
166 auto loop = [&](
auto sentinel,
unsigned int left,
unsigned int right) {
167 using T =
decltype(sentinel);
170 bool thread_ready =
false;
172 const auto view = hyperbolic_system_->template view<dim, T>();
173 view.precomputation_loop(
175 [&](
const unsigned int i) {
176 synchronization_dispatch.check(
177 thread_ready, i >= n_export_indices && i < n_internal);
186 loop(Number(), n_internal, n_owned);
188 loop(VA(), 0, n_internal);
210 template <
typename T>
211 bool all_below_diagonal(
unsigned int i,
const unsigned int *js)
213 if constexpr (std::is_same_v<T, typename get_value_type<T>::type>) {
221 constexpr auto simd_length = T::size();
223 bool all_below_diagonal =
true;
224 for (
unsigned int k = 0; k < simd_length; ++k)
225 if (js[k] >= i + k) {
226 all_below_diagonal =
false;
229 return all_below_diagonal;
235 template <
typename Description,
int dim,
typename Number>
236 template <
int stages>
239 std::array<std::reference_wrapper<const StateVector>, stages>
241 const std::array<Number, stages> stage_weights,
244 std::atomic<Number> tau_max )
const
247 std::cout <<
"HyperbolicModule<Description, dim, Number>::step()"
251 auto &old_U = std::get<0>(old_state_vector);
252 auto &old_precomputed = std::get<1>(old_state_vector);
253 auto &new_U = std::get<0>(new_state_vector);
271 constexpr bool shallow_water =
272 std::is_same_v<Description, ShallowWater::Description>;
274 using VA = VectorizedArray<Number>;
278 constexpr auto simd_length = VA::size();
279 const unsigned int n_export_indices = offline_data_->n_export_indices();
280 const unsigned int n_internal = offline_data_->n_locally_internal();
281 const unsigned int n_owned = offline_data_->n_locally_owned();
285 const auto &sparsity_simd = offline_data_->sparsity_pattern_simd();
287 const auto &mass_matrix = offline_data_->mass_matrix();
288 const auto &mass_matrix_inverse = offline_data_->mass_matrix_inverse();
289 const auto &lumped_mass_matrix = offline_data_->lumped_mass_matrix();
290 const auto &lumped_mass_matrix_inverse =
291 offline_data_->lumped_mass_matrix_inverse();
293 const auto &cij_matrix = offline_data_->cij_matrix();
294 const auto &incidence_matrix = offline_data_->incidence_matrix();
296 const auto &coupling_boundary_pairs =
297 offline_data_->coupling_boundary_pairs();
299 const Number measure_of_omega_inverse =
300 Number(1.) / offline_data_->measure_of_omega();
303 unsigned int channel = 10;
307 const auto scoped_name = [&step_no](
const auto &name,
308 const bool advance =
true) {
309 advance || step_no--;
310 return "time step [H] " + std::to_string(++step_no) +
" - " + name;
314 std::atomic<bool> restart_needed =
false;
343 Scope scope(computing_timer_, scoped_name(
"compute d_ij, and alpha_i"));
346 alpha_.update_ghost_values_start(channel++);
347 alpha_.update_ghost_values_finish();
353 auto loop = [&](
auto sentinel,
unsigned int left,
unsigned int right) {
354 using T =
decltype(sentinel);
355 unsigned int stride_size = get_stride_size<T>;
362 *hyperbolic_system_, riemann_solver_parameters_, old_precomputed);
366 *hyperbolic_system_, indicator_parameters_, old_precomputed);
368 bool thread_ready =
false;
371 for (
unsigned int i = left; i < right; i += stride_size) {
374 const unsigned int row_length = sparsity_simd.row_length(i);
378 synchronization_dispatch.check(
379 thread_ready, i >= n_export_indices && i < n_internal);
381 const auto U_i = old_U.template get_tensor<T>(i);
383 indicator.
reset(i, U_i);
385 const unsigned int *js = sparsity_simd.columns(i);
386 for (
unsigned int col_idx = 0; col_idx < row_length;
387 ++col_idx, js += stride_size) {
389 const auto U_j = old_U.template get_tensor<T>(js);
391 const auto c_ij = cij_matrix.template get_tensor<T>(i, col_idx);
400 if (all_below_diagonal<T>(i, js))
403 const auto norm = c_ij.norm();
404 const auto n_ij = c_ij / norm;
405 const auto lambda_max =
406 riemann_solver.
compute(U_i, U_j, i, js, n_ij);
407 const auto d_ij = norm * lambda_max;
409 dij_matrix_.write_entry(d_ij, i, col_idx,
true);
412 const auto mass = get_entry<T>(lumped_mass_matrix, i);
413 const auto hd_i = mass * measure_of_omega_inverse;
414 write_entry<T>(alpha_, indicator.
alpha(hd_i), i);
419 loop(Number(), n_internal, n_owned);
421 loop(VA(), 0, n_internal);
434 Scope scope(computing_timer_,
435 scoped_name(
"compute bdry d_ij, diag d_ii, and tau_max"));
453 *hyperbolic_system_, riemann_solver_parameters_, old_precomputed);
455 Number local_tau_max = std::numeric_limits<Number>::max();
463 for (std::size_t k = 0; k < coupling_boundary_pairs.size(); ++k) {
464 const auto &[i, col_idx, j] = coupling_boundary_pairs[k];
477 const auto U_i = old_U.get_tensor(i);
478 const auto U_j = old_U.get_tensor(j);
480 const auto c_ji = cij_matrix.get_transposed_tensor(i, col_idx);
481 Assert(c_ji.norm() > 1.e-12, ExcInternalError());
482 const auto norm_ji = c_ji.norm();
483 const auto n_ji = c_ji / norm_ji;
485 const auto d_ij = dij_matrix_.get_entry(i, col_idx);
487 const auto lambda_max = riemann_solver.
compute(U_j, U_i, j, &i, n_ji);
488 const auto d_ji = norm_ji * lambda_max;
490 dij_matrix_.write_entry(std::max(d_ij, d_ji), i, col_idx);
496 for (
unsigned int i = 0; i < n_owned; ++i) {
499 const unsigned int row_length = sparsity_simd.row_length(i);
503 Number d_sum = Number(0.);
506 const unsigned int *js = sparsity_simd.columns(i);
507 for (
unsigned int col_idx = 1; col_idx < row_length; ++col_idx) {
509 *(i < n_internal ? js + col_idx * simd_length : js + col_idx);
513 const auto d_ji = dij_matrix_.get_transposed_entry(i, col_idx);
518 const auto U_i = old_U.get_tensor(i);
519 const auto U_j = old_U.get_tensor(j);
521 const auto c_ij = cij_matrix.get_tensor(i, col_idx);
522 Assert(c_ij.norm() > 1.e-12, ExcInternalError());
523 const auto norm_ij = c_ij.norm();
524 const auto n_ij = c_ij / norm_ij;
526 const auto lambda_max =
527 riemann_solver.
compute(U_i, U_j, i, &j, n_ij);
528 const auto d_ij = norm_ij * lambda_max;
530 Assert(d_ij <= d_ji + 1.0e-12,
531 dealii::ExcMessage(
"d_ij not symmetrized correctly on "
532 "boundary degrees of freedom."));
535 dij_matrix_.write_entry(d_ji, i, col_idx);
538 d_sum -= dij_matrix_.get_entry(i, col_idx);
547 std::min(d_sum, Number(-1.e6) * std::numeric_limits<Number>::min());
550 dij_matrix_.write_entry(d_sum, i, 0);
552 const Number mass = lumped_mass_matrix.local_element(i);
553 const Number tau = cfl_ * mass / (Number(-2.) * d_sum);
554 local_tau_max = std::min(local_tau_max, tau);
558 Number current_tau_max = tau_max.load();
559 while (current_tau_max > local_tau_max &&
560 !tau_max.compare_exchange_weak(current_tau_max, local_tau_max))
568 Scope scope(computing_timer_,
569 "time step [H] _ - synchronization barriers");
575 tau_max.store(Utilities::MPI::min(
576 tau_max.load(), mpi_ensemble_.synchronization_communicator()));
579 !std::isnan(tau_max) && !std::isinf(tau_max) && tau_max > 0.,
581 "I'm sorry, Dave. I'm afraid I can't do that.\nWe crashed."));
583 tau = (tau == Number(0.) ? tau_max.load() : tau);
586 std::cout <<
" computed tau_max = " << tau_max << std::endl;
587 std::cout <<
" perform time-step with tau = " << tau << std::endl;
593 dij_matrix_.update_ghost_rows();
603 Scope scope(computing_timer_,
604 scoped_name(
"l.-o. update, compute bounds, r_i, and p_ij"));
607 r_.update_ghost_values_start(channel++);
608 r_.update_ghost_values_finish();
609 if (offline_data_->discretization().have_discontinuous_ansatz()) {
615 bounds_.update_ghost_values_start(channel++);
616 bounds_.update_ghost_values_finish();
620 const Number weight =
621 -std::accumulate(stage_weights.begin(), stage_weights.end(), -1.);
627 auto loop = [&](
auto sentinel,
628 auto have_discontinuous_ansatz,
630 unsigned int right) {
631 using T =
decltype(sentinel);
635 using flux_contribution_type =
typename View::flux_contribution_type;
638 unsigned int stride_size = get_stride_size<T>;
640 const auto view = hyperbolic_system_->template view<dim, T>();
644 *hyperbolic_system_, limiter_parameters_, old_precomputed);
645 bool thread_ready =
false;
648 for (
unsigned int i = left; i < right; i += stride_size) {
651 const unsigned int row_length = sparsity_simd.row_length(i);
655 synchronization_dispatch.check(
656 thread_ready, i >= n_export_indices && i < n_internal);
658 const auto U_i = old_U.template get_tensor<T>(i);
661 const auto alpha_i = get_entry<T>(alpha_, i);
662 const auto m_i = get_entry<T>(lumped_mass_matrix, i);
663 const auto m_i_inv = get_entry<T>(lumped_mass_matrix_inverse, i);
665 const auto flux_i = view.flux_contribution(
666 old_precomputed, initial_precomputed_, i, U_i);
668 std::array<flux_contribution_type, stages> flux_iHs;
671 for (
int s = 0; s < stages; ++s) {
672 const auto &[U_s, prec_s, V_s] = stage_state_vectors[s].get();
674 const auto U_iHs = U_s.template get_tensor<T>(i);
676 view.flux_contribution(prec_s, initial_precomputed_, i, U_iHs);
678 if constexpr (View::have_source_terms) {
680 stage_weights[s] * view.nodal_source(prec_s, i, U_iHs, tau);
687 if constexpr (View::have_source_terms) {
688 S_i = view.nodal_source(old_precomputed, i, U_i, tau);
689 S_iH += weight * S_i;
690 U_i_new += tau * S_i;
694 limiter.
reset(i, U_i, flux_i);
704 const unsigned int *js = sparsity_simd.columns(i);
705 if constexpr (shallow_water) {
706 for (
unsigned int col_idx = 0; col_idx < row_length;
707 ++col_idx, js += stride_size) {
709 const auto U_j = old_U.template get_tensor<T>(js);
710 const auto flux_j = view.flux_contribution(
711 old_precomputed, initial_precomputed_, js, U_j);
713 const auto d_ij = dij_matrix_.template get_entry<T>(i, col_idx);
714 const auto c_ij = cij_matrix.template get_tensor<T>(i, col_idx);
716 const auto B_ij = view.affine_shift(flux_i, flux_j, c_ij, d_ij);
717 affine_shift += B_ij;
720 affine_shift *= tau * m_i_inv;
723 if constexpr (View::have_source_terms) {
724 affine_shift += tau * S_i;
727 js = sparsity_simd.columns(i);
728 for (
unsigned int col_idx = 0; col_idx < row_length;
729 ++col_idx, js += stride_size) {
731 const auto U_j = old_U.template get_tensor<T>(js);
733 const auto alpha_j = get_entry<T>(alpha_, js);
735 const auto d_ij = dij_matrix_.template get_entry<T>(i, col_idx);
736 auto factor = (alpha_i + alpha_j) * Number(.5);
738 if constexpr (have_discontinuous_ansatz) {
739 const auto incidence_ij =
740 incidence_matrix.template get_entry<T>(i, col_idx);
741 factor = std::max(factor, incidence_ij);
744 const auto d_ijH = d_ij * factor;
754 dij_matrix_.template get_transposed_entry<T>(i, col_idx);
755 Assert(std::max(std::abs(d_ij - d_ji), T(1.0e-12)) == T(1.0e-12),
757 "d_ij not symmetrized correctly over MPI ranks"));
760 const auto c_ij = cij_matrix.template get_tensor<T>(i, col_idx);
761 constexpr auto eps = std::numeric_limits<Number>::epsilon();
762 const auto scale = dealii::compare_and_apply_mask<
763 dealii::SIMDComparison::less_than>(
764 std::abs(d_ij), T(eps * eps), T(0.), T(1.) / d_ij);
765 const auto scaled_c_ij = c_ij * scale;
767 const auto flux_j = view.flux_contribution(
768 old_precomputed, initial_precomputed_, js, U_j);
770 const auto m_ij = mass_matrix.template get_entry<T>(i, col_idx);
776 const auto flux_ij = view.flux_divergence(flux_i, flux_j, c_ij);
777 U_i_new += tau * m_i_inv * flux_ij;
778 auto P_ij = -flux_ij;
780 if constexpr (shallow_water) {
785 const auto &[U_star_ij, U_star_ji] =
786 view.equilibrated_states(flux_i, flux_j);
788 U_i_new += tau * m_i_inv * d_ij * (U_star_ji - U_star_ij);
789 F_iH += d_ijH * (U_star_ji - U_star_ij);
790 P_ij += (d_ijH - d_ij) * (U_star_ji - U_star_ij);
793 U_j, U_star_ij, U_star_ji, scaled_c_ij, affine_shift);
797 U_i_new += tau * m_i_inv * d_ij * (U_j - U_i);
798 F_iH += d_ijH * (U_j - U_i);
799 P_ij += (d_ijH - d_ij) * (U_j - U_i);
801 limiter.
accumulate(js, U_j, flux_j, scaled_c_ij, affine_shift);
804 if constexpr (View::have_source_terms) {
813 if constexpr (View::have_high_order_flux) {
814 const auto high_order_flux_ij =
815 view.high_order_flux_divergence(flux_i, flux_j, c_ij);
816 F_iH += weight * high_order_flux_ij;
817 P_ij += weight * high_order_flux_ij;
819 F_iH += weight * flux_ij;
820 P_ij += weight * flux_ij;
823 if constexpr (View::have_source_terms) {
824 const auto S_j = view.nodal_source(old_precomputed, js, U_j, tau);
825 F_iH += weight * m_ij * S_j;
826 P_ij += weight * m_ij * S_j;
829 for (
int s = 0; s < stages; ++s) {
830 const auto &[U_s, prec_s, V_s] = stage_state_vectors[s].get();
832 const auto U_jHs = U_s.template get_tensor<T>(js);
833 const auto flux_jHs = view.flux_contribution(
834 prec_s, initial_precomputed_, js, U_jHs);
836 if constexpr (View::have_high_order_flux) {
837 const auto high_order_flux_ij = view.high_order_flux_divergence(
838 flux_iHs[s], flux_jHs, c_ij);
839 F_iH += stage_weights[s] * high_order_flux_ij;
840 P_ij += stage_weights[s] * high_order_flux_ij;
843 view.flux_divergence(flux_iHs[s], flux_jHs, c_ij);
844 F_iH += stage_weights[s] * flux_ij;
845 P_ij += stage_weights[s] * flux_ij;
848 if constexpr (View::have_source_terms) {
849 const auto S_js = view.nodal_source(prec_s, js, U_jHs, tau);
850 F_iH += stage_weights[s] * m_ij * S_js;
851 P_ij += stage_weights[s] * m_ij * S_js;
855 pij_matrix_.write_entry(P_ij, i, col_idx,
true);
858#ifdef EXPENSIVE_BOUNDS_CHECK
859 if (!view.is_admissible(U_i_new)) {
860 restart_needed =
true;
864 new_U.template write_tensor<T>(U_i_new, i);
865 r_.template write_tensor<T>(F_iH, i);
867 const auto hd_i = m_i * measure_of_omega_inverse;
868 const auto relaxed_bounds = limiter.
bounds(hd_i);
869 bounds_.template write_tensor<T>(relaxed_bounds, i);
879 if (offline_data_->discretization().have_discontinuous_ansatz()) {
881 loop(Number(), std::true_type{}, n_internal, n_owned);
882 loop(VA(), std::true_type{}, 0, n_internal);
885 loop(Number(), std::false_type{}, n_internal, n_owned);
886 loop(VA(), std::false_type{}, 0, n_internal);
899 if (limiter_parameters_.iterations() != 0) {
900 Scope scope(computing_timer_, scoped_name(
"compute p_ij, and l_ij"));
903 lij_matrix_.update_ghost_rows_start(channel++);
904 lij_matrix_.update_ghost_rows_finish();
910 auto loop = [&](
auto sentinel,
911 auto have_discontinuous_ansatz,
913 unsigned int right) {
914 using T =
decltype(sentinel);
919 unsigned int stride_size = get_stride_size<T>;
923 *hyperbolic_system_, limiter_parameters_, old_precomputed);
924 bool thread_ready =
false;
927 for (
unsigned int i = left; i < right; i += stride_size) {
930 const unsigned int row_length = sparsity_simd.row_length(i);
934 synchronization_dispatch.check(
935 thread_ready, i >= n_export_indices && i < n_internal);
938 bounds_.template get_tensor<T, std::array<T, n_bounds>>(i);
945 if constexpr (have_discontinuous_ansatz) {
947 const unsigned int *js = sparsity_simd.columns(i) + stride_size;
948 for (
unsigned int col_idx = 1; col_idx < row_length;
949 ++col_idx, js += stride_size) {
952 bounds_.template get_tensor<T, std::array<T, n_bounds>>(js));
954 bounds_.template write_tensor<T>(bounds, i);
957 [[maybe_unused]] T m_i;
958 if constexpr (have_discontinuous_ansatz)
959 m_i = get_entry<T>(lumped_mass_matrix, i);
960 const auto m_i_inv = get_entry<T>(lumped_mass_matrix_inverse, i);
962 const auto U_i_new = new_U.template get_tensor<T>(i);
964 const auto F_iH = r_.template get_tensor<T>(i);
966 const auto lambda_inv = Number(row_length - 1);
967 const auto factor = tau * m_i_inv * lambda_inv;
970 const unsigned int *js = sparsity_simd.columns(i) + stride_size;
971 for (
unsigned int col_idx = 1; col_idx < row_length;
972 ++col_idx, js += stride_size) {
974 auto P_ij = pij_matrix_.template get_tensor<T>(i, col_idx);
975 const auto F_jH = r_.template get_tensor<T>(js);
981 const auto kronecker_ij = col_idx == 0 ? T(1.) : T(0.);
983 if constexpr (have_discontinuous_ansatz) {
986 const auto m_j = get_entry<T>(lumped_mass_matrix, js);
987 const auto m_ij_inv =
988 mass_matrix_inverse.template get_entry<T>(i, col_idx);
989 const auto b_ij = m_i * m_ij_inv - kronecker_ij;
990 const auto b_ji = m_j * m_ij_inv - kronecker_ij;
992 P_ij += b_ij * F_jH - b_ji * F_iH;
997 const auto m_j_inv = get_entry<T>(lumped_mass_matrix_inverse, js);
998 const auto m_ij = mass_matrix.template get_entry<T>(i, col_idx);
999 const auto b_ij = kronecker_ij - m_ij * m_j_inv;
1000 const auto b_ji = kronecker_ij - m_ij * m_i_inv;
1002 P_ij += b_ij * F_jH - b_ji * F_iH;
1006 pij_matrix_.write_entry(P_ij, i, col_idx);
1012 const auto &[l_ij, success] = limiter.
limit(bounds, U_i_new, P_ij);
1013 lij_matrix_.template write_entry<T>(l_ij, i, col_idx,
true);
1025 restart_needed =
true;
1036 if (offline_data_->discretization().have_discontinuous_ansatz()) {
1038 loop(Number(), std::true_type{}, n_internal, n_owned);
1039 loop(VA(), std::true_type{}, 0, n_internal);
1042 loop(Number(), std::false_type{}, n_internal, n_owned);
1043 loop(VA(), std::false_type{}, 0, n_internal);
1060 const auto n_iterations = limiter_parameters_.iterations();
1061 for (
unsigned int pass = 0; pass < n_iterations; ++pass) {
1062 bool last_round = (pass + 1 == n_iterations);
1064 std::string additional_step = (last_round ?
"" :
", next l_ij");
1067 scoped_name(
"symmetrize l_ij, h.-o. update" + additional_step));
1069 if ((n_iterations == 2) && last_round) {
1070 std::swap(lij_matrix_, lij_matrix_next_);
1075 lij_matrix_next_.update_ghost_rows_start(channel++);
1076 lij_matrix_next_.update_ghost_rows_finish();
1083 auto loop = [&](
auto sentinel,
unsigned int left,
unsigned int right) {
1084 using T =
decltype(sentinel);
1089 unsigned int stride_size = get_stride_size<T>;
1092 AlignedVector<T> lij_row;
1094 *hyperbolic_system_, limiter_parameters_, old_precomputed);
1095 bool thread_ready =
false;
1098 for (
unsigned int i = left; i < right; i += stride_size) {
1101 const unsigned int row_length = sparsity_simd.row_length(i);
1102 if (row_length == 1)
1105 synchronization_dispatch.check(
1106 thread_ready, i >= n_export_indices && i < n_internal);
1108 auto U_i_new = new_U.template get_tensor<T>(i);
1110 const Number lambda = Number(1.) / Number(row_length - 1);
1111 lij_row.resize_fast(row_length);
1114 for (
unsigned int col_idx = 1; col_idx < row_length; ++col_idx) {
1116 const auto l_ij = std::min(
1117 lij_matrix_.template get_entry<T>(i, col_idx),
1118 lij_matrix_.template get_transposed_entry<T>(i, col_idx));
1120 const auto p_ij = pij_matrix_.template get_tensor<T>(i, col_idx);
1122 U_i_new += l_ij * lambda * p_ij;
1125 lij_row[col_idx] = l_ij;
1128#ifdef EXPENSIVE_BOUNDS_CHECK
1129 const auto view = hyperbolic_system_->template view<dim, T>();
1130 if (!view.is_admissible(U_i_new)) {
1131 restart_needed =
true;
1135 new_U.template write_tensor<T>(U_i_new, i);
1142 bounds_.template get_tensor<T, std::array<T, n_bounds>>(i);
1144 for (
unsigned int col_idx = 1; col_idx < row_length; ++col_idx) {
1146 const auto old_l_ij = lij_row[col_idx];
1148 const auto new_p_ij =
1149 (T(1.) - old_l_ij) *
1150 pij_matrix_.template get_tensor<T>(i, col_idx);
1152 const auto &[new_l_ij, success] =
1153 limiter.
limit(bounds, U_i_new, new_p_ij);
1165#ifdef EXPENSIVE_BOUNDS_CHECK
1167 restart_needed =
true;
1176 const auto entry = (T(1.) - old_l_ij) * new_l_ij;
1177 lij_matrix_next_.write_entry(entry, i, col_idx,
true);
1183 loop(Number(), n_internal, n_owned);
1185 loop(VA(), 0, n_internal);
1198 Scope scope(computing_timer_,
1199 "time step [H] _ - synchronization barriers");
1208 restart_needed.store(Utilities::MPI::logical_or(
1209 restart_needed.load(), mpi_ensemble_.synchronization_communicator()));
1212 if (restart_needed) {
1213 switch (id_violation_strategy_) {
1224 Vectors::debug_poison_precomputed_values<Description>(new_state_vector,
HyperbolicModule(const MPIEnsemble &mpi_ensemble, std::map< std::string, dealii::Timer > &computing_timer, const OfflineData< dim, Number > &offline_data, const HyperbolicSystem &hyperbolic_system, const InitialValues< Description, dim, Number > &initial_values, const std::string &subsection="/HyperbolicModule")
typename Description::HyperbolicSystem HyperbolicSystem
typename View::StateVector StateVector
typename View::state_type state_type
typename Description::template HyperbolicSystemView< dim, Number > View
Number step(const StateVector &old_state_vector, std::array< std::reference_wrapper< const StateVector >, stages > stage_state_vectors, const std::array< Number, stages > stage_weights, StateVector &new_state_vector, Number tau=Number(0.), std::atomic< Number > tau_max=std::numeric_limits< Number >::max()) const
void prepare_state_vector(StateVector &state_vector, Number t) const
void reset(const unsigned int i, const state_type &U_i)
void accumulate(const unsigned int *js, const state_type &U_j, const dealii::Tensor< 1, dim, Number > &c_ij)
Number alpha(const Number h_i) const
Bounds combine_bounds(const Bounds &bounds_left, const Bounds &bounds_right) const
void reset(const unsigned int i, const state_type &U_i, const flux_contribution_type &flux_i)
std::tuple< Number, bool > limit(const Bounds &bounds, const state_type &U, const state_type &P, const Number t_min=Number(0.), const Number t_max=Number(1.))
Bounds bounds(const Number hd_i) const
void accumulate(const unsigned int *js, const state_type &U_j, const flux_contribution_type &flux_j, const dealii::Tensor< 1, dim, Number > &scaled_c_ij, const state_type &affine_shift)
Number compute(const Number &u_i, const Number &u_j, const precomputed_type &prec_i, const precomputed_type &prec_j, const dealii::Tensor< 1, dim, Number > &n_ij) const
#define RYUJIN_PARALLEL_REGION_BEGIN
#define RYUJIN_PARALLEL_REGION_END
#define LIKWID_MARKER_START(opt)
#define CALLGRIND_START_INSTRUMENTATION
#define LIKWID_MARKER_STOP(opt)
#define CALLGRIND_STOP_INSTRUMENTATION