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::ChMapData
 Utility class for reading and setting an (x,y) map. More...
 
class  chrono::ChYamlFileHandler
 Utility class for handling data paths in YAML specification files. 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.
 
ChApi void chrono::ReadFileJSON (const std::string &filename, rapidjson::Document &d)
 Load and return a RapidJSON document from the specified file. More...
 
ChApi ChVector3d chrono::ReadVectorJSON (const rapidjson::Value &a)
 Load and return a ChVector3d from the specified JSON array.
 
ChApi ChQuaternion chrono::ReadQuaternionJSON (const rapidjson::Value &a)
 Load and return a ChQuaternion from the specified JSON array.
 
ChApi ChCoordsys chrono::ReadCoordinateSystemJSON (const rapidjson::Value &a)
 Load and return a coordinate system from the specific JSON value.
 
ChApi ChFrame chrono::ReadFrameJSON (const rapidjson::Value &a)
 Load and return a ChFrame from the specified JSON array.
 
ChApi ChColor chrono::ReadColorJSON (const rapidjson::Value &a)
 Load and return a ChColor from the specified JSON array.
 
ChContactMaterialData chrono::ReadMaterialInfoJSON (const rapidjson::Value &mat)
 
std::shared_ptr< ChJoint::BushingDatachrono::ReadBushingDataJSON (const rapidjson::Value &bd)
 
ChApi ChJoint::Type chrono::ReadJointTypeJSON (const rapidjson::Value &a)
 Load and return a joint type from the specific JSON value.
 
utils::ChBodyGeometry chrono::ReadBodyGeometryJSON (const rapidjson::Value &d)
 Load and return a body geometry structure from the specified JSON value. More...
 
utils::ChTSDAGeometry chrono::ReadTSDAGeometryJSON (const rapidjson::Value &d)
 Load and return a TSDA geometry structure from the specified JSON value.
 
std::shared_ptr< ChLinkTSDA::ForceFunctorchrono::ReadTSDAFunctorJSON (const rapidjson::Value &tsda, double &free_length)
 
std::shared_ptr< ChLinkRSDA::TorqueFunctorchrono::ReadRSDAFunctorJSON (const rapidjson::Value &rsda, double &free_angle)
 
void chrono::CheckVersion (const YAML::Node &a)
 Check the version specified in the given YAML node against the Chrono version. More...
 
ChVector3d chrono::ReadVector (const YAML::Node &a)
 Load and return a ChVector3d from the specified node.
 
ChQuaterniond chrono::ReadQuaternion (const YAML::Node &a)
 Load and return a ChQuaternion from the specified node.
 
ChQuaterniond chrono::ReadCardanAngles (const YAML::Node &a, bool use_degrees)
 Load a Cardan angle sequence from the specified node and return as a quaternion. More...
 
ChQuaterniond chrono::ReadRotation (const YAML::Node &a, bool use_degrees)
 Return a quaternion loaded from the specified node. More...
 
ChCoordsysd chrono::ReadCoordinateSystem (const YAML::Node &a, bool use_degrees)
 Load and return a coordinate system from the specified node.
 
std::shared_ptr< ChFunctionchrono::ReadFunction (const YAML::Node &a, bool use_degrees)
 Load and return a ChFunction object from the specified node.
 
ChColor chrono::ReadColor (const YAML::Node &a)
 Load and return a ChColor from the specified node.
 
ChColormap::Type chrono::ReadColorMapType (const YAML::Node &a)
 Load and return a ChColor from the specified node.
 
VisualizationType chrono::ReadVisualizationType (const YAML::Node &a)
 Load and return a VisualizationType from the specified node.
 
ChOutput::Type chrono::ReadOutputType (const YAML::Node &a)
 Load and return the output type from the specified node.
 
ChOutput::Mode chrono::ReadOutputMode (const YAML::Node &a)
 Load and return the output mode from the specified node.
 
ChSolver::Type chrono::ReadSolverType (const YAML::Node &a)
 Load and return the solver type from the specified node.
 
ChTimestepper::Type chrono::ReadIntegratorType (const YAML::Node &a)
 Load and return the integrator type from the specified node.
 
void chrono::PrintNodeType (const YAML::Node &node)
 Print YAML node type.
 
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

◆ CheckVersion()

ChApi void chrono::CheckVersion ( const YAML::Node &  a)

Check the version specified in the given YAML node against the Chrono version.

Throw an exception if the versions are incompatible.

◆ ReadBodyGeometryJSON()

ChApi utils::ChBodyGeometry chrono::ReadBodyGeometryJSON ( const rapidjson::Value &  d)

Load and return a body geometry structure from the specified JSON value.

Collision geometry and contact material information is set in the return ChBodyGeometry object if the given JSON object has a member "Contact". Visualization geometry is loaded if the JSON object has a member "Visualization". Note that file names for collision and visualization geometry are assumed to be relative to the Chrono data directory.

◆ 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.

◆ ReadCardanAngles()

ChApi ChQuaterniond chrono::ReadCardanAngles ( const YAML::Node &  a,
bool  use_degrees 
)

Load a Cardan angle sequence from the specified node and return as a quaternion.

The sequence is assumed to be extrinsic rotations X-Y-Z.

◆ ReadFileJSON()

ChApi void chrono::ReadFileJSON ( const std::string &  filename,
rapidjson::Document &  d 
)

Load and return a RapidJSON document from the specified file.

A Null document is returned if the file cannot be opened.

◆ ReadRotation()

ChApi ChQuaterniond chrono::ReadRotation ( const YAML::Node &  a,
bool  use_degrees 
)

Return a quaternion loaded from the specified node.

Data is assumed to provide a quaternion or a Cardan extrinsic X-Y-Z angle set.

◆ 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
systemcontaining 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
systemcontaining system
filenameoutput file name
selectorselect bodies
body_infoinclude body state information
delimCSV delimitator