Loading [MathJax]/extensions/tex2jax.js
Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
•All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SAMRAI/CompleteFromCons.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_SAMRAI_RECONSTRUCTION_HPP
22 #define FUB_SAMRAI_RECONSTRUCTION_HPP
23 
24 #include "fub/CompleteFromCons.hpp"
26 #include "fub/SAMRAI/ViewPatch.hpp"
27 
28 namespace fub::samrai {
29 
30 template <typename Tag, typename Equation_> class CompleteFromConsCalculation {
31 public:
32  using Equation = Equation_;
33  using ExecutionTag = Tag;
34 
35  static constexpr int Rank = Equation::Rank();
36 
37  CompleteFromConsCalculation(Tag, const Equation& eq) : rec_{eq} {}
38 
39  void CompleteFromCons(SAMRAI::hier::Patch& dest_patch,
40  span<const int> dest_ids,
41  const SAMRAI::hier::Patch& src_patch,
42  span<const int> src_ids);
43 
44  void CompleteFromCons(IntegratorContext& context, int level,
45  [[maybe_unused]] Duration time_step_size);
46 
47 private:
49 };
50 
51 template <typename Tag, typename Equation>
53  SAMRAI::hier::Patch& dest_patch, span<const int> dest_ids,
54  const SAMRAI::hier::Patch& src_patch, span<const int> src_ids) {
55  Equation& equation = rec_.equation_;
56  std::vector<SAMRAI::pdat::CellData<double>*> dest_data(dest_ids.size());
57  GetPatchData(span{dest_data}, dest_patch, dest_ids);
58  std::vector<SAMRAI::pdat::CellData<double>*> src_data(src_ids.size());
59  GetPatchData(span{src_data}, src_patch, src_ids);
60  IndexBox<Rank> box = AsIndexBox<Rank>(dest_data[0]->getGhostBox());
61  View<Complete<Equation>> complete =
62  MakeView<Complete<Equation>>(span{dest_data}, equation, box);
63  View<const Conservative<Equation>> conservative =
64  MakeView<const Conservative<Equation>>(src_data, equation, box);
65  rec_.CompleteFromCons(Tag(), complete, conservative);
66 }
67 
68 template <typename Tag, typename Equation>
70  IntegratorContext& context, int level,
71  [[maybe_unused]] Duration time_step_size) {
72  SAMRAI::hier::PatchLevel& patch_level = context.GetPatchLevel(level);
73  const int n_cons = static_cast<int>(context.GetFluxIds().size());
74  for (const std::shared_ptr<SAMRAI::hier::Patch>& patch : patch_level) {
75  CompleteFromCons(*patch, context.GetScratchIds(), *patch,
76  context.GetScratchIds().first(n_cons));
77  }
78 }
79 
80 } // namespace fub::samrai
81 
82 #endif
Definition: SAMRAI/CompleteFromCons.hpp:30
CompleteFromConsFn< Equation > rec_
Definition: SAMRAI/CompleteFromCons.hpp:48
void CompleteFromCons(SAMRAI::hier::Patch &dest_patch, span< const int > dest_ids, const SAMRAI::hier::Patch &src_patch, span< const int > src_ids)
Definition: SAMRAI/CompleteFromCons.hpp:52
CompleteFromConsCalculation(Tag, const Equation &eq)
Definition: SAMRAI/CompleteFromCons.hpp:37
static constexpr int Rank
Definition: SAMRAI/CompleteFromCons.hpp:35
Equation_ Equation
Definition: SAMRAI/CompleteFromCons.hpp:32
Tag ExecutionTag
Definition: SAMRAI/CompleteFromCons.hpp:33
This class is used by the HypebrolicSplitLevelIntegrator and delegates AMR related tasks to the AMReX...
Definition: SAMRAI/IntegratorContext.hpp:52
span< const int > GetScratchIds() const
Returns the MultiFab associated with level data on the specifed level number.
SAMRAI::hier::PatchLevel & GetPatchLevel(int level)
Returns the MultiFab associated with level data on the specifed level number.
span< const int > GetFluxIds() const
Returns the MultiFab associated with level data on the specifed level number.
A span is a view over a contiguous sequence of objects, the storage of which is owned by some other o...
Definition: span.hpp:81
constexpr index_type size() const noexcept
Returns the number of elements in the span.
Definition: span.hpp:392
void CompleteFromCons(Equation &&equation, Complete< std::decay_t< Equation >> &complete, const Conservative< std::decay_t< Equation >> &cons)
Definition: CompleteFromCons.hpp:42
Definition: CartesianPatchHierarchy.hpp:41
std::enable_if_t< std::is_pointer_v< PatchData >, void > GetPatchData(span< PatchData > patch_datas, SAMRAI::hier::Patch &patch, span< const int > data_ids)
Definition: ViewPatch.hpp:100
std::chrono::duration< double > Duration
Definition: Duration.hpp:31
Definition: State.hpp:403
Definition: CompleteFromCons.hpp:141
Definition: PatchDataView.hpp:56