https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | List of all members
WebServerControl::RealEigenMatrixValue Class Reference

Class that stores a RealEigenMatrix controllable value to be set. More...

#include <WebServerControl.h>

Inheritance diagram for WebServerControl::RealEigenMatrixValue:
[legend]

Public Types

using value_type = RealEigenMatrix
 The underlying type of the value. More...
 

Public Member Functions

 RealEigenMatrixValue (const std::string &name, const std::string &type)
 
 RealEigenMatrixValue (const std::string &name, const std::string &type, const miniJson::Json &json_value)
 
const RealEigenMatrix & value () const
 
virtual void setControllableValue (WebServerControl &control) override final
 Sets the controllable value given the name and type via the controllable interface in control. More...
 
const std::string & name () const
 
const std::string & type () const
 

Static Public Member Functions

static RealEigenMatrix getMatrixJSONValue (const miniJson::Json &json_value)
 

Detailed Description

Class that stores a RealEigenMatrix controllable value to be set.

Definition at line 148 of file WebServerControl.h.

Member Typedef Documentation

◆ value_type

using WebServerControl::TypedValueBase< RealEigenMatrix >::value_type = RealEigenMatrix
inherited

The underlying type of the value.

Definition at line 76 of file WebServerControl.h.

Constructor & Destructor Documentation

◆ RealEigenMatrixValue() [1/2]

WebServerControl::RealEigenMatrixValue::RealEigenMatrixValue ( const std::string &  name,
const std::string &  type 
)

Definition at line 453 of file WebServerControl.C.

455  : TypedValueBase<RealEigenMatrix>(name, type)
456 {
457 }

◆ RealEigenMatrixValue() [2/2]

WebServerControl::RealEigenMatrixValue::RealEigenMatrixValue ( const std::string &  name,
const std::string &  type,
const miniJson::Json &  json_value 
)

Definition at line 459 of file WebServerControl.C.

462  : TypedValueBase<RealEigenMatrix>(name, type, getMatrixJSONValue(json_value))
463 {
464 }
static RealEigenMatrix getMatrixJSONValue(const miniJson::Json &json_value)

Member Function Documentation

◆ getMatrixJSONValue()

RealEigenMatrix WebServerControl::RealEigenMatrixValue::getMatrixJSONValue ( const miniJson::Json &  json_value)
static

Definition at line 467 of file WebServerControl.C.

468 {
469  const auto from_json_type = json_value.getType();
470  if (from_json_type != miniJson::JsonType::kArray)
471  throw ValueBase::Exception("The value '" + json_value.serialize() + "' of type " +
472  stringifyJSONType(from_json_type) + " is not an array");
473 
474  const auto & array_of_array_value = json_value.toArray();
475  const auto nrows = array_of_array_value.size();
476  if (nrows == 0)
477  return RealEigenMatrix::Zero(0, 0);
478 
479  RealEigenMatrix matrix;
480  for (const auto i : make_range(nrows))
481  {
482  if (array_of_array_value[i].getType() != miniJson::JsonType::kArray)
483  throw ValueBase::Exception(
484  "Element " + std::to_string(i) + " of '" + json_value.serialize() + "' of type " +
485  stringifyJSONType(array_of_array_value[i].getType()) + " is not an array");
486 
487  const auto & array_value = array_of_array_value[i].toArray();
488  if (i == 0)
489  matrix.resize(nrows, array_value.size());
490  else if (array_value.size() != (std::size_t)matrix.cols())
491  throw ValueBase::Exception("The matrix '" + json_value.serialize() + "' is jagged.");
492 
493  for (const auto j : index_range(array_value))
494  matrix(i, j) = array_value[j].toDouble();
495  }
496 
497  return matrix;
498 }
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
Definition: MooseTypes.h:149
static std::string stringifyJSONType(const miniJson::JsonType &json_type)
IntRange< T > make_range(T beg, T end)
auto index_range(const T &sizable)

◆ name()

const std::string& Moose::WebServerControlTypeRegistry::ValueBase::name ( ) const
inlineinherited
Returns
The name that the value is for

Definition at line 57 of file WebServerControlTypeRegistry.h.

Referenced by WebServerControl::TypedValueBase< std::vector< T > >::setControllableValue().

57 { return _name; }
const std::string _name
The name that the value is for.

◆ setControllableValue()

virtual void WebServerControl::TypedValueBase< RealEigenMatrix >::setControllableValue ( WebServerControl control)
inlinefinaloverridevirtualinherited

Sets the controllable value given the name and type via the controllable interface in control.

Will broadcast the value for setting it.

Implements Moose::WebServerControlTypeRegistry::ValueBase.

Definition at line 83 of file WebServerControl.h.

84  {
85  control.comm().broadcast(_value);
86  control.setControllableValueByName<T>(name(), value());
87  }
const Parallel::Communicator & comm() const
RealEigenMatrix _value
The underlying value.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
void setControllableValueByName(const std::string &name, const T &value)
Definition: Control.h:251

◆ type()

const std::string& Moose::WebServerControlTypeRegistry::ValueBase::type ( ) const
inlineinherited
Returns
The string representation of the type

Definition at line 61 of file WebServerControlTypeRegistry.h.

61 { return _type; }
const std::string _type
The string representation of the type.

◆ value()

const RealEigenMatrix & WebServerControl::TypedValueBase< RealEigenMatrix >::value ( ) const
inlineinherited
Returns
The underlying value

Definition at line 81 of file WebServerControl.h.

81 { return _value; }
RealEigenMatrix _value
The underlying value.

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