SpECTRE  v2024.05.11
imex::protocols::ImplicitSector Struct Reference

Protocol for an implicit sector of an IMEX system. More...

#include <ImplicitSector.hpp>

Classes

struct  test
 

Detailed Description

Protocol for an implicit sector of an IMEX system.

An implicit sector describes the sources for one implicit solve performed during IMEX evolution. A system may have multiple implicit sectors, but they must be independent, i.e., their sources must not depend on any tensors in other sectors.

Classes implementing this protocol must define:

  • a tensors type alias of tags for the variables to be solved for
  • an initial_guess type to be passed to db::mutate_apply, taking additional arguments for the inhomogeneous terms \(X\) and implicit weight \(w\) in the equation to be solved: \(u = X + w S(u)\). (See example below.) It must return a std::vector<GuessResult> indicating, for each point, whether the implicit equation has been solved analytically or whether the numerical solve should continue. An empty return is equivalent to imex::GuessResult::InitialGuess for every point, so numerical solves will be performed for each. When this is called, the sector variables will have the value from the explicit part of the time step. This mutator will not be called if the implicit weight is zero, as the solution is trivial in that case. If using the value of the explicit step as an initial guess is acceptable, this can be the type imex::GuessExplicitResult.
  • a solve_attempts list of sources that will be attempted to be solved, in order. The first one that succeeds at each point will be used. Pieces of code that need "the" source for the sector will use the source from the first entry. Each attempt must be a struct with the following types:
    • lists used to construct a DataBox during the pointwise implicit solve:
      • tags_from_evolution for tags in addition to the sector tensors to be made available from the evolution DataBox. Volume quantities will be reduced to have one grid point, with the appropriate value for the point being solved for.
      • simple_tags for temporaries (e.g., primitives)
      • compute_tags
    • a source type to be passed to db::mutate_apply to compute the sources.
    • a jacobian type to be passed to db::mutate_apply to compute the source jacobian. If the implicit equation can always be solved analytically for the sector, the jacobian is not required and this may be the type imex::NoJacobianBecauseSolutionIsAnalytic.
    • lists source_prep and jacobian_prep that will be called before the corresponding main mutator, e.g., for computing primitives. Mutators appearing in multiple lists, as well as the source and jacobian mutators, will be skipped if they have already been applied for the current point. Note that the source_prep mutators are only used during the implicit solve, and any preparation needed before the source call in the main action loop to record the history is the responsibility of the user.

All Variables in the DataBox, including the sources and source jacobian, will be initialized to zero with a single grid point.

struct Sector : tt::ConformsTo<imex::protocols::ImplicitSector> {
using tensors = tmpl::list<Var>;
struct initial_guess {
using return_tags = tmpl::list<Var>;
using argument_tags = tmpl::list<>;
const Variables<tmpl::list<Var>>& inhomogeneous_terms,
const double implicit_weight) {
get(*var) = get(get<Var>(inhomogeneous_terms)) / (1.0 + implicit_weight);
return {get(*var).size(), imex::GuessResult::ExactSolution};
}
};
struct SolveAttempt {
struct source {
using return_tags = tmpl::list<Tags::Source<Var>>;
using argument_tags = tmpl::list<Var>;
static void apply(const gsl::not_null<Scalar<DataVector>*> source,
const Scalar<DataVector>& var) {
get(*source) = -get(var);
}
};
using tags_from_evolution = tmpl::list<>;
using simple_tags = tmpl::list<>;
using compute_tags = tmpl::list<>;
using source_prep = tmpl::list<>;
using jacobian_prep = tmpl::list<>;
};
using solve_attempts = tmpl::list<SolveAttempt>;
};
Definition: ContractFirstNIndices.hpp:16
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
const auto & get(const DataBox< TagList > &box)
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1264
auto apply(F &&f, const ObservationBox< ComputeTagsList, DataBoxType > &observation_box, Args &&... args)
Apply the function object f using its nested argument_tags list of tags.
Definition: ObservationBox.hpp:238
ylm::Tags::aliases::Jacobian< Fr > jacobian(const tnsr::i< DataVector, 2, ::Frame::Spherical< Fr > > &theta_phi)
Mutator for the jacobian of an implicit sector that has an analytic solution. Such a sector never doe...
Definition: GuessResult.hpp:36
Indicate a class conforms to the Protocol.
Definition: ProtocolHelpers.hpp:22

Examples of definitions of a complicated implicit source and jacobian:

struct Source {
using return_tags = tmpl::list<::Tags::Source<Var2>, ::Tags::Source<Var3>>;
using argument_tags = tmpl::list<Var1, Var2, Var3, NonTensor,
RecordPreparersForTest, SomeComputeTagBase>;
static void apply(const gsl::not_null<tnsr::II<DataVector, 2>*> source_var2,
const Scalar<DataVector>& var1,
const tnsr::I<DataVector, 2>& var3, const double non_tensor,
const RecordPreparersForTest::type& prep_run_values,
const double compute_tag_value) {
Prefix indicating a source term.
Definition: Prefixes.hpp:66
struct Jacobian {
using return_tags =
tmpl::list<imex::Tags::Jacobian<Var2, ::Tags::Source<Var2>>,
using argument_tags =
tmpl::list<Var1, Var3, NonTensor, RecordPreparersForTest>;
static void apply(const gsl::not_null<tnsr::iiJJ<DataVector, 2>*> dvar2_dvar2,
const Scalar<DataVector>& var1,
const tnsr::I<DataVector, 2>& var3, const double non_tensor,
const RecordPreparersForTest::type& prep_run_values) {
Definition: Jacobian.hpp:23

The documentation for this struct was generated from the following file: