ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Utils Namespace Reference

Namespaces

namespace  Interpolation
namespace  Mpi
namespace  Statistics

Classes

struct  AccumulatorData
class  Accumulator
struct  Array
class  Bag
 Bag of elements. More...
class  Cache
class  compact_vector
 Custom vector container optimized for size. More...
class  Counter
class  Factory
 Factory template. More...
class  Histogram
 Histogram in Cartesian coordinates. More...
class  CylindricalHistogram
 Histogram in cylindrical coordinates. More...
class  CylindricalTransformationParameters
 A class to hold and validate parameters for a cylindrical coordinate transformations. More...
struct  Matrix
 Matrix representation with static size. More...
class  NumeratedContainer
 Container for objects that are identified by a numeric id. More...
struct  Quaternion
 Quaternion representation. More...
struct  is_statically_serializable
 Type trait to indicate that a type is serializable with a static size, e.g. More...
class  MemcpyIArchive
 Archive that deserializes from a buffer via memcpy. More...
class  MemcpyOArchive
 Archive that serializes to a buffer via memcpy. More...
class  Vector
struct  decay_to_scalar
 Meta function to turn a Vector<T, 1> into T. More...
struct  decay_to_scalar< Vector< T, N > >
struct  decay_to_scalar< Vector< T, 1 > >

Typedefs

using Vector3b = Utils::Vector<bool, 3>
template<class T>
using Vector3 = Vector<T, 3>
template<std::size_t N>
using VectorXd = Vector<double, N>
using Vector2d = VectorXd<2>
using Vector3d = VectorXd<3>
using Vector4d = VectorXd<4>
using Vector6d = VectorXd<6>
using Vector9d = VectorXd<9>
template<std::size_t N>
using VectorXf = Vector<float, N>
using Vector3f = VectorXf<3>
template<std::size_t N>
using VectorXi = Vector<int, N>
using Vector3i = VectorXi<3>

Enumerations

enum class  MemoryOrder { COLUMN_MAJOR , ROW_MAJOR }

Functions

template<std::size_t I, class T, std::size_t N>
T & get (Array< T, N > &a) noexcept
template<std::size_t I, class T, std::size_t N>
T const & get (Array< T, N > const &a) noexcept
template<typename Body, typename... ForwardRange>
void cartesian_product (const Body &op, const ForwardRange &...rng)
 Call op with each element of the Cartesian product set of rng.
template<class Range, class T>
bool contains (Range &&rng, T const &value)
 Check whether a range contains a value.
template<class T>
std::string demangle ()
 Get a human-readable name for a type.
template<class Range, class OutputIterator>
void flatten (Range const &v, OutputIterator out)
 Flatten a range of ranges.
template<typename ForwardIterator, typename BinaryOp>
void for_each_pair (ForwardIterator first, ForwardIterator last, BinaryOp op)
 Execute op for each pair of elements in [first, last) once.
template<typename ForwardRange, typename BinaryOp>
void for_each_pair (ForwardRange &&rng, BinaryOp &&op)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename ForwardIterator, typename BinaryOp>
void for_each_cartesian_pair (ForwardIterator first1, ForwardIterator last1, ForwardIterator first2, ForwardIterator last2, BinaryOp op)
 Execute op for each pair of elements between [first1, last1) and [first2, last2).
template<typename ForwardRange, typename BinaryOp>
void for_each_cartesian_pair (ForwardRange &&rng1, ForwardRange &&rng2, BinaryOp &&op)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename ForwardIterator, typename BinaryOp, typename BinaryCmp>
void for_each_cartesian_pair_if (ForwardIterator first1, ForwardIterator last1, ForwardIterator first2, ForwardIterator last2, BinaryOp op, BinaryCmp cmp)
 Execute op for each pair of elements between [first1, last1) and [first2, last2) if a condition is satisfied.
template<typename ForwardRange, typename BinaryOp, typename BinaryCmp>
void for_each_cartesian_pair_if (ForwardRange &&rng1, ForwardRange &&rng2, BinaryOp &&op, BinaryCmp cmp)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<MemoryOrder memory_order>
DEVICE_QUALIFIER int get_linear_index (int a, int b, int c, Vector3i const &adim)
DEVICE_QUALIFIER int get_linear_index (int a, int b, int c, Vector3i const &adim, MemoryOrder memory_order=MemoryOrder::COLUMN_MAJOR)
 Get the linear index from the position (a,b,c) in a 3D grid of dimensions adim.
DEVICE_QUALIFIER int get_linear_index (Vector3i const &ind, Vector3i const &adim, MemoryOrder memory_order=MemoryOrder::COLUMN_MAJOR)
template<MemoryOrder memory_order>
DEVICE_QUALIFIER int get_linear_index (Vector3i const &ind, Vector3i const &adim)
template<class T>
DEVICE_QUALIFIER T lower_triangular (T i, T j)
 Linear index into a lower triangular matrix.
template<typename T, template< T > class F, T min, T max, class... Args>
decltype(auto) integral_parameter (T i, Args &&...args)
 Generate a call table for an integral non-type template parameter.
template<typename T, typename Container>
T linear_interpolation (Container const &table, T hi, T offset, T x)
 Linear interpolation between two data points.
template<class T>
T mask (std::unsigned_integral auto mask, T const &t)
 Pick elements of a tuple-like by a bit mask.
template<typename T>
constexpr T AS_erfc_part (T d)
 Approximate \( \exp(d^2) \mathrm{erfc}(d)\) by applying a formula from [1] chapter 7.
template<int order, typename T>
DEVICE_QUALIFIER auto bspline (int i, T x) -> T requires((order > 0) and(order<=7))
 Formula of the B-spline.
template<int order, typename T = double>
DEVICE_QUALIFIER auto bspline_d (int i, T x) -> T requires((order > 0) and(order<=7))
 Derivative of the B-spline.
Vector3d basis_change (Vector3d const &b1, Vector3d const &b2, Vector3d const &b3, Vector3d const &v, bool reverse=false)
 Basis change.
Vector3d transform_coordinate_cartesian_to_cylinder (Vector3d const &pos)
 Coordinate transformation from Cartesian to cylindrical coordinates.
Vector3d transform_coordinate_cartesian_to_cylinder (Vector3d const &pos, Vector3d const &axis, Vector3d const &orientation)
 Coordinate transformation from Cartesian to cylindrical coordinates with change of basis.
Vector3d transform_coordinate_cylinder_to_cartesian (Vector3d const &pos)
 Coordinate transformation from cylindrical to Cartesian coordinates.
Vector3d transform_coordinate_cylinder_to_cartesian (Vector3d const &pos, Vector3d const &axis, Vector3d const &orientation)
 Coordinate transformation from cylindrical to Cartesian coordinates with change of basis.
Vector3d transform_vector_cartesian_to_cylinder (Vector3d const &vec, Vector3d const &axis, Vector3d const &pos)
 Vector transformation from Cartesian to cylindrical coordinates.
double gaussian (Vector3d x, Vector3d x0, double sigma)
Utils::Vector3d del_gaussian (Vector3d x, Vector3d x0, double sigma)
template<unsigned n, typename T>
DEVICE_QUALIFIER constexpr T int_pow (T x)
 Calculate integer powers.
template<class T>
auto make_lin_space (T start, T stop, std::size_t number, bool endpoint=true)
 Equally spaced values in interval.
template<typename T, std::size_t N>
Vector< T, N > calc_orthonormal_vector (Vector< T, N > const &vec)
 Return a vector that is orthonormal to vec.
void permute_ifield (int *field, int size, int permute)
 permute an integer array field of size size about permute positions.
template<class T>
constexpr Vector< T, 3 > convert_quaternion_to_director (Quaternion< T > const &quat)
 Convert quaternion to director.
template<class T>
Quaternion< T > convert_director_to_quaternion (Vector< T, 3 > const &d)
 Convert director to quaternion.
template<typename T>
DEVICE_QUALIFIER constexpr T sqr (T x)
 Calculates the SQuaRe of x.
template<typename T, std::size_t N, std::size_t M>
Matrix< T, N, M > tensor_product (const Vector< T, N > &x, const Vector< T, M > &y)
template<typename T, std::size_t N>
Vector< T, N > tensor_product (const T &x, const Vector< T, N > &y)
Vector3d get_n_triangle (const Vector3d &P1, const Vector3d &P2, const Vector3d &P3)
 Computes the normal vector of a triangle.
double area_triangle (const Vector3d &P1, const Vector3d &P2, const Vector3d &P3)
 Computes the area of triangle between vectors P1,P2,P3, by computing the cross product P1P2 x P1P3 and taking the half of its norm.
double angle_btw_triangles (const Vector3d &P1, const Vector3d &P2, const Vector3d &P3, const Vector3d &P4)
 Computes the angle between two triangles in 3D space.
Vector3d vec_rotate (const Vector3d &axis, double angle, const Vector3d &vector)
 Rotate a vector around an axis.
double angle_between (Vector3d const &v1, Vector3d const &v2)
 Determine the angle between two vectors.
template<typename T, std::size_t M, std::size_t N>
Utils::Vector< T, M *N > flatten (Matrix< T, M, N > const &m) noexcept
template<typename T, std::size_t Rows, std::size_t Cols>
Matrix< T, Rows, Cols > diagonal_mat (Utils::Vector< T, Rows > const &v)
template<typename T, std::size_t Rows, std::size_t Cols>
Matrix< T, Rows, Cols > identity_mat ()
template<typename T, typename U>
requires (std::is_arithmetic_v<U>)
Quaternion< T > operator* (const U &b, const Quaternion< T > &a)
 Product quaternion and arithmetic type.
template<typename T>
Matrix< T, 3, 3 > rotation_matrix (Quaternion< T > const &q)
 Convert quaternion to rotation matrix.
template<class T, class F>
auto raster (Vector< T, 3 > const &offset, Vector< T, 3 > const &grid_spacing, Vector3i const &size, F f)
 Raster a function over a regular 3d grid.
std::vector< Vector3d > get_cylindrical_sampling_positions (std::pair< double, double > const &r_limits, std::pair< double, double > const &phi_limits, std::pair< double, double > const &z_limits, std::size_t n_r_bins, std::size_t n_phi_bins, std::size_t n_z_bins, double sampling_density)
 Generate sampling positions for a cylindrical histogram.
template<class T>
std::string pack (T const &v)
 Pack a serialize type into a string.
template<class T>
T unpack (std::string const &state)
 Unpack a serialize type into a string.
DEVICE_QUALIFIER constexpr uint64_t u32_to_u64 (uint32_t high, uint32_t low)
constexpr DEVICE_QUALIFIER double uniform (uint64_t in)
 Uniformly map unsigned integer to double.
template<std::size_t N, typename T, typename U>
auto operator+ (Vector< T, N > const &a, Vector< U, N > const &b)
template<std::size_t N, typename T>
ESPRESSO_ATTR_ALWAYS_INLINE auto & operator+= (Vector< T, N > &a, Vector< T, N > const &b)
template<std::size_t N, typename T, typename U>
auto operator- (Vector< T, N > const &a, Vector< U, N > const &b)
template<std::size_t N, typename T>
Vector< T, N > operator- (Vector< T, N > const &a)
template<std::size_t N, typename T>
ESPRESSO_ATTR_ALWAYS_INLINE Vector< T, N > & operator-= (Vector< T, N > &a, Vector< T, N > const &b)
template<std::size_t N, typename T, class U>
requires (std::is_arithmetic_v<U>)
constexpr auto operator* (U const &a, Vector< T, N > const &b)
template<std::size_t N, typename T, class U>
requires (std::is_arithmetic_v<U>)
constexpr auto operator* (Vector< T, N > const &a, U const &b)
template<std::size_t N, typename T>
auto & operator*= (Vector< T, N > &b, T const &a)
template<std::size_t N, typename T, class U>
auto operator/ (Vector< T, N > const &a, U const &b)
template<std::size_t N, typename T, class U>
auto operator/ (U const &a, Vector< T, N > const &b)
template<std::size_t N, typename T>
auto & operator/= (Vector< T, N > &a, T const &b)
template<std::size_t N, typename T, class U>
requires (not(detail::is_vector<T>::value or detail::is_vector<U>::value))
auto constexpr operator* (Vector< T, N > const &a, Vector< U, N > const &b)
template<std::size_t N, typename T, class U>
requires (std::is_integral_v<T> and std::is_integral_v<U>)
auto operator% (Vector< T, N > const &a, Vector< U, N > const &b)
template<std::size_t N, typename T>
auto sqrt (Vector< T, N > const &a)
template<class T>
Vector< T, 3 > vector_product (Vector< T, 3 > const &a, Vector< T, 3 > const &b)
template<class T, std::size_t N>
T product (Vector< T, N > const &v)
template<class T, class U, std::size_t N>
auto hadamard_product (Vector< T, N > const &a, Vector< U, N > const &b)
template<typename T, typename U>
requires (not(detail::is_vector<T>::value and detail::is_vector<U>::value))
auto hadamard_product (T const &a, U const &b)
template<class T, class U, std::size_t N>
auto hadamard_division (Vector< T, N > const &a, Vector< U, N > const &b)
template<typename T, typename U>
requires (not(detail::is_vector<T>::value and detail::is_vector<U>::value))
auto hadamard_division (T const &a, U const &b)
template<typename T>
Vector< T, 3 > unit_vector (unsigned int i)
template<std::size_t I, class T, std::size_t N>
T & get (Vector< T, N > &a) noexcept
template<std::size_t I, class T, std::size_t N>
T const & get (Vector< T, N > const &a) noexcept

Typedef Documentation

◆ Vector2d

Definition at line 206 of file Vector.hpp.

◆ Vector3

template<class T>
using Utils::Vector3 = Vector<T, 3>

Definition at line 203 of file Vector.hpp.

◆ Vector3b

using Utils::Vector3b = Utils::Vector<bool, 3>

Definition at line 44 of file Variant.hpp.

◆ Vector3d

Definition at line 207 of file Vector.hpp.

◆ Vector3f

Definition at line 213 of file Vector.hpp.

◆ Vector3i

Definition at line 216 of file Vector.hpp.

◆ Vector4d

Definition at line 208 of file Vector.hpp.

◆ Vector6d

Definition at line 209 of file Vector.hpp.

◆ Vector9d

Definition at line 210 of file Vector.hpp.

◆ VectorXd

template<std::size_t N>
using Utils::VectorXd = Vector<double, N>

Definition at line 205 of file Vector.hpp.

◆ VectorXf

template<std::size_t N>
using Utils::VectorXf = Vector<float, N>

Definition at line 212 of file Vector.hpp.

◆ VectorXi

template<std::size_t N>
using Utils::VectorXi = Vector<int, N>

Definition at line 215 of file Vector.hpp.

Enumeration Type Documentation

◆ MemoryOrder

enum class Utils::MemoryOrder
strong
Enumerator
COLUMN_MAJOR 
ROW_MAJOR 

Definition at line 33 of file index.hpp.

Function Documentation

◆ angle_between()

double Utils::angle_between ( Vector3d const & v1,
Vector3d const & v2 )
inline

◆ angle_btw_triangles()

double Utils::angle_btw_triangles ( const Vector3d & P1,
const Vector3d & P2,
const Vector3d & P3,
const Vector3d & P4 )
inline

Computes the angle between two triangles in 3D space.

Returns the angle between two triangles in 3D space given by points P1P2P3 and P2P3P4. Note, that the common edge is given as the second and the third argument. Here, the angle can have values from 0 to 2 * PI, depending on the orientation of the two triangles. So the angle can be convex or concave. For each triangle, an inward direction has been defined as the direction of one of the two normal vectors. Particularly, for triangle P1P2P3 it is the vector N1 = P2P1 x P2P3 and for triangle P2P3P4 it is N2 = P2P3 x P2P4. The method first computes the angle between N1 and N2, which gives always value between 0 and PI and then it checks whether this value must be corrected to a value between PI and 2 * PI.

As an example, consider 4 points A,B,C,D in space given by coordinates A = [1,1,1], B = [2,1,1], C = [1,2,1], D = [1,1,2]. We want to determine the angle between triangles ABC and ACD. In case the orientation of the triangle ABC is [0,0,1] and orientation of ACD is [1,0,0], the resulting angle must be PI/2.0. To get correct results, note that the common edge is AC, and one must call the method as angle_btw_triangles(B,A,C,D). With this call we have ensured that N1 = AB x AC (which coincides with [0,0,1]) and N2 = AC x AD (which coincides with [1,0,0]). Alternatively, if the orientations of the two triangles were the opposite, the correct call would be angle_btw_triangles(B,C,A,D) so that N1 = CB x CA and N2 = CA x CD.

Definition at line 79 of file triangle_functions.hpp.

References get_n_triangle().

Referenced by OifLocalForcesBond::calc_forces().

◆ area_triangle()

double Utils::area_triangle ( const Vector3d & P1,
const Vector3d & P2,
const Vector3d & P3 )
inline

Computes the area of triangle between vectors P1,P2,P3, by computing the cross product P1P2 x P1P3 and taking the half of its norm.

Definition at line 48 of file triangle_functions.hpp.

References get_n_triangle(), and Utils::Vector< T, N >::norm().

Referenced by add_oif_global_forces(), OifLocalForcesBond::calc_forces(), and calc_oif_mesh().

◆ AS_erfc_part()

template<typename T>
T Utils::AS_erfc_part ( T d)
constexpr

Approximate \( \exp(d^2) \mathrm{erfc}(d)\) by applying a formula from [1] chapter 7.

Definition at line 29 of file AS_erfc_part.hpp.

Referenced by CoulombP3M::pair_energy(), DipolarP3M::pair_energy(), CoulombP3M::pair_force(), and DipolarP3M::pair_force().

◆ basis_change()

Vector3d Utils::basis_change ( Vector3d const & b1,
Vector3d const & b2,
Vector3d const & b3,
Vector3d const & v,
bool reverse = false )
inline

◆ bspline()

template<int order, typename T>
DEVICE_QUALIFIER auto Utils::bspline ( int i,
T x )->Trequires((order >0) and(order<=7))

◆ bspline_d()

template<int order, typename T = double>
DEVICE_QUALIFIER auto Utils::bspline_d ( int i,
T x )->Trequires((order >0) and(order<=7))

Derivative of the B-spline.

Definition at line 204 of file bspline.hpp.

References DEVICE_ASSERT, DEVICE_QUALIFIER, and DEVICE_THROW.

Referenced by Utils::Interpolation::bspline_3d_gradient().

◆ calc_orthonormal_vector()

template<typename T, std::size_t N>
Vector< T, N > Utils::calc_orthonormal_vector ( Vector< T, N > const & vec)

◆ cartesian_product()

template<typename Body, typename... ForwardRange>
void Utils::cartesian_product ( const Body & op,
const ForwardRange &... rng )

Call op with each element of the Cartesian product set of rng.

Parameters
opOperation to call for each element of the product set.
rngRanges to form the product over

Definition at line 54 of file cartesian_product.hpp.

◆ contains()

template<class Range, class T>
bool Utils::contains ( Range && rng,
T const & value )

Check whether a range contains a value.

Re-implementation of std::ranges::contains() from C++23.

Parameters
rngThe range to search in.
valueThe value to search for.
Returns
True iff range contains the value.

Definition at line 36 of file contains.hpp.

Referenced by add_exclusion(), gather_traits_for_types(), mindist(), and CellStructure::remove_particle().

◆ convert_director_to_quaternion()

template<class T>
Quaternion< T > Utils::convert_director_to_quaternion ( Vector< T, 3 > const & d)

Convert director to quaternion.

Parameters
dDirector
Returns
A (non-normalized) quaternion from the director, or {1, 0, 0, 0} if the director is the null vector.

Definition at line 55 of file math/quaternion.hpp.

References Utils::Vector< T, N >::norm().

Referenced by calculate_vs_relate_to_params(), convert_dip_to_quat(), and ScriptInterface::Particles::ParticleHandle::ParticleHandle().

◆ convert_quaternion_to_director()

template<class T>
Vector< T, 3 > Utils::convert_quaternion_to_director ( Quaternion< T > const & quat)
constexpr

Convert quaternion to director.

Returns
A (non-normalized) director.

Definition at line 42 of file math/quaternion.hpp.

Referenced by ParticlePosition::calc_director(), commit_particle(), connection_vector(), gb_pair_energy(), gb_pair_force(), and ScriptInterface::Particles::ParticleHandle::ParticleHandle().

◆ del_gaussian()

Utils::Vector3d Utils::del_gaussian ( Vector3d x,
Vector3d x0,
double sigma )
inline

Definition at line 31 of file utils/include/utils/math/gaussian.hpp.

References gaussian().

◆ demangle()

template<class T>
std::string Utils::demangle ( )

Get a human-readable name for a type.

Uses boost to demangle the name, for details see documentation for boost::core::demangle.

Template Parameters
Ttype
Returns
name

Definition at line 37 of file demangle.hpp.

Referenced by Coulomb::LongRangePressure::operator()(), and ScriptInterface::Scafacos::ConvertToStringVector::operator()().

◆ diagonal_mat()

template<typename T, std::size_t Rows, std::size_t Cols>
Matrix< T, Rows, Cols > Utils::diagonal_mat ( Utils::Vector< T, Rows > const & v)

Definition at line 232 of file matrix.hpp.

◆ flatten() [1/2]

template<typename T, std::size_t M, std::size_t N>
Utils::Vector< T, M *N > Utils::flatten ( Matrix< T, M, N > const & m)
noexcept

Definition at line 227 of file matrix.hpp.

◆ flatten() [2/2]

template<class Range, class OutputIterator>
void Utils::flatten ( Range const & v,
OutputIterator out )

Flatten a range of ranges.

Copy a range of ranges to an output range by subsequently copying the nested ranges to the output. Arbitrary deep nesting is supported, the elements are copied into the output in a depth-first fashion.

Template Parameters
RangeA Forward Range
OutputIteratorAn OutputIterator
Parameters
vInput Range
outOutput iterator

Definition at line 56 of file flatten.hpp.

Referenced by calculate_positional_correction(), System::System::calculate_pressure(), dpd_pressure(), Observables::ParticleObservable< ParticleObservables::CenterOfMassPosition >::evaluate(), DipolarDirectSum::long_range_pressure(), Utils::Matrix< T, codim, 3 >::Matrix(), AngleBondsPressureKernel::operator()(), DihedralBondsPressureKernel::operator()(), PairBondsPressureKernel::operator()(), and PressureKernel::operator()().

◆ for_each_cartesian_pair() [1/2]

template<typename ForwardIterator, typename BinaryOp>
void Utils::for_each_cartesian_pair ( ForwardIterator first1,
ForwardIterator last1,
ForwardIterator first2,
ForwardIterator last2,
BinaryOp op )

Execute op for each pair of elements between [first1, last1) and [first2, last2).

Diagonal elements are not excluded. Pairs are traversed ordered, so that for op(*it, *jt), it holds that distance(it - first) < distance(jt - first), and distance(it_n - first) < distance(it_n+1 - first) for consecutive calls.

Definition at line 61 of file for_each_pair.hpp.

Referenced by for_each_cartesian_pair().

◆ for_each_cartesian_pair() [2/2]

template<typename ForwardRange, typename BinaryOp>
void Utils::for_each_cartesian_pair ( ForwardRange && rng1,
ForwardRange && rng2,
BinaryOp && op )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 72 of file for_each_pair.hpp.

References for_each_cartesian_pair().

◆ for_each_cartesian_pair_if() [1/2]

template<typename ForwardIterator, typename BinaryOp, typename BinaryCmp>
void Utils::for_each_cartesian_pair_if ( ForwardIterator first1,
ForwardIterator last1,
ForwardIterator first2,
ForwardIterator last2,
BinaryOp op,
BinaryCmp cmp )

Execute op for each pair of elements between [first1, last1) and [first2, last2) if a condition is satisfied.

Diagonal elements are not excluded. Pairs are traversed ordered, so that for op(*it, *jt), it holds that distance(it - first) < distance(jt - first), and distance(it_n - first) < distance(it_n+1 - first) for consecutive calls.

Definition at line 89 of file for_each_pair.hpp.

Referenced by for_each_cartesian_pair_if().

◆ for_each_cartesian_pair_if() [2/2]

template<typename ForwardRange, typename BinaryOp, typename BinaryCmp>
void Utils::for_each_cartesian_pair_if ( ForwardRange && rng1,
ForwardRange && rng2,
BinaryOp && op,
BinaryCmp cmp )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 104 of file for_each_pair.hpp.

References for_each_cartesian_pair_if().

◆ for_each_pair() [1/2]

template<typename ForwardIterator, typename BinaryOp>
void Utils::for_each_pair ( ForwardIterator first,
ForwardIterator last,
BinaryOp op )

Execute op for each pair of elements in [first, last) once.

Diagonal elements are excluded. Pairs are traversed ordered, so that for op(*it, *jt), it holds that distance(it - first) < distance(jt - first), and distance(it_n - first) < distance(it_n+1 - first) for consecutive calls.

Definition at line 36 of file for_each_pair.hpp.

Referenced by for_each_pair(), and ClusterAnalysis::ClusterStructure::run_for_all_pairs().

◆ for_each_pair() [2/2]

template<typename ForwardRange, typename BinaryOp>
void Utils::for_each_pair ( ForwardRange && rng,
BinaryOp && op )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 46 of file for_each_pair.hpp.

References for_each_pair().

◆ gaussian()

double Utils::gaussian ( Vector3d x,
Vector3d x0,
double sigma )
inline

Definition at line 27 of file utils/include/utils/math/gaussian.hpp.

Referenced by del_gaussian().

◆ get() [1/4]

template<std::size_t I, class T, std::size_t N>
T & Utils::get ( Array< T, N > & a)
noexcept

Definition at line 210 of file Array.hpp.

◆ get() [2/4]

template<std::size_t I, class T, std::size_t N>
T const & Utils::get ( Array< T, N > const & a)
noexcept

Definition at line 215 of file Array.hpp.

◆ get() [3/4]

template<std::size_t I, class T, std::size_t N>
T & Utils::get ( Vector< T, N > & a)
noexcept

Definition at line 440 of file Vector.hpp.

◆ get() [4/4]

template<std::size_t I, class T, std::size_t N>
T const & Utils::get ( Vector< T, N > const & a)
noexcept

Definition at line 445 of file Vector.hpp.

◆ get_cylindrical_sampling_positions()

std::vector< Vector3d > Utils::get_cylindrical_sampling_positions ( std::pair< double, double > const & r_limits,
std::pair< double, double > const & phi_limits,
std::pair< double, double > const & z_limits,
std::size_t n_r_bins,
std::size_t n_phi_bins,
std::size_t n_z_bins,
double sampling_density )

Generate sampling positions for a cylindrical histogram.

Parameters
r_limitsRange for radial coordinate as std::pair.
phi_limitsRange for azimuthal angle as std::pair.
z_limitsRange for z coordinate as std::pair.
n_r_binsNumber of bins in radial direction.
n_phi_binsNumber of bins in azimuthal direction.
n_z_binsNumber of bins in z direction.
sampling_densityThe number of samples per unit volume.
Return values
Cartesiansampling coordinates.

Definition at line 46 of file sampling.hpp.

References make_lin_space(), and sqr().

Referenced by Observables::CylindricalLBProfileObservable::calculate_sampling_positions().

◆ get_linear_index() [1/4]

◆ get_linear_index() [2/4]

DEVICE_QUALIFIER int Utils::get_linear_index ( int a,
int b,
int c,
Vector3i const & adim,
MemoryOrder memory_order = MemoryOrder::COLUMN_MAJOR )
inline

Get the linear index from the position (a,b,c) in a 3D grid of dimensions adim.

Returns
The linear index
Parameters
a,b,cPosition in 3D space
adimDimensions of the underlying grid
memory_orderRow- or column-major

Definition at line 56 of file index.hpp.

References COLUMN_MAJOR, and get_linear_index().

◆ get_linear_index() [3/4]

template<MemoryOrder memory_order>
DEVICE_QUALIFIER int Utils::get_linear_index ( Vector3i const & ind,
Vector3i const & adim )
inline

Definition at line 71 of file index.hpp.

References DEVICE_QUALIFIER, and get_linear_index().

◆ get_linear_index() [4/4]

DEVICE_QUALIFIER int Utils::get_linear_index ( Vector3i const & ind,
Vector3i const & adim,
MemoryOrder memory_order = MemoryOrder::COLUMN_MAJOR )
inline

Definition at line 65 of file index.hpp.

References COLUMN_MAJOR, and get_linear_index().

◆ get_n_triangle()

Vector3d Utils::get_n_triangle ( const Vector3d & P1,
const Vector3d & P2,
const Vector3d & P3 )
inline

Computes the normal vector of a triangle.

The sign convention is such that P1P2, P1P3 and the normal form a right-handed system. The normal vector is not normalized, i.e. its length is arbitrary.

Definition at line 37 of file triangle_functions.hpp.

References vector_product().

Referenced by add_oif_global_forces(), angle_btw_triangles(), area_triangle(), OifLocalForcesBond::calc_forces(), and calc_oif_mesh().

◆ hadamard_division() [1/2]

template<typename T, typename U>
requires (not(detail::is_vector<T>::value and detail::is_vector<U>::value))
auto Utils::hadamard_division ( T const & a,
U const & b )

Definition at line 413 of file Vector.hpp.

◆ hadamard_division() [2/2]

template<class T, class U, std::size_t N>
auto Utils::hadamard_division ( Vector< T, N > const & a,
Vector< U, N > const & b )

◆ hadamard_product() [1/2]

template<typename T, typename U>
requires (not(detail::is_vector<T>::value and detail::is_vector<U>::value))
auto Utils::hadamard_product ( T const & a,
U const & b )

Definition at line 396 of file Vector.hpp.

◆ hadamard_product() [2/2]

◆ identity_mat()

template<typename T, std::size_t Rows, std::size_t Cols>
Matrix< T, Rows, Cols > Utils::identity_mat ( )

Definition at line 238 of file matrix.hpp.

Referenced by rotation_matrix().

◆ int_pow()

template<unsigned n, typename T>
DEVICE_QUALIFIER constexpr T Utils::int_pow ( T x)
constexpr

Calculate integer powers.

This functions calculates x^n, where n is a positive integer that is known at compile time. It uses exponentiation by squaring to construct an efficient function.

Definition at line 34 of file int_pow.hpp.

References DEVICE_QUALIFIER, and int_pow().

