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