Line data Source code
1 0 : // 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 : #include <vector> 10 : 11 : #include "DataStructures/Tensor/TypeAliases.hpp" 12 : #include "Elliptic/BoundaryConditions/BoundaryCondition.hpp" 13 : #include "Elliptic/BoundaryConditions/BoundaryConditionType.hpp" 14 : #include "Options/String.hpp" 15 : #include "Utilities/Gsl.hpp" 16 : #include "Utilities/Serialization/CharmPupable.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : 19 : /// \cond 20 : class DataVector; 21 : /// \endcond 22 : 23 : namespace Elasticity::BoundaryConditions { 24 : namespace detail { 25 : 26 : template <elliptic::BoundaryConditionType BoundaryConditionType> 27 : struct ZeroHelpString; 28 : template <> 29 : struct ZeroHelpString<elliptic::BoundaryConditionType::Dirichlet> { 30 : static constexpr Options::String help = 31 : "Zero Dirichlet boundary conditions imposed on the displacement vector, " 32 : "i.e. the elastic material is held fixed at this boundary."; 33 : }; 34 : template <> 35 : struct ZeroHelpString<elliptic::BoundaryConditionType::Neumann> { 36 : static constexpr Options::String help = 37 : "Zero Neumann boundary conditions imposed on the stress tensor " 38 : "perpendicular to the surface, i.e. the elastic material is free to " 39 : "deform at this boundary."; 40 : }; 41 : 42 : } // namespace detail 43 : 44 : /// Impose zero Dirichlet ("fixed") or Neumann ("free") boundary conditions. 45 : template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType> 46 1 : class Zero : public elliptic::BoundaryConditions::BoundaryCondition<Dim> { 47 : private: 48 0 : using Base = elliptic::BoundaryConditions::BoundaryCondition<Dim>; 49 : 50 : static_assert(BoundaryConditionType == 51 : elliptic::BoundaryConditionType::Dirichlet or 52 : BoundaryConditionType == 53 : elliptic::BoundaryConditionType::Neumann, 54 : "Unexpected boundary condition type. Supported are Dirichlet " 55 : "and Neumann."); 56 : 57 : public: 58 0 : static std::string name(); 59 0 : using options = tmpl::list<>; 60 0 : static constexpr Options::String help = 61 : detail::ZeroHelpString<BoundaryConditionType>::help; 62 : 63 0 : Zero() = default; 64 0 : Zero(const Zero&) = default; 65 0 : Zero& operator=(const Zero&) = default; 66 0 : Zero(Zero&&) = default; 67 0 : Zero& operator=(Zero&&) = default; 68 0 : ~Zero() = default; 69 : 70 : /// \cond 71 : explicit Zero(CkMigrateMessage* m) : Base(m) {} 72 : using PUP::able::register_constructor; 73 : WRAPPED_PUPable_decl_template(Zero); 74 : /// \endcond 75 : 76 0 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition> get_clone() 77 : const override { 78 : return std::make_unique<Zero>(*this); 79 : } 80 : 81 0 : std::vector<elliptic::BoundaryConditionType> boundary_condition_types() 82 : const override { 83 : return {Dim, BoundaryConditionType}; 84 : } 85 : 86 0 : using argument_tags = tmpl::list<>; 87 0 : using volume_tags = tmpl::list<>; 88 : 89 0 : static void apply(gsl::not_null<tnsr::I<DataVector, Dim>*> displacement, 90 : gsl::not_null<tnsr::I<DataVector, Dim>*> n_dot_minus_stress, 91 : const tnsr::iJ<DataVector, Dim>& deriv_displacement); 92 : 93 0 : using argument_tags_linearized = tmpl::list<>; 94 0 : using volume_tags_linearized = tmpl::list<>; 95 : 96 0 : static void apply_linearized( 97 : gsl::not_null<tnsr::I<DataVector, Dim>*> displacement, 98 : gsl::not_null<tnsr::I<DataVector, Dim>*> n_dot_minus_stress, 99 : const tnsr::iJ<DataVector, Dim>& deriv_displacement); 100 : }; 101 : 102 : template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType> 103 0 : bool operator==(const Zero<Dim, BoundaryConditionType>& /*lhs*/, 104 : const Zero<Dim, BoundaryConditionType>& /*rhs*/) { 105 : return true; 106 : } 107 : 108 : template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType> 109 0 : bool operator!=(const Zero<Dim, BoundaryConditionType>& lhs, 110 : const Zero<Dim, BoundaryConditionType>& rhs) { 111 : return not(lhs == rhs); 112 : } 113 : 114 : /// \cond 115 : template <size_t Dim, elliptic::BoundaryConditionType BoundaryConditionType> 116 : PUP::able::PUP_ID Zero<Dim, BoundaryConditionType>::my_PUP_ID = 0; // NOLINT 117 : /// \endcond 118 : 119 : } // namespace Elasticity::BoundaryConditions