Skip to content

Commit

Permalink
files: common features for system
Browse files Browse the repository at this point in the history
  • Loading branch information
skim0119 committed Jul 12, 2024
1 parent b42fab3 commit ee2fa43
Show file tree
Hide file tree
Showing 23 changed files with 1,916 additions and 0 deletions.
118 changes: 118 additions & 0 deletions backend/src/Systems/common/Access.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
#include <cstddef> // 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
42 changes: 42 additions & 0 deletions backend/src/Systems/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
75 changes: 75 additions & 0 deletions backend/src/Systems/common/Cardinality.hpp
Original file line number Diff line number Diff line change
@@ -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 <typename Plugin>
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 <typename Plugin>
struct HasMultipleCardinality {
//**Type definitions********************************************************
//! Type of cardinality
using cardinality = MultipleCardinality;
//**************************************************************************
};
//****************************************************************************

} // namespace elastica
13 changes: 13 additions & 0 deletions backend/src/Systems/common/Components.hpp
Original file line number Diff line number Diff line change
@@ -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"
35 changes: 35 additions & 0 deletions backend/src/Systems/common/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
51 changes: 51 additions & 0 deletions backend/src/Systems/common/Components/Component.hpp
Original file line number Diff line number Diff line change
@@ -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 <typename DerivedComponent>
struct Component;
//****************************************************************************

//****************************************************************************
/*! \cond ELASTICA_INTERNAL */
/*!\brief Specialized of Component for Cosserat Rod components
* \ingroup systems
*/
template <template <typename, typename, typename...> class DerivedComponent,
typename Traits, typename InstantiatedBlock,
typename... DerivedComponentMetaArgs>
struct Component<DerivedComponent<Traits, InstantiatedBlock,
DerivedComponentMetaArgs...>> {};
/*! \endcond */
//****************************************************************************

} // namespace elastica
45 changes: 45 additions & 0 deletions backend/src/Systems/common/Components/GeometryComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
#include "Systems/common/Components/Types.hpp"
//
#include "Systems/common/Components/Component.hpp"

namespace elastica {

//============================================================================
//
// CLASS DEFINITION
//
//============================================================================

//****************************************************************************
/*!\brief Base class for all geometry components.
* \ingroup systems
*
* \details
* The Geometry component is the base class for all geometry components
* used in programming systems within \elastica. All classes that represent a
* geometry 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 DerivedGeometryComponent A downstream component that derives from
* the Component class using the CRTP pattern.
*/
template <typename DerivedGeometryComponent>
struct GeometryComponent : public Component<DerivedGeometryComponent> {
// for ease in programming, ideally we shouldnt need it
//**Type definitions********************************************************
//! Type of geometry component
using geometry_component = DerivedGeometryComponent;
//**************************************************************************
};
//****************************************************************************

} // namespace elastica
Loading

0 comments on commit ee2fa43

Please sign in to comment.