ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
Classes
Miscellaneous

Classes

class  ryujin::ComputingTimer
 
class  ryujin::Lazy< T >
 
class  ryujin::MPIEnsemble
 
class  ryujin::MPIEnsembleContainer< T >
 

Various convenience wrappers for dealing with dealii::Function,

dealii::Tensor:

template<int dim, typename Number , typename Callable >
ToFunction< dim, Number, Callable > ryujin::to_function (const Callable &callable, const unsigned int k)
 
template<int dim, typename Number , typename Callable >
ToVectorFunction< dim, Number, Callable > ryujin::to_vector_function (const Callable &callable, const unsigned int n_components)
 
template<typename FT , int problem_dim = FT::dimension, typename TT = typename FT::value_type, typename T = typename TT::value_type>
DEAL_II_HOST_DEVICE_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > ryujin::contract (const FT &flux_ij, const TT &c_ij)
 
template<typename FT , int problem_dim = FT::dimension>
DEAL_II_HOST_DEVICE_ALWAYS_INLINE FT ryujin::add (const FT &flux_left_ij, const FT &flux_right_ij)
 

Functions

template<typename Number >
DEAL_II_HOST_DEVICE_ALWAYS_INLINE void ryujin::quadratic_newton_step (Number &p_1, Number &p_2, const Number phi_p_1, const Number phi_p_2, const Number dphi_p_1, const Number dphi_p_2, const Number sign=Number(1.0))
 

Macros for accessor definitions with automatic dereferencing

#define ACCESSOR_READ_ONLY(member)
 
#define ACCESSOR(member)
 
#define ACCESSOR_READ_ONLY_NO_DEREFERENCE(member)
 
#define ACCESSOR_CONTAINER_READ_ONLY(container, member)
 

Macros for compiler hints

#define RYUJIN_PRAGMA(x)   _Pragma(#x)
 
#define RYUJIN_LIKELY(x)   (__builtin_expect(!!(x), 1))
 
#define RYUJIN_UNLIKELY(x)   (__builtin_expect(!!(x), 0))
 
#define ASM_LABEL(label)   asm("#" label);
 

Exception handling in SIMD context

#define AssertThrowSIMD(variable, condition, exception)
 

Detailed Description

Miscellaneous helper functions, macros and classes.

Macro Definition Documentation

◆ ACCESSOR_READ_ONLY

#define ACCESSOR_READ_ONLY (   member)
Value:
inline const auto &member() const \
{ \
return dereference(member##_); \
}

A convenience macro that automatically writes out an accessor (or getter) function:

const Foo& bar() const { return bar_; }

or

const Foo& bar() const { return *bar_; }

depending on whether bar_ can be dereferenced, or not.

Definition at line 229 of file convenience_macros.h.

◆ ACCESSOR

#define ACCESSOR (   member)
Value:
inline auto &member() \
{ \
return dereference(member##_); \
}

Variant of the macro above that returns a mutable reference.

Definition at line 241 of file convenience_macros.h.

◆ ACCESSOR_READ_ONLY_NO_DEREFERENCE

#define ACCESSOR_READ_ONLY_NO_DEREFERENCE (   member)
Value:
inline const auto &member() const \
{ \
return member##_; \
}

Variant of the macro above that does not attempt to dereference the underlying object.

Definition at line 254 of file convenience_macros.h.

◆ ACCESSOR_CONTAINER_READ_ONLY

#define ACCESSOR_CONTAINER_READ_ONLY (   container,
  member 
)
Value:
inline const auto &member() const \
{ \
return dereference(dereference(container).member); \
}

Variant of the macro above that takes two arguments, container and member, and creates an accessor function.

const Foo& member() const { return container_.member; }

The function will dereference container and member if they are of pointer type.

Definition at line 272 of file convenience_macros.h.

◆ RYUJIN_PRAGMA

#define RYUJIN_PRAGMA (   x)    _Pragma(#x)

Defined during the device compilation pass of a "single source" offloading compiler (clang CUDA/HIP, SYCL), i.e., when the current translation unit is compiled for the device and not for the host. Macro expanding to a #pragma directive that looks nicer in indented code and can be used in other preprocessor macro definitions.

Definition at line 304 of file convenience_macros.h.

◆ RYUJIN_LIKELY

#define RYUJIN_LIKELY (   x)    (__builtin_expect(!!(x), 1))

Compiler hint annotating a boolean to be likely true.

Intended use:

if (RYUJIN_LIKELY(thread_ready == true)) {
// likely branch
}
#define RYUJIN_LIKELY(x)
Note
The performance penalty of incorrectly marking a condition as likely is severe. Use only if the condition is almost always true.

Definition at line 321 of file convenience_macros.h.

◆ RYUJIN_UNLIKELY

#define RYUJIN_UNLIKELY (   x)    (__builtin_expect(!!(x), 0))

Compiler hint annotating a boolean expression to be likely false.

Intended use:

if (RYUJIN_UNLIKELY(thread_ready == false)) {
// unlikely branch
}
#define RYUJIN_UNLIKELY(x)
Note
The performance penalty of incorrectly marking a condition as unlikely is severe. Use only if the condition is almost always false.

Definition at line 338 of file convenience_macros.h.

◆ ASM_LABEL

#define ASM_LABEL (   label)    asm("#" label);

Injects a label into the generated assembly.

Definition at line 346 of file convenience_macros.h.

◆ AssertThrowSIMD

#define AssertThrowSIMD (   variable,
  condition,
  exception 
)
Value:
if constexpr (std::is_same< \
typename std::remove_const<decltype(variable)>::type, \
double>::value || \
std::is_same< \
typename std::remove_const<decltype(variable)>::type, \
float>::value) { \
AssertThrow(condition(variable), exception); \
} else { \
for (unsigned int k = 0; k < decltype(variable)::size(); ++k) { \
AssertThrow(condition((variable)[k]), exception); \
} \
}

