Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <array>
7 : #include <boost/range/combine.hpp>
8 : #include <cstddef>
9 :
10 : #include "DataStructures/DataBox/DataBox.hpp"
11 : #include "DataStructures/Index.hpp"
12 : #include "DataStructures/SliceIterator.hpp"
13 : #include "DataStructures/SliceTensorToVariables.hpp"
14 : #include "DataStructures/Variables.hpp"
15 : #include "Utilities/TMPL.hpp"
16 : #include "Utilities/TypeTraits.hpp"
17 :
18 : namespace db {
19 : /*!
20 : * \ingroup DataBoxGroup
21 : * \brief Slices volume `Tensor`s from a `DataBox` into a `Variables`
22 : *
23 : * The slice has a constant logical coordinate in direction `sliced_dim`,
24 : * slicing the volume at `fixed_index` in that dimension. For
25 : * example, to get the lower boundary of `sliced_dim`, pass `0` for
26 : * `fixed_index`; to get the upper boundary, pass
27 : * `extents[sliced_dim] - 1`. The last argument to the function is the typelist
28 : * holding the tags to slice.
29 : *
30 : * \snippet Test_DataBox.cpp data_on_slice
31 : */
32 : template <size_t VolumeDim, typename TagsList, typename... TagsToSlice>
33 1 : Variables<tmpl::list<TagsToSlice...>> data_on_slice(
34 : const db::DataBox<TagsList>& box, const Index<VolumeDim>& element_extents,
35 : const size_t sliced_dim, const size_t fixed_index,
36 : tmpl::list<TagsToSlice...> /*meta*/) {
37 : return data_on_slice<TagsToSlice...>(element_extents, sliced_dim, fixed_index,
38 : db::get<TagsToSlice>(box)...);
39 : }
40 : } // namespace db
|