Protocols

Classes that define metaprogramming interfaces. More...

## Classes

struct  tt::ConformsTo< Protocol >
Indicate a class conforms to the Protocol. More...

## Typedefs

template<typename ConformingType >
using dg::protocols::NumericalFlux = std::conditional_t< tmpl2::flat_all_v< detail::has_variables_tags_v< ConformingType >, detail::has_argument_tags_v< ConformingType >, detail::has_package_field_tags_v< ConformingType >, detail::has_package_extra_tags_v< ConformingType > >, cpp17::conjunction< detail::IsPackageDataCallable< ConformingType >, detail::IsNumericalFluxCallable< ConformingType > >, std::false_type >
Defines the interface for DG numerical fluxes. More...

template<typename ConformingType , template< class > class Protocol>
using tt::conforms_to = typename std::is_convertible< ConformingType *, ConformsTo< Protocol > * >
Checks if the ConformingType conforms to the Protocol. More...

template<typename ConformingType , template< class > class Protocol>
constexpr bool tt::conforms_to_v
Checks if the ConformingType conforms to the Protocol. More...

## Detailed Description

Classes that define metaprogramming interfaces.

See the Protocols section of the dev guide for details.

## ◆ conforms_to

template<typename ConformingType , template< class > class Protocol>
 using tt::conforms_to = typedef typename std::is_convertible*>

Checks if the ConformingType conforms to the Protocol.

By default, only checks if the class derives off the protocol to reduce compile time. Protocol conformance is tested rigorously in the unit tests instead. Set the SPECTRE_ALWAYS_CHECK_PROTOCOL_CONFORMANCE CMake option to always enable rigorous protocol conformance checks.

Documentation on Protocols

## ◆ NumericalFlux

template<typename ConformingType >
 using dg::protocols::NumericalFlux = typedef std::conditional_t< tmpl2::flat_all_v, detail::has_argument_tags_v, detail::has_package_field_tags_v, detail::has_package_extra_tags_v >, cpp17::conjunction, detail::IsNumericalFluxCallable >, std::false_type>

Defines the interface for DG numerical fluxes.

This protocol defines the interface that a class must conform to so that it can be used as a numerical flux in DG boundary schemes. Essentially, the class must be able to compute the quantity $$G$$ that appears, for example, in the strong first-order DG boundary scheme $$G_\alpha(n_i^\mathrm{int}, u_\alpha^\mathrm{int}, n_i^\mathrm{ext}, u_\alpha^\mathrm{ext}) - n_i^\mathrm{int} F^{i,\mathrm{int}}_\alpha$$ where $$u_\alpha$$ are the system variables and $$F^i_\alpha$$ their corresponding fluxes. See also Eq. (2.20) in [55] where the quantity $$G$$ is denoted $$n_i F^{i*}$$, which is why we occasionally refer to it as the "normal-dot-numerical-fluxes".

Requires the ConformingType has these type aliases:

• variables_tags: A typelist of DataBox tags that the class computes numerical fluxes for.
• argument_tags: A typelist of DataBox tags that will be retrieved on interfaces and passed to the package_data function (see below). The ConformingType may also have a volume_tags typelist that specifies the subset of argument_tags that should be retrieved from the volume instead of the interface.
• package_field_tags: A typelist of DataBox tags with Tensor types that the package_data function will compute from the argument_tags. These quantities will be made available on both sides of a mortar and passed to the call operator to compute the numerical flux.
• package_extra_tags: Additional non-tensor tags that will be made available on both sides of a mortar, e.g. geometric quantities.

Requires the ConformingType has these member functions:

• package_data: Takes the types of the package_field_tags and the package_extra_tags by gsl::not_null pointer, followed by the types of the argument_tags.
• operator(): Takes the types of the variables_tags by gsl::not_null pointer, followed by the types of the package_field_tags and the package_extra_tags from the interior side of the mortar and from the exterior side. Note that the data from the exterior side was computed entirely with data from the neighboring element, including its interface normal which is (at least when it's independent of the system variables) opposite to the interior element's interface normal. Therefore, make sure to take into account the sign flip for quantities that include the interface normal.

Here's an example for a simple "central" numerical flux $$G_\alpha(n_i^\mathrm{int}, u_\alpha^\mathrm{int}, n_i^\mathrm{ext}, u_\alpha^\mathrm{ext}) = \frac{1}{2}\left(n_i^\mathrm{int} F^{i,\mathrm{int}}_\alpha - n_i^\mathrm{ext} F^{i,\mathrm{ext}}_\alpha \right)$$:

struct CentralFlux : tt::ConformsTo<dg::protocols::NumericalFlux> {
using variables_tags = tmpl::list<FieldTag>;
using argument_tags = tmpl::list<::Tags::NormalDotFlux<FieldTag>>;
using package_field_tags = tmpl::list<::Tags::NormalDotFlux<FieldTag>>;
using package_extra_tags = tmpl::list<>;
void package_data(
const gsl::not_null<Scalar<DataVector>*> packaged_normal_dot_flux,
const Scalar<DataVector>& normal_dot_flux) const noexcept {
*packaged_normal_dot_flux = normal_dot_flux;
}
void operator()(const gsl::not_null<Scalar<DataVector>*> numerical_flux,
const Scalar<DataVector>& normal_dot_flux_interior,
const Scalar<DataVector>& normal_dot_flux_exterior) const
noexcept {
// The minus sign appears because the normal_dot_flux_exterior was
// computed with the interface normal from the neighboring element
get(*numerical_flux) =
0.5 * (get(normal_dot_flux_interior) - get(normal_dot_flux_exterior));
}
};

Note that this numerical flux reduces to the interface average $$G_\alpha=\frac{n^\mathrm{int}_i}{2}\left(F^{i,\mathrm{int}}_\alpha + F^{i,\mathrm{ext}}_\alpha\right)$$ for the case where the interface normal is independent of the system variables and therefore $$n_i^\mathrm{ext} = -n_i^\mathrm{int}$$.

## ◆ conforms_to_v

template<typename ConformingType , template< class > class Protocol>
 constexpr bool tt::conforms_to_v
Initial value:
=
cpp17::is_convertible_v<ConformingType*, ConformsTo<Protocol>*>

Checks if the ConformingType conforms to the Protocol.

By default, only checks if the class derives off the protocol to reduce compile time. Protocol conformance is tested rigorously in the unit tests instead. Set the SPECTRE_ALWAYS_CHECK_PROTOCOL_CONFORMANCE CMake option to always enable rigorous protocol conformance checks.