chrono::ch_precice::ChPreciceAdapterMbs Class Reference

Description

preCICE adapter for Chrono MBS simulation.

#include <ChPreciceAdapterMbs.h>

Inheritance diagram for chrono::ch_precice::ChPreciceAdapterMbs:
Collaboration diagram for chrono::ch_precice::ChPreciceAdapterMbs:

Classes

class  AfterStepDynamicsCallback
 Class to be used as a callback interface for user-defined actions to be performed after advancing MBS dynamics. More...
 
class  BeforeStepDynamicsCallback
 Class to be used as a callback interface for user-defined actions to be performed before advancing MBS dynamics. More...
 

Public Member Functions

 ChPreciceAdapterMbs (std::shared_ptr< ChSystem > sys, double time_step, bool verbose=false)
 Construct a Chrono MBS preCICE participant for the specified Chrono system. More...
 
ChSystemGetSystem ()
 Get underlying Chrono multibody system.
 
void EnforceRealtime (bool realtime)
 Enable/disable soft real-time for MBS simulation (default: false).
 
void AddCouplingBody (std::shared_ptr< ChBodyAuxRef > body, const std::vector< ChVector3d > &points)
 Add the specified body as a preCICE interface object. More...
 
void RegisterBeforeStepDynamicsCallback (std::shared_ptr< BeforeStepDynamicsCallback > callback)
 Register a callback for operations to be performed before advancing dynamics at each step.
 
void RegisterAfterStepDynamicsCallback (std::shared_ptr< AfterStepDynamicsCallback > callback)
 Register a callback for operations to be performed after advancing dynamics at each step.
 
- Public Member Functions inherited from chrono::ch_precice::ChPreciceAdapter
void SetVerbose (bool verbose)
 Enable/disable verbose terminal output (default: false).
 
void EnableVisualization (bool vis)
 Enable/disable run-time visualization (default: false). More...
 
void EnableOutput (bool out)
 Enable/disable simulation output (default: false). More...
 
void SetOutputDir (const std::string &out_dir)
 Set root output directory (default: "."). More...
 
void SetOutputSettings (const ChOutput::Settings &settings)
 Set Chrono simulation output settings. More...
 
void SetOutputSettings (ChOutput::Format format, ChOutput::Mode mode, double output_fps)
 Set Chrono simulation output settings. More...
 
void SetModelName (const std::string &name)
 Set the Chrono model name.
 
const std::string & GetModelName () const
 Get the name of the Chrono model.
 
void RegisterParticipant (const std::string &precice_config_filename, int process_index=0, int process_size=1)
 Register the participant with preCICE, using the specified preCICE configuration file, and the solver process size and index.
 
int GetCouplingMeshDimensions (const std::string &mesh_name) const
 Get the number of spatial dimensions for the mesh with specified name. More...
 
size_t GetNumVertices (const std::string &mesh_name)
 Get the number of vertices for the mesh with specified name.
 
CouplingMeshType GetCouplingMeshType (const std::string &mesh_name) const
 Get the type (vertex semantics) for the mesh with specified name.
 
std::string GetCouplingMeshTypeAsString (const std::string &mesh_name) const
 Get the type (vertex semantics) for the mesh with specified name.
 
int GetCouplingDataDimensions (const std::string &mesh_name, const std::string &data_name) const
 Get the data dimensions for the data with specified name on the mesh with specified name. More...
 
CouplingDataType GetCouplingDataType (const std::string &mesh_name, const std::string &data_name) const
 Get the type for the coupling data with specified name on the mesh with specified name.
 
bool GetCouplingDataUsed (const std::string &mesh_name, const std::string &data_name) const
 Get the used flag for the coupling data with specified name on the mesh with specified name. More...
 
std::string GetCouplingDataTypeAsString (const std::string &mesh_name, const std::string &data_name) const
 Get the type for the coupling data with specified name on the mesh with specified name.
 
double GetMaxTimeStepSize () const
 Get the maximum time step size from preCICE.
 
const std::string & GetParticipantName () const
 Get the preCICE participant name.
 
