Zero.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <pup.h>
8 #include <string>
9 
11 #include "Elliptic/BoundaryConditions/BoundaryCondition.hpp"
12 #include "Elliptic/BoundaryConditions/BoundaryConditionType.hpp"
13 #include "Options/Options.hpp"
15 #include "Utilities/Gsl.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 /// \cond
19 class DataVector;
20 /// \endcond
21 
22 namespace Elasticity::BoundaryConditions {
23 namespace detail {
24 
25 template <elliptic::BoundaryConditionType BoundaryConditionType>
26 struct ZeroHelpString;
27 template <>
28 struct ZeroHelpString<elliptic::BoundaryConditionType::Dirichlet> {
29  static constexpr Options::String help =
30  "Zero Dirichlet boundary conditions imposed on the displacement vector, "
31  "i.e. the elastic material is held fixed at this boundary.";
32 };
33 template <>
34 struct ZeroHelpString<elliptic::BoundaryConditionType::Neumann> {
35  static constexpr Options::String help =
36  "Zero Neumann boundary conditions imposed on the stress tensor "
37  "perpendicular to the surface, i.e. the elastic material is free to "
38  "deform at this boundary.";
39 };
40 
41 template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType>
42 struct ZeroImpl {
43  static_assert(BoundaryConditionType ==
45  BoundaryConditionType ==
47  "Unexpected boundary condition type. Supported are Dirichlet "
48  "and Neumann.");
49 
50  static std::string name() noexcept;
51  using options = tmpl::list<>;
52  static constexpr Options::String help =
53  ZeroHelpString<BoundaryConditionType>::help;
54 
55  using argument_tags = tmpl::list<>;
56  using volume_tags = tmpl::list<>;
57 
58  static void apply(
59  gsl::not_null<tnsr::I<DataVector, Dim>*> displacement,
60  gsl::not_null<tnsr::I<DataVector, Dim>*> n_dot_minus_stress) noexcept;
61 
62  using argument_tags_linearized = tmpl::list<>;
63  using volume_tags_linearized = tmpl::list<>;
64 
65  static void apply_linearized(
66  gsl::not_null<tnsr::I<DataVector, Dim>*> displacement,
67  gsl::not_null<tnsr::I<DataVector, Dim>*> n_dot_minus_stress) noexcept;
68 };
69 
70 template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType>
71 bool operator==(const ZeroImpl<Dim, BoundaryConditionType>& lhs,
72  const ZeroImpl<Dim, BoundaryConditionType>& rhs) noexcept;
73 
74 template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType>
75 bool operator!=(const ZeroImpl<Dim, BoundaryConditionType>& lhs,
76  const ZeroImpl<Dim, BoundaryConditionType>& rhs) noexcept;
77 
78 } // namespace detail
79 
80 // The following implements the registration and factory-creation mechanism
81 
82 /// \cond
83 template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType,
84  typename Registrars>
85 struct Zero;
86 
87 namespace Registrars {
88 template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType>
89 struct Zero {
90  template <typename Registrars>
91  using f = BoundaryConditions::Zero<Dim, BoundaryConditionType, Registrars>;
92 };
93 } // namespace Registrars
94 /// \endcond
95 
96 /// Impose zero Dirichlet ("fixed") or Neumann ("free") boundary conditions.
98  typename Registrars =
99  tmpl::list<Registrars::Zero<Dim, BoundaryConditionType>>>
100 class Zero
101  : public elliptic::BoundaryConditions::BoundaryCondition<Dim, Registrars>,
102  public detail::ZeroImpl<Dim, BoundaryConditionType> {
103  private:
105 
106  public:
107  Zero() = default;
108  Zero(const Zero&) noexcept = default;
109  Zero& operator=(const Zero&) noexcept = default;
110  Zero(Zero&&) noexcept = default;
111  Zero& operator=(Zero&&) noexcept = default;
112  ~Zero() noexcept = default;
113 
114  /// \cond
115  explicit Zero(CkMigrateMessage* m) noexcept : Base(m) {}
116  using PUP::able::register_constructor;
118  /// \endcond
119 
121  const noexcept override {
122  return std::make_unique<Zero>(*this);
123  }
124 };
125 
126 /// \cond
127 template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType,
128  typename Registrars>
129 PUP::able::PUP_ID Zero<Dim, BoundaryConditionType,
130  Registrars>::my_PUP_ID = 0; // NOLINT
131 /// \endcond
132 
133 } // namespace Elasticity::BoundaryConditions
std::string
CharmPupable.hpp
Options.hpp
elliptic::BoundaryConditionType
BoundaryConditionType
Identify types of boundary conditions for elliptic equations.
Definition: BoundaryConditionType.hpp:19
elliptic::BoundaryConditionType::Dirichlet
@ Dirichlet
Dirichlet boundary conditions like .
elliptic::BoundaryConditionType::Neumann
@ Neumann
Neumann boundary conditions like , where is the normal to the domain boundary.
Options
Utilities for parsing input files.
Definition: MinmodType.hpp:8
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
Elasticity::BoundaryConditions::Zero
Impose zero Dirichlet ("fixed") or Neumann ("free") boundary conditions.
Definition: Zero.hpp:100
cstddef
elliptic::BoundaryConditions::BoundaryCondition
Base class for boundary conditions for elliptic systems.
Definition: BoundaryCondition.hpp:91
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
tnsr
Type aliases to construct common Tensors.
Definition: TypeAliases.hpp:31
Gsl.hpp
elliptic
Functionality related to solving elliptic partial differential equations.
Definition: InitializeAnalyticSolution.hpp:29
TypeAliases.hpp
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
std::unique_ptr< domain::BoundaryConditions::BoundaryCondition >
gsl
Implementations from the Guideline Support Library.
Definition: ReadSpecPiecewisePolynomial.hpp:11
TMPL.hpp
string