Model Class Reference

Kynema API: kynema::Model Class Reference
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches

Struct to define the connectivity structure of elements, nodes, and constraints defining an Kynema problem. More...

#include <model.hpp>

Public Member Functions

 Model ()=default
 Default constructor.
 
 Model (std::array< double, 3 > gravity)
 Constructor with gravity specified.
 
void SetGravity (double x, double y, double z)
 Sets the gravity components for the model.
 
NodeBuilder AddNode ()
 Adds a node to the model.
 
const NodeGetNode (size_t id) const
 Returns a node by ID.
 
NodeGetNode (size_t id)
 Returns a node by ID.
 
size_t NumNodes () const
 Gets the number of nodes present in the model.
 
const std::vector< Node > & GetNodes () const
 Returns constant reference to nodes vector.
 
size_t AddBeamElement (std::span< const size_t > node_ids, std::span< const BeamSection > sections, std::span< const std::array< double, 2 > > quadrature)
 Adds a beam element to the model.
 
const BeamElementGetBeamElement (size_t id) const
 Returns a beam element by ID.
 
BeamElementGetBeamElement (size_t id)
 Returns a beam element by ID.
 
const std::vector< BeamElement > & GetBeamElements () const
 Returns a reference to the beam elements present in the model.
 
size_t NumBeamElements () const
 Returns the number of beam elements present in the model.
 
BeamsInput CreateBeamsInput () const
 Createsa Beams input file based on the beam elements in the model.
 
template<typename DeviceType >
Beams< DeviceType > CreateBeams () const
 Createsa Beams structure based on the beam elements in the model.
 
void TranslateBeam (size_t beam_elem_id, const std::array< double, 3 > &displacement)
 Translate all beam nodes by given displacement.
 
void RotateBeamAboutPoint (size_t beam_elem_id, const std::array< double, 4 > &displacement_quaternion, const std::array< double, 3 > &point)
 Rotate all beam nodes by given quaternion about a given point.
 
void SetBeamVelocityAboutPoint (size_t beam_elem_id, const std::array< double, 6 > &velocity, const std::array< double, 3 > &point)
 Set the translational and rotational velocity of the beam about a given point.
 
void SetBeamAccelerationAboutPoint (size_t beam_elem_id, const std::array< double, 6 > &acceleration, const std::array< double, 3 > &omega, const std::array< double, 3 > &point)
 Set the acceleration of the beam about a given point.
 
size_t AddMassElement (const size_t node_id, const std::array< std::array< double, 6 >, 6 > &mass)
 Adds a mass element to the model.
 
const MassElementGetMassElement (size_t id) const
 Returns a mass element by ID.
 
MassElementGetMassElement (size_t id)
 Returns a mass element by ID.
 
const std::vector< MassElement > & GetMassElements () const
 Returns a reference to the mass elements present in the model.
 
size_t NumMassElements () const
 Returns the number of mass elements present in the model.
 
template<typename DeviceType >
Masses< DeviceType > CreateMasses () const
 Create a a masses struct based on the mass elements present in the model.
 
size_t AddSpringElement (const size_t node1_id, const size_t node2_id, const double stiffness, const double undeformed_length)
 Adds a spring element to the model.
 
const SpringElementGetSpringElement (size_t id) const
 Returns a spring element by ID.
 
SpringElementGetSpringElement (size_t id)
 Returns a spring element by ID.
 
size_t NumSpringElements () const
 Returns the number of spring elements present in the model.
 
template<typename DeviceType >
Springs< DeviceType > CreateSprings () const
 Creates a Springs struct based on the spring elements in the model.
 
template<typename DeviceType >
Elements< DeviceType > CreateElements () const
 Creates an Elements struct with Beams, Masses, and Springs.
 
template<typename DeviceType >
State< DeviceType > CreateState () const
 Creates an State struct based on the nodes in this model.
 
size_t AddFixedBC (const size_t node_id)
 Adds a fixed boundary condition constraint to the model and returns the ID.
 
size_t AddPrescribedBC (const size_t node_id, const std::array< double, 7 > &initial_displacement={0., 0., 0., 1., 0., 0., 0.})
 Adds a prescribed boundary condition constraint to the model and returns the ID.
 
