Class CoordData#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

Class Documentation#

class CoordData : public Karana::Core::LockingBase#

Class for managing coordinates for managing a set of CoordBase coordinate provider objects. See the.

The CoordData container section for more information on this class.

Public Functions

CoordData(std::string_view name, const std::vector<kc::ks_ptr<CoordBase>> &coordobjs_list)#

Constructor.

Parameters:
  • instance – name

  • list – of CoordBase objects to manage

~CoordData()#

Destructor.

inline virtual std::string_view typeString() const noexcept override#

Returns the type string of Base.

Returns:

The type string.

km::Vec getQ() const#

Return the Q coordinates as an array.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Returns:

Array of values

km::Vec getU() const#

Return the U velocity coordinates as an array.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Returns:

Array of values

km::Vec getUdot() const#

Return the Udot acceleration coordinates as an array.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Returns:

Array of values

km::Vec getT() const#

Return the T generalized forces as an array.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Returns:

Array of values

km::Vec getQdot() const#

Return the Qdot rate coordinates as an array.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Returns:

Array of values

void setQ(const Eigen::Ref<const km::Vec> &vals)#

Set the Q coordinates.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

vals – Array of values.

void setQ(double fill_value)#

Set the Q coordinates to a constant value.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

fill_value – Fill value.

void setU(const Eigen::Ref<const km::Vec> &vals)#

Set the U velocity coordinates.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

vals – Array of values.

void setU(double fill_value)#

Set the U velocity coordinates to a constant value.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

fill_value – Fill value.

void setT(const Eigen::Ref<const km::Vec> &vals)#

Set the T generalized forces.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

vals – Array of values.

void setT(double fill_value)#

Set the T generalized forces to a constant value.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

fill_value – Fill value.

void setUdot(const Eigen::Ref<const km::Vec> &vals)#

Set the Udot acceleration coordinates.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

vals – Array of values.

void setUdot(double fill_value)#

Set the Udot acceleration coordinates to a constant value.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

fill_value – Fill value.

size_t nQ() const#

The number of Q generalized coords for the CoordBase.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Returns:

the number of coordinates

size_t nU() const#

The number of U velocity coords for the CoordBase.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Returns:

the number of velocity coordinates

virtual bool isFinalized() const override#

Checks is the params for the object have been initialized.

Returns:

True if the params have set up.

void dumpState(std::string_view prefix, std::vector<std::string> filter = {"ALL"}) const#

Print out the coordinate values for all the coordinates.

The filter values for controlling output are any combination of: ‘Q’, ‘U’, ‘Udot’, ‘T’, ‘ALL’

Parameters:
  • prefix – The prefix to add to each output line

  • filter – Filter output to the specified coordinate types.

virtual std::string dumpString(std::string_view prefix = "", const Karana::Core::Base::DumpOptions *options = nullptr) const override#

Return information about the object.

Parameters:
  • prefix – A string to use as prefix for each output line

  • options – Struct with options to tailor the output

Returns:

String with the information about the object.

bool contains(const CoordBase &c) const#

Check if a CoordBase instance belongs to this CoordData.

Parameters:

c – The CoordBase to check for

Returns:

True if the CoordBase instance belongs to the CoordData

bool contains(kc::id_t id) const#

Check if a obj with specified id instance belongs to this CoordData.

Parameters:

id – The id to check for

Returns:

True if the CoordBase instance belongs to the CoordData

const CoordOffset &coordOffsets(const CoordBase &c) const#

Returns the packing offset for the specified CoordBase.

The CoordData has get/set methods to pack and unpack the coordinate values for its set of CoordBase instances. This method returns the offsets for the Q and U values for the specified CoordBase in these arrays.

Parameters:

c – The CoordBase to check for

Returns:

A CoordOffset struct with the Q and U offsets

const std::pair<kc::ks_ptr<CoordBase>, size_t> coordAt(size_t u_offset) const#

Returns coord obj and its coord offset corresponding to overall U offset.

The CoordData has get/set methods to pack and unpack the coordinate values for its set of CoordBase instances. This method returns the CoordBase and its local coordinate offset corresponding to the specificied overall U offset value.

Parameters:

u_offset – the input overall U offset value

Returns:

The CoordBase instance and its local U coord offset

inline std::vector<kc::ks_ptr<CoordBase>> coordBases()#

Get a vector of the CoordBase instances for this CoordData.

Returns:

A vector of CoordBase instances.

kc::ks_ptr<CoordBase> parent(const CoordBase &cb) const#

Return the CoordBase that is the closed parent to the specified one.

Parameters:

cb – the CoordBase to check for

Returns:

the CoordBase parent if it exists

std::map<std::string, std::vector<km::Vec>> toMap()#

Dump the CoordData to a map. They keys are named after the CoordBase objects, and the values are a vector of the Coord Base data.

Returns:

A map representation of the CoordData object.

Protected Functions

std::vector<kc::ks_ptr<CoordBase>> _children(const CoordBase &cb) const#

Return the list of CoordBase children.

Parameters:

cb – the CoordBase to check for

Returns:

the list of children CoordBase

bool _isAncestorOf(const CoordBase &anc, const CoordBase &desc, bool strict) const#

Check whether a CoordBase is an ancestor of another.

Parameters:
  • anc – the candidate CoordBase ancestor

  • desc – the candidate CoordBase descendant

  • strict – if true, a CoordBase cannot be its own ancestor

Returns:

true if anc is an ancestor of desc

kc::ks_ptr<CoordBase> _getAncestor(const CoordBase &first, const CoordBase &second) const#

Return the common ancestor CoordBase.

Parameters:
Returns:

the common ancestor CoordBase

const CoordOffset &_coordOffsets(kc::id_t id) const#
void _makeTree() const#

Create the structure tree if it has not been created yet

void _localChartSetQ(const Eigen::Ref<const km::Vec> &val)#

Set the local chart Q coordinates.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Parameters:

val – Array of values.

km::Vec _localChartGetQ() const#

Return the local chart Q coordinates - without santizing coordinates.

See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.

Returns:

Array of values.

Protected Attributes

size_t _nQ#

the total number of coordinate dofs

size_t _nU#
kc::RegistryList<CoordBase> _coord_objs_list#

List of coord objs.

std::map<kc::id_t, CoordOffset> _coord_offsets#

map of the coord offset for subhinges and body coordinates

mutable std::unique_ptr<const kc::Tree<kc::id_t>> _tree = nullptr#

tree with the CoordBase hierarchy info

Protected Static Functions

static kc::ks_ptr<CoordData> _mergeCoordData(const std::vector<kc::ks_ptr<CoordData>> &cds, std::string_view name = "")#

Method to combine CoordData instances.

Return a new CoordData containing the union of the CoordBase elements from the input CoordData list

Parameters:

cds – List of CoordData to be combined

Returns:

Merged CoordData

struct CoordOffset#

struct for tracking the offset for the generalized coordinates in the uber list for a collection of bodies and subhinges

Public Members

size_t Q#

offset for the generalized coordinates

size_t U#

offset for the generalized velociy coordinates

kc::ks_ptr<CoordBase> obj#

the CoordBase instance itself