Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <algorithm>
7 : #include <cstddef>
8 : #include <vector>
9 :
10 : #include "DataStructures/DataBox/PrefixHelpers.hpp"
11 : #include "DataStructures/DataBox/Prefixes.hpp"
12 : #include "DataStructures/VariablesTag.hpp"
13 : #include "Domain/Structure/Element.hpp"
14 : #include "Domain/Tags.hpp"
15 : #include "Evolution/DiscontinuousGalerkin/OnlyDgBlockIds.hpp"
16 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/System.hpp"
17 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/System.hpp"
18 : #include "Utilities/Algorithm.hpp"
19 : #include "Utilities/TMPL.hpp"
20 :
21 : namespace grmhd::GhValenciaDivClean::subcell {
22 : /*!
23 : * \brief Zeros out the MHD time derivatives in the elements next to a DG-only
24 : * block that themselves are not DG-only elements.
25 : */
26 : template <typename System>
27 1 : struct ZeroMhdTimeDerivatives {
28 0 : using return_tags = tmpl::list<::Tags::Variables<
29 : db::wrap_tags_in<::Tags::dt, typename System::variables_tag::tags_list>>>;
30 0 : using argument_tags = tmpl::list<domain::Tags::Element<3>,
31 : evolution::dg::Tags::OnlyDgBlockIds<3>>;
32 :
33 : template <class DtTagsList>
34 0 : static void apply(const gsl::not_null<Variables<DtTagsList>*> dt_variables,
35 : const Element<3>& element,
36 : const std::vector<size_t>& only_dg_block_ids) {
37 : const bool bordering_dg_block = alg::any_of(
38 : element.neighbors(),
39 : [&only_dg_block_ids](const auto& direction_and_neighbor) {
40 : const size_t first_block_id =
41 : direction_and_neighbor.second.ids().begin()->block_id();
42 : return alg::found(only_dg_block_ids, first_block_id);
43 : });
44 : const bool in_dg_only_zone =
45 : alg::found(only_dg_block_ids, element.id().block_id());
46 : if (bordering_dg_block and not in_dg_only_zone) {
47 : tmpl::for_each<
48 : typename grmhd::ValenciaDivClean::System::variables_tag::tags_list>(
49 : [&dt_variables]<class Tag>(tmpl::type_<Tag> /*meta*/) {
50 : auto& var = get<::Tags::dt<Tag>>(*dt_variables);
51 : for (size_t i = 0; i < var.size(); ++i) {
52 : var[i] = 0.0;
53 : }
54 : });
55 : }
56 : }
57 : };
58 : } // namespace grmhd::GhValenciaDivClean::subcell
|