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/Elasticity/AnalyticData.hpp"
11 #include "Utilities/FakeVirtual.hpp"
12 #include "Utilities/Registration.hpp"
13 #include "Utilities/TMPL.hpp"
14 #include "Utilities/TaggedTuple.hpp"
15 
16 namespace Elasticity {
17 /// Analytic solutions of the linear Elasticity equations
18 namespace Solutions {
19 
20 /*!
21  * \brief Base class for analytic solutions of the linear Elasticity equations
22  *
23  * This abstract base class allows factory-creating derived classes from
24  * input-file options (see `Registration`). The list of `Registrars` may also
25  * contain classes that aren't analytic solutions but only derive off
26  * `Elasticity::AnalyticData::AnalyticData`. This allows factory-creating any
27  * choice of analytic solution _or_ analytic data from input-file options, but
28  * you must use the `Elasticity::AnalyticData::AnalyticData` class for the
29  * factory-creation. Note that analytic solutions provide more variables than
30  * analytic data classes, so to request variables that only analytic solutions
31  * provide you must perform a cast to `AnalyticSolution`.
32  */
33 template <size_t Dim, typename Registrars>
35  : public Elasticity::AnalyticData::AnalyticData<Dim, Registrars> {
36  private:
38 
39  protected:
40  /// \cond
41  AnalyticSolution() = default;
42  AnalyticSolution(const AnalyticSolution&) = default;
44  AnalyticSolution& operator=(const AnalyticSolution&) = default;
45  AnalyticSolution& operator=(AnalyticSolution&&) = default;
46  /// \endcond
47 
48  public:
49  ~AnalyticSolution() override = default;
50 
51  using registrars = Registrars;
52  using creatable_classes = Registration::registrants<registrars>;
53 
54  /// \cond
55  explicit AnalyticSolution(CkMigrateMessage* m) noexcept : Base(m) {}
57  /// \endcond
58 
59  template <typename DataType, typename... RequestedTags>
60  tuples::TaggedTuple<RequestedTags...> variables(
61  const tnsr::I<DataType, Dim, Frame::Inertial>& x,
62  tmpl::list<RequestedTags...> /*meta*/) const noexcept {
64  tuples::TaggedTuple<RequestedTags...>,
65  tmpl::filter<
66  creatable_classes,
68  this, [&x](auto* const derived) noexcept {
69  return derived->variables(x, tmpl::list<RequestedTags...>{});
70  });
71  }
72 };
73 
74 } // namespace Solutions
75 } // namespace Elasticity
Elasticity::Solutions::AnalyticSolution
Base class for analytic solutions of the linear Elasticity equations.
Definition: AnalyticSolution.hpp:34
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
Elasticity
Items related to solving elasticity problems.
Definition: LaserBeam.cpp:13
cstddef
Elasticity::AnalyticData::AnalyticData
Base class for the background of the Elasticity system, i.e. its variable-independent quantities....
Definition: AnalyticData.hpp:25
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
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
TMPL.hpp
std::is_base_of