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

Namespaces

namespace  Accumulators
 
namespace  Analysis
 
namespace  BondBreakage
 
namespace  CellSystem
 
namespace  ClusterAnalysis
 
namespace  CodeInfo
 
namespace  CollisionDetection
 
namespace  Constraints
 
namespace  Coulomb
 
namespace  Dipoles
 
namespace  Galilei
 
namespace  Integrators
 
namespace  Interactions
 
namespace  LeesEdwards
 
namespace  Math
 
namespace  MPIIO
 
namespace  Observables
 
namespace  PairCriteria
 
namespace  Particles
 
namespace  Profiler
 
namespace  ReactionMethods
 
namespace  Scafacos
 
namespace  Shapes
 
namespace  System
 
namespace  Thermostat
 
namespace  walberla
 
namespace  Writer
 

Classes

struct  AutoParameter
 Description and getter/setter for a parameter. More...
 
class  AutoParameters
 Bind parameters in the script interface. More...
 
class  Context
 Context of an object handle. More...
 
class  ContextManager
 Manage object contexts. More...
 
struct  Exception
 
class  GlobalContext
 Global synchronizing context. More...
 
class  LatticeIndices
 Interface to carry out simple operations on lattice indices. More...
 
class  LocalContext
 Trivial context. More...
 
class  None
 Type to indicate no value in Variant. More...
 
class  ObjectHandle
 Base class for interface handles. More...
 
class  ObjectList
 Owning list of ObjectHandles. More...
 
class  ObjectMap
 Owning map of ObjectHandles. More...
 
struct  ObjectState
 State of an object ready for serialization. More...
 
struct  PackVisitor
 Visitor that converts a Variant to a PackedVariant. More...
 
class  ParallelExceptionHandler
 Handle exceptions thrown in MPI parallel code. More...
 
struct  UnpackVisitor
 Visitor that converts a PackedVariant to a Variant. More...
 

Typedefs

template<template< typename... > class Container, typename ManagedType , class BaseType , class = std::enable_if_t<std::is_base_of_v<ObjectHandle, ManagedType>>>
using ObjectContainer = std::conditional_t< std::is_same_v< BaseType, ObjectHandle >, AutoParameters< Container< ManagedType, BaseType >, BaseType >, BaseType >
 Base class for containers whose BaseType might be a full specialization of AutoParameters.
 
using ObjectId = std::size_t
 
using PackedVariant = boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectId, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type
 Packed version of Variant.
 
using PackedMap = std::vector< std::pair< std::string, PackedVariant > >
 
using ObjectRef = std::shared_ptr< ObjectHandle >
 
using Variant = boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type
 Possible types for parameters.
 
using VariantMap = std::unordered_map< std::string, Variant >
 

Functions

template<typename T >
mpi_reduce_sum (boost::mpi::communicator const &comm, T const &result)
 Reduce object by sum on the head node.
 
template<typename T >
get_value (Variant const &v)
 Extract value of specific type T from a Variant.
 
template<typename T >
get_value (VariantMap const &vals, std::string const &name)
 Get a value from a VariantMap by name, or throw if it does not exist or is not convertible to the target type.
 
template<typename T >
get_value_or (VariantMap const &vals, std::string const &name, T const &default_)
 Get a value from a VariantMap by name, or return a default value if it does not exist.
 
template<typename T , typename... Types, typename... ArgNames>
std::shared_ptr< T > make_shared_from_args (VariantMap const &vals, ArgNames &&...args)
 Make a new std::shared_ptr<T> with arguments extracted from a VariantMap.
 
template<typename T >
void set_from_args (T &dst, VariantMap const &vals, const char *name)
 
void initialize (Utils::Factory< ObjectHandle > *f)
 
ObjectId object_id (const ObjectHandle *p)
 Id for object.
 
PackedVariant pack (const Variant &v)
 Transform a Variant to a PackedVariant.
 
Variant unpack (const PackedVariant &v, std::unordered_map< ObjectId, ObjectRef > const &objects)
 Unpack a PackedVariant.
 
PackedMap pack (const VariantMap &v)
 Pack a VariantMap.
 
VariantMap unpack (const PackedMap &v, std::unordered_map< ObjectId, ObjectRef > const &objects)
 Unpack a PackedMap.
 
template<typename T >
Variant make_variant (const T &x)
 Make a Variant from argument.
 
template<typename K , typename V >
auto make_unordered_map_of_variants (std::unordered_map< K, V > const &v)
 
template<typename T >
auto make_vector_of_variants (std::vector< T > const &v)
 
template<class T >
bool is_type (Variant const &v)
 Check is a Variant holds a specific type.
 
bool is_none (Variant const &v)
 

Variables

constexpr const None none {}
 None-"literal".
 

Typedef Documentation

◆ ObjectContainer

template<template< typename... > class Container, typename ManagedType , class BaseType , class = std::enable_if_t<std::is_base_of_v<ObjectHandle, ManagedType>>>
using ScriptInterface::ObjectContainer = typedef std::conditional_t< std::is_same_v<BaseType, ObjectHandle>, AutoParameters<Container<ManagedType, BaseType>, BaseType>, BaseType>

