Skip to content

Commit

Permalink
files: CosseratRod system
Browse files Browse the repository at this point in the history
  • Loading branch information
skim0119 committed Jul 11, 2024
1 parent 23cf020 commit 9802213
Show file tree
Hide file tree
Showing 46 changed files with 6,053 additions and 14 deletions.
8 changes: 8 additions & 0 deletions backend/src/Systems/Block.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
#include "Systems/Block/Block.hpp"
// do not include in block as it overrides an elastica namespace function
// #include "Systems/Block/Serialize.hpp"
4 changes: 3 additions & 1 deletion backend/src/Systems/Block/Block/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Includes
//******************************************************************************

// #include "Systems/Block/Block/Block.hpp" // only declaration, so ok to include.
#include "Systems/Block/Block/Concepts/Types.hpp"

namespace blocks {
Expand All @@ -17,6 +16,9 @@ namespace blocks {

//****************************************************************************
/*! \cond ELASTICA_INTERNAL */
template <typename /* Plugin */>
class Block;

template <typename /* Plugin */>
class BlockSlice;

Expand Down
11 changes: 11 additions & 0 deletions backend/src/Systems/CosseratRods.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
#include "Systems/CosseratRods/CosseratRods.hpp"
// include utilities
#include "Systems/CosseratRods/Access.hpp"
// #include "Systems/CosseratRods/Serialize.hpp"
#include "Systems/CosseratRods/Utility.hpp"
// #include "Systems/Customization/CosseratRods.hpp"
59 changes: 59 additions & 0 deletions backend/src/Systems/CosseratRods/Components.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
/// Types first
#include "Systems/CosseratRods/Components/Types.hpp"
///
#include "Systems/CosseratRods/Components/Elasticity.hpp"
#include "Systems/CosseratRods/Components/Geometry.hpp"
#include "Systems/CosseratRods/Components/Kinematics.hpp"
#include "Systems/CosseratRods/Components/Names.hpp"
#include "Systems/CosseratRods/Components/Tags.hpp"
#include "Systems/CosseratRods/Components/helpers.hpp"

namespace elastica {

namespace cosserat_rod {

//**************************************************************************
/*!\defgroup cosserat_rod_component Cosserat Rod Components
* \ingroup cosserat_rod
* \brief Data-structures to customize orthogonal aspects of Cosserat rods
*
* \details
* `Components` are structures customizing orthogonal aspects of a Cosserat
* rod within \elastica. Indeed, a typical rod has features broadly
* encompassing geometry, elasticity etc. which can be decoupled from one
* another and whose communication happens by a common interface/protocol.
* These features are implemented as `Components`. Within
* the parlance of `c++`, `Components` are implemented as curious mixins
* intended as policy classes that control the behavior of the downstream
* Cosserat-rod blocks and its slices.
*/
//**************************************************************************

//**************************************************************************
/*!\defgroup cosserat_rod_custom_entries Cosserat Rod customization
* \ingroup cosserat_rod_component
* \brief Entry points to customize core-rod functionality
*
* \details
* To customize the behavior of the library-provided CosseratRods, users are
* encouraged to overload these set of functions with the following
* signature
* TODO
*/
//**************************************************************************

//**************************************************************************
/*!\brief Components comprising Cosserat rods
// \ingroup cosserat_rod_component
*/
namespace component {}
//**************************************************************************

} // namespace cosserat_rod

} // namespace elastica
1 change: 1 addition & 0 deletions backend/src/Systems/CosseratRods/Components/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
StrongTypes.hpp
9 changes: 9 additions & 0 deletions backend/src/Systems/CosseratRods/Components/Elasticity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
/// Types first
#include "Systems/CosseratRods/Components/Elasticity/Types.hpp"
///
#include "Systems/CosseratRods/Components/Elasticity/Components.hpp"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
/// Types always first
#include "Systems/CosseratRods/Components/Elasticity/Types.hpp"
///
/// details next
#include "Systems/CosseratRods/Components/Elasticity/detail/Components.hpp"
///
#include "Systems/CosseratRods/Components/Elasticity/WithDiagonalLinearHyperElasticModel.hpp"
#include "Systems/CosseratRods/Components/Elasticity/WithExplicitlyDampedDiagonalLinearHyperElasticModel.hpp"
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
#include <cmath>
#include <utility>

///// Types always first
#include "Systems/CosseratRods/Components/Elasticity/Types.hpp"
/////
#include "Systems/CosseratRods/Components/Elasticity/detail/ExplicitDampingAdapter.hpp"
#include "Utilities/Math/Vec3.hpp"
#include "Utilities/ProtocolHelpers.hpp"
#include "Utilities/Requires.hpp"

namespace elastica {

namespace cosserat_rod {

namespace component {

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

//************************************************************************
/*!\brief Adapter for adding explicit damping to an elasticity component
* \ingroup cosserat_rod_component
*
* \details
* ExplicitDampingAdapter adapts an Elasticity component for use
* within Cosserat rods implemented in the Blocks framework. It adds
* an additional damping force and torque to those arising from the
* Elasticity model. It assumes that the Elasticity model operates on a
* 1-D parametrized entity spanning a single spatial dimension (i.e.
* along center-line coordinates, such as a Cosserat rod data-structure).
* By design it only binds to classes with signature of a Component.
*
* \usage
* Since ExplicitDampingAdapter is useful for wrapping an
* ElasticityModel with additional damping, one should use it using the
* Adapt class as follows:
*
* \code
* template <typename Traits, typename Block>
* class MyCustomElasticityModel : public
* Component<MyCustomElasticityModel<Traits, Block>> {
* // ...implementation
* };
*
* template <typename Traits, typename Block>
* class MyCustomElasticityModelWithDamping : public
* Adapt<MyCustomElasticityModel<CRT, ComputationalBlock>>::
* template with<ExplicitDampingAdapter> {};
* \endcode
*
* Note that however, this does not provide the appropriate interface
* required by the rest of the components within a Cosserat rod hierarchy.
* To do so, we need to add the ElasticityInterface adapter, like so
*
* \code
* template <typename Traits, typename Block>
* class MyCustomElasticityModelWithDampingPerRodThatWorks : public
* Adapt<MyCustomElasticityModel<CRT, ComputationalBlock>>::
* template with<ElasticityInterface, ExplicitDampingAdapter>
* {};
* \endcode
* The ElasticityInterface needs to be the left-most argument to with,
* else a compilation error is raised.
*
* \tparam CRT A valid Cosserat Rod Traits class
* \tparam ComputationalBlock The final block which is derived from the
* current component
* \tparam ElasticityModelParam The user defined elasticity model which
* is to be wrapped in the interface type
*
* \see ExplicitDampingAdapterVariables
*/
using detail::ExplicitDampingAdapter;
//************************************************************************

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

//************************************************************************
/*!\brief Adapter for adding explicit damping to an elasticity component
* \ingroup cosserat_rod_component
*
* \details
* ExplicitDampingAdapterPerRod adapts an Elasticity component for use
* within Cosserat rods implemented in the Blocks framework. It adds
* an additional damping force and torque to those arising from the
* Elasticity model. It assumes that the Elasticity model operates on a
* 1-D parametrized entity spanning a single spatial dimension (i.e.
* along center-line coordinates, such as a Cosserat rod data-structure).
* By design it only binds to classes with signature of a Component.
* Note that instead of having damping for every grid node/element
* (which is achieved by ExplicitDampingAdapter) it reserves the same
* damping for an entire rod.
*
* \usage
* Since ExplicitDampingAdapterPerRod is useful for wrapping an
* ElasticityModel with additional damping, one should use it using the
* Adapt class as follows:
*
* \code
* template <typename Traits, typename Block>
* class MyCustomElasticityModel : public
* Component<MyCustomElasticityModel<Traits, Block>> {
* // ...implementation
* };
*
* template <typename Traits, typename Block>
* class MyCustomElasticityModelWithDampingPerRod : public
* Adapt<MyCustomElasticityModel<CRT, ComputationalBlock>>::
* template with<ExplicitDampingAdapterPerRod> {};
* \endcode
*
* Note that however, this does not provide the appropriate interface
* required by the rest of the components within a Cosserat rod hierarchy.
* To do so, we need to add the ElasticityInterface adapter, like so
*
* \code
* template <typename Traits, typename Block>
* class MyCustomElasticityModelWithDampingPerRodThatWorks : public
* Adapt<MyCustomElasticityModel<CRT, ComputationalBlock>>::
* template with<ElasticityInterface, ExplicitDampingAdapterPerRod>
* {};
* \endcode
* The ElasticityInterface needs to be the left-most argument to with,
* else a compilation error is raised.
*
*
* \tparam CRT A valid Cosserat Rod Traits class
* \tparam ComputationalBlock The final block which is derived from the
* current component
* \tparam ElasticityModelParam The user defined elasticity model which
* is to be wrapped in the interface type
*
* \see ExplicitDampingAdapterVariablesPerRod
*/
using detail::ExplicitDampingAdapterPerRod;
//************************************************************************

//// should not include any protocols
// template <
// typename CRT, // Cosserat Rod Traits
// typename ComputationalBlock, // Block
// template <typename /*CRT*/, typename /* ComputationalBlock*/,
// typename...> class ElasticityModelParam, typename...
// ElasticityModelMetaArgs>
// class ExplicitDampingAdapter<
// CRT, ComputationalBlock,
// ElasticityModelParam<CRT, ComputationalBlock,
// ElasticityModelMetaArgs...>> : public detail::ElasticityInterface<
// CRT, ComputationalBlock,
// detail::ExplicitDampingAdapter<
// CRT, ComputationalBlock,
// ElasticityModelParam<CRT, ComputationalBlock,
// ElasticityModelMetaArgs...>>> {
// private:
// using Traits = CRT;
// using ThisModel = ElasticityModelParam<Traits, ComputationalBlock,
// ElasticityModelMetaArgs...>;
// using This = ExplicitDampingAdapter<Traits, ComputationalBlock,
// ThisModel>; using Implementation =
// detail::ExplicitDampingAdapter<Traits, ComputationalBlock,
// ThisModel>;
// using Parent =
// detail::ElasticityInterface<Traits, ComputationalBlock,
// Implementation>;
//
// protected:
// static_assert(std::is_same<ThisModel, ElasticityModel>::value,
// "Invariant failure!");
//
// using Parent::initialize;
// using typename Parent::ComputedVariables;
// using typename Parent::InitializedVariables;
// using typename Parent::Variables;
// };
//
//// should not include any protocols
// template <
// typename CRT, // Cosserat Rod Traits
// typename ComputationalBlock, // Block
// template <typename /*CRT*/, typename /* ComputationalBlock*/,
// typename...> class ElasticityModelParam, typename...
// ElasticityModelMetaArgs>
// class ExplicitDampingAdapterPerRod<
// CRT, ComputationalBlock,
// ElasticityModelParam<CRT, ComputationalBlock,
// ElasticityModelMetaArgs...>> : public detail::ElasticityInterface<
// CRT, ComputationalBlock,
// detail::ExplicitDampingAdapterPerRod<
// CRT, ComputationalBlock,
// ElasticityModelParam<CRT, ComputationalBlock,
// ElasticityModelMetaArgs...>>> {
// private:
// using Traits = CRT;
// using ThisModel = ElasticityModelParam<Traits, ComputationalBlock,
// ElasticityModelMetaArgs...>;
// using This =
// ExplicitDampingAdapterPerRod<Traits, ComputationalBlock,
// ThisModel>;
// using Implementation =
// detail::ExplicitDampingAdapterPerRod<Traits, ComputationalBlock,
// ThisModel>;
// using Parent =
// detail::ElasticityInterface<Traits, ComputationalBlock,
// Implementation>;
//
// protected:
// static_assert(std::is_same<ThisModel, ElasticityModel>::value,
// "Invariant failure!");
//
// using Parent::initialize;
// using typename Parent::ComputedVariables;
// using typename Parent::InitializedVariables;
// using typename Parent::Variables;
// };

} // namespace component

} // namespace cosserat_rod

} // namespace elastica
Loading

0 comments on commit 9802213

Please sign in to comment.