AnalyticSolution.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
10 #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
11 #include "Utilities/FakeVirtual.hpp"
12 #include "Utilities/TMPL.hpp"
13 #include "Utilities/TaggedTuple.hpp"
14 
15 namespace Poisson {
16 /// Analytic solutions of the Poisson equation
17 namespace Solutions {
18 /*!
19  * \brief Base class for analytic solutions of the Poisson equation
20  *
21  * This abstract base class allows factory-creating derived classes from
22  * input-file options (see `Registration`). The list of `Registrars` may also
23  * contain classes that aren't analytic solutions but only derive off
24  * `::AnalyticData`. This allows factory-creating any choice of analytic
25  * solution _or_ analytic data from input-file options, but you must use the
26  * `::AnalyticData` class for the factory-creation. Note that analytic solutions
27  * provide more variables than analytic data classes, so to request variables
28  * that only analytic solutions provide you must perform a cast to
29  * `AnalyticSolution`.
30  */
31 template <size_t Dim, typename Registrars>
32 class AnalyticSolution : public ::AnalyticData<Dim, Registrars> {
33  private:
35 
36  protected:
37  /// \cond
38  AnalyticSolution() = default;
39  AnalyticSolution(const AnalyticSolution&) = default;
41  AnalyticSolution& operator=(const AnalyticSolution&) = default;
42  AnalyticSolution& operator=(AnalyticSolution&&) = default;
43  /// \endcond
44 
45  public:
46  ~AnalyticSolution() override = default;
47 
48  using registrars = Registrars;
49  using creatable_classes = Registration::registrants<registrars>;
50 
51  /// \cond
52  explicit AnalyticSolution(CkMigrateMessage* m) noexcept : Base(m) {}
54  /// \endcond
55 
56  template <typename DataType, typename... RequestedTags>
57  tuples::TaggedTuple<RequestedTags...> variables(
58  const tnsr::I<DataType, Dim>& x,
59  tmpl::list<RequestedTags...> /*meta*/) const noexcept {
61  tuples::TaggedTuple<RequestedTags...>,
62  tmpl::filter<
63  creatable_classes,
65  this, [&x](auto* const derived) noexcept {
66  return derived->variables(x, tmpl::list<RequestedTags...>{});
67  });
68  }
69 };
70 } // namespace Solutions
71 } // namespace Poisson
CharmPupable.hpp
call_with_dynamic_type
Result call_with_dynamic_type(Base *const obj, Callable &&f) noexcept
Call a functor with the derived type of a base class pointer.
Definition: FakeVirtual.hpp:103
cstddef
WRAPPED_PUPable_abstract
#define WRAPPED_PUPable_abstract(className)
Wraps the Charm++ macro, see the Charm++ documentation.
Definition: CharmPupable.hpp:41
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Poisson::Solutions::AnalyticSolution
Base class for analytic solutions of the Poisson equation.
Definition: AnalyticSolution.hpp:32
AnalyticData
Provides analytic tensor data as a function of the spatial coordinates.
Definition: AnalyticData.hpp:34
Tensor.hpp
Registration::registrants
tmpl::transform< tmpl::remove_duplicates< RegistrarList >, detail::registrant< tmpl::pin< tmpl::remove_duplicates< RegistrarList > >, tmpl::_1 > > registrants
Transform a list of registrars into the list of associated registrants. This is usually used to defin...
Definition: Registration.hpp:65
Poisson
Items related to solving a Poisson equation .
Definition: Robin.hpp:21
TMPL.hpp
std::is_base_of