Base class for containers whose BaseType might be a full specialization of AutoParameters.

Definition at line 36 of file ObjectContainer.hpp.

◆ ObjectId

using ScriptInterface::ObjectId = typedef std::size_t

Definition at line 32 of file packed_variant.hpp.

◆ ObjectRef

using ScriptInterface::ObjectRef = typedef std::shared_ptr<ObjectHandle>

Definition at line 59 of file Variant.hpp.

◆ PackedMap

using ScriptInterface::PackedMap = typedef std::vector<std::pair<std::string, PackedVariant> >

Definition at line 62 of file packed_variant.hpp.

◆ PackedVariant

using ScriptInterface::PackedVariant = typedef boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectId, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector<int>, std::vector<double>, std::vector<boost::recursive_variant_>, std::unordered_map<int, boost::recursive_variant_>, std::unordered_map<std::string, boost::recursive_variant_> >::type

Packed version of Variant.

When packing variants by PackVisitor, objects of type ObjectRef are packed as ObjectId. Other than that, all other types allowed in Variant must appear here.

Definition at line 54 of file packed_variant.hpp.

◆ Variant

using ScriptInterface::Variant = typedef boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector<int>, std::vector<double>, std::vector<boost::recursive_variant_>, std::unordered_map<int, boost::recursive_variant_>, std::unordered_map<std::string, boost::recursive_variant_> >::type

Possible types for parameters.

The visitors and packing functions need to be adapted accordingly when extending this variant with new types. For the exact details, see commit b48ab62. The number of types is limited by macro BOOST_MPL_LIMIT_LIST_SIZE (defaults to 20).

Definition at line 74 of file Variant.hpp.

◆ VariantMap

using ScriptInterface::VariantMap = typedef std::unordered_map<std::string, Variant>

Definition at line 82 of file Variant.hpp.

Function Documentation

◆ get_value() [1/2]

◆ get_value() [2/2]

template<typename T >
T ScriptInterface::get_value ( VariantMap const &  vals,
std::string const &  name 
)

Get a value from a VariantMap by name, or throw if it does not exist or is not convertible to the target type.

Definition at line 412 of file get_value.hpp.

◆ get_value_or()

template<typename T >
T ScriptInterface::get_value_or ( VariantMap const &  vals,
std::string const &  name,
T const &  default_ 
)

Get a value from a VariantMap by name, or return a default value if it does not exist.

Definition at line 424 of file get_value.hpp.

References get_value_or().

Referenced by ScriptInterface::ReactionMethods::ConstantpHEnsemble::do_construct(), ScriptInterface::ReactionMethods::ReactionEnsemble::do_construct(), and get_value_or().

◆ initialize()

◆ is_none()

◆ is_type()

template<class T >
bool ScriptInterface::is_type ( Variant const &  v)

Check is a Variant holds a specific type.

Template Parameters
Ttype to check for
Parameters
vVariant to check in
Returns
true, if v holds a T.

Definition at line 124 of file Variant.hpp.

Referenced by ScriptInterface::walberla::EKFieldSerializer::deserialize(), and ScriptInterface::walberla::LBFieldSerializer::deserialize().

◆ make_shared_from_args()

◆ make_unordered_map_of_variants()

◆ make_variant()

template<typename T >
Variant ScriptInterface::make_variant ( const T &  x)

Make a Variant from argument.

This is a convenience function, so that rather involved constructors from boost::variant are not needed in the script interfaces.

Definition at line 90 of file Variant.hpp.

Referenced by ScriptInterface::LeesEdwards::LeesEdwards::LeesEdwards().

◆ make_vector_of_variants()

◆ mpi_reduce_sum()

template<typename T >
T ScriptInterface::mpi_reduce_sum ( boost::mpi::communicator const &  comm,
T const &  result 
)

Reduce object by sum on the head node.

Worker nodes get a default-constructed object.

Definition at line 35 of file script_interface/communication.hpp.

Referenced by ScriptInterface::Analysis::Analysis::do_call_method().

◆ object_id()

ObjectId ScriptInterface::object_id ( const ObjectHandle p)
inline

◆ pack() [1/2]

◆ pack() [2/2]

PackedMap ScriptInterface::pack ( const VariantMap v)
inline

Pack a VariantMap.

Applies pack to every value in the input map.

Definition at line 192 of file packed_variant.hpp.

◆ set_from_args()

◆ unpack() [1/2]

VariantMap ScriptInterface::unpack ( const PackedMap v,
std::unordered_map< ObjectId, ObjectRef > const &  objects 
)
inline

Unpack a PackedMap.

Applies unpack to every value in the input map.

Definition at line 209 of file packed_variant.hpp.

References unpack().

◆ unpack() [2/2]

Variant ScriptInterface::unpack ( const PackedVariant v,
std::unordered_map< ObjectId, ObjectRef > const &  objects 
)
inline

Unpack a PackedVariant.

Applies UnpackVisitor to a Variant.

Parameters
vPacked Variant.
objectsMap of ids to reference.
Returns
Transformed variant.

Definition at line 181 of file packed_variant.hpp.

Referenced by ScriptInterface::Particles::ParticleList::set_internal_state(), and unpack().

Variable Documentation

◆ none