Referenced by BMHTF_pair_energy(), BMHTF_pair_force_factor(), BMHTF_Parameters::BMHTF_Parameters(), DipolarP3MHeffte< FloatType, Architecture, FFTConfig >::calc_average_self_energy_k_space(), DipolarP3MHeffte< FloatType, Architecture, FFTConfig >::calc_energy_correction(), ScriptInterface::walberla::EKReaction::calculate_bulk_conversion_factor(), ScriptInterface::walberla::EKSpecies::do_construct(), ScriptInterface::walberla::LBFluid::do_construct(), ScriptInterface::walberla::LBFluidNode::do_construct(), ScriptInterface::walberla::LBFluidSlice::do_construct(), dp3m_k_space_error(), dp3m_real_space_error(), estimate_max_counts(), QuarticBond::force(), G_opt(), G_opt_dipolar(), gb_pair_energy(), gb_pair_force(), LJ_Parameters::get_auto_shift(), grid_influence_function_dipolar(), CoulombP3MImpl< FloatType, Architecture, FFTConfig >::init_cpu_kernels(), DipolarP3MHeffte< FloatType, Architecture, FFTConfig >::init_cpu_kernels(), int_pow(), lj_pair_energy(), lj_pair_force_factor(), ljcos2_pair_energy(), ljcos2_pair_force_factor(), ljcos_pair_energy(), ljcos_pair_force_factor(), DipolarP3MHeffte< FloatType, Architecture, FFTConfig >::long_range_kernel(), ScriptInterface::walberla::EKFFT::make_instance(), p3m_calc_blocks(), p3m_k_space_error_gpu_kernel_ik(), ReactionField::pair_energy(), CoulombMMM1D::pair_force(), DebyeHueckel::pair_force(), ReactionField::pair_force(), ScriptInterface::walberla::EKPoissonSolver::set_potential_conversion(), LB::LBWalberla::veto_kT(), wca_pair_energy(), and wca_pair_force_factor().

◆ integral_parameter()

template<typename T, template< T > class F, T min, T max, class... Args>
decltype(auto) Utils::integral_parameter ( T i,
Args &&... args )

◆ linear_interpolation()

template<typename T, typename Container>
T Utils::linear_interpolation ( Container const & table,
T hi,
T offset,
T x )

Linear interpolation between two data points.

Parameters
[in]tableTabulated values, equally-spaced along the x-axis
[in]hiInverse distance on the x-axis between tabulated values
[in]offsetPosition on the x-axis of the first tabulated value
[in]xPosition on the x-axis at which to interpolate the value
Returns
Interpolated value on the y-axis at x.

Definition at line 34 of file linear_interpolation.hpp.

Referenced by TabulatedPotential::energy(), and TabulatedPotential::force().

◆ lower_triangular()

template<class T>
DEVICE_QUALIFIER T Utils::lower_triangular ( T i,
T j )

Linear index into a lower triangular matrix.

This is row-major.

Template Parameters
TIntegral type
Parameters
irow index
jcolumn index
Returns
linear index

Definition at line 86 of file index.hpp.

References DEVICE_ASSERT, and DEVICE_QUALIFIER.

Referenced by InteractionsNonBonded::get_ia_param_key(), EnergyBinLayout::nb_inter_idx(), PressureBinLayout::nb_inter_idx(), EnergyBinLayout::nb_intra_idx(), and PressureBinLayout::nb_intra_idx().

◆ make_lin_space()

template<class T>
auto Utils::make_lin_space ( T start,
T stop,
std::size_t number,
bool endpoint = true )

Equally spaced values in interval.

Returns a range of equally spaced values in the range start to stop, like numpy.linspace().

Template Parameters
Tfloating point type
Parameters
startStart value of the interval
stopEnd value of the interval
numberNumber of partition points
endpointIf true, the last point is stop.
Returns
Range of equally-spaced values

Definition at line 41 of file make_lin_space.hpp.

Referenced by Observables::ProfileObservable::edges(), get_cylindrical_sampling_positions(), and raster().

◆ mask()

template<class T>
T Utils::mask ( std::unsigned_integral auto mask,
T const & t )

Pick elements of a tuple-like by a bit mask.

E.g. every element of the input for which the corresponding bit is set in the mask is set is copied to the output unmodified, the elements that are not set are set to zero (default constructed instance of the type).

Example: mask(0b1011u, {1, 2, 3, 4}) => {1, 2, 0, 4}

Template Parameters
Timplements the tuple interface(get, tuple_size, ...)
Parameters
maskbit mask, if the i-th bit is set, the i-th element in t is copied to the output, otherwise it is set to zero.
tinput elements
Returns
t partially zeroed out according to mask

Definition at line 55 of file mask.hpp.

References mask().

Referenced by convert_torque_to_body_frame_apply_fix(), mask(), and propagate_omega_quat_particle().

◆ operator%()

template<std::size_t N, typename T, class U>
requires (std::is_integral_v<T> and std::is_integral_v<U>)
auto Utils::operator% ( Vector< T, N > const & a,
Vector< U, N > const & b )

Definition at line 354 of file Vector.hpp.

◆ operator*() [1/4]

template<typename T, typename U>
requires (std::is_arithmetic_v<U>)
Quaternion< T > Utils::operator* ( const U & b,
const Quaternion< T > & a )

Product quaternion and arithmetic type.

Template Parameters
TData type of quaternion a.
UType of multiplier b.
Parameters
bQuaternion.
aMultiplier.
Returns
Multiplied quaternion.

Definition at line 142 of file quaternion.hpp.

◆ operator*() [2/4]

template<std::size_t N, typename T, class U>
requires (std::is_arithmetic_v<U>)
auto Utils::operator* ( U const & a,
Vector< T, N > const & b )
constexpr

Definition at line 289 of file Vector.hpp.

◆ operator*() [3/4]

template<std::size_t N, typename T, class U>
requires (std::is_arithmetic_v<U>)
auto Utils::operator* ( Vector< T, N > const & a,
U const & b )
constexpr

Definition at line 298 of file Vector.hpp.

◆ operator*() [4/4]

template<std::size_t N, typename T, class U>
requires (not(detail::is_vector<T>::value or detail::is_vector<U>::value))
auto constexpr Utils::operator* ( Vector< T, N > const & a,
Vector< U, N > const & b )
constexpr

Definition at line 341 of file Vector.hpp.

◆ operator*=()

template<std::size_t N, typename T>
auto & Utils::operator*= ( Vector< T, N > & b,
T const & a )

Definition at line 306 of file Vector.hpp.