size_t AddRigidJointConstraint (const std::array< size_t, 2 > &node_ids)
 Adds a rigid constraint to the model and returns the ID.
 
size_t AddRevoluteJointConstraint (const std::array< size_t, 2 > &node_ids, const std::array< double, 3 > &axis, double *torque)
 Adds a revolute/hinge constraint to the model and returns the ID.
 
size_t AddRotationControl (const std::array< size_t, 2 > &node_ids, const std::array< double, 3 > &axis, double *control)
 Adds a rotation control constraint to the model and returns the ID.
 
size_t AddFixedBC3DOFs (const size_t node_id)
 Adds a fixed boundary condition constraint (6DOFs to 3DOFs) to the model and returns the ID.
 
size_t AddPrescribedBC3DOFs (const size_t node_id)
 Adds a prescribed boundary condition constraint (6DOFs to 3DOFs) to the model and returns the ID.
 
size_t AddRigidJoint6DOFsTo3DOFs (const std::array< size_t, 2 > &node_ids)
 Adds a rigid joint constraint (6DOFs to 3DOFs) to the model and returns the ID.
 
size_t NumConstraints () const
 Returns the number of constraints present in the model.
 
template<typename DeviceType >
Constraints< DeviceType > CreateConstraints () const
 Returns a Constraints object initialized from the model constraints.
 
template<typename DeviceType = Kokkos::Device< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space>>
std::tuple< State< DeviceType >, Elements< DeviceType >, Constraints< DeviceType > > CreateSystem () const
 Returns a State, Elements, and Constraints object initialized from the model.
 
template<typename DeviceType = Kokkos::Device< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space>>
std::tuple< State< DeviceType >, Elements< DeviceType >, Constraints< DeviceType >, Solver< DeviceType > > CreateSystemWithSolver () const
 Returns a State, Elements, Constraints, and Solver object initialized from the model.
 
const model::MeshConnectivityGetMeshConnectivity () const
 Get the mesh connectivity.
 
model::MeshConnectivityGetMeshConnectivity ()
 Get the mesh connectivity.
 
void ExportMeshConnectivityToYAML (const std::string &filename="mesh_connectivity.yaml") const
 Export mesh connectivity to a YAML file.
 

Static Public Attributes

static constexpr size_t InvalidNodeID {0U}
 Represents an invalid node in constraints that only uses the target node.
 

Detailed Description

Struct to define the connectivity structure of elements, nodes, and constraints defining an Kynema problem.

A model is a collection of nodes, elements, and constraints that define the geometry and relationships between components in an Kynema problem. Model also provides methods to consistantly manipulate the nodes associated with a given element (for example, rotating all nodes in a beam) to ease the process of defining problems.

Constructor & Destructor Documentation

◆ Model() [1/2]

kynema::Model::Model ( )
default

Default constructor.

◆ Model() [2/2]

kynema::Model::Model ( std::array< double, 3 >  gravity)
inlineexplicit

Constructor with gravity specified.

Parameters
gravityThe gravity vector that will be applied during the simulation

Member Function Documentation

◆ AddBeamElement()

size_t kynema::Model::AddBeamElement ( std::span< const size_t >  node_ids,
std::span< const BeamSection sections,
std::span< const std::array< double, 2 > >  quadrature 
)
inline

Adds a beam element to the model.

Parameters
node_idsA list of the node IDs to be contained in the beam
sectionsThe physical properties defined at each quadrature point
quadratureThe quadrature point locations and weights
Returns
the index of the newly added beam

◆ AddFixedBC()

size_t kynema::Model::AddFixedBC ( const size_t  node_id)
inline

Adds a fixed boundary condition constraint to the model and returns the ID.

Parameters
node_idthe ID of the node where the constraint is to be added
Returns
The ID of the created constraint

◆ AddFixedBC3DOFs()

size_t kynema::Model::AddFixedBC3DOFs ( const size_t  node_id)
inline

Adds a fixed boundary condition constraint (6DOFs to 3DOFs) to the model and returns the ID.

Parameters
node_idThe node ID where the constraint will be applied
Returns
the ID of the created constraint