std::vector< std::string > GetCouplingMeshNames () const
 Get the coupled mesh names on this participant.
 
std::vector< std::string > GetReadDataNamesOnMesh (const std::string &mesh_name) const
 Get the data names for reading on the mesh with specified name.
 
std::vector< std::string > GetWriteDataNamesOnMesh (const std::string &mesh_name) const
 Get the data names for writing on the mesh with specified name.
 
bool MustWriteInitialData ()
 Check if the participant is required to provide initial data. More...
 
bool IsCouplingOngoing ()
 Check if coupling is ongoing.
 
bool IsTimeWindowComplete ()
 Check if the time window has completed.
 
void InitializeSimulation ()
 Wrapper function for initializing the coupled simulation for this participant. More...
 
void RunSimulation ()
 Wrapper function for performing the simulation loop. More...
 
void FinalizeSimulation ()
 Wrapper function for finalizing the coupled simulation for this participant. More...
 

Additional Inherited Members

- Public Types inherited from chrono::ch_precice::ChPreciceAdapter
enum  CouplingMeshType {
  CouplingMeshType::GENERIC, CouplingMeshType::RIGID_BODY_REFS, CouplingMeshType::RIGID_BODY_POINTS, CouplingMeshType::FEA_MESH_NODES,
  CouplingMeshType::FEA_MESH_POINTS
}
 Chrono coupling mesh types (mesh vertex semantics). More...
 
enum  CouplingDataType {
  CouplingDataType::GENERIC, CouplingDataType::POSITIONS, CouplingDataType::ROTATIONS, CouplingDataType::DISPLACEMENTS,
  CouplingDataType::LINEAR_VELOCITIES, CouplingDataType::ANGULAR_VELOCITIES, CouplingDataType::FORCES, CouplingDataType::TORQUES
}
 Chrono coupling data type. More...
 
- Static Public Member Functions inherited from chrono::ch_precice::ChPreciceAdapter
static std::string GetCouplingDataTypeAsString (CouplingDataType type)
 Return the data type as a string.
 
- Protected Types inherited from chrono::ch_precice::ChPreciceAdapter
using CouplingData = std::map< std::string, CouplingDataInfo >
 Data type to hold information for all data blocks in a coupling mesh, indexed by the data name.
 
using CouplingMeshes = std::map< std::string, CouplingMeshInfo >
 Data type to hold data for all coupling meshes, indexed by the mesh name.
 
using MeshDataNames = std::map< std::string, std::vector< std::string > >
 Data type to hold data names associated with a given mesh name.
 
- Protected Member Functions inherited from chrono::ch_precice::ChPreciceAdapter
 ChPreciceAdapter (const std::string &model_name="")
 
 ChPreciceAdapter (const ChPreciceAdapter &)=delete
 
void operator= (const ChPreciceAdapter &)=delete
 
void SetParticipantName (const std::string &participant_name)
 Set the participant name. More...
 
void AddCouplingMeshInterface (const std::string &mesh_name, CouplingMeshType data_type, const std::vector< std::string > &data_write_names, const std::vector< std::string > &data_read_names)
 Add a coupling mesh with specified data type, using the given lists of data names for writing and reading. More...
 
void RegisterMesh (const std::string &mesh_name, const std::vector< ChVector3d > &positions)
 Register a coupling mesh with preCICE, using the specified mesh name and its vertex positions (of ChVector3d type). More...
 
void RegisterMesh (const std::string &mesh_name, const std::vector< double > &positions)
 Register a coupling mesh with preCICE, using the specified mesh name and its vertex positions (as a flattened vector of doubles). More...
 
void SetDataBlock (const std::string &mesh_name, const std::string &data_name, const std::vector< double > &data)
 
void WriteDataBlock (const std::string &mesh_name, const std::string &data_name)
 Write (send) a block of data to preCICE.
 
void WriteDataBlock (const std::string &mesh_name, const std::string &data_name, const std::vector< double > &data)
 Set and write (send) a block of data to preCICE. More...
 