◆ operator+()

template<std::size_t N, typename T, typename U>
auto Utils::operator+ ( Vector< T, N > const & a,
Vector< U, N > const & b )

Definition at line 256 of file Vector.hpp.

◆ operator+=()

template<std::size_t N, typename T>
ESPRESSO_ATTR_ALWAYS_INLINE auto & Utils::operator+= ( Vector< T, N > & a,
Vector< T, N > const & b )
inline

Definition at line 261 of file Vector.hpp.

References ESPRESSO_ATTR_ALWAYS_INLINE.

◆ operator-() [1/2]

template<std::size_t N, typename T>
Vector< T, N > Utils::operator- ( Vector< T, N > const & a)

Definition at line 273 of file Vector.hpp.

◆ operator-() [2/2]

template<std::size_t N, typename T, typename U>
auto Utils::operator- ( Vector< T, N > const & a,
Vector< U, N > const & b )

Definition at line 268 of file Vector.hpp.

◆ operator-=()

template<std::size_t N, typename T>
ESPRESSO_ATTR_ALWAYS_INLINE Vector< T, N > & Utils::operator-= ( Vector< T, N > & a,
Vector< T, N > const & b )
inline

Definition at line 281 of file Vector.hpp.

◆ operator/() [1/2]

template<std::size_t N, typename T, class U>
auto Utils::operator/ ( U const & a,
Vector< T, N > const & b )

Definition at line 321 of file Vector.hpp.

◆ operator/() [2/2]

template<std::size_t N, typename T, class U>
auto Utils::operator/ ( Vector< T, N > const & a,
U const & b )

Definition at line 313 of file Vector.hpp.

◆ operator/=()

template<std::size_t N, typename T>
auto & Utils::operator/= ( Vector< T, N > & a,
T const & b )

Definition at line 329 of file Vector.hpp.

◆ pack()

template<class T>
std::string Utils::pack ( T const & v)

Pack a serialize type into a string.

Template Parameters
TSerializable type
Parameters
vValue to serialize
Returns
String representation

Definition at line 38 of file pack.hpp.

Referenced by ScriptInterface::Interactions::NonBondedInteractions::get_internal_state(), ScriptInterface::System::System::get_internal_state(), and ScriptInterface::ContextManager::serialize().

◆ permute_ifield()

void Utils::permute_ifield ( int * field,
int size,
int permute )
inline

permute an integer array field of size size about permute positions.

Definition at line 24 of file permute_ifield.hpp.

◆ product()

◆ raster()

template<class T, class F>
auto Utils::raster ( Vector< T, 3 > const & offset,
Vector< T, 3 > const & grid_spacing,
Vector3i const & size,
F f )

Raster a function over a regular 3d grid.

This evaluates a function over a regular grid and returns the function values at the grid points.

Parameters
offsetPosition of the lowest grid point
grid_spacingGrid constant
sizeGrid size
fFunction to evaluate
Returns
Function values at the grid points.

Definition at line 42 of file raster.hpp.

References Utils::Vector< T, N >::data(), and make_lin_space().

◆ rotation_matrix()

template<typename T>
Matrix< T, 3, 3 > Utils::rotation_matrix ( Quaternion< T > const & q)

Convert quaternion to rotation matrix.

Template Parameters
TData type of quaternion.
Parameters
qQuaternion.
Returns
Rotation matrix.

Definition at line 152 of file quaternion.hpp.

References identity_mat(), and Utils::Quaternion< T >::normalized().

◆ sqr()

template<typename T>
DEVICE_QUALIFIER constexpr T Utils::sqr ( T x)
constexpr

Calculates the SQuaRe of x.

Definition at line 28 of file sqr.hpp.

References DEVICE_QUALIFIER.

Referenced by math::analytic_cotangent_sum(), bspline(), IBMTriel::calc_forces(), calc_part_distribution(), calc_re(), calc_rg(), calc_rh(), Shapes::Ellipsoid::calculate_dist(), Shapes::SimplePore::calculate_dist(), Shapes::Slitpore::calculate_dist(), Shapes::Torus::calculate_dist(), System::System::calculate_pressure(), CellStructure::check_resort_required(), CoulombMMM1D::CoulombMMM1D(), CoulombP3MImpl< FloatType, Architecture, FFTConfig >::count_charged_particles(), create_specialized_verlet_pair_loop(), elc_data::dielectric_layers_self_energy(), elc_data::dielectric_layers_self_forces(), dp3m_k_space_error(), dp3m_real_space_error(), dp3m_tune_aliasing_sums(), AngleCosineBond::energy(), AngleCossquareBond::energy(), AngleHarmonicBond::energy(), HarmonicBond::energy(), QuarticBond::energy(), DipolarLayerCorrection::energy_correction(), Accumulators::fcs_acf(), FeneBond::FeneBond(), force_capping(), AngleCosineBond::forces(), AngleHarmonicBond::forces(), TabulatedAngleBond::forces(), G_opt(), G_opt_dipolar(), gaussian_pair_energy(), gaussian_pair_force_factor(), gb_pair_energy(), gb_pair_force(), get_cylindrical_sampling_positions(), get_interacting_neighbors(), get_pairs_filtered(), get_short_range_neighbors(), CollisionDetection::BindAtPointOfCollision::initialize(), CollisionDetection::BindCenters::initialize(), CollisionDetection::GlueToSurface::initialize(), lj_pair_energy(), ljcos2_pair_energy(), ljcos_pair_energy(), ljcos_pair_force_factor(), LJcos_Parameters::LJcos_Parameters(), ljgen_pair_force_factor(), CoulombP3MImpl< FloatType, Architecture, FFTConfig >::long_range_kernel(), DipolarP3MHeffte< FloatType, Architecture, FFTConfig >::long_range_kernel(), CoulombP3MImpl< FloatType, Architecture, FFTConfig >::long_range_pressure(), DipolarP3MHeffte< FloatType, Architecture, FFTConfig >::long_range_pressure(), modify_p3m_sums(), morse_pair_energy(), morse_pair_force_factor(), Observables::LBFluidPressureTensor::operator()(), p3m_k_space_error(), p3m_k_space_error_gpu_kernel_ik(), p3m_real_space_error(), p3m_tune_aliasing_sums(), DipolarP3M::pair_energy(), DipolarP3M::pair_force(), LB::ParticleCoupling::ParticleCoupling(), SteepestDescent::propagate(), SmSt_pair_force_factor(), structure_factor(), CoulombMMM1D::tune(), velocity_verlet_npt_propagate_AVOVA_And(), velocity_verlet_npt_propagate_vel(), velocity_verlet_npt_propagate_vel_final(), velocity_verlet_npt_propagate_vel_MTK(), and wca_pair_energy().

◆ sqrt()

template<std::size_t N, typename T>
auto Utils::sqrt ( Vector< T, N > const & a)

Definition at line 362 of file Vector.hpp.

References Utils::Vector< T, N >::begin(), and sqrt().

Referenced by LB::ParticleCoupling::get_noise_term(), and sqrt().

◆ tensor_product() [1/2]

template<typename T, std::size_t N>
Vector< T, N > Utils::tensor_product ( const T & x,
const Vector< T, N > & y )

Definition at line 38 of file tensor_product.hpp.

◆ tensor_product() [2/2]

◆ transform_coordinate_cartesian_to_cylinder() [1/2]

Vector3d Utils::transform_coordinate_cartesian_to_cylinder ( Vector3d const & pos)
inline

◆ transform_coordinate_cartesian_to_cylinder() [2/2]

Vector3d Utils::transform_coordinate_cartesian_to_cylinder ( Vector3d const & pos,
Vector3d const & axis,
Vector3d const & orientation )
inline

Coordinate transformation from Cartesian to cylindrical coordinates with change of basis.

The origins of the coordinate systems co-incide.

If the parameter axis is not equal to [0, 0, 1], the value of the angle \( \phi \) in cylindrical coordinates is under-defined. To fully define it, it is necessary to provide an orientation vector in Cartesian coordinates that will be used as the reference point (i.e. such that \( \phi = 0 \)), by default it is the x-axis.

Parameters
posVector to transform
axisLongitudinal axis of the cylindrical coordinates
orientationReference point (in untransformed coordinates) for which \( \phi = 0 \)

Definition at line 92 of file coordinate_transformation.hpp.

References basis_change(), transform_coordinate_cartesian_to_cylinder(), and vector_product().

◆ transform_coordinate_cylinder_to_cartesian() [1/2]

Vector3d Utils::transform_coordinate_cylinder_to_cartesian ( Vector3d const & pos)
inline

Coordinate transformation from cylindrical to Cartesian coordinates.

The origins and z-axis of the coordinate systems co-incide. The \( \phi = 0 \) direction corresponds to the x-axis in the transformed coordinate system.

Parameters
posVector to transform

Definition at line 110 of file coordinate_transformation.hpp.

Referenced by Shapes::HollowConicalFrustum::calculate_dist(), Observables::CylindricalLBProfileObservable::calculate_sampling_positions(), and transform_coordinate_cylinder_to_cartesian().

◆ transform_coordinate_cylinder_to_cartesian() [2/2]

Vector3d Utils::transform_coordinate_cylinder_to_cartesian ( Vector3d const & pos,
Vector3d const & axis,
Vector3d const & orientation )
inline

Coordinate transformation from cylindrical to Cartesian coordinates with change of basis.

The origins of the coordinate systems co-incide.

If the parameter axis is not equal to [0, 0, 1], the value of the angle \( \phi \) in cylindrical coordinates is under-defined. To fully define it, it is necessary to provide an orientation vector in Cartesian coordinates that will be used as the reference point (i.e. such that \( \phi = 0 \)).

Parameters
posVector to transform
axisLongitudinal axis of the cylindrical coordinates
orientationReference point (in Cartesian coordinates) for which \( \phi = 0 \)

Definition at line 132 of file coordinate_transformation.hpp.

References basis_change(), transform_coordinate_cylinder_to_cartesian(), and vector_product().

◆ transform_vector_cartesian_to_cylinder()

Vector3d Utils::transform_vector_cartesian_to_cylinder ( Vector3d const & vec,
Vector3d const & axis,
Vector3d const & pos )
inline

◆ u32_to_u64()

DEVICE_QUALIFIER constexpr uint64_t Utils::u32_to_u64 ( uint32_t high,
uint32_t low )
inlineconstexpr

Definition at line 27 of file u32_to_u64.hpp.

References DEVICE_QUALIFIER.

Referenced by Random::philox_4_uint64s().

◆ uniform()

DEVICE_QUALIFIER double Utils::uniform ( uint64_t in)
inlineconstexpr

Uniformly map unsigned integer to double.

This maps a unsigned integer to the double interval (0., 1.], where 0 is mapped to the smallest representable value larger than 0., and the maximal integer value is mapped to 1.

Parameters
inUnsigned integer value
Returns
Mapped floating point value.

Definition at line 37 of file uniform.hpp.

References DEVICE_QUALIFIER.

Referenced by System::System::integrate_magnetodynamics(), Random::noise_gaussian(), and Random::noise_uniform().

◆ unit_vector()

template<typename T>
Vector< T, 3 > Utils::unit_vector ( unsigned int i)

Definition at line 417 of file Vector.hpp.

Referenced by LeesEdwards::shear_direction().

◆ unpack()

template<class T>
T Utils::unpack ( std::string const & state)

Unpack a serialize type into a string.

Template Parameters
TSerializable type
Parameters
stateString to construct the value from, as returned by Utils::pack.
Returns
Unpacked value

Definition at line 53 of file pack.hpp.

Referenced by ScriptInterface::ContextManager::deserialize(), ScriptInterface::ObjectHandle::deserialize(), ScriptInterface::System::System::get_internal_state(), ScriptInterface::Interactions::NonBondedInteractions::set_internal_state(), and ScriptInterface::System::System::set_internal_state().

◆ vec_rotate()

Vector3d Utils::vec_rotate ( const Vector3d & axis,
double angle,
const Vector3d & vector )
inline

Rotate a vector around an axis.

Parameters
axisThe axis to rotate about
angleAngle to rotate
vectorVector to act on
Returns
Rotated vector

Definition at line 41 of file vec_rotate.hpp.

Referenced by Observables::CylindricalLBProfileObservable::calculate_sampling_positions(), draw_polymer_positions(), ScriptInterface::System::rotate_system(), and transform_vector_cartesian_to_cylinder().

◆ vector_product()