◆ AddMassElement()

size_t kynema::Model::AddMassElement ( const size_t  node_id,
const std::array< std::array< double, 6 >, 6 > &  mass 
)
inline

Adds a mass element to the model.

Parameters
node_idID of the node where the mass element will be placed
massThe inertia matrix of the element
Returns
The index of the newly added element

◆ AddNode()

NodeBuilder kynema::Model::AddNode ( )
inline

Adds a node to the model.

Returns
NodeBuilder object wrapping the newly added node

◆ AddPrescribedBC()

size_t kynema::Model::AddPrescribedBC ( const size_t  node_id,
const std::array< double, 7 > &  initial_displacement = {0., 0., 0., 1., 0., 0., 0.} 
)
inline

Adds a prescribed boundary condition constraint to the model and returns the ID.

Parameters
node_idthe ID of the node where the constraint is to be added
initial_displacementThe displacement of the node to be forced on the node
Returns
the ID of the created constraint

◆ AddPrescribedBC3DOFs()

size_t kynema::Model::AddPrescribedBC3DOFs ( const size_t  node_id)
inline

Adds a prescribed boundary condition constraint (6DOFs to 3DOFs) to the model and returns the ID.

Parameters
node_idThe node ID where the constraint will be applied
Returns
the ID of the created constraint

◆ AddRevoluteJointConstraint()

size_t kynema::Model::AddRevoluteJointConstraint ( const std::array< size_t, 2 > &  node_ids,
const std::array< double, 3 > &  axis,
double *  torque 
)
inline

Adds a revolute/hinge constraint to the model and returns the ID.

Parameters
node_idsthe IDs of the two nodes to be linked by the constraint
axisThe axis about which the torque force will be applied
torqueA pointer to the location in memory where the torque will be set
Returns
the ID of the created constraint

◆ AddRigidJoint6DOFsTo3DOFs()

size_t kynema::Model::AddRigidJoint6DOFsTo3DOFs ( const std::array< size_t, 2 > &  node_ids)
inline

Adds a rigid joint constraint (6DOFs to 3DOFs) to the model and returns the ID.

Parameters
node_idsthe IDs of the nodes which will be joined by the constraint
Returns
the ID of the created constraint

◆ AddRigidJointConstraint()

size_t kynema::Model::AddRigidJointConstraint ( const std::array< size_t, 2 > &  node_ids)
inline

Adds a rigid constraint to the model and returns the ID.

Parameters
node_idsThe IDs of the two nodes to be linked by the constraint
Returns
The ID of the created constraint

◆ AddRotationControl()

size_t kynema::Model::AddRotationControl ( const std::array< size_t, 2 > &  node_ids,
const std::array< double, 3 > &  axis,
double *  control 
)
inline

Adds a rotation control constraint to the model and returns the ID.

Parameters
node_idsthe IDs of the two nodes to be linked by the constraint
axisThe axis about which the torque force will be applied
controlA pointer to the location in memory where the control rotation will be set
Returns
the ID of the created constraint

◆ AddSpringElement()

size_t kynema::Model::AddSpringElement ( const size_t  node1_id,
const size_t  node2_id,
const double  stiffness,
const double  undeformed_length 
)
inline

Adds a spring element to the model.

Parameters
node1_idID of the node at one end of the spring
node2_idID of the node at the other end of the spring
stiffnessStiffness of the spring
undeformed_lengthLength of the spring at which the spring force is zero
Returns
the index of the newly added spring

◆ CreateBeams()

template<typename DeviceType >
Beams< DeviceType > kynema::Model::CreateBeams ( ) const
inline

Createsa Beams structure based on the beam elements in the model.

Template Parameters
AKokkos Device where the Beams struct will exist
Returns
An initialized Beams struct

◆ CreateBeamsInput()

BeamsInput kynema::Model::CreateBeamsInput ( ) const
inline

Createsa Beams input file based on the beam elements in the model.

Returns
An initialized BeamsInput struct

◆ CreateConstraints()

template<typename DeviceType >
Constraints< DeviceType > kynema::Model::CreateConstraints ( ) const
inline

Returns a Constraints object initialized from the model constraints.

