Zero.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <cstddef>
7 #include <pup.h>
8
13 #include "Options/Options.hpp"
15 #include "PointwiseFunctions/AnalyticSolutions/Poisson/AnalyticSolution.hpp"
17 #include "Utilities/TMPL.hpp"
18 #include "Utilities/TaggedTuple.hpp"
19
20 namespace Poisson::Solutions {
21
22 /// \cond
23 template <size_t Dim, typename Registrars>
24 struct Zero;
25
26 namespace Registrars {
27 template <size_t Dim>
28 struct Zero {
29  template <typename Registrars>
30  using f = Solutions::Zero<Dim, Registrars>;
31 };
32 } // namespace Registrars
33 /// \endcond
34
35 /// The trivial solution \f$u=0\f$ of a Poisson equation. Useful as initial
36 /// guess.
37 template <size_t Dim,
38  typename Registrars = tmpl::list<Solutions::Registrars::Zero<Dim>>>
39 class Zero : public AnalyticSolution<Dim, Registrars> {
40  private:
42
43  public:
44  using options = tmpl::list<>;
45  static constexpr Options::String help{
46  "The trivial solution, useful as initial guess."};
47
48  Zero() = default;
49  Zero(const Zero&) noexcept = default;
50  Zero& operator=(const Zero&) noexcept = default;
51  Zero(Zero&&) noexcept = default;
52  Zero& operator=(Zero&&) noexcept = default;
53  ~Zero() noexcept override = default;
54
55  /// \cond
56  explicit Zero(CkMigrateMessage* m) noexcept : Base(m) {}
57  using PUP::able::register_constructor;
59  /// \endcond
60
61  template <typename DataType, typename... RequestedTags>
62  tuples::TaggedTuple<RequestedTags...> variables(
63  const tnsr::I<DataType, Dim>& x,
64  tmpl::list<RequestedTags...> /*meta*/) const noexcept {
65  using supported_tags = tmpl::list<
70  static_assert(tmpl::size<tmpl::list_difference<tmpl::list<RequestedTags...>,
71  supported_tags>>::value == 0,
72  "The requested tag is not supported");
73  return {make_with_value<typename RequestedTags::type>(x, 0.)...};
74  }
75
77  void pup(PUP::er& /*p*/) noexcept override {}
78 };
79
80 /// \cond
81 template <size_t Dim, typename Registrars>
82 PUP::able::PUP_ID Zero<Dim, Registrars>::my_PUP_ID = 0; // NOLINT
83 /// \endcond
84
85 template <size_t Dim, typename Registrars>
86 bool operator==(const Zero<Dim, Registrars>& /*lhs*/,
87  const Zero<Dim, Registrars>& /*rhs*/) noexcept {
88  return true;
89 }
90
91 template <size_t Dim, typename Registrars>
92 bool operator!=(const Zero<Dim, Registrars>& lhs,
93  const Zero<Dim, Registrars>& rhs) noexcept {
94  return not(lhs == rhs);
95 }
96
97 } // namespace Poisson::Solutions
CharmPupable.hpp
Frame::Inertial
Definition: IndexType.hpp:44
Options.hpp
Poisson::Solutions::Zero
The trivial solution of a Poisson equation. Useful as initial guess.
Definition: Zero.hpp:39
Tags::Flux
Prefix indicating a flux.
Definition: Prefixes.hpp:40
Tags::FixedSource
Prefix indicating a source term that is independent of dynamic variables.
Definition: Prefixes.hpp:75
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
cstddef
MakeWithValue.hpp
Poisson::Solutions
Analytic solutions of the Poisson equation.
Definition: AnalyticSolution.hpp:17
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
Poisson::Tags::Field
The scalar field to solve for.
Definition: Tags.hpp:28
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Tensor.hpp
Tags::deriv
Prefix indicating spatial derivatives.
Definition: PartialDerivatives.hpp:52
PartialDerivatives.hpp
Prefixes.hpp
brigand::list_difference
fold< Sequence2, Sequence1, lazy::remove< _state, _element > > list_difference
Obtain the elements of Sequence1 that are not in Sequence2.
Definition: TMPL.hpp:625
TMPL.hpp
Tags.hpp