NodeStateWriter Class Reference

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

Class for writing Kynema nodal state data to NetCDF-based output files. More...

#include <node_state_writer.hpp>

Public Member Functions

 NodeStateWriter (const std::string &file_path, bool create, size_t num_nodes, const std::vector< std::string > &enabled_state_prefixes={"x", "u", "v", "a", "f"}, size_t buffer_size=kDefaultBufferSize)
 Constructor to create a NodeStateWriter object.
 
 ~NodeStateWriter ()
 Destructor to flush any remaining buffered data.
 
 NodeStateWriter (const NodeStateWriter &)=delete
 
NodeStateWriteroperator= (const NodeStateWriter &)=delete
 
 NodeStateWriter (NodeStateWriter &&)=delete
 
NodeStateWriteroperator= (NodeStateWriter &&)=delete
 
void WriteStateDataAtTimestep (size_t timestep, const std::string &component_prefix, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::vector< double > &i, const std::vector< double > &j, const std::vector< double > &k, const std::vector< double > &w=std::vector< double >())
 Writes state data for a specific timestep.
 
const NetCdfFileGetFile () const
 Get the NetCDF file object.
 
size_t GetNumNodes () const
 Get the number of nodes with state data in output file.
 
void Close ()
 Manually flush and close the underlying NetCDF file.
 
void Open ()
 Manually (re)open the underlying NetCDF file.
 

Static Public Attributes

static constexpr size_t kDefaultBufferSize {0}
 Default buffer size (number of timesteps to accumulate before auto-flush, 0 = no buffering)
 

Detailed Description

Class for writing Kynema nodal state data to NetCDF-based output files.

This class handles the writing of nodal state data for Kynema simulations to NetCDF format. It manages the output of:

  • Position (x, y, z, w, i, j, k)
  • Displacement (x, y, z, w, i, j, k)
  • Velocity (x, y, z, i, j, k)
  • Acceleration (x, y, z, i, j, k)
  • Force (x, y, z, i, j, k)
Note
Each item is stored as a separate variable in the NetCDF file, organized by timestep and node index. The file structure uses an unlimited time dimension to allow for continuous writing of timesteps during simulation.
The class includes buffering to improve write performance by batching multiple timesteps together before writing to disk.

Constructor & Destructor Documentation

◆ NodeStateWriter() [1/3]

kynema::util::NodeStateWriter::NodeStateWriter ( const std::string &  file_path,
bool  create,
size_t  num_nodes,
const std::vector< std::string > &  enabled_state_prefixes = {"x", "u", "v", "a", "f"},
size_t  buffer_size = kDefaultBufferSize 
)

Constructor to create a NodeStateWriter object.

Parameters
file_pathPath to the output NetCDF file
createWhether to create a new file or open an existing one
num_nodesNumber of nodes in the simulation
enabled_state_prefixesVector of state component prefixes to enable for writing (default: all state components i.e. {"x", "u", "v", "a", "f"})
buffer_sizeNumber of timesteps to accumulate before auto-flush (0 = no buffering)

◆ ~NodeStateWriter()

kynema::util::NodeStateWriter::~NodeStateWriter ( )

Destructor to flush any remaining buffered data.

◆ NodeStateWriter() [2/3]

kynema::util::NodeStateWriter::NodeStateWriter ( const NodeStateWriter )
delete

◆ NodeStateWriter() [3/3]

kynema::util::NodeStateWriter::NodeStateWriter ( NodeStateWriter &&  )
delete

Member Function Documentation

◆ Close()

void kynema::util::NodeStateWriter::Close ( )

Manually flush and close the underlying NetCDF file.

◆ GetFile()

const NetCdfFile & kynema::util::NodeStateWriter::GetFile ( ) const

Get the NetCDF file object.

◆ GetNumNodes()

size_t kynema::util::NodeStateWriter::GetNumNodes ( ) const

Get the number of nodes with state data in output file.

◆ Open()

void kynema::util::NodeStateWriter::Open ( )

Manually (re)open the underlying NetCDF file.

◆ operator=() [1/2]

NodeStateWriter & kynema::util::NodeStateWriter::operator= ( const NodeStateWriter )
delete

◆ operator=() [2/2]

NodeStateWriter & kynema::util::NodeStateWriter::operator= ( NodeStateWriter &&  )
delete

◆ WriteStateDataAtTimestep()

void kynema::util::NodeStateWriter::WriteStateDataAtTimestep ( size_t  timestep,
const std::string &  component_prefix,
const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  z,
const std::vector< double > &  i,
const std::vector< double > &  j,
const std::vector< double > &  k,
const std::vector< double > &  w = std::vector<double>() 
)

Writes state data for a specific timestep.

Parameters
timestepCurrent timestep index
component_prefixPrefix for the component
xData for component 1
yData for component 2
zData for component 3
iData for component 4
jData for component 5
kData for component 6
wData for component 7 (optional, only used for position and displacement)

Member Data Documentation

◆ kDefaultBufferSize

constexpr size_t kynema::util::NodeStateWriter::kDefaultBufferSize {0}
staticconstexpr

Default buffer size (number of timesteps to accumulate before auto-flush, 0 = no buffering)


The documentation for this class was generated from the following files: