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 : 9 : #include "DataStructures/DataBox/Prefixes.hpp" 10 : #include "DataStructures/DataVector.hpp" 11 : #include "DataStructures/TaggedTuple.hpp" 12 : #include "DataStructures/Tensor/Tensor.hpp" 13 : #include "Elliptic/Systems/Poisson/Tags.hpp" 14 : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp" 15 : #include "NumericalAlgorithms/Spectral/Mesh.hpp" 16 : #include "Options/String.hpp" 17 : #include "PointwiseFunctions/InitialDataUtilities/AnalyticSolution.hpp" 18 : #include "Utilities/MakeWithValue.hpp" 19 : #include "Utilities/Serialization/CharmPupable.hpp" 20 : #include "Utilities/TMPL.hpp" 21 : 22 : namespace Poisson::Solutions { 23 : 24 : /// The trivial solution \f$u=0\f$ of a Poisson equation. Useful as initial 25 : /// guess. 26 : template <size_t Dim, typename DataType = DataVector> 27 1 : class Zero : public elliptic::analytic_data::AnalyticSolution { 28 : public: 29 0 : using options = tmpl::list<>; 30 0 : static constexpr Options::String help{ 31 : "The trivial solution, useful as initial guess."}; 32 : 33 0 : Zero() = default; 34 0 : Zero(const Zero&) = default; 35 0 : Zero& operator=(const Zero&) = default; 36 0 : Zero(Zero&&) = default; 37 0 : Zero& operator=(Zero&&) = default; 38 0 : ~Zero() override = default; 39 0 : std::unique_ptr<elliptic::analytic_data::AnalyticSolution> get_clone() 40 : const override { 41 : return std::make_unique<Zero>(*this); 42 : } 43 : 44 : /// \cond 45 : explicit Zero(CkMigrateMessage* m) 46 : : elliptic::analytic_data::AnalyticSolution(m) {} 47 : using PUP::able::register_constructor; 48 : WRAPPED_PUPable_decl_template(Zero); // NOLINT 49 : /// \endcond 50 : 51 : template <typename... RequestedTags> 52 0 : tuples::TaggedTuple<RequestedTags...> variables( 53 : const tnsr::I<DataVector, Dim>& x, 54 : tmpl::list<RequestedTags...> /*meta*/) const { 55 : using supported_tags = tmpl::list< 56 : Tags::Field<DataType>, 57 : ::Tags::deriv<Tags::Field<DataType>, tmpl::size_t<Dim>, 58 : Frame::Inertial>, 59 : ::Tags::Flux<Tags::Field<DataType>, tmpl::size_t<Dim>, Frame::Inertial>, 60 : ::Tags::FixedSource<Tags::Field<DataType>>>; 61 : static_assert(tmpl::size<tmpl::list_difference<tmpl::list<RequestedTags...>, 62 : supported_tags>>::value == 0, 63 : "The requested tag is not supported"); 64 : return {make_with_value<typename RequestedTags::type>(x, 0.)...}; 65 : } 66 : 67 : template <typename... RequestedTags> 68 0 : tuples::TaggedTuple<RequestedTags...> variables( 69 : const tnsr::I<DataVector, Dim>& x, const Mesh<Dim>& /*mesh*/, 70 : const InverseJacobian<DataVector, Dim, Frame::ElementLogical, 71 : Frame::Inertial>& /*inv_jacobian*/, 72 : tmpl::list<RequestedTags...> meta) const { 73 : return variables(x, meta); 74 : } 75 : }; 76 : 77 : /// \cond 78 : template <size_t Dim, typename DataType> 79 : PUP::able::PUP_ID Zero<Dim, DataType>::my_PUP_ID = 0; // NOLINT 80 : /// \endcond 81 : 82 : template <size_t Dim, typename DataType> 83 0 : bool operator==(const Zero<Dim, DataType>& /*lhs*/, 84 : const Zero<Dim, DataType>& /*rhs*/) { 85 : return true; 86 : } 87 : 88 : template <size_t Dim, typename DataType> 89 0 : bool operator!=(const Zero<Dim, DataType>& lhs, 90 : const Zero<Dim, DataType>& rhs) { 91 : return not(lhs == rhs); 92 : } 93 : 94 : } // namespace Poisson::Solutions