Template Parameters
DeviceTypethe Kokkos Device where the created constraints will reside
Returns
The constructed Constraints object

◆ CreateElements()

template<typename DeviceType >
Elements< DeviceType > kynema::Model::CreateElements ( ) const
inline

Creates an Elements struct with Beams, Masses, and Springs.

Template Parameters
DeviceTypea Kokkos device where the Elements object will reside
Returns
an initialized Elements object

◆ CreateMasses()

template<typename DeviceType >
Masses< DeviceType > kynema::Model::CreateMasses ( ) const
inline

Create a a masses struct based on the mass elements present in the model.

Template Parameters
DeviceTypeA Kokkos device where the Masses object will reside
Returns
an initialized Masses object

◆ CreateSprings()

template<typename DeviceType >
Springs< DeviceType > kynema::Model::CreateSprings ( ) const
inline

Creates a Springs struct based on the spring elements in the model.

Template Parameters
DeviceTypea Kokkos device where the Springs object will reside
Returns
An initialized Springs object

◆ CreateState()

template<typename DeviceType >
State< DeviceType > kynema::Model::CreateState ( ) const
inline

Creates an State struct based on the nodes in this model.

Template Parameters
DeviceTypea Kokkos device where the State object will reside
Returns
an initialized State object

◆ CreateSystem()

template<typename DeviceType = Kokkos::Device< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space>>
std::tuple< State< DeviceType >, Elements< DeviceType >, Constraints< DeviceType > > kynema::Model::CreateSystem ( ) const
inline

Returns a State, Elements, and Constraints object initialized from the model.

Template Parameters
DeviceTypeThe Kokkos Device where the created objects will reside
Returns
Constructed State, Elements, and Constraints objects

◆ CreateSystemWithSolver()

template<typename DeviceType = Kokkos::Device< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space>>
std::tuple< State< DeviceType >, Elements< DeviceType >, Constraints< DeviceType >, Solver< DeviceType > > kynema::Model::CreateSystemWithSolver ( ) const
inline

Returns a State, Elements, Constraints, and Solver object initialized from the model.

Template Parameters
DeviceTypeThe Kokkos Device where the created objects will reside
Returns
Constructed State, Elements, Constraints, and Solver objects

◆ ExportMeshConnectivityToYAML()

void kynema::Model::ExportMeshConnectivityToYAML ( const std::string &  filename = "mesh_connectivity.yaml") const
inline

Export mesh connectivity to a YAML file.

Parameters
filenameThe name of the file to which to write the connectivity

◆ GetBeamElement() [1/2]

BeamElement & kynema::Model::GetBeamElement ( size_t  id)
inline

Returns a beam element by ID.

Parameters
idThe index of the beam element
Returns
The beam element itself

◆ GetBeamElement() [2/2]

const BeamElement & kynema::Model::GetBeamElement ( size_t  id) const
inline

Returns a beam element by ID.

Parameters
idThe index of the beam element
Returns
The beam element itself

◆ GetBeamElements()

const std::vector< BeamElement > & kynema::Model::GetBeamElements ( ) const
inline

Returns a reference to the beam elements present in the model.

Returns
a reference to the vector containing the beam elements

◆ GetMassElement() [1/2]

MassElement & kynema::Model::GetMassElement ( size_t  id)
inline

Returns a mass element by ID.

Parameters
idID of desired mass element
Returns
The Mass element

◆ GetMassElement() [2/2]

const MassElement & kynema::Model::GetMassElement ( size_t  id) const
inline

Returns a mass element by ID.

Parameters
idID of desired mass element
Returns
The Mass element

◆ GetMassElements()

const std::vector< MassElement > & kynema::Model::GetMassElements ( ) const
inline

Returns a reference to the mass elements present in the model.

Returns
A reference to the vector containing the mass elements

◆ GetMeshConnectivity() [1/2]

model::MeshConnectivity & kynema::Model::GetMeshConnectivity ( )
inline

Get the mesh connectivity.

Returns
A reference to this Model's MeshConnectivity model

◆ GetMeshConnectivity() [2/2]

const model::MeshConnectivity & kynema::Model::GetMeshConnectivity ( ) const
inline

