diff --git a/backend/src/Systems/common/Access.hpp b/backend/src/Systems/common/Access.hpp new file mode 100644 index 00000000..58ab1969 --- /dev/null +++ b/backend/src/Systems/common/Access.hpp @@ -0,0 +1,118 @@ +#pragma once + +//****************************************************************************** +// Includes +//****************************************************************************** +#include // size_t + +namespace elastica { + + //============================================================================ + // + // ACCESS API FUNCTIONS + // + //============================================================================ + + //**************************************************************************** + /*!\brief Any physical system adhering to elastica::protocols::PhysicalSystem + // \ingroup systems + */ + struct AnyPhysicalSystem {}; + //**************************************************************************** + + //**Position functions******************************************************** + /*!\name Position functions */ + //@{ + /*!\brief Retrieves position from the systems + * \ingroup systems + */ + inline constexpr decltype(auto) position(AnyPhysicalSystem& t) noexcept; + inline constexpr decltype(auto) position(AnyPhysicalSystem const& t) noexcept; + inline constexpr decltype(auto) position(AnyPhysicalSystem& t, + std::size_t index) noexcept; + inline constexpr decltype(auto) position(AnyPhysicalSystem const& t, + std::size_t index) noexcept; + //@} + //**************************************************************************** + + //**Director functions******************************************************** + /*!\name Director functions */ + //@{ + /*!\brief Retrieves directors from the systems + * \ingroup systems + */ + inline constexpr decltype(auto) director(AnyPhysicalSystem& t) noexcept; + inline constexpr decltype(auto) director(AnyPhysicalSystem const& t) noexcept; + inline constexpr decltype(auto) director(AnyPhysicalSystem& t, + std::size_t index) noexcept; + inline constexpr decltype(auto) director(AnyPhysicalSystem const& t, + std::size_t index) noexcept; + //@} + //**************************************************************************** + + //**Velocity functions******************************************************** + /*!\name Velocity functions */ + //@{ + /*!\brief Retrieves velocities from the systems + * \ingroup systems + */ + inline constexpr decltype(auto) velocity(AnyPhysicalSystem& t) noexcept; + inline constexpr decltype(auto) velocity(AnyPhysicalSystem const& t) noexcept; + inline constexpr decltype(auto) velocity(AnyPhysicalSystem& t, + std::size_t index) noexcept; + inline constexpr decltype(auto) velocity(AnyPhysicalSystem const& t, + std::size_t index) noexcept; + //@} + //**************************************************************************** + + //**Angular Velocity functions************************************************ + /*!\name Angular Velocity functions */ + //@{ + /*!\brief Retrieves angular velocities from the systems + * \ingroup systems + */ + inline constexpr decltype(auto) angular_velocity( + AnyPhysicalSystem& t) noexcept; + inline constexpr decltype(auto) angular_velocity( + AnyPhysicalSystem const& t) noexcept; + inline constexpr decltype(auto) angular_velocity(AnyPhysicalSystem& t, + std::size_t index) noexcept; + inline constexpr decltype(auto) angular_velocity(AnyPhysicalSystem const& t, + std::size_t index) noexcept; + //@} + //**************************************************************************** + + //**External loads functions************************************************** + /*!\name External loads functions */ + //@{ + /*!\brief Retrieves external loads of a given system + * \ingroup systems + */ + inline constexpr decltype(auto) external_loads(AnyPhysicalSystem& t) noexcept; + inline constexpr decltype(auto) external_loads( + AnyPhysicalSystem const& t) noexcept; + inline constexpr decltype(auto) external_loads(AnyPhysicalSystem& t, + std::size_t index) noexcept; + inline constexpr decltype(auto) external_loads(AnyPhysicalSystem const& t, + std::size_t index) noexcept; + //@} + //**************************************************************************** + + //**External torques functions************************************************ + /*!\name External torques functions */ + //@{ + /*!\brief Retrieves external torques of a given system + * \ingroup systems + */ + inline constexpr decltype(auto) external_torques( + AnyPhysicalSystem& t) noexcept; + inline constexpr decltype(auto) external_torques( + AnyPhysicalSystem const& t) noexcept; + inline constexpr decltype(auto) external_torques(AnyPhysicalSystem& t, + std::size_t index) noexcept; + inline constexpr decltype(auto) external_torques(AnyPhysicalSystem const& t, + std::size_t index) noexcept; + //@} + //**************************************************************************** + +} // namespace elastica diff --git a/backend/src/Systems/common/CMakeLists.txt b/backend/src/Systems/common/CMakeLists.txt new file mode 100644 index 00000000..1bef0074 --- /dev/null +++ b/backend/src/Systems/common/CMakeLists.txt @@ -0,0 +1,42 @@ +# Distributed under the MIT License. See LICENSE.txt for details. + +set(LIBRARY SystemsCommon) + +add_elastica_library(${LIBRARY} INTERFACE) + +set(TARGET_SOURCES + Access.hpp + Cardinality.hpp + Components.hpp + IndexCheck.hpp + Initialization.hpp + Protocols.hpp + SymplecticStepperAdapter.hpp + Tags.hpp + Types.hpp + ) + +elastica_target_headers( + ${LIBRARY} + INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/elastica + ${TARGET_SOURCES} +) + +elastica_target_sources( + ${LIBRARY} + INTERFACE + ${TARGET_SOURCES} +) + +add_subdirectory(Components) +add_subdirectory(Warnings) +add_subdirectory(Python) +add_subdirectory(Traits) + +target_link_libraries( + ${LIBRARY} + INTERFACE + Components + SystemsWarnings + SystemsCommonTraits +) diff --git a/backend/src/Systems/common/Cardinality.hpp b/backend/src/Systems/common/Cardinality.hpp new file mode 100644 index 00000000..8ae16038 --- /dev/null +++ b/backend/src/Systems/common/Cardinality.hpp @@ -0,0 +1,75 @@ +#pragma once + +//****************************************************************************** +// Includes +//****************************************************************************** +#include "Systems/common/Components/Types.hpp" +// + +namespace elastica { + + //============================================================================ + // + // CLASS DEFINITION + // + //============================================================================ + + //**************************************************************************** + /*!\brief Tag representing unit cardinality + * \ingroup systems + * + * \details + * Indicates that one system of a plugin has only one Lagrangian degree + * of freedom. + */ + struct UnitCardinality { + //! Index for unit cardinality + static constexpr auto index() noexcept -> std::size_t { return 0UL; } + }; + //**************************************************************************** + + //**************************************************************************** + /*!\brief Tag representing multiple cardinality + * \ingroup systems + * + * \details + * Indicates that one system of a plugin has multiple Lagrangian degrees + * of freedom. + * + */ + struct MultipleCardinality {}; + //**************************************************************************** + + //**************************************************************************** + /*!\brief Indicates unit cardinality of a plugin. + * \ingroup systems + * + * \tparam Plugin A system plugin. + * \see UnitCardinality + */ + template + struct HasUnitCardinality { + //**Type definitions******************************************************** + //! Type of cardinality + using cardinality = UnitCardinality; + //************************************************************************** + }; + //**************************************************************************** + + //**************************************************************************** + /*!\brief Indicates multiple cardinality of a plugin. + * \ingroup systems + * + * \tparam Plugin A system plugin. + * \see MultipleCardinality + */ + template + struct HasMultipleCardinality { + //**Type definitions******************************************************** + //! Type of cardinality + using cardinality = MultipleCardinality; + //************************************************************************** + }; + //**************************************************************************** + +} // namespace elastica diff --git a/backend/src/Systems/common/Components.hpp b/backend/src/Systems/common/Components.hpp new file mode 100644 index 00000000..64f6fea0 --- /dev/null +++ b/backend/src/Systems/common/Components.hpp @@ -0,0 +1,13 @@ +#pragma once + +//****************************************************************************** +// Includes +//****************************************************************************** + +/// +#include "Systems/common/Components/Types.hpp" +/// +#include "Systems/common/Components/Component.hpp" +#include "Systems/common/Components/GeometryComponent.hpp" +#include "Systems/common/Components/KinematicsComponent.hpp" +#include "Systems/common/Components/TypeTraits.hpp" diff --git a/backend/src/Systems/common/Components/CMakeLists.txt b/backend/src/Systems/common/Components/CMakeLists.txt new file mode 100644 index 00000000..806b16a5 --- /dev/null +++ b/backend/src/Systems/common/Components/CMakeLists.txt @@ -0,0 +1,35 @@ +# Distributed under the MIT License. See LICENSE.txt for details. + +set(LIBRARY Components) + +add_elastica_library(${LIBRARY} INTERFACE) + +elastica_target_headers( + ${LIBRARY} + INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/elastica + Component.hpp + GeometryComponent.hpp + KinematicsComponent.hpp + NameComponent.hpp + NameAdapter.hpp + Types.hpp + TypeTraits.hpp +) + +elastica_target_sources( + ${LIBRARY} + INTERFACE + Component.hpp + GeometryComponent.hpp + KinematicsComponent.hpp + NameComponent.hpp + NameAdapter.hpp + Types.hpp + TypeTraits.hpp +) + +target_link_libraries( + ${LIBRARY} + INTERFACE + Utilities +) diff --git a/backend/src/Systems/common/Components/Component.hpp b/backend/src/Systems/common/Components/Component.hpp new file mode 100644 index 00000000..0af1f591 --- /dev/null +++ b/backend/src/Systems/common/Components/Component.hpp @@ -0,0 +1,51 @@ +#pragma once + +//****************************************************************************** +// Includes +//****************************************************************************** +#include "Systems/common/Components/Types.hpp" + +namespace elastica { + + //============================================================================ + // + // CLASS DEFINITION + // + //============================================================================ + + //**************************************************************************** + /*!\brief Base class for all component templates. + * \ingroup systems + * + * \details + * The Component class is the base class for all component templates + * used in programming systems within \elastica. All classes that represent a + * component and that are used within the @ref blocks environment of \elastica + * library have to derive publicly from this class in order to qualify as a + * component. + * + * Only in case a class is derived publicly from the Component base + * class, the IsComponent type trait recognizes the class as valid + * component. + * + * \tparam DerivedComponent A downstream component that derives from + * the Component class using the CRTP pattern. + */ + template + struct Component; + //**************************************************************************** + + //**************************************************************************** + /*! \cond ELASTICA_INTERNAL */ + /*!\brief Specialized of Component for Cosserat Rod components + * \ingroup systems + */ + template