void ReadDataBlock (const std::string &mesh_name, const std::string &data_name, double relative_read_time)
 Read (receive) a block of data from preCICE.
 
const std::vector< double > & GetDataBlock (const std::string &mesh_name, const std::string &data_name) const
 Get the (read) data vector for the specified mesh and data names.
 
const std::vector< double > & ReadDataBlock (const std::string &mesh_name, const std::string &data_name)
 Read (receive) a block of data from preCICE and return the data vector. More...
 
bool WriteCheckpointIfRequired (double time)
 Write the solver state to a checkpoint if required by preCICE. More...
 
bool ReadCheckpointIfRequired (double time)
 Read the solver state from a checkpoint if required by preCICE. More...
 
virtual void FinalizeParticipant ()
 Let the derived class perform any necessary operations during simulation shutdown. More...
 
void Output (double time)
 Save output at the current frame is output is enabled. More...
 
void Render (double time)
 Render the current frame if run-time visualization is available and enabled. More...
 
- Static Protected Member Functions inherited from chrono::ch_precice::ChPreciceAdapter
static std::vector< double > SetVerticesToData (const std::vector< ChVector2d > &vertices)
 Convert a vector of ChVector2d to a vector of doubles in the format (x0, y0, x1, y1, ...).
 
static std::vector< double > SetVerticesToData (const std::vector< ChVector3d > &vertices)
 Convert a vector of ChVector3d to a vector of doubles in the format (x0, y0, z0, x1, y1, z1, ...).
 
static std::vector< ChVector3dReadPoints (const std::string &filename)
 Read a set of 3D points from an ASCII file (one point per line, space-delimited).
 
- Protected Attributes inherited from chrono::ch_precice::ChPreciceAdapter
std::string m_model_name
 Chrono model name.
 
std::unique_ptr< precice::Participant > m_participant
 preCICE instance
 
std::string m_precice_config_filename
 name of the preCICE configuration file
 
std::string m_participant_name
 name of the participant/solver
 
int m_process_size
 number of processes used by an instance of this solver
 
int m_process_index
 index for each process used by this solver
 
CouplingMeshes m_coupling_meshes
 data for all coupling meshes
 
MeshDataNames m_data_read
 input data names for all coupling meshes
 
MeshDataNames m_data_write
 output data names for all coupling meshes
 
bool m_interfaces_created
 true if the data interfaces were created
 
bool m_participant_created
 true if the preCICE participant was created
 
bool m_mesh_created
 true if preCICE coupling meshes were created
 
bool m_initialized
 true if preCICE participant was initialized
 
bool m_verbose
 verbose terminal output
 
std::string m_prefix1
 prefix for terminal messages (first line)
 
std::string m_prefix2
 prefix for terminal messages (subsequent lines)
 
bool m_visualize
 enable/disable run-time visualization
 
bool m_output
 enable/disable run-time output
 
std::string m_output_dir
 output directory name
 
ChOutput::Settings m_output_settings
 output settings
 
std::unique_ptr< ChOutputm_output_db
 output database
 

Constructor & Destructor Documentation

◆ ChPreciceAdapterMbs()

chrono::ch_precice::ChPreciceAdapterMbs::ChPreciceAdapterMbs ( std::shared_ptr< ChSystem sys,
double  time_step,
bool  verbose = false 
)

Construct a Chrono MBS preCICE participant for the specified Chrono system.

No preCICE interfaces (coupling bodies and FEA meshes) are defined.

Member Function Documentation

◆ AddCouplingBody()

void chrono::ch_precice::ChPreciceAdapterMbs::AddCouplingBody ( std::shared_ptr< ChBodyAuxRef body,
const std::vector< ChVector3d > &  points 
)

Add the specified body as a preCICE interface object.

Notes:

  • if the MBS preCICE participant is created from a YAML specification file, calls to this function are made automatically.

The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_precice/ChPreciceAdapterMbs.h
  • /builds/uwsbel/chrono/src/chrono_precice/ChPreciceAdapterMbs.cpp