Get the mesh connectivity.

Returns
A reference to this Model's MeshConnectivity model

◆ GetNode() [1/2]

Node & kynema::Model::GetNode ( size_t  id)
inline

Returns a node by ID.

Parameters
idIndex number of node
Returns
The desired node

◆ GetNode() [2/2]

const Node & kynema::Model::GetNode ( size_t  id) const
inline

Returns a node by ID.

Parameters
idIndex number of node
Returns
The desired node

◆ GetNodes()

const std::vector< Node > & kynema::Model::GetNodes ( ) const
inline

Returns constant reference to nodes vector.

Returns
A reference to the vector containing all of the nodes in the model

◆ GetSpringElement() [1/2]

SpringElement & kynema::Model::GetSpringElement ( size_t  id)
inline

Returns a spring element by ID.

Parameters
idThe ID of the spring
Returns
The requested spring element

◆ GetSpringElement() [2/2]

const SpringElement & kynema::Model::GetSpringElement ( size_t  id) const
inline

Returns a spring element by ID.

Parameters
idThe ID of the spring
Returns
The requested spring element

◆ NumBeamElements()

size_t kynema::Model::NumBeamElements ( ) const
inline

Returns the number of beam elements present in the model.

Returns
the number of beam elements

◆ NumConstraints()

size_t kynema::Model::NumConstraints ( ) const
inline

Returns the number of constraints present in the model.

Returns
the number of constraints

◆ NumMassElements()

size_t kynema::Model::NumMassElements ( ) const
inline

Returns the number of mass elements present in the model.

Returns
The number of mass elements

◆ NumNodes()

size_t kynema::Model::NumNodes ( ) const
inline

Gets the number of nodes present in the model.

Returns
The number of nodes

◆ NumSpringElements()

size_t kynema::Model::NumSpringElements ( ) const
inline

Returns the number of spring elements present in the model.

Returns
the number of springs in the model

◆ RotateBeamAboutPoint()

void kynema::Model::RotateBeamAboutPoint ( size_t  beam_elem_id,
const std::array< double, 4 > &  displacement_quaternion,
const std::array< double, 3 > &  point 
)
inline

Rotate all beam nodes by given quaternion about a given point.

Parameters
beam_elem_idThe index of the beam to be rotated
displacement_quaternionThe displacement quaternion
pointThe point around which the beam will be rotated

◆ SetBeamAccelerationAboutPoint()

void kynema::Model::SetBeamAccelerationAboutPoint ( size_t  beam_elem_id,
const std::array< double, 6 > &  acceleration,
const std::array< double, 3 > &  omega,
const std::array< double, 3 > &  point 
)
inline

Set the acceleration of the beam about a given point.

Parameters
beam_elem_idThe index of the beam
accelerationThe acceleration of the beam
omegaThe rotational acceleration of the beam
pointThe point about which the rotational velocity is based

◆ SetBeamVelocityAboutPoint()

void kynema::Model::SetBeamVelocityAboutPoint ( size_t  beam_elem_id,
const std::array< double, 6 > &  velocity,
const std::array< double, 3 > &  point 
)
inline

Set the translational and rotational velocity of the beam about a given point.

Parameters
beam_elem_idThe index of the beam
velocityThe velocity of the beam
pointThe point about which the rotational velocity is based

◆ SetGravity()

void kynema::Model::SetGravity ( double  x,
double  y,
double  z 
)
inline

Sets the gravity components for the model.

Parameters
xX gravity component
yY gravity component
zZ gravity component

◆ TranslateBeam()

void kynema::Model::TranslateBeam ( size_t  beam_elem_id,
const std::array< double, 3 > &  displacement 
)
inline

Translate all beam nodes by given displacement.

Parameters
beam_elem_idThe index of the beam to be translated
displacementThe displacement vector

Member Data Documentation

◆ InvalidNodeID

constexpr size_t kynema::Model::InvalidNodeID {0U}
staticconstexpr

Represents an invalid node in constraints that only uses the target node.


The documentation for this class was generated from the following file:
  • /home/runner/work/kynema/kynema/kynema/src/model/model.hpp