Input/output

Description

Collaboration diagram for Input/output:

Classes

class  chrono::ChCheckpoint
 Base class for a Chrono checkpoint database. More...
 
class  chrono::ChCheckpointASCII
 ASCII text Chrono checkpoint database. More...
 
class  chrono::ChOutput
 Base class for a Chrono output database. More...
 
class  chrono::ChOutputASCII
 ASCII text Chrono output database. More...
 
class  chrono::ChOutputHDF5
 HDF5 Chrono output database. More...
 
class  chrono::ChWriterCSV
 General output to a Comma-Separated Values ASCII file. More...
 

Functions

bool chrono::utils::WriteBodyShapesCheckpoint (ChSystem *system, const std::string &filename)
 Create a CSV file with a checkpoint of bodies and collision shapes. More...
 
void chrono::utils::ReadBodyShapesCheckpoint (ChSystem *system, const std::string &filename)
 Read a CSV file with a checkpoint of bodies and collision shapes. More...
 
void chrono::utils::WriteVisualizationAssets (ChSystem *system, const std::string &filename, bool body_info=true, const std::string &delim=",")
 Write CSV output file with body and asset information for off-line visualization. More...
 
void chrono::utils::WriteVisualizationAssets (ChSystem *system, const std::string &filename, std::function< bool(const ChBody &)> selector, bool body_info=true, const std::string &delim=",")
 Write CSV output file with body and asset information for off-line visualization. More...
 
void chrono::utils::WriteMeshPovray (ChTriangleMeshConnected &trimesh, const std::string &mesh_name, const std::string &out_dir, const ChColor &color=ChColor(0.4f, 0.4f, 0.4f), const ChVector3d &pos=ChVector3d(0, 0, 0), const ChQuaternion<> &rot=ChQuaternion<>(1, 0, 0, 0), bool smoothed=false)
 Write the specified mesh as a macro in a PovRay include file. More...
 
bool chrono::utils::WriteMeshPovray (const std::string &obj_filename, const std::string &mesh_name, const std::string &out_dir, const ChColor &color=ChColor(0.4f, 0.4f, 0.4f), const ChVector3d &pos=ChVector3d(0, 0, 0), const ChQuaternion<> &rot=ChQuaternion<>(1, 0, 0, 0))
 Write the triangular mesh from the specified OBJ file as a macro in a PovRay include file. More...
 
void chrono::utils::WriteCurvePovray (const ChBezierCurve &curve, const std::string &curve_name, const std::string &out_dir, double radius=0.03, const ChColor &col=ChColor(0.8f, 0.8f, 0.2f))
 Write the specified Bezier curve as a macro in a PovRay include file.
 
template<typename T >
ChWriterCSVchrono::operator<< (ChWriterCSV &out, const ChVector3< T > &v)
 
template<typename T >
ChWriterCSVchrono::operator<< (ChWriterCSV &out, const ChQuaternion< T > &q)
 
ChWriterCSVchrono::operator<< (ChWriterCSV &out, const ChColor &c)
 
template<typename T >
ChWriterCSVchrono::operator<< (ChWriterCSV &out, const std::vector< T > &vec)
 

Function Documentation

◆ ReadBodyShapesCheckpoint()

ChApi void chrono::utils::ReadBodyShapesCheckpoint ( ChSystem system,
const std::string &  filename 
)

Read a CSV file with a checkpoint of bodies and collision shapes.

This function creates bodies in the given Chrono system using states and collision shapes read from the checkpoint file with given name (assumed to have been produced with WriteBodyShapesCheckpoint). This is a specialized checkpointing function suitable for DEM simulations (e.g., with Chrono::Multicore). Note that only body states are checkpointed and therefore this function should not be used for Chrono multibody systems.

◆ WriteBodyShapesCheckpoint()

ChApi bool chrono::utils::WriteBodyShapesCheckpoint ( ChSystem system,
const std::string &  filename 
)

Create a CSV file with a checkpoint of bodies and collision shapes.

This is a specialized checkpointing function suitable for DEM simulations (e.g., with Chrono::Multicore). Note that only body states are checkpointed and therefore this function should not be used for Chrono multibody systems.

◆ WriteMeshPovray() [1/2]

ChApi void chrono::utils::WriteMeshPovray ( ChTriangleMeshConnected trimesh,
const std::string &  mesh_name,
const std::string &  out_dir,
const ChColor color = ChColor(0.4f, 0.4f, 0.4f),
const ChVector3d pos = ChVector3d(0, 0, 0),
const ChQuaternion<> &  rot = ChQuaternion<>(1, 0, 0, 0),
bool  smoothed = false 
)

Write the specified mesh as a macro in a PovRay include file.

The output file will be "[out_dir]/[mesh_name].inc". The mesh vertices will be transformed to the frame with specified offset and orientation.

◆ WriteMeshPovray() [2/2]

ChApi bool chrono::utils::WriteMeshPovray ( const std::string &  obj_filename,
const std::string &  mesh_name,
const std::string &  out_dir,
const ChColor color = ChColor(0.4f, 0.4f, 0.4f),
const ChVector3d pos = ChVector3d(0, 0, 0),
const ChQuaternion<> &  rot = ChQuaternion<>(1, 0, 0, 0) 
)

Write the triangular mesh from the specified OBJ file as a macro in a PovRay include file.

The output file will be "[out_dir]/[mesh_name].inc". The mesh vertices will be transformed to the frame with specified offset and orientation.

◆ WriteVisualizationAssets() [1/2]

ChApi void chrono::utils::WriteVisualizationAssets ( ChSystem system,
const std::string &  filename,
bool  body_info = true,
const std::string &  delim = "," 
)

Write CSV output file with body and asset information for off-line visualization.

(1) The first line of the output file contains:

  • the number of bodies (0 if no body information is included below)
  • the number of visual assets
  • the number of links
  • the number of TSDA spring-dampers (2) If the number of bodies is not zero, the next block of lines includes information about the rigid bodies. Each line contains 9 values:
  • the body identifier
  • a flag (1 or 0) indicating whether the body is active or not
  • the body position expressed in global frame
  • the body orientation (as a quaternion, expressed in global frame) (3) The next block of lines includes information about the visual assets. Each line contains:
  • the identifier of the associated body
  • a flag (1 or 0) indicating whether the body is active or not
  • the asset position expresssed in global frame
  • the asset orientation (as a quaternion, expressed in global frame)
  • the visualization asset type (an enum value)
  • geometry information depending on the type above (4) The next block of lines includes information about the joints. Each line contains:
  • the joint type (an enum value)
  • joint position and orientation information depending on the type above (5) The next block of lines includes information about TSDA elements. Each line contains:
  • the type of visual asset (0 for segment or 1 for coil)
  • start point position
  • end point position
Parameters
systemcontaing system
filenameoutput file name
body_infoinclude body state information
delimCSV delimitator

◆ WriteVisualizationAssets() [2/2]

ChApi void chrono::utils::WriteVisualizationAssets ( ChSystem system,
const std::string &  filename,
std::function< bool(const ChBody &)>  selector,
bool  body_info = true,
const std::string &  delim = "," 
)

Write CSV output file with body and asset information for off-line visualization.

This version uses a discriminator function to select which bodies and assets are included in the output. The function selector receives as argument a body reference and must return 'true' if the body and its assets should be included in the output file and 'false' otherwise.

Parameters
systemcontaing system
filenameoutput file name
selectorselect bodies
body_infoinclude body state information
delimCSV delimitator