Mixed serial/SIMD variant of the dealii AssertThrow macro. If variable is just a plain double or float, then this macro defaults to a simple call to dealii::AssertThrow(condition(variable), exception). Otherwise (if decltype(variable) has a subscript operator operator[], the dealii::AssertThrow macro is expanded for all components of the variable.

Definition at line 34 of file simd.h.

Function Documentation

◆ to_function()

template<int dim, typename Number , typename Callable >
ToFunction< dim, Number, Callable > ryujin::to_function ( const Callable &  callable,
const unsigned int  k 
)

Convenience wrapper that creates a (scalar) dealii::Function object out of a (fairly general) callable object returning array-like values. An example usage is given by the interpolation of initial values performed in InitialValues::interpolate_hyperbolic_vector() and InitialValues::interpolate_initial_precomputed_vector()

for(unsigned int i = 0; i < problem_dimension; ++i)
dealii::VectorTools::interpolate(
dof_handler,
to_function<dim, Number>(callable, i),
U[i]);
Parameters
callableA callable object that provides an operator(const Point<dim> &) and returns an array or rank-1 tensor. More precisely, the return type must have a subscript operator operator[].
kIndex describing the component that is returned by the function object.

Definition at line 104 of file convenience_macros.h.

◆ to_vector_function()

template<int dim, typename Number , typename Callable >
ToVectorFunction< dim, Number, Callable > ryujin::to_vector_function ( const Callable &  callable,
const unsigned int  n_components 
)

Convenience wrapper that creates a vector-valued dealii::Function object out of a (fairly general) callable object returning array-like values. An example usage is given by the interpolation of initial values performed in InitialValues::interpolate_hyperbolic_vector() and InitialValues::interpolate_initial_precomputed_vector()

dealii::VectorTools::interpolate(
dof_handler,
to_function<dim, Number>(callable, block_size),
block_vector);
Parameters
callableA callable object that provides an operator(const Point<dim> &) and returns an array or rank-1 tensor. More precisely, the return type must have a subscript operator operator[].
n_componentsnumber of components.

Definition at line 134 of file convenience_macros.h.

◆ quadratic_newton_step()

template<typename Number >
DEAL_II_HOST_DEVICE_ALWAYS_INLINE void ryujin::quadratic_newton_step ( Number &  p_1,
Number &  p_2,
const Number  phi_p_1,
const Number  phi_p_2,
const Number  dphi_p_1,
const Number  dphi_p_2,
const Number  sign = Number(1.0) 
)

Perform one step of a quadratic Newton iteration, see [12], Algorithm 3.

Note
For this, it has to hold true that \(p_1\le p^\ast\le p_2\), and \(\phi(p_1)\le 0\le \phi(p_2)\), or \(\phi(p_1)\ge 0\ge \phi(p_2)\) and that \(\phi\) itself is a 3-convex/concave function, i.e., \(\phi'''<0\), or \(\phi'''>0\).

Modifies p_1 and P_2 ensures that p_1 <= p_2, and that p_1 (p_2) is monotonically increasing (decreasing).

Todo:
Write out the quadratic Newton step in more detail.

Definition at line 39 of file newton.h.

Referenced by ryujin::Euler::WaveSpeedEstimatorView< dim, Number, MemorySpace >::compute(), ryujin::Euler::LimiterView< dim, Number, MemorySpace >::limit(), ryujin::EulerAEOS::LimiterView< dim, Number >::limit(), and ryujin::ShallowWater::LimiterView< dim, Number >::limit().

◆ contract()

template<typename FT , int problem_dim = FT::dimension, typename TT = typename FT::value_type, typename T = typename TT::value_type>
DEAL_II_HOST_DEVICE_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > ryujin::contract ( const FT &  flux_ij,
const TT &  c_ij 
)

◆ add()

template<typename FT , int problem_dim = FT::dimension>
DEAL_II_HOST_DEVICE_ALWAYS_INLINE FT ryujin::add ( const FT &  flux_left_ij,
const FT &  flux_right_ij 
)