ryujin 2.1.1 revision 6759a3f00bf045f3527c5e7e7dfd18c7d96a6edb
Classes | Functions
Miscellaneous

Classes

class  ryujin::SynchronizationDispatch
 
class  ryujin::Scope
 

Functions

template<int dim>
void ryujin::Checkpointing::load_mesh (Discretization< dim > &discretization, const std::string &base_name)
 
template<int dim, typename Number , int n_comp, int simd_length>
void ryujin::Checkpointing::load_state_vector (const OfflineData< dim, Number > &offline_data, const std::string &base_name, MultiComponentVector< Number, n_comp, simd_length > &U, Number &t, unsigned int &output_cycle, const MPI_Comm &mpi_communicator)
 
template<int dim, typename Number , int n_comp, int simd_length>
void ryujin::Checkpointing::write_checkpoint (const OfflineData< dim, Number > &offline_data, const std::string &base_name, const MultiComponentVector< Number, n_comp, simd_length > &U, const Number t, const unsigned int output_cycle, const MPI_Comm &mpi_communicator)
 
template<int dim, typename Number , typename Callable >
ToFunction< dim, Number, Callable > ryujin::to_function (const Callable &callable, const unsigned int k)
 

Various convenience functions and macros

#define AssertThrowSIMD(variable, condition, exception)
 
#define ACCESSOR_READ_ONLY(member)
 
#define ACCESSOR(member)
 
#define ACCESSOR_READ_ONLY_NO_DEREFERENCE(member)
 
#define ASM_LABEL(label)   asm("#" label);
 

OpenMP parallel for macros

Intended use:

// serial work
// per thread work and thread-local storage declarations
for (unsigned int i = 0; i < size_internal; i += simd_length) {
// parallel for loop that is statically distributed on all available
// worker threads by slicing the interval [0,size_internal)
}
#define RYUJIN_PARALLEL_REGION_BEGIN
Definition: openmp.h:54
#define RYUJIN_OMP_FOR
Definition: openmp.h:70
#define RYUJIN_PARALLEL_REGION_END
Definition: openmp.h:63
#define RYUJIN_PRAGMA(x)   _Pragma(#x)
 
#define RYUJIN_PARALLEL_REGION_BEGIN
 
#define RYUJIN_PARALLEL_REGION_END   }
 
#define RYUJIN_OMP_FOR   RYUJIN_PRAGMA(omp for)
 
#define RYUJIN_OMP_FOR_NOWAIT   RYUJIN_PRAGMA(omp for nowait)
 
#define RYUJIN_OMP_BARRIER   RYUJIN_PRAGMA(omp barrier)
 
#define RYUJIN_OMP_CRITICAL   RYUJIN_PRAGMA(omp critical)
 
#define RYUJIN_OMP_SINGLE   RYUJIN_PRAGMA(omp single)
 
#define RYUJIN_LIKELY(x)   (__builtin_expect(!!(x), 1))
 
#define RYUJIN_UNLIKELY(x)   (__builtin_expect(!!(x), 0))
 

Detailed Description

Miscellaneous helper functions, macros and classes.

Macro Definition Documentation

◆ 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 119 of file convenience_macros.h.

◆ ACCESSOR_READ_ONLY

#define ACCESSOR_READ_ONLY (   member)
Value:
inline 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 185 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 197 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 210 of file convenience_macros.h.

◆ ASM_LABEL

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

Injects a label into the generated assembly.

Definition at line 222 of file convenience_macros.h.

◆ RYUJIN_PRAGMA

#define RYUJIN_PRAGMA (   x)    _Pragma(#x)

Macro expanding to a #pragma directive that can be used in other preprocessor macro definitions.

Definition at line 47 of file openmp.h.

◆ RYUJIN_PARALLEL_REGION_BEGIN

#define RYUJIN_PARALLEL_REGION_BEGIN
Value:
RYUJIN_PRAGMA(omp parallel default(shared)) \
{
#define RYUJIN_PRAGMA(x)
Definition: openmp.h:47

Begin an openmp parallel region.

Definition at line 54 of file openmp.h.

◆ RYUJIN_PARALLEL_REGION_END

#define RYUJIN_PARALLEL_REGION_END   }

End an openmp parallel region.

Definition at line 63 of file openmp.h.

◆ RYUJIN_OMP_FOR

#define RYUJIN_OMP_FOR   RYUJIN_PRAGMA(omp for)

Enter a parallel for loop.

Definition at line 70 of file openmp.h.

◆ RYUJIN_OMP_FOR_NOWAIT

#define RYUJIN_OMP_FOR_NOWAIT   RYUJIN_PRAGMA(omp for nowait)

Enter a parallel for loop with "nowait" declaration, i.e., the end of the for loop does not include an implicit thread synchronization barrier.

Definition at line 79 of file openmp.h.

◆ RYUJIN_OMP_BARRIER

#define RYUJIN_OMP_BARRIER   RYUJIN_PRAGMA(omp barrier)

Declare an explicit Thread synchronization barrier.

Definition at line 86 of file openmp.h.

◆ RYUJIN_OMP_CRITICAL

#define RYUJIN_OMP_CRITICAL   RYUJIN_PRAGMA(omp critical)

Annotate a critical section that has to be accessed sequentially.

Definition at line 93 of file openmp.h.

◆ RYUJIN_OMP_SINGLE

#define RYUJIN_OMP_SINGLE   RYUJIN_PRAGMA(omp single)

Annotate a section that has to be executed on one thread only.

Definition at line 100 of file openmp.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)
Definition: openmp.h:116
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 116 of file openmp.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)
Definition: openmp.h:132
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 132 of file openmp.h.

Function Documentation

◆ load_mesh()

template<int dim>
void ryujin::Checkpointing::load_mesh ( Discretization< dim > &  discretization,
const std::string &  base_name 
)

Performs a resume operation. Given a base_name the function tries to locate correponding checkpoint files and will read in the saved mesh and reinitializes the Discretization object.

Definition at line 39 of file checkpointing.h.

References ryujin::Discretization< dim >::prepare(), and ryujin::Discretization< dim >::triangulation().

Referenced by ryujin::TimeLoop< Description, dim, Number >::run().

◆ load_state_vector()

template<int dim, typename Number , int n_comp, int simd_length>
void ryujin::Checkpointing::load_state_vector ( const OfflineData< dim, Number > &  offline_data,
const std::string &  base_name,
MultiComponentVector< Number, n_comp, simd_length > &  U,
Number &  t,
unsigned int &  output_cycle,
const MPI_Comm &  mpi_communicator 
)

Performs a resume operation. Given a base_name the function tries to locate correponding checkpoint files and will read in the saved state U at saved time t with saved output cycle output_cycle.

Definition at line 61 of file checkpointing.h.

References ryujin::OfflineData< dim, Number >::dof_handler(), ryujin::MultiComponentVector< Number, n_comp, simd_length >::insert_component(), and ryujin::OfflineData< dim, Number >::scalar_partitioner().

Referenced by ryujin::TimeLoop< Description, dim, Number >::run().

◆ write_checkpoint()

template<int dim, typename Number , int n_comp, int simd_length>
void ryujin::Checkpointing::write_checkpoint ( const OfflineData< dim, Number > &  offline_data,
const std::string &  base_name,
const MultiComponentVector< Number, n_comp, simd_length > &  U,
const Number  t,
const unsigned int  output_cycle,
const MPI_Comm &  mpi_communicator 
)

Writes out a checkpoint to disk. Given a base_name and a current state U at time t and output cycle output_cycle the function writes out the state to disk using boost::archive for serialization.

Todo:
Some day, we should refactor this into a class and do something smarter...

Definition at line 145 of file checkpointing.h.

References ryujin::OfflineData< dim, Number >::discretization(), ryujin::OfflineData< dim, Number >::dof_handler(), ryujin::MultiComponentVector< Number, n_comp, simd_length >::extract_component(), and ryujin::OfflineData< dim, Number >::scalar_partitioner().

Referenced by ryujin::TimeLoop< Description, dim, Number >::output().

◆ 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();

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 68 of file convenience_macros.h.