Namespaces
ApplyAt.hpp File Reference
#include <tuple>
#include <utility>
#include "DataStructures/DataBox/DataBox.hpp"
#include "Utilities/ForceInline.hpp"
#include "Utilities/Gsl.hpp"
#include "Utilities/TMPL.hpp"
#include "Utilities/TaggedTuple.hpp"
#include "Utilities/TupleSlice.hpp"

Go to the source code of this file.

Namespaces

 elliptic
 Functionality related to solving elliptic partial differential equations.
 

Functions

template<typename ArgumentTags , typename PassthroughArgumentTags , typename... MapKeys, typename F , typename TaggedContainer , typename... Args>
decltype(auto) elliptic::util::apply_at (F &&f, const TaggedContainer &box, const std::tuple< MapKeys... > &map_keys, Args &&... args) noexcept
 Apply the invokable f with arguments from maps in the DataBox. More...
 
template<typename ArgumentTags , typename PassthroughArgumentTags , typename MapKey , typename F , typename TaggedContainer , typename... Args>
decltype(auto) elliptic::util::apply_at (F &&f, const TaggedContainer &box, const MapKey &map_key, Args &&... args) noexcept
 Apply the invokable f with arguments from maps in the DataBox. More...
 
template<typename MutateTags , typename ArgumentTags , typename PassthroughTags , typename F , typename TaggedContainer , typename... MapKeys, typename... Args>
void elliptic::util::mutate_apply_at (F &&f, const gsl::not_null< TaggedContainer * > box, const std::tuple< MapKeys... > &map_keys, Args &&... args) noexcept
 Apply the invokable f to mutate items in maps in the DataBox. More...
 
template<typename MutateTags , typename ArgumentTags , typename PassthroughTags , typename F , typename TaggedContainer , typename MapKey , typename... Args>
void elliptic::util::mutate_apply_at (F &&f, const gsl::not_null< TaggedContainer * > box, const MapKey &map_key, Args &&... args) noexcept
 Apply the invokable f to mutate items in maps in the DataBox. More...
 
template<typename ArgumentTags , typename PassthroughArgumentTags , typename... MapKeys, typename F , typename TaggedContainer , typename... Args>
decltype(auto) elliptic::util::apply_at (F &&f, const TaggedContainer &box, const std::tuple< MapKeys... > &map_keys, Args &&... args) noexcept
 Apply the invokable f with arguments from maps in the DataBox. More...
 
template<typename ArgumentTags , typename PassthroughArgumentTags , typename MapKey , typename F , typename TaggedContainer , typename... Args>
decltype(auto) elliptic::util::apply_at (F &&f, const TaggedContainer &box, const MapKey &map_key, Args &&... args) noexcept
 Apply the invokable f with arguments from maps in the DataBox. More...
 
template<typename MutateTags , typename ArgumentTags , typename PassthroughTags , typename F , typename TaggedContainer , typename... MapKeys, typename... Args>
void elliptic::util::mutate_apply_at (F &&f, const gsl::not_null< TaggedContainer * > box, const std::tuple< MapKeys... > &map_keys, Args &&... args) noexcept
 Apply the invokable f to mutate items in maps in the DataBox. More...
 
template<typename MutateTags , typename ArgumentTags , typename PassthroughTags , typename F , typename TaggedContainer , typename MapKey , typename... Args>
void elliptic::util::mutate_apply_at (F &&f, const gsl::not_null< TaggedContainer * > box, const MapKey &map_key, Args &&... args) noexcept
 Apply the invokable f to mutate items in maps in the DataBox. More...
 

Detailed Description

Utilities to retrieve values from maps in tagged containers

Function Documentation

◆ apply_at() [1/2]

template<typename ArgumentTags , typename PassthroughArgumentTags , typename MapKey , typename F , typename TaggedContainer , typename... Args>
decltype(auto) elliptic::util::apply_at ( F &&  f,
const TaggedContainer &  box,
const MapKey &  map_key,
Args &&...  args 
)
noexcept

Apply the invokable f with arguments from maps in the DataBox.

Retrieves the ArgumentTags from the DataBox, evaluates them at the map_key(s) (by calling their at member function for every map key in turn) and calls the invokable f with the unmapped arguments. The tags in PassthroughArgumentTags are passed directly to f without unmapping them.

For example, a DataBox may have these tags of which two are maps:

struct MapTag : db::SimpleTag {
};
struct NonMapTag : db::SimpleTag {
using type = int;
};
struct NestedMapTag : db::SimpleTag {
};
struct DirectionMapTag : db::SimpleTag {
using type = DirectionMap<1, bool>;
};

You can use apply_at to evaluate a function at a particular key for these maps:

apply_at<tmpl::list<MapTag, NonMapTag, NestedMapTag>,
tmpl::list<NonMapTag>>(
[](const std::string& arg1, const int arg0,
CHECK(arg0 == 1);
CHECK(arg1 == "A");
CHECK(arg2.at("key") == true);
},
box, 0);
See also
db::apply

◆ apply_at() [2/2]

template<typename ArgumentTags , typename PassthroughArgumentTags , typename... MapKeys, typename F , typename TaggedContainer , typename... Args>
decltype(auto) elliptic::util::apply_at ( F &&  f,
const TaggedContainer &  box,
const std::tuple< MapKeys... > &  map_keys,
Args &&...  args 
)
noexcept

Apply the invokable f with arguments from maps in the DataBox.

Retrieves the ArgumentTags from the DataBox, evaluates them at the map_key(s) (by calling their at member function for every map key in turn) and calls the invokable f with the unmapped arguments. The tags in PassthroughArgumentTags are passed directly to f without unmapping them.

For example, a DataBox may have these tags of which two are maps:

struct MapTag : db::SimpleTag {
};
struct NonMapTag : db::SimpleTag {
using type = int;
};
struct NestedMapTag : db::SimpleTag {
};
struct DirectionMapTag : db::SimpleTag {
using type = DirectionMap<1, bool>;
};

You can use apply_at to evaluate a function at a particular key for these maps:

apply_at<tmpl::list<MapTag, NonMapTag, NestedMapTag>,
tmpl::list<NonMapTag>>(
[](const std::string& arg1, const int arg0,
CHECK(arg0 == 1);
CHECK(arg1 == "A");
CHECK(arg2.at("key") == true);
},
box, 0);
See also
db::apply

◆ mutate_apply_at() [1/2]

template<typename MutateTags , typename ArgumentTags , typename PassthroughTags , typename F , typename TaggedContainer , typename MapKey , typename... Args>
void elliptic::util::mutate_apply_at ( F &&  f,
const gsl::not_null< TaggedContainer * >  box,
const MapKey &  map_key,
Args &&...  args 
)
noexcept

Apply the invokable f to mutate items in maps in the DataBox.

Retrieves the MutateTags and ArgumentTags from the DataBox, evaluates them at the map_key(s) (by calling their at member function for every map key in turn) and calls the invokable f with the unmapped arguments. The tags in PassthroughTags are passed directly to f without unmapping them.

For example, a DataBox may have these tags of which two are maps:

struct MapTag : db::SimpleTag {
};
struct NonMapTag : db::SimpleTag {
using type = int;
};
struct NestedMapTag : db::SimpleTag {
};
struct DirectionMapTag : db::SimpleTag {
using type = DirectionMap<1, bool>;
};

You can use mutate_apply_at to mutate items at a particular key for these maps:

mutate_apply_at<tmpl::list<MapTag>, tmpl::list<NonMapTag, NestedMapTag>,
tmpl::list<NonMapTag>>(
[](const gsl::not_null<std::string*> mutate_arg, const int arg0,
*mutate_arg = "B";
CHECK(arg0 == 1);
CHECK(arg2.at("key") == true);
},
make_not_null(&box), 0);
See also
db::mutate_apply

◆ mutate_apply_at() [2/2]

template<typename MutateTags , typename ArgumentTags , typename PassthroughTags , typename F , typename TaggedContainer , typename... MapKeys, typename... Args>
void elliptic::util::mutate_apply_at ( F &&  f,
const gsl::not_null< TaggedContainer * >  box,
const std::tuple< MapKeys... > &  map_keys,
Args &&...  args 
)
noexcept

Apply the invokable f to mutate items in maps in the DataBox.

Retrieves the MutateTags and ArgumentTags from the DataBox, evaluates them at the map_key(s) (by calling their at member function for every map key in turn) and calls the invokable f with the unmapped arguments. The tags in PassthroughTags are passed directly to f without unmapping them.

For example, a DataBox may have these tags of which two are maps:

struct MapTag : db::SimpleTag {
};
struct NonMapTag : db::SimpleTag {
using type = int;
};
struct NestedMapTag : db::SimpleTag {
};
struct DirectionMapTag : db::SimpleTag {
using type = DirectionMap<1, bool>;
};

You can use mutate_apply_at to mutate items at a particular key for these maps:

mutate_apply_at<tmpl::list<MapTag>, tmpl::list<NonMapTag, NestedMapTag>,
tmpl::list<NonMapTag>>(
[](const gsl::not_null<std::string*> mutate_arg, const int arg0,
*mutate_arg = "B";
CHECK(arg0 == 1);
CHECK(arg2.at("key") == true);
},
make_not_null(&box), 0);
See also
db::mutate_apply
std::string
db::SimpleTag
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
std::map
DirectionMap
Definition: DirectionMap.hpp:15
make_not_null
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion,...
Definition: Gsl.hpp:880
std::unordered_map
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13