List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
casadi::Fmu3 Class Reference

Interface to a binary FMU, adhering to FMI version 2.0. More...

#include <fmu3.hpp>

Detailed Description

Author
Joel Andersson
Date
2024

Extra doc: https://github.com/casadi/casadi/wiki/L_2ba

Definition at line 42 of file fmu3.hpp.

Inheritance diagram for casadi::Fmu3:
Inheritance graph
[legend]
Collaboration diagram for casadi::Fmu3:
Collaboration graph
[legend]

Classes

struct  Value
 

Public Types

using weak_ref_type = WeakRefInternal
 

Public Member Functions

 Fmu3 (const std::string &name, const std::vector< std::string > &scheme_in, const std::vector< std::string > &scheme_out, const std::map< std::string, std::vector< size_t >> &scheme, const std::vector< std::string > &aux)
 
 ~Fmu3 () override
 Destructor. More...
 
std::string class_name () const override
 Get type name. More...
 
void init (const DaeBuilderInternal *dae) override
 
int init_mem (FmuMemory *m) const override
 Initalize memory block. More...
 
FmuMemoryalloc_mem (const FmuFunction &f) const override
 Create memory block. More...
 
void free_mem (void *mem) const override
 Free memory block. More...
 
void finalize () override
 
void load_functions () override
 
std::string system_infix () const override
 
void * instantiate () const override
 
void free_instance (void *instance) const override
 
int reset (void *instance)
 
int enter_initialization_mode (void *instance) const override
 
int exit_initialization_mode (void *instance) const override
 
int enter_continuous_time_mode (void *instance) const override
 
int update_discrete_states (void *instance, EventMemory *eventmem) const override
 
int get_derivatives (void *instance, double *derivatives, size_t nx) const override
 
int set_real (void *instance, const unsigned int *vr, size_t n_vr, const double *values, size_t n_values) const override
 
int get_real (void *instance, const unsigned int *vr, size_t n_vr, double *values, size_t n_values) const override
 
int get_directional_derivative (void *instance, const unsigned int *vr_out, size_t n_out, const unsigned int *vr_in, size_t n_in, const double *seed, size_t n_seed, double *sensitivity, size_t n_sensitivity) const override
 
int get_adjoint_derivative (void *instance, const unsigned int *vr_out, size_t n_out, const unsigned int *vr_in, size_t n_in, const double *seed, size_t n_seed, double *sensitivity, size_t n_sensitivity) const override
 
int set_values (void *instance) const override
 
int get_aux (void *instance) override
 
int get_aux_impl (void *instance, Value &aux_value) const
 
void get_stats (FmuMemory *m, Dict *stats, const std::vector< std::string > &name_in, const InputStruct *in) const override
 Get stats. More...
 
void serialize_body (SerializingStream &s) const override
 
void disp (std::ostream &stream, bool more) const override
 Print. More...
 
size_t n_in () const
 Get the number of scheme inputs. More...
 
size_t n_out () const
 Get the number of scheme outputs. More...
 
size_t index_in (const std::string &n) const
 
size_t index_out (const std::string &n) const
 
Sparsity jac_sparsity (const std::vector< size_t > &osub, const std::vector< size_t > &isub) const
 
Sparsity hess_sparsity (const std::vector< size_t > &r, const std::vector< size_t > &c) const
 
std::string desc_in (FmuMemory *m, size_t id, bool more=true) const
 
template<typename T >
T * load_function (const std::string &symname)
 
int discrete_states_iter (void *instance) const
 
void set (FmuMemory *m, size_t ind, const double *value) const
 
void request (FmuMemory *m, size_t ind) const
 
int eval (FmuMemory *m) const
 
void get (FmuMemory *m, size_t id, double *value) const
 
void set_fwd (FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
 
void set_fwd (FmuMemory *m, size_t ind, const double *v) const
 
void request_fwd (FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
 
void request_fwd (FmuMemory *m, casadi_int ind) const
 
int eval_fwd (FmuMemory *m, bool independent_seeds) const
 
int eval_ad (FmuMemory *m) const
 
int eval_fd (FmuMemory *m, bool independent_seeds) const
 
void get_fwd (FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
 
void get_fwd (FmuMemory *m, size_t ind, double *v) const
 
void set_adj (FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
 
void set_adj (FmuMemory *m, size_t ind, const double *v) const
 
void request_adj (FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
 
void request_adj (FmuMemory *m, casadi_int ind) const
 
int eval_adj (FmuMemory *m) const
 
void get_adj (FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
 
void get_adj (FmuMemory *m, size_t ind, double *v) const
 
void gather_fwd (FmuMemory *m) const
 
void gather_adj (FmuMemory *m) const
 
void gather_io (FmuMemory *m) const
 
void serialize (SerializingStream &s) const
 
virtual void serialize_type (SerializingStream &s) const
 
casadi_int getCount () const
 Get the reference count. More...
 
std::string debug_repr (const SharedObjectInternal *) const
 
GenericWeakRef< SharedObject, SharedObjectInternal > * weak ()
 Get a weak reference to the object. More...
 
std::vector< double > all_nominal_in (size_t i) const
 Retreive nominal values. More...
 
std::vector< double > all_nominal_out (size_t i) const
 Retreive nominal values. More...
 

Static Public Member Functions

static void log_message_callback (fmi3InstanceEnvironment instanceEnvironment, fmi3Status status, fmi3String category, fmi3String message)
 
static Fmu3deserialize (DeserializingStream &s)
 
static std::string dll_suffix ()
 

Public Attributes

std::vector< fmi3ValueReference > vr_real_
 
std::vector< fmi3ValueReference > vr_integer_
 
std::vector< fmi3ValueReference > vr_boolean_
 
std::vector< fmi3ValueReference > vr_string_
 
std::vector< fmi3Float64 > init_real_
 
std::vector< fmi3Int32 > init_integer_
 
std::vector< fmi3Boolean > init_boolean_
 
std::vector< std::string > init_string_
 
std::vector< std::string > vn_aux_real_
 
std::vector< std::string > vn_aux_integer_
 
std::vector< std::string > vn_aux_boolean_
 
std::vector< std::string > vn_aux_string_
 
std::vector< fmi3ValueReference > vr_aux_real_
 
std::vector< fmi3ValueReference > vr_aux_integer_
 
std::vector< fmi3ValueReference > vr_aux_boolean_
 
std::vector< fmi3ValueReference > vr_aux_string_
 
fmi3InstantiateModelExchangeTYPE * instantiate_model_exchange_
 
fmi3FreeInstanceTYPE * free_instance_
 
fmi3ResetTYPE * reset_
 
fmi3EnterInitializationModeTYPE * enter_initialization_mode_
 
fmi3ExitInitializationModeTYPE * exit_initialization_mode_
 
fmi3EnterContinuousTimeModeTYPE * enter_continuous_time_mode_
 
fmi3SetTimeTYPE * set_time_
 
fmi3GetFloat64TYPE * get_float64_
 
fmi3SetFloat64TYPE * set_float64_
 
fmi3GetBooleanTYPE * get_boolean_
 
fmi3SetBooleanTYPE * set_boolean_
 
fmi3GetInt32TYPE * get_int32_
 
fmi3SetInt32TYPE * set_int32_
 
fmi3GetStringTYPE * get_string_
 
fmi3SetStringTYPE * set_string_
 
fmi3GetDirectionalDerivativeTYPE * get_directional_derivative_
 
fmi3GetAdjointDerivativeTYPE * get_adjoint_derivative_
 
fmi3UpdateDiscreteStatesTYPE * update_discrete_states_
 
Value aux_value_
 

Protected Member Functions

 Fmu3 (DeserializingStream &s)
 
void initSingleton ()
 
void destroySingleton ()
 
shared_from_this ()
 Get a shared object from the current internal object. More...
 
const B shared_from_this () const
 Get a shared object from the current internal object. More...
 

Protected Attributes

Resource resource_
 
std::string name_
 Instance name. More...
 
std::vector< std::string > scheme_in_
 
std::vector< std::string > scheme_out_
 
std::map< std::string, std::vector< size_t > > scheme_
 
std::vector< std::string > aux_
 
std::string resource_loc_
 
double fmutol_
 
std::string instance_name_
 
std::string instantiation_token_
 
bool logging_on_
 
casadi_int number_of_event_indicators_
 
bool provides_directional_derivatives_
 
bool provides_adjoint_derivatives_
 
bool can_be_instantiated_only_once_per_process_
 
Importer li_
 DLL. More...
 
std::vector< size_t > iind_
 
std::vector< size_t > iind_map_
 
std::vector< size_t > oind_
 
std::vector< size_t > oind_map_
 
bool has_independent_
 
std::vector< double > nominal_in_
 
std::vector< double > nominal_out_
 
std::vector< double > min_in_
 
std::vector< double > min_out_
 
std::vector< double > max_in_
 
std::vector< double > max_out_
 
std::vector< std::string > vn_in_
 
std::vector< std::string > vn_out_
 
std::vector< unsigned int > vr_in_
 
std::vector< unsigned int > vr_out_
 
std::vector< double > value_in_
 
std::vector< std::vector< size_t > > ired_
 
std::vector< std::vector< size_t > > ored_
 
Sparsity jac_sp_
 
Sparsity hess_sp_
 
bool warning_fired_discrete_states_need_update_
 
bool warning_fired_terminate_simulation_
 
bool warning_fired_nominals_of_continuous_states_changed_
 
bool warning_fired_values_of_continuous_states_changed_
 
bool warning_fired_next_event_time_defined_
 
size_t nx_
 
bool do_evaluation_dance_
 

Member Typedef Documentation

◆ weak_ref_type

Definition at line 152 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ Fmu3() [1/2]

casadi::Fmu3::Fmu3 ( const std::string &  name,
const std::vector< std::string > &  scheme_in,
const std::vector< std::string > &  scheme_out,
const std::map< std::string, std::vector< size_t >> &  scheme,
const std::vector< std::string > &  aux 
)

Definition at line 500 of file fmu3.cpp.

505  : FmuInternal(name, scheme_in, scheme_out, scheme, aux) {
507  free_instance_ = 0;
508  reset_ = 0;
512  set_time_ = 0;
513  set_float64_ = 0;
514  set_boolean_ = 0;
515  get_float64_ = 0;
519 }
fmi3InstantiateModelExchangeTYPE * instantiate_model_exchange_
Definition: fmu3.hpp:95
fmi3ExitInitializationModeTYPE * exit_initialization_mode_
Definition: fmu3.hpp:99
fmi3SetFloat64TYPE * set_float64_
Definition: fmu3.hpp:103
fmi3EnterContinuousTimeModeTYPE * enter_continuous_time_mode_
Definition: fmu3.hpp:100
fmi3SetTimeTYPE * set_time_
Definition: fmu3.hpp:101
fmi3GetFloat64TYPE * get_float64_
Definition: fmu3.hpp:102
fmi3SetBooleanTYPE * set_boolean_
Definition: fmu3.hpp:105
fmi3GetDirectionalDerivativeTYPE * get_directional_derivative_
Definition: fmu3.hpp:110
fmi3ResetTYPE * reset_
Definition: fmu3.hpp:97
fmi3GetAdjointDerivativeTYPE * get_adjoint_derivative_
Definition: fmu3.hpp:111
fmi3UpdateDiscreteStatesTYPE * update_discrete_states_
Definition: fmu3.hpp:112
fmi3FreeInstanceTYPE * free_instance_
Definition: fmu3.hpp:96
fmi3EnterInitializationModeTYPE * enter_initialization_mode_
Definition: fmu3.hpp:98
FmuInternal(const std::string &name, const std::vector< std::string > &scheme_in, const std::vector< std::string > &scheme_out, const std::map< std::string, std::vector< size_t >> &scheme, const std::vector< std::string > &aux)
Definition: fmu.cpp:440

References enter_continuous_time_mode_, enter_initialization_mode_, exit_initialization_mode_, free_instance_, get_adjoint_derivative_, get_directional_derivative_, get_float64_, instantiate_model_exchange_, reset_, set_boolean_, set_float64_, set_time_, and update_discrete_states_.

Referenced by deserialize().

◆ ~Fmu3()

casadi::Fmu3::~Fmu3 ( )
override

Definition at line 58 of file fmu3.cpp.

58  {
59 }

◆ Fmu3() [2/2]

casadi::Fmu3::Fmu3 ( DeserializingStream s)
explicitprotected

Definition at line 528 of file fmu3.cpp.

528  : FmuInternal(s) {
530  free_instance_ = 0;
531  reset_ = 0;
535  set_time_ = 0;
536  set_float64_ = 0;
537  set_boolean_ = 0;
538  get_float64_ = 0;
542 
543  s.version("Fmu3", 1);
544  s.unpack("Fmu3::vr_real", vr_real_);
545  s.unpack("Fmu3::vr_integer", vr_integer_);
546  s.unpack("Fmu3::vr_boolean", vr_boolean_);
547  s.unpack("Fmu3::vr_string", vr_string_);
548  s.unpack("Fmu3::init_real", init_real_);
549  s.unpack("Fmu3::init_integer", init_integer_);
550  s.unpack("Fmu3::init_boolean", init_boolean_);
551  s.unpack("Fmu3::init_string", init_string_);
552 
553  s.unpack("Fmu3::vn_aux_real", vn_aux_real_);
554  s.unpack("Fmu3::vn_aux_integer", vn_aux_integer_);
555  s.unpack("Fmu3::vn_aux_boolean", vn_aux_boolean_);
556  s.unpack("Fmu3::vn_aux_string", vn_aux_string_);
557  s.unpack("Fmu3::vr_aux_real", vr_aux_real_);
558  s.unpack("Fmu3::vr_aux_integer", vr_aux_integer_);
559  s.unpack("Fmu3::vr_aux_boolean", vr_aux_boolean_);
560  s.unpack("Fmu3::vr_aux_string", vr_aux_string_);
561 }
std::vector< fmi3ValueReference > vr_string_
Definition: fmu3.hpp:82
std::vector< fmi3ValueReference > vr_aux_real_
Definition: fmu3.hpp:90
std::vector< std::string > vn_aux_boolean_
Definition: fmu3.hpp:89
std::vector< fmi3ValueReference > vr_boolean_
Definition: fmu3.hpp:82
std::vector< fmi3ValueReference > vr_aux_string_
Definition: fmu3.hpp:90
std::vector< fmi3Boolean > init_boolean_
Definition: fmu3.hpp:85
std::vector< fmi3Int32 > init_integer_
Definition: fmu3.hpp:84
std::vector< std::string > vn_aux_real_
Definition: fmu3.hpp:89
std::vector< std::string > init_string_
Definition: fmu3.hpp:86
std::vector< fmi3ValueReference > vr_integer_
Definition: fmu3.hpp:82
std::vector< std::string > vn_aux_integer_
Definition: fmu3.hpp:89
std::vector< fmi3ValueReference > vr_real_
Definition: fmu3.hpp:82
std::vector< fmi3ValueReference > vr_aux_boolean_
Definition: fmu3.hpp:90
std::vector< fmi3ValueReference > vr_aux_integer_
Definition: fmu3.hpp:90
std::vector< fmi3Float64 > init_real_
Definition: fmu3.hpp:83
std::vector< std::string > vn_aux_string_
Definition: fmu3.hpp:89

References enter_continuous_time_mode_, enter_initialization_mode_, exit_initialization_mode_, free_instance_, get_adjoint_derivative_, get_directional_derivative_, get_float64_, init_boolean_, init_integer_, init_real_, init_string_, instantiate_model_exchange_, reset_, set_boolean_, set_float64_, set_time_, casadi::DeserializingStream::unpack(), update_discrete_states_, casadi::DeserializingStream::version(), vn_aux_boolean_, vn_aux_integer_, vn_aux_real_, vn_aux_string_, vr_aux_boolean_, vr_aux_integer_, vr_aux_real_, vr_aux_string_, vr_boolean_, vr_integer_, vr_real_, and vr_string_.

Member Function Documentation

◆ all_nominal_in()

std::vector< double > casadi::FmuInternal::all_nominal_in ( size_t  i) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26r

Definition at line 687 of file fmu.cpp.

687  {
688  auto&& ind = ired_.at(i);
689  std::vector<double> n;
690  n.reserve(ind.size());
691  for (size_t k : ind) n.push_back(nominal_in_.at(k));
692  return n;
693 }
std::vector< std::vector< size_t > > ired_
Definition: fmu_impl.hpp:340
std::vector< double > nominal_in_
Definition: fmu_impl.hpp:330

References casadi::FmuInternal::ired_, and casadi::FmuInternal::nominal_in_.

◆ all_nominal_out()

std::vector< double > casadi::FmuInternal::all_nominal_out ( size_t  i) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26r

Definition at line 695 of file fmu.cpp.

695  {
696  auto&& ind = ored_.at(i);
697  std::vector<double> n;
698  n.reserve(ind.size());
699  for (size_t k : ind) n.push_back(nominal_out_.at(k));
700  return n;
701 }
std::vector< std::vector< size_t > > ored_
Definition: fmu_impl.hpp:340
std::vector< double > nominal_out_
Definition: fmu_impl.hpp:330

References casadi::FmuInternal::nominal_out_, and casadi::FmuInternal::ored_.

◆ alloc_mem()

FmuMemory * casadi::Fmu3::alloc_mem ( const FmuFunction f) const
overridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_2ds

Implements casadi::FmuInternal.

Definition at line 50 of file fmu3.cpp.

50  {
51  return new Fmu3Memory(f);
52 }

◆ class_name()

std::string casadi::Fmu3::class_name ( ) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_2bb

Implements casadi::SharedObjectInternal.

Definition at line 55 of file fmu3.hpp.

55 { return "Fmu3";}

◆ debug_repr()

std::string casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::debug_repr ( const Internal *  i) const
inherited

Definition at line 62 of file generic_shared_internal.hpp.

162  {
163  // Note: i != this because of something something multiple inheritance
164  return str( (casadi_int)(i)) + "/" + static_cast<const Internal*>(this)->class_name();
165  }
std::string str(const T &v)
String representation, any type.

◆ desc_in()

std::string casadi::FmuInternal::desc_in ( FmuMemory m,
size_t  id,
bool  more = true 
) const
inherited

Definition at line 716 of file fmu.cpp.

716  {
717  // Create description
718  if (more) {
719  // Detailed description
720  std::stringstream ss;
721  ss << vn_in_[id] << " = " << m->ibuf_[id] << " (nominal " << nominal_in_[id]
722  << ", min " << min_in_[id] << ", max " << max_in_[id] << ")";
723  return ss.str();
724  } else {
725  return vn_in_[id];
726  }
727 }
std::vector< double > max_in_
Definition: fmu_impl.hpp:332
std::vector< std::string > vn_in_
Definition: fmu_impl.hpp:333
std::vector< double > min_in_
Definition: fmu_impl.hpp:331

References casadi::FmuMemory::ibuf_, casadi::FmuInternal::max_in_, casadi::FmuInternal::min_in_, casadi::FmuInternal::nominal_in_, and casadi::FmuInternal::vn_in_.

Referenced by casadi::FmuInternal::eval_fd().

◆ deserialize()

Fmu3 * casadi::Fmu3::deserialize ( DeserializingStream s)
static

Definition at line 522 of file fmu3.cpp.

522  {
523  Fmu3* ret = new Fmu3(s);
524  ret->finalize();
525  return ret;
526 }
Fmu3(const std::string &name, const std::vector< std::string > &scheme_in, const std::vector< std::string > &scheme_out, const std::map< std::string, std::vector< size_t >> &scheme, const std::vector< std::string > &aux)
Definition: fmu3.cpp:500

References finalize(), and Fmu3().

Referenced by casadi::FmuInternal::deserialize().

◆ destroySingleton()

void casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::destroySingleton ( )
inlineprotectedinherited

Called in the destructor of singletons

Definition at line 77 of file generic_shared_internal.hpp.

77  {
78  static_cast<Internal*>(this)->count--;
79  }

◆ discrete_states_iter()

int casadi::FmuInternal::discrete_states_iter ( void *  instance) const
inherited

Definition at line 1098 of file fmu.cpp.

1098  {
1099  // Helper function: update_discrete_states
1100  EventMemory eventmem;
1101  const size_t max_update_iter = 10;
1102  for (size_t update_iter = 0; update_iter < max_update_iter; ++update_iter) {
1103  if (update_discrete_states(instance, &eventmem)) {
1104  casadi_warning("update_discrete_states");
1105  return 1;
1106  }
1107  // Not implemented
1108  if (eventmem.discrete_states_need_update) {
1111  casadi_warning("Discrete state update not implemented");
1112  }
1113  }
1114  if (eventmem.terminate_simulation) {
1117  casadi_warning("Terminate simulation not implemented");
1118  }
1119  }
1120  if (eventmem.nominals_of_continuous_states_changed) {
1123  casadi_warning("Nominals of continuous states not implemented");
1124  }
1125  }
1126  if (eventmem.values_of_continuous_states_changed) {
1129  casadi_warning("Values of continuous states not implemented");
1130  }
1131  }
1132  if (eventmem.next_event_time_defined) {
1135  casadi_warning("Next event time not implemented");
1136  }
1137  }
1138  // Successful return
1139  if (!eventmem.discrete_states_need_update) {
1140  return 0;
1141  }
1142  }
1143  // Too many iterations
1144  casadi_warning("Discrete state update failed");
1145  return 1;
1146 }
bool warning_fired_values_of_continuous_states_changed_
Definition: fmu_impl.hpp:348
bool warning_fired_next_event_time_defined_
Definition: fmu_impl.hpp:349
bool warning_fired_nominals_of_continuous_states_changed_
Definition: fmu_impl.hpp:347
bool warning_fired_terminate_simulation_
Definition: fmu_impl.hpp:346
bool warning_fired_discrete_states_need_update_
Definition: fmu_impl.hpp:345
virtual int update_discrete_states(void *instance, EventMemory *eventmem) const =0

References casadi::EventMemory::discrete_states_need_update, casadi::EventMemory::next_event_time_defined, casadi::EventMemory::nominals_of_continuous_states_changed, casadi::EventMemory::terminate_simulation, casadi::FmuInternal::update_discrete_states(), casadi::EventMemory::values_of_continuous_states_changed, casadi::FmuInternal::warning_fired_discrete_states_need_update_, casadi::FmuInternal::warning_fired_next_event_time_defined_, casadi::FmuInternal::warning_fired_nominals_of_continuous_states_changed_, casadi::FmuInternal::warning_fired_terminate_simulation_, and casadi::FmuInternal::warning_fired_values_of_continuous_states_changed_.

Referenced by casadi::FmuInternal::init_mem().

◆ disp()

void casadi::FmuInternal::disp ( std::ostream &  stream,
bool  more 
) const
overridevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26m

Implements casadi::SharedObjectInternal.

Definition at line 631 of file fmu.cpp.

631  {
632  (void)more; // unused
633  stream << name_ << " " << class_name();
634 }
std::string name_
Instance name.
Definition: fmu_impl.hpp:287
virtual std::string class_name() const =0
Readable name of the internal class.

References casadi::SharedObjectInternal::class_name(), and casadi::FmuInternal::name_.

◆ dll_suffix()

std::string casadi::FmuInternal::dll_suffix ( )
staticinherited

Definition at line 703 of file fmu.cpp.

703  {
704 #if defined(_WIN32)
705  // Windows system
706  return ".dll";
707 #elif defined(__APPLE__)
708  // OSX
709  return ".dylib";
710 #else
711  // Linux
712  return ".so";
713 #endif
714 }

Referenced by casadi::FmuInternal::finalize().

◆ enter_continuous_time_mode()

int casadi::Fmu3::enter_continuous_time_mode ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 295 of file fmu3.cpp.

295  {
296  auto c = static_cast<fmi3Instance>(instance);
297  fmi3Status status = enter_continuous_time_mode_(c);
298  if (status != fmi3OK) {
299  casadi_warning("fmi3EnterContinuousTimeMode failed");
300  return 1;
301  }
302  return 0;
303 }

References enter_continuous_time_mode_.

◆ enter_initialization_mode()

int casadi::Fmu3::enter_initialization_mode ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 275 of file fmu3.cpp.

275  {
276  auto c = static_cast<fmi3Instance>(instance);
277  fmi3Status status = enter_initialization_mode_(c, fmutol_ > 0, fmutol_, 0., fmi3True, 1.);
278  if (status != fmi3OK) {
279  casadi_warning("fmi3EnterInitializationMode failed: " + str(status));
280  return 1;
281  }
282  return 0;
283 }

References enter_initialization_mode_, casadi::FmuInternal::fmutol_, and casadi::str().

◆ eval()

int casadi::FmuInternal::eval ( FmuMemory m) const
inherited

Definition at line 1222 of file fmu.cpp.

1222  {
1223  // Gather inputs and outputs
1224  gather_io(m);
1225  // Number of inputs and outputs
1226  size_t n_set = m->id_in_.size();
1227  size_t n_out = m->id_out_.size();
1228  // Set all variables
1229  if (set_real(m->instance, get_ptr(m->vr_in_), n_set, get_ptr(m->v_in_), n_set)) {
1230  casadi_warning("Setting FMU variables failed");
1231  return 1;
1232  }
1233  // Quick return if nothing requested
1234  if (n_out == 0) return 0;
1235  // Calculate all variables
1236  m->v_out_.resize(n_out);
1237  if (get_real(m->instance, get_ptr(m->vr_out_), n_out, get_ptr(m->v_out_), n_out)) {
1238  casadi_warning("Evaluation failed");
1239  return 1;
1240  }
1241  // Collect requested variables
1242  auto it = m->v_out_.begin();
1243  for (size_t id : m->id_out_) {
1244  m->obuf_[id] = *it++;
1245  }
1246  // Successful return
1247  return 0;
1248 }
virtual int get_real(void *instance, const unsigned int *vr, size_t n_vr, double *values, size_t n_values) const =0
void gather_io(FmuMemory *m) const
Definition: fmu.cpp:1294
virtual int set_real(void *instance, const unsigned int *vr, size_t n_vr, const double *values, size_t n_values) const =0
size_t n_out() const
Get the number of scheme outputs.
Definition: fmu_impl.hpp:132
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.

References casadi::FmuInternal::gather_io(), casadi::get_ptr(), casadi::FmuInternal::get_real(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::instance, casadi::FmuInternal::n_out(), casadi::FmuMemory::obuf_, casadi::FmuInternal::set_real(), casadi::FmuMemory::v_in_, casadi::FmuMemory::v_out_, casadi::FmuMemory::vr_in_, and casadi::FmuMemory::vr_out_.

◆ eval_ad()

int casadi::FmuInternal::eval_ad ( FmuMemory m) const
inherited

Definition at line 768 of file fmu.cpp.

768  {
769  // Number of inputs and outputs
770  size_t n_known = m->id_in_.size();
771  size_t n_unknown = m->id_out_.size();
772  // Quick return if nothing to be calculated
773  if (n_unknown == 0) return 0;
774  // Evalute (should not be necessary)
775  if (get_real(m->instance, get_ptr(m->vr_out_), n_unknown, get_ptr(m->v_out_), n_unknown)) {
776  casadi_warning("FMU evaluation failed");
777  return 1;
778  }
779  // Evaluate directional derivatives
780  if (get_directional_derivative(m->instance,
781  get_ptr(m->vr_out_), n_unknown,
782  get_ptr(m->vr_in_), n_known,
783  get_ptr(m->d_in_), n_known,
784  get_ptr(m->d_out_), n_unknown)) {
785  casadi_warning("FMU directional derivative failed");
786  return 1;
787  }
788  // Collect requested variables
789  auto it = m->d_out_.begin();
790  for (size_t id : m->id_out_) {
791  m->osens_[id] = *it++;
792  }
793  // Successful return
794  return 0;
795 }
virtual int get_directional_derivative(void *instance, const unsigned int *vr_out, size_t n_out, const unsigned int *vr_in, size_t n_in, const double *seed, size_t n_seed, double *sensitivity, size_t n_sensitivity) const =0

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, casadi::FmuInternal::get_directional_derivative(), casadi::get_ptr(), casadi::FmuInternal::get_real(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::instance, casadi::FmuMemory::osens_, casadi::FmuMemory::v_out_, casadi::FmuMemory::vr_in_, and casadi::FmuMemory::vr_out_.

Referenced by casadi::FmuInternal::eval_fwd().

◆ eval_adj()

int casadi::FmuInternal::eval_adj ( FmuMemory m) const
inherited

Definition at line 745 of file fmu.cpp.

745  {
746  // Gather input and output indices
747  gather_adj(m);
748  // Quick return if nothing to be calculated
749  if (m->id_in_.size() == 0) return 0;
750  // Evaluate adjoint derivatives
751  if (get_adjoint_derivative(m->instance,
752  get_ptr(m->vr_out_), m->id_out_.size(),
753  get_ptr(m->vr_in_), m->id_in_.size(),
754  get_ptr(m->d_out_), m->id_out_.size(),
755  get_ptr(m->d_in_), m->id_in_.size())) {
756  casadi_warning("FMU adjoint derivative failed");
757  return 1;
758  }
759  // Collect requested variables
760  auto it = m->d_in_.begin();
761  for (size_t id : m->id_in_) {
762  m->isens_[id] = *it++;
763  }
764  // Successful return
765  return 0;
766 }
virtual int get_adjoint_derivative(void *instance, const unsigned int *vr_out, size_t n_out, const unsigned int *vr_in, size_t n_in, const double *seed, size_t n_seed, double *sensitivity, size_t n_sensitivity) const
Definition: fmu.cpp:572
void gather_adj(FmuMemory *m) const
Definition: fmu.cpp:1338

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, casadi::FmuInternal::gather_adj(), casadi::FmuInternal::get_adjoint_derivative(), casadi::get_ptr(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::instance, casadi::FmuMemory::isens_, casadi::FmuMemory::vr_in_, and casadi::FmuMemory::vr_out_.

◆ eval_fd()

int casadi::FmuInternal::eval_fd ( FmuMemory m,
bool  independent_seeds 
) const
inherited

Definition at line 797 of file fmu.cpp.

797  {
798  // Number of inputs and outputs
799  size_t n_known = m->id_in_.size();
800  size_t n_unknown = m->id_out_.size();
801  // Quick return if nothing to be calculated
802  if (n_unknown == 0) return 0;
803  // Evalute (should not be necessary)
804  if (get_real(m->instance, get_ptr(m->vr_out_), n_unknown, get_ptr(m->v_out_), n_unknown)) {
805  casadi_warning("Evaluating FMU failed");
806  return 1;
807  }
808  // Make outputs dimensionless
809  for (size_t k = 0; k < n_unknown; ++k) m->v_out_[k] /= nominal_out_[m->id_out_[k]];
810  // Number of points in FD stencil
811  casadi_int n_points = n_fd_points(m->self.fd_);
812  // Offset for points
813  casadi_int offset = fd_offset(m->self.fd_);
814  // Memory for perturbed outputs
815  m->fd_out_.resize(n_points * n_unknown);
816  // Which inputs are in bounds
817  m->in_bounds_.resize(n_known);
818  // Memory for perturbed inputs
819  m->v_pert_.resize(n_known);
820  // Do any any inputs need flipping?
821  m->flip_.resize(n_known);
822  size_t first_flip = -1;
823  for (size_t i = 0; i < n_known; ++i) {
824  // Try to take step
825  double test = m->v_in_[i] + m->self.step_ * m->d_in_[i];
826  // Check if in bounds
827  size_t id = m->id_in_[i];
828  if (test >= min_in_[id] && test <= max_in_[id]) {
829  // Positive perturbation is fine
830  m->flip_[i] = false;
831  } else {
832  // Try negative direction instead
833  test = m->v_in_[i] - m->self.step_ * m->d_in_[i];
834  casadi_assert(test >= min_in_[id] && test <= max_in_[id],
835  "Cannot perturb " + vn_in_[id] + " at " + str(m->v_in_[i]) + ", min " + str(min_in_[id])
836  + ", max " + str(max_in_[id]) + ", nominal " + str(nominal_in_[id]));
837  m->flip_[i] = true;
838  if (first_flip == size_t(-1)) first_flip = i;
839  }
840  }
841  // If seeds are not independent, we have to flip the sign for all of the seeds or none
842  if (first_flip != size_t(-1) && !independent_seeds) {
843  // Flip the rest of the seeds
844  for (size_t i = 0; i < n_known; ++i) {
845  if (!m->flip_[i]) {
846  // Test negative direction
847  double test = m->v_in_[i] - m->self.step_ * m->d_in_[i];
848  size_t id = m->id_in_[i];
849  casadi_assert(test >= min_in_[id] && test <= max_in_[id],
850  "Cannot perturb both " + vn_in_[id] + " and " + vn_in_[first_flip]);
851  // Flip it too
852  m->flip_[i] = true;
853  }
854  }
855  }
856  // All perturbed outputs
857  const double* yk_all[5] = {0};
858 
859  // Calculate all perturbed outputs
860  for (casadi_int k = 0; k < n_points; ++k) {
861  // Where to save the perturbed outputs
862  double* yk = &m->fd_out_[n_unknown * k];
863  casadi_assert_dev(k < 5);
864  yk_all[k] = yk;
865  // If unperturbed output, quick return
866  if (k == offset) {
867  casadi_copy(get_ptr(m->v_out_), n_unknown, yk);
868  continue;
869  }
870  // Perturbation size
871  double pert = (k - offset) * m->self.step_;
872  // Perturb inputs, if allowed
873  for (size_t i = 0; i < n_known; ++i) {
874  // Try to take step
875  double sign = m->flip_[i] ? -1 : 1;
876  double test = m->v_in_[i] + pert * sign * m->d_in_[i];
877  // Check if in bounds
878  size_t id = m->id_in_[i];
879  m->in_bounds_[i] = test >= min_in_[id] && test <= max_in_[id];
880  // Take step, if allowed
881  m->v_pert_[i] = m->in_bounds_[i] ? test : m->v_in_[i];
882  }
883  // Pass perturbed inputs to FMU
884  if (set_real(m->instance, get_ptr(m->vr_in_), n_known, get_ptr(m->v_pert_), n_known)) {
885  casadi_warning("Setting FMU variables failed");
886  return 1;
887  }
888  // Evaluate perturbed FMU
889  if (get_real(m->instance, get_ptr(m->vr_out_), n_unknown, yk, n_unknown)) {
890  casadi_warning("Evaluation failed");
891  return 1;
892  }
893  // Post-process yk if there was any scaling
894  if (independent_seeds) {
895  for (size_t i = 0; i < n_unknown; ++i) {
896  // Variable id
897  size_t id = m->id_out_[i];
898  // Differentiation with respect to what variable
899  size_t wrt_id = m->wrt_.at(id);
900  // Find the corresponding input variable
901  size_t wrt_i;
902  for (wrt_i = 0; wrt_i < n_known; ++wrt_i) {
903  if (m->id_in_[wrt_i] == wrt_id) break;
904  }
905  // Check if in bounds
906  if (m->in_bounds_.at(wrt_i)) {
907  // Input was in bounds: Keep output, make dimensionless
908  yk[i] /= nominal_out_[m->id_out_[i]];
909  } else {
910  // Input was out of bounds: Discard output
911  yk[i] = nan;
912  }
913  }
914  }
915  }
916  // Restore FMU inputs
917  if (set_real(m->instance, get_ptr(m->vr_in_), n_known, get_ptr(m->v_in_), n_known)) {
918  casadi_warning("Setting FMU variables failed");
919  return 1;
920  }
921  // Step size
922  double h = m->self.step_;
923 
924  // Calculate FD approximation
925  finite_diff(m->self.fd_, yk_all, get_ptr(m->d_out_), h, n_unknown, eps);
926 
927  // If seeds are dependent, quick return
928  if (!independent_seeds) {
929  // Simpy copy the results to output (no validation)
930  for (size_t ind = 0; ind < m->id_out_.size(); ++ind) {
931  m->osens_[m->id_out_[ind]] = m->d_out_[ind];
932  }
933  return 0;
934  }
935 
936  // Collect requested variables
937  for (size_t ind = 0; ind < m->id_out_.size(); ++ind) {
938  // Variable id
939  size_t id = m->id_out_[ind];
940  // With respect to what variable
941  size_t wrt = m->wrt_[id];
942  // Find the corresponding input variable
943  size_t wrt_i;
944  for (wrt_i = 0; wrt_i < n_known; ++wrt_i) {
945  if (m->id_in_[wrt_i] == wrt) break;
946  }
947  // Nominal value
948  double n = nominal_out_[id];
949  // Get the value
950  double d_fd = m->d_out_[ind] * n;
951  // Correct sign, if necessary
952  if (m->flip_[wrt_i]) d_fd = -d_fd;
953  // Use FD instead of AD or to compare with AD
954  if (m->self.validate_forward_) {
955  // Value to compare with
956  double d_ad = m->osens_[id];
957  // Nominal value used as seed
958  d_ad /= nominal_in_[wrt];
959  d_fd /= nominal_in_[wrt];
960  // Is it a not a number?
961  bool d_is_nan = d_ad != d_ad;
962  // Magnitude of derivatives
963  double d_max = std::fmax(std::fabs(d_fd), std::fabs(d_ad));
964  // Check if NaN or error exceeds thresholds
965  if (d_is_nan || (d_max > n * m->self.abstol_
966  && std::fabs(d_ad - d_fd) > d_max * m->self.reltol_)) {
967  // Offset for printing the stencil
968  double off = m->fd_out_.at(ind + offset * n_unknown);
969  // Warning or add to file
970  std::stringstream ss;
971  if (m->self.validate_ad_file_.empty()) {
972  // Issue warning
973  ss << (d_is_nan ? "NaN" : "Inconsistent") << " derivatives of " << vn_out_[id]
974  << " w.r.t. " << desc_in(m, wrt) << ", got " << d_ad
975  << " for AD vs. " << d_fd << " for FD[" << to_string(m->self.fd_) << "].";
976  // Print the stencil:
977  ss << "\nValues for step size " << h << ": " << (n * off) << " + [";
978  for (casadi_int k = 0; k < n_points; ++k) {
979  if (k > 0) ss << ", ";
980  ss << (n * (m->fd_out_.at(ind + k * n_unknown) - off));
981  }
982  ss << "]";
983  // Issue warning
984  casadi_warning(ss.str());
985  } else {
986  // Output
987  ss << vn_out_[id] << " ";
988  // Input
989  ss << vn_in_[wrt] << " ";
990  // Value
991  ss << m->ibuf_[wrt] << " ";
992  // Noninal
993  ss << nominal_in_[wrt] << " ";
994  // Min
995  ss << min_in_[wrt] << " ";
996  // Max
997  ss << max_in_[wrt] << " ";
998  // AD
999  ss << d_ad << " ";
1000  // FD
1001  ss << d_fd << " ";
1002  // Step
1003  ss << h << " ";
1004  // Offset
1005  ss << off << " ";
1006  // Stencil
1007  ss << "[";
1008  for (casadi_int k = 0; k < n_points; ++k) {
1009  if (k > 0) ss << ",";
1010  ss << (n * (m->fd_out_.at(ind + k * n_unknown) - off));
1011  }
1012  ss << "]" << std::endl;
1013  // Append to file
1014  auto valfile_ptr = Filesystem::ofstream_ptr(m->self.validate_ad_file_,
1015  std::ios_base::app);
1016  std::ostream& valfile = *valfile_ptr;
1017  valfile << ss.str();
1018  }
1019  }
1020  } else {
1021  // Use instead of AD
1022  m->osens_[id] = d_fd;
1023  }
1024  }
1025  // Successful return
1026  return 0;
1027 }
static std::unique_ptr< std::ostream > ofstream_ptr(const std::string &path, std::ios_base::openmode mode=std::ios_base::out)
Definition: filesystem.cpp:115
std::string desc_in(FmuMemory *m, size_t id, bool more=true) const
Definition: fmu.cpp:716
std::vector< std::string > vn_out_
Definition: fmu_impl.hpp:333
const double eps
Machine epsilon.
Definition: calculus.hpp:56
casadi_int n_fd_points(FdMode v)
Length of FD stencil, including unperturbed input.
casadi_int fd_offset(FdMode v)
Offset for FD stencil, i.e. index of unperturbed input.
double sign(double x)
Sign function, note that sign(nan) == nan.
Definition: calculus.hpp:264
void casadi_copy(const T1 *x, casadi_int n, T1 *y)
COPY: y <-x.
std::string to_string(TypeFmi2 v)
const double nan
Not a number.
Definition: calculus.hpp:53
CASADI_EXPORT void finite_diff(FdMode v, const T1 **yk, T1 *J, T1 h, casadi_int n_y, T1 smoothing)
Calculate FD estimate.

References casadi::FmuFunction::abstol_, casadi::casadi_copy(), casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, casadi::FmuInternal::desc_in(), casadi::eps, casadi::FmuFunction::fd_, casadi::fd_offset(), casadi::FmuMemory::fd_out_, casadi::finite_diff(), casadi::FmuMemory::flip_, casadi::get_ptr(), casadi::FmuInternal::get_real(), casadi::FmuMemory::ibuf_, casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::in_bounds_, casadi::FmuMemory::instance, casadi::FmuInternal::max_in_, casadi::FmuInternal::min_in_, casadi::n_fd_points(), casadi::nan, casadi::FmuInternal::nominal_in_, casadi::FmuInternal::nominal_out_, casadi::Filesystem::ofstream_ptr(), casadi::FmuMemory::osens_, casadi::FmuFunction::reltol_, casadi::FmuMemory::self, casadi::FmuInternal::set_real(), casadi::sign(), casadi::FmuFunction::step_, casadi::str(), casadi::to_string(), casadi::FmuMemory::v_in_, casadi::FmuMemory::v_out_, casadi::FmuMemory::v_pert_, casadi::FmuFunction::validate_ad_file_, casadi::FmuFunction::validate_forward_, casadi::FmuInternal::vn_in_, casadi::FmuInternal::vn_out_, casadi::FmuMemory::vr_in_, casadi::FmuMemory::vr_out_, and casadi::FmuMemory::wrt_.

Referenced by casadi::FmuInternal::eval_fwd().

◆ eval_fwd()

int casadi::FmuInternal::eval_fwd ( FmuMemory m,
bool  independent_seeds 
) const
inherited

Definition at line 729 of file fmu.cpp.

729  {
730  // Gather input and output indices
731  gather_fwd(m);
732  // Calculate derivatives using FMU directional derivative support
733  if (m->self.uses_directional_derivatives_) {
734  // Evaluate using AD
735  if (eval_ad(m)) return 1;
736  }
737  // Calculate derivatives using finite differences
738  if (!m->self.uses_directional_derivatives_ || m->self.validate_forward_) {
739  // Evaluate using FD
740  if (eval_fd(m, independent_seeds)) return 1;
741  }
742  return 0;
743 }
void gather_fwd(FmuMemory *m) const
Definition: fmu.cpp:1319
int eval_fd(FmuMemory *m, bool independent_seeds) const
Definition: fmu.cpp:797
int eval_ad(FmuMemory *m) const
Definition: fmu.cpp:768

References casadi::FmuInternal::eval_ad(), casadi::FmuInternal::eval_fd(), casadi::FmuInternal::gather_fwd(), casadi::FmuMemory::self, casadi::FmuFunction::uses_directional_derivatives_, and casadi::FmuFunction::validate_forward_.

◆ exit_initialization_mode()

int casadi::Fmu3::exit_initialization_mode ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 285 of file fmu3.cpp.

285  {
286  auto c = static_cast<fmi3Instance>(instance);
287  fmi3Status status = exit_initialization_mode_(c);
288  if (status != fmi3OK) {
289  casadi_warning("fmi3ExitInitializationMode failed");
290  return 1;
291  }
292  return 0;
293 }

References exit_initialization_mode_.

◆ finalize()

void casadi::Fmu3::finalize ( )
overridevirtual

Allocate numerical values for initial auxilliary variables

Reimplemented from casadi::FmuInternal.

Definition at line 194 of file fmu3.cpp.

194  {
196  aux_value_.v_real.resize(vn_aux_real_.size());
197  aux_value_.v_integer.resize(vn_aux_integer_.size());
198  aux_value_.v_boolean.resize(vn_aux_boolean_.size());
199  aux_value_.v_string.resize(vn_aux_string_.size());
200 
201  // Recursive call
203 }
Value aux_value_
Definition: fmu3.hpp:122
virtual void finalize()
Definition: fmu.cpp:579
std::vector< fmi3Float64 > v_real
Definition: fmu3.hpp:116
std::vector< std::string > v_string
Definition: fmu3.hpp:119
std::vector< fmi3Boolean > v_boolean
Definition: fmu3.hpp:118
std::vector< fmi3Int32 > v_integer
Definition: fmu3.hpp:117

References aux_value_, casadi::FmuInternal::finalize(), casadi::Fmu3::Value::v_boolean, casadi::Fmu3::Value::v_integer, casadi::Fmu3::Value::v_real, casadi::Fmu3::Value::v_string, vn_aux_boolean_, vn_aux_integer_, vn_aux_real_, and vn_aux_string_.

Referenced by deserialize().

◆ free_instance()

void casadi::Fmu3::free_instance ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 256 of file fmu3.cpp.

256  {
257  if (free_instance_) {
258  auto c = static_cast<fmi3Instance>(instance);
259  free_instance_(c);
260  } else {
261  casadi_warning("No free_instance function pointer available");
262  }
263 }

References free_instance_.

◆ free_mem()

void casadi::Fmu3::free_mem ( void *  mem) const
overridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_2dw

Implements casadi::FmuInternal.

Definition at line 54 of file fmu3.cpp.

54  {
55  delete static_cast<Fmu3Memory*>(mem);
56 }

◆ gather_adj()

void casadi::FmuInternal::gather_adj ( FmuMemory m) const
inherited

Definition at line 1338 of file fmu.cpp.

1338  {
1339  // Gather input and output indices
1340  gather_io(m);
1341  // Number of inputs and outputs
1342  size_t n_known = m->id_in_.size();
1343  size_t n_unknown = m->id_out_.size();
1344  // Get/clear seeds
1345  m->d_out_.clear();
1346  for (size_t id : m->id_out_) {
1347  m->d_out_.push_back(m->osens_[id]);
1348  m->osens_[id] = 0;
1349  }
1350  // Ensure at least one seed
1351  casadi_assert(n_unknown != 0, "No seeds");
1352  // Allocate result vectors
1353  m->v_in_.resize(n_known);
1354  m->d_in_.resize(n_known);
1355 }

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, casadi::FmuInternal::gather_io(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::osens_, and casadi::FmuMemory::v_in_.

Referenced by casadi::FmuInternal::eval_adj().

◆ gather_fwd()

void casadi::FmuInternal::gather_fwd ( FmuMemory m) const
inherited

Definition at line 1319 of file fmu.cpp.

1319  {
1320  // Gather input and output indices
1321  gather_io(m);
1322  // Number of inputs and outputs
1323  size_t n_known = m->id_in_.size();
1324  size_t n_unknown = m->id_out_.size();
1325  // Get/clear seeds
1326  m->d_in_.clear();
1327  for (size_t id : m->id_in_) {
1328  m->d_in_.push_back(m->isens_[id]);
1329  m->isens_[id] = 0;
1330  }
1331  // Ensure at least one seed
1332  casadi_assert(n_known != 0, "No seeds");
1333  // Allocate result vectors
1334  m->v_out_.resize(n_unknown);
1335  m->d_out_.resize(n_unknown);
1336 }

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, casadi::FmuInternal::gather_io(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::isens_, and casadi::FmuMemory::v_out_.

Referenced by casadi::FmuInternal::eval_fwd().

◆ gather_io()

void casadi::FmuInternal::gather_io ( FmuMemory m) const
inherited

Definition at line 1294 of file fmu.cpp.

1294  {
1295  // Collect input indices and corresponding value references and values
1296  m->id_in_.clear();
1297  m->vr_in_.clear();
1298  m->v_in_.clear();
1299  for (size_t id = 0; id < m->imarked_.size(); ++id) {
1300  if (m->imarked_[id]) {
1301  m->id_in_.push_back(id);
1302  m->vr_in_.push_back(vr_in_[id]);
1303  m->v_in_.push_back(m->ibuf_[id]);
1304  m->imarked_[id] = false;
1305  }
1306  }
1307  // Collect output indices, corresponding value references
1308  m->id_out_.clear();
1309  m->vr_out_.clear();
1310  for (size_t id = 0; id < m->omarked_.size(); ++id) {
1311  if (m->omarked_[id]) {
1312  m->id_out_.push_back(id);
1313  m->vr_out_.push_back(vr_out_[id]);
1314  m->omarked_[id] = false;
1315  }
1316  }
1317 }
std::vector< unsigned int > vr_out_
Definition: fmu_impl.hpp:334
std::vector< unsigned int > vr_in_
Definition: fmu_impl.hpp:334

References casadi::FmuMemory::ibuf_, casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::imarked_, casadi::FmuMemory::omarked_, casadi::FmuMemory::v_in_, casadi::FmuMemory::vr_in_, casadi::FmuInternal::vr_in_, casadi::FmuMemory::vr_out_, and casadi::FmuInternal::vr_out_.

Referenced by casadi::FmuInternal::eval(), casadi::FmuInternal::gather_adj(), and casadi::FmuInternal::gather_fwd().

◆ get()

void casadi::FmuInternal::get ( FmuMemory m,
size_t  id,
double *  value 
) const
inherited

Definition at line 1250 of file fmu.cpp.

1250  {
1251  // Save to return
1252  for (size_t id : ored_[ind]) {
1253  *value++ = m->obuf_.at(id);
1254  }
1255 }

References casadi::FmuMemory::obuf_, and casadi::FmuInternal::ored_.

Referenced by casadi::Fmu::get().

◆ get_adj() [1/2]

void casadi::FmuInternal::get_adj ( FmuMemory m,
casadi_int  nsens,
const casadi_int *  id,
double *  v 
) const
inherited

Definition at line 1082 of file fmu.cpp.

1082  {
1083  for (casadi_int i = 0; i < nsens; ++i) {
1084  *v++ = m->isens_.at(*id++);
1085  }
1086 }

References casadi::FmuMemory::isens_.

Referenced by casadi::FmuInternal::get_adj().

◆ get_adj() [2/2]

void casadi::FmuInternal::get_adj ( FmuMemory m,
size_t  ind,
double *  v 
) const
inherited

Definition at line 1088 of file fmu.cpp.

1088  {
1089  // Quick return if not needed
1090  if (!v) return;
1091  // Retrieve all sensitivities FIXME(@jaeandersson): should use compatible types
1092  for (size_t id : ired_[ind]) {
1093  casadi_int id2 = id;
1094  get_adj(m, 1, &id2, v++);
1095  }
1096 }
void get_adj(FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
Definition: fmu.cpp:1082

References casadi::FmuInternal::get_adj(), and casadi::FmuInternal::ired_.

◆ get_adjoint_derivative()

int casadi::Fmu3::get_adjoint_derivative ( void *  instance,
const unsigned int *  vr_out,
size_t  n_out,
const unsigned int *  vr_in,
size_t  n_in,
const double *  seed,
size_t  n_seed,
double *  sensitivity,
size_t  n_sensitivity 
) const
overridevirtual

Reimplemented from casadi::FmuInternal.

Definition at line 361 of file fmu3.cpp.

363  {
364  fmi3Status status = get_adjoint_derivative_(instance, vr_out, n_out, vr_in, n_in,
365  seed, n_seed, sensitivity, n_sensitivity);
366  return status != fmi3OK;
367 }
size_t n_in() const
Get the number of scheme inputs.
Definition: fmu_impl.hpp:127

References get_adjoint_derivative_, casadi::FmuInternal::n_in(), and casadi::FmuInternal::n_out().

◆ get_aux()

int casadi::Fmu3::get_aux ( void *  instance)
overridevirtual

Implements casadi::FmuInternal.

Definition at line 413 of file fmu3.cpp.

413  {
414  return get_aux_impl(instance, aux_value_);
415 }
int get_aux_impl(void *instance, Value &aux_value) const
Definition: fmu3.cpp:417

References aux_value_, and get_aux_impl().

◆ get_aux_impl()

int casadi::Fmu3::get_aux_impl ( void *  instance,
Value aux_value 
) const

Definition at line 417 of file fmu3.cpp.

417  {
418  auto c = static_cast<fmi3Instance>(instance);
419  // Get real auxilliary variables
420  if (!vr_aux_real_.empty()) {
421  fmi3Status status = get_float64_(c, get_ptr(vr_aux_real_), vr_aux_real_.size(),
422  get_ptr(aux_value.v_real), vr_aux_real_.size());
423  if (status != fmi3OK) {
424  casadi_warning("fmi3GetFloat64 failed");
425  return 1;
426  }
427  }
428  // Get integer/enum auxilliary variables
429  if (!vr_aux_integer_.empty()) {
430  fmi3Status status = get_int32_(c, get_ptr(vr_aux_integer_), vr_aux_integer_.size(),
431  get_ptr(aux_value.v_integer), vr_aux_integer_.size());
432  if (status != fmi3OK) {
433  casadi_warning("fmi3GetInt32 failed");
434  return 1;
435  }
436  }
437  // Get boolean auxilliary variables
438  if (!vr_aux_boolean_.empty()) {
439  casadi_error("Broken");
440  // nullptr -> get_ptr(v->v_boolean)
441  fmi3Status status = get_boolean_(c, get_ptr(vr_aux_boolean_), vr_aux_boolean_.size(),
442  nullptr, vr_aux_boolean_.size());
443  if (status != fmi3OK) {
444  casadi_warning("fmi3GetBoolean failed");
445  return 1;
446  }
447  }
448  // Get string auxilliary variables
449  for (size_t k = 0; k < vr_aux_string_.size(); ++k) {
450  fmi3ValueReference vr = vr_aux_string_[k];
451  fmi3String value = aux_value.v_string.at(k).c_str();
452  fmi3Status status = set_string_(c, &vr, 1, &value, 1);
453  if (status != fmi3OK) {
454  casadi_error("fmi3GetString failed for value reference " + str(vr));
455  }
456  }
457  // Successful return
458  return 0;
459 }
fmi3GetInt32TYPE * get_int32_
Definition: fmu3.hpp:106
fmi3SetStringTYPE * set_string_
Definition: fmu3.hpp:109
fmi3GetBooleanTYPE * get_boolean_
Definition: fmu3.hpp:104

References get_boolean_, get_float64_, get_int32_, casadi::get_ptr(), set_string_, casadi::str(), casadi::Fmu3::Value::v_integer, casadi::Fmu3::Value::v_real, casadi::Fmu3::Value::v_string, vr_aux_boolean_, vr_aux_integer_, vr_aux_real_, and vr_aux_string_.

Referenced by get_aux(), and get_stats().

◆ get_derivatives()

int casadi::Fmu3::get_derivatives ( void *  instance,
double *  derivatives,
size_t  nx 
) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 325 of file fmu3.cpp.

325  {
326  return 0;
327 }

◆ get_directional_derivative()

int casadi::Fmu3::get_directional_derivative ( void *  instance,
const unsigned int *  vr_out,
size_t  n_out,
const unsigned int *  vr_in,
size_t  n_in,
const double *  seed,
size_t  n_seed,
double *  sensitivity,
size_t  n_sensitivity 
) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 353 of file fmu3.cpp.

355  {
356  fmi3Status status = get_directional_derivative_(instance, vr_out, n_out, vr_in, n_in,
357  seed, n_seed, sensitivity, n_sensitivity);
358  return status != fmi3OK;
359 }

References get_directional_derivative_, casadi::FmuInternal::n_in(), and casadi::FmuInternal::n_out().

◆ get_fwd() [1/2]

void casadi::FmuInternal::get_fwd ( FmuMemory m,
casadi_int  nsens,
const casadi_int *  id,
double *  v 
) const
inherited

Definition at line 1029 of file fmu.cpp.

1029  {
1030  for (casadi_int i = 0; i < nsens; ++i) {
1031  *v++ = m->osens_.at(*id++);
1032  }
1033 }

References casadi::FmuMemory::osens_.

Referenced by casadi::FmuInternal::get_fwd().

◆ get_fwd() [2/2]

void casadi::FmuInternal::get_fwd ( FmuMemory m,
size_t  ind,
double *  v 
) const
inherited

Definition at line 1035 of file fmu.cpp.

1035  {
1036  // Quick return if not needed
1037  if (!v) return;
1038  // Retrieve all sensitivities FIXME(@jaeandersson): should use compatible types
1039  for (size_t id : ored_[ind]) {
1040  casadi_int id2 = id;
1041  get_fwd(m, 1, &id2, v++);
1042  }
1043 }
void get_fwd(FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
Definition: fmu.cpp:1029

References casadi::FmuInternal::get_fwd(), and casadi::FmuInternal::ored_.

◆ get_real()

int casadi::Fmu3::get_real ( void *  instance,
const unsigned int *  vr,
size_t  n_vr,
double *  values,
size_t  n_values 
) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 347 of file fmu3.cpp.

348  {
349  fmi3Status status = get_float64_(instance, vr, n_vr, values, n_values);
350  return status != fmi3OK;
351 }

References get_float64_.

◆ get_stats()

void casadi::Fmu3::get_stats ( FmuMemory m,
Dict stats,
const std::vector< std::string > &  name_in,
const InputStruct in 
) const
overridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_2bc

Implements casadi::FmuInternal.

Definition at line 461 of file fmu3.cpp.

462  {
463  Value& v = static_cast<Fmu3Memory*>(m)->aux_value;
464  get_aux_impl(m->instance, v);
465  // Collect auxilliary variables
466  Dict aux;
467  // Real
468  for (size_t k = 0; k < vn_aux_real_.size(); ++k) {
469  aux[vn_aux_real_[k]] = static_cast<double>(v.v_real[k]);
470  }
471  // Integer
472  for (size_t k = 0; k < vn_aux_integer_.size(); ++k) {
473  aux[vn_aux_integer_[k]] = static_cast<casadi_int>(v.v_integer[k]);
474  }
475  // Boolean
476  for (size_t k = 0; k < vn_aux_boolean_.size(); ++k) {
477  aux[vn_aux_boolean_[k]] = static_cast<bool>(v.v_boolean[k]);
478  }
479  // String
480  for (size_t k = 0; k < vn_aux_string_.size(); ++k) {
481  aux[vn_aux_string_[k]] = v.v_string[k];
482  }
483  // Copy to stats
484  (*stats)["aux"] = aux;
485  // Loop over input variables
486  for (size_t k = 0; k < name_in.size(); ++k) {
487  // Only consider regular inputs
488  if (in[k].type == InputType::REG) {
489  // Get the indices
490  const std::vector<size_t>& iind = ired_.at(in[k].ind);
491  // Collect values
492  std::vector<double> v(iind.size());
493  for (size_t i = 0; i < v.size(); ++i) v[i] = value_in_.at(iind[i]);
494  // Save to stats
495  (*stats)[name_in[k]] = v;
496  }
497  }
498 }
std::vector< double > value_in_
Definition: fmu_impl.hpp:337
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.

References get_aux_impl(), casadi::FmuMemory::instance, casadi::FmuInternal::ired_, casadi::REG, casadi::Fmu3::Value::v_boolean, casadi::Fmu3::Value::v_integer, casadi::Fmu3::Value::v_real, casadi::Fmu3::Value::v_string, casadi::FmuInternal::value_in_, vn_aux_boolean_, vn_aux_integer_, vn_aux_real_, and vn_aux_string_.

◆ getCount()

Definition at line 60 of file generic_shared_internal.hpp.

186  {
187  return static_cast<const Internal*>(this)->count;
188  }

◆ hess_sparsity()

Sparsity casadi::FmuInternal::hess_sparsity ( const std::vector< size_t > &  r,
const std::vector< size_t > &  c 
) const
inherited

Definition at line 676 of file fmu.cpp.

677  {
678  // Convert to casadi_int type
679  std::vector<casadi_int> r1(r.begin(), r.end());
680  std::vector<casadi_int> c1(c.begin(), c.end());
681  // Index mapping (not used)
682  std::vector<casadi_int> mapping;
683  // Get selection
684  return hess_sp_.sub(r1, c1, mapping);
685 }
Sparsity sub(const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, std::vector< casadi_int > &mapping, bool ind1=false) const
Get a submatrix.
Definition: sparsity.cpp:334

References casadi::FmuInternal::hess_sp_, and casadi::Sparsity::sub().

◆ index_in()

size_t casadi::FmuInternal::index_in ( const std::string &  n) const
inherited

Definition at line 645 of file fmu.cpp.

645  {
646  // Linear search for the input
647  for (size_t i = 0; i < scheme_in_.size(); ++i) {
648  if (scheme_in_[i] == n) return i;
649  }
650  // Not found
651  casadi_error("No such input: " + n);
652  return -1;
653 }
std::vector< std::string > scheme_in_
Definition: fmu_impl.hpp:290

References casadi::FmuInternal::scheme_in_.

Referenced by casadi::InputStruct::parse(), and casadi::OutputStruct::parse().

◆ index_out()

size_t casadi::FmuInternal::index_out ( const std::string &  n) const
inherited

Definition at line 655 of file fmu.cpp.

655  {
656  // Linear search for the input
657  for (size_t i = 0; i < scheme_out_.size(); ++i) {
658  if (scheme_out_[i] == n) return i;
659  }
660  // Not found
661  casadi_error("No such output: " + n);
662  return -1;
663 }
std::vector< std::string > scheme_out_
Definition: fmu_impl.hpp:290

References casadi::FmuInternal::scheme_out_.

Referenced by casadi::InputStruct::parse(), and casadi::OutputStruct::parse().

◆ init()

void casadi::Fmu3::init ( const DaeBuilderInternal dae)
overridevirtual

Reimplemented from casadi::FmuInternal.

Definition at line 106 of file fmu3.cpp.

106  {
107  // Initialize base classes
108  FmuInternal::init(dae);
109 
110  // Collect input and parameter values
111  vr_real_.clear();
112  vr_integer_.clear();
113  vr_boolean_.clear();
114  vr_string_.clear();
115  init_real_.clear();
116  init_integer_.clear();
117  init_boolean_.clear();
118  init_string_.clear();
119  for (size_t i = 0; i < dae->n_variables(); ++i) {
120  const Variable& v = dae->variable(i);
121  casadi_assert(v.numel == 1, "Vector variable support not implemented");
122  // Skip if the wrong type
123  if (v.causality != Causality::PARAMETER && v.causality != Causality::INPUT) continue;
124  // Variable has not been set - keep default value
125  if (!v.is_set()) continue;
126  // Value reference
127  fmi3ValueReference vr = v.value_reference;
128  // Get value
129  switch (to_fmi2(v.type)) {
130  case TypeFmi2::REAL:
131  init_real_.push_back(static_cast<fmi3Float64>(v.value.front()));
132  vr_real_.push_back(vr);
133  break;
134  case TypeFmi2::INTEGER:
135  case TypeFmi2::ENUM:
136  init_integer_.push_back(static_cast<fmi3Int32>(v.value.front()));
137  vr_integer_.push_back(vr);
138  break;
139  case TypeFmi2::BOOLEAN:
140  init_boolean_.push_back(static_cast<fmi3Boolean>(v.value.front()));
141  vr_boolean_.push_back(vr);
142  break;
143  case TypeFmi2::STRING:
144  init_string_.push_back(v.stringvalue);
145  vr_string_.push_back(vr);
146  break;
147  default:
148  casadi_warning("Ignoring " + v.name + ", type: " + to_string(v.type));
149  }
150  }
151 
152  // Collect auxilliary variables
153  vn_aux_real_.clear();
154  vn_aux_integer_.clear();
155  vn_aux_boolean_.clear();
156  vn_aux_string_.clear();
157  vr_aux_real_.clear();
158  vr_aux_integer_.clear();
159  vr_aux_boolean_.clear();
160  vr_aux_string_.clear();
161  for (auto&& s : aux_) {
162  const Variable& v = dae->variable(s);
163  // Convert to expected type
164  fmi3ValueReference vr = v.value_reference;
165  // Sort by type
166  switch (to_fmi2(v.type)) {
167  case TypeFmi2::REAL:
168  // Real
169  vn_aux_real_.push_back(v.name);
170  vr_aux_real_.push_back(vr);
171  break;
172  case TypeFmi2::INTEGER:
173  case TypeFmi2::ENUM:
174  // Integer or enum
175  vn_aux_integer_.push_back(v.name);
176  vr_aux_integer_.push_back(vr);
177  break;
178  case TypeFmi2::BOOLEAN:
179  // Boolean
180  vn_aux_boolean_.push_back(v.name);
181  vr_aux_boolean_.push_back(vr);
182  break;
183  case TypeFmi2::STRING:
184  // String
185  vn_aux_string_.push_back(v.name);
186  vr_aux_string_.push_back(vr);
187  break;
188  default:
189  casadi_warning("Ignoring " + v.name + ", type: " + to_string(v.type));
190  }
191  }
192 }
std::vector< std::string > aux_
Definition: fmu_impl.hpp:294
virtual void init(const DaeBuilderInternal *dae)
Definition: fmu.cpp:451
struct VariableStruct Variable
TypeFmi2 to_fmi2(Type v)

References casadi::FmuInternal::aux_, casadi::BOOLEAN, casadi::Variable::causality, casadi::ENUM, casadi::FmuInternal::init(), init_boolean_, init_integer_, init_real_, init_string_, casadi::INPUT, casadi::INTEGER, casadi::Variable::is_set(), casadi::DaeBuilderInternal::n_variables(), casadi::Variable::name, casadi::Variable::numel, casadi::PARAMETER, casadi::REAL, casadi::STRING, casadi::Variable::stringvalue, casadi::to_fmi2(), casadi::to_string(), casadi::Variable::type, casadi::Variable::value, casadi::Variable::value_reference, casadi::DaeBuilderInternal::variable(), vn_aux_boolean_, vn_aux_integer_, vn_aux_real_, vn_aux_string_, vr_aux_boolean_, vr_aux_integer_, vr_aux_real_, vr_aux_string_, vr_boolean_, vr_integer_, vr_real_, and vr_string_.

◆ init_mem()

int casadi::Fmu3::init_mem ( FmuMemory m) const
overridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_2dr

Allocate numerical values for initial auxilliary variables

Reimplemented from casadi::FmuInternal.

Definition at line 39 of file fmu3.cpp.

39  {
40  if (FmuInternal::init_mem(mem)) return 1;
41  auto m = static_cast<Fmu3Memory*>(mem);
43  m->aux_value.v_real.resize(vn_aux_real_.size());
44  m->aux_value.v_integer.resize(vn_aux_integer_.size());
45  m->aux_value.v_boolean.resize(vn_aux_boolean_.size());
46  m->aux_value.v_string.resize(vn_aux_string_.size());
47  return 0;
48 }
virtual int init_mem(FmuMemory *m) const
Initalize memory block.
Definition: fmu.cpp:1148

References casadi::FmuInternal::init_mem(), vn_aux_boolean_, vn_aux_integer_, vn_aux_real_, and vn_aux_string_.

◆ initSingleton()

void casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::initSingleton ( )
inlineprotectedinherited

Called in the constructor of singletons to avoid that the counter reaches zero

Definition at line 71 of file generic_shared_internal.hpp.

71  {
72  casadi_assert_dev(static_cast<Internal*>(this)->count==0);
73  static_cast<Internal*>(this)->count++;
74  }

◆ instantiate()

void * casadi::Fmu3::instantiate ( ) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 243 of file fmu3.cpp.

243  {
244  // Instantiate FMU
245  fmi3String instanceName = instance_name_.c_str();
246  fmi3String instantiationToken = instantiation_token_.c_str();
247  fmi3String resourcePath = resource_loc_.c_str();
248  fmi3Boolean visible = fmi3False;
249  fmi3InstanceEnvironment instanceEnvironment = 0;
250  fmi3Instance c = instantiate_model_exchange_(instanceName, instantiationToken, resourcePath,
251  visible, logging_on_, instanceEnvironment, log_message_callback);
252  if (c == 0) casadi_error("fmi3Instantiate failed");
253  return c;
254 }
static void log_message_callback(fmi3InstanceEnvironment instanceEnvironment, fmi3Status status, fmi3String category, fmi3String message)
Definition: fmu3.cpp:237
std::string instantiation_token_
Definition: fmu_impl.hpp:306
std::string resource_loc_
Definition: fmu_impl.hpp:297
std::string instance_name_
Definition: fmu_impl.hpp:303

References casadi::FmuInternal::instance_name_, instantiate_model_exchange_, casadi::FmuInternal::instantiation_token_, log_message_callback(), casadi::FmuInternal::logging_on_, and casadi::FmuInternal::resource_loc_.

◆ jac_sparsity()

Sparsity casadi::FmuInternal::jac_sparsity ( const std::vector< size_t > &  osub,
const std::vector< size_t > &  isub 
) const
inherited

Definition at line 665 of file fmu.cpp.

666  {
667  // Convert to casadi_int type
668  std::vector<casadi_int> osub1(osub.begin(), osub.end());
669  std::vector<casadi_int> isub1(isub.begin(), isub.end());
670  // Index mapping (not used)
671  std::vector<casadi_int> mapping;
672  // Get selection
673  return jac_sp_.sub(osub1, isub1, mapping);
674 }

References casadi::FmuInternal::jac_sp_, and casadi::Sparsity::sub().

◆ load_function()

template<typename T >
T * casadi::FmuInternal::load_function ( const std::string &  symname)
inherited

Definition at line 357 of file fmu_impl.hpp.

357  {
358  // Load the function
359  signal_t f = li_.get_function(symname);
360  // Ensure that it was found
361  casadi_assert(f != 0, "Cannot retrieve '" + symname + "'");
362  // Return function with the right type
363  return reinterpret_cast<T*>(f);
364 }
Importer li_
DLL.
Definition: fmu_impl.hpp:321
signal_t get_function(const std::string &symname)
Get a function pointer for numerical evaluation.
Definition: importer.cpp:79
void(* signal_t)(void)
Function pointer types for the C API.

References casadi::Importer::get_function(), casadi::FmuInternal::li_, and casadi::T.

◆ load_functions()

void casadi::Fmu3::load_functions ( )
overridevirtual

Implements casadi::FmuInternal.

Definition at line 205 of file fmu3.cpp.

205  {
206  instantiate_model_exchange_ = load_function<fmi3InstantiateModelExchangeTYPE>(
207  "fmi3InstantiateModelExchange");
208  free_instance_ = load_function<fmi3FreeInstanceTYPE>("fmi3FreeInstance");
209  reset_ = load_function<fmi3ResetTYPE>("fmi3Reset");
210  enter_initialization_mode_ = load_function<fmi3EnterInitializationModeTYPE>(
211  "fmi3EnterInitializationMode");
212  exit_initialization_mode_ = load_function<fmi3ExitInitializationModeTYPE>(
213  "fmi3ExitInitializationMode");
214  enter_continuous_time_mode_ = load_function<fmi3EnterContinuousTimeModeTYPE>(
215  "fmi3EnterContinuousTimeMode");
216  set_time_ = load_function<fmi3SetTimeTYPE>("fmi3SetTime");
217  get_float64_ = load_function<fmi3GetFloat64TYPE>("fmi3GetFloat64");
218  set_float64_ = load_function<fmi3SetFloat64TYPE>("fmi3SetFloat64");
219  get_int32_ = load_function<fmi3GetInt32TYPE>("fmi3GetInt32");
220  set_int32_ = load_function<fmi3SetInt32TYPE>("fmi3SetInt32");
221  get_boolean_ = load_function<fmi3GetBooleanTYPE>("fmi3GetBoolean");
222  set_boolean_ = load_function<fmi3SetBooleanTYPE>("fmi3SetBoolean");
223  get_string_ = load_function<fmi3GetStringTYPE>("fmi3GetString");
224  set_string_ = load_function<fmi3SetStringTYPE>("fmi3SetString");
227  load_function<fmi3GetDirectionalDerivativeTYPE>("fmi3GetDirectionalDerivative");
228  }
231  load_function<fmi3GetAdjointDerivativeTYPE>("fmi3GetAdjointDerivative");
232  }
234  load_function<fmi3UpdateDiscreteStatesTYPE>("fmi3UpdateDiscreteStates");
235 }
fmi3GetStringTYPE * get_string_
Definition: fmu3.hpp:108
fmi3SetInt32TYPE * set_int32_
Definition: fmu3.hpp:107
bool provides_adjoint_derivatives_
Definition: fmu_impl.hpp:315
bool provides_directional_derivatives_
Definition: fmu_impl.hpp:315

References enter_continuous_time_mode_, enter_initialization_mode_, exit_initialization_mode_, free_instance_, get_adjoint_derivative_, get_boolean_, get_directional_derivative_, get_float64_, get_int32_, get_string_, instantiate_model_exchange_, casadi::FmuInternal::provides_adjoint_derivatives_, casadi::FmuInternal::provides_directional_derivatives_, reset_, set_boolean_, set_float64_, set_int32_, set_string_, set_time_, and update_discrete_states_.

◆ log_message_callback()

void casadi::Fmu3::log_message_callback ( fmi3InstanceEnvironment  instanceEnvironment,
fmi3Status  status,
fmi3String  category,
fmi3String  message 
)
static

Definition at line 237 of file fmu3.cpp.

238  {
239  // Print message content
240  uout() << "[" << category << "] " << message << std::endl;
241 }
std::ostream & uout()

References casadi::uout().

Referenced by instantiate().

◆ n_in()

size_t casadi::FmuInternal::n_in ( ) const
inlineinherited

◆ n_out()

size_t casadi::FmuInternal::n_out ( ) const
inlineinherited

◆ request()

void casadi::FmuInternal::request ( FmuMemory m,
size_t  ind 
) const
inherited

Definition at line 1213 of file fmu.cpp.

1213  {
1214  for (size_t id : ored_[ind]) {
1215  // Mark as requested
1216  m->omarked_.at(id) = true;
1217  // Also log corresponding input index
1218  m->wrt_.at(id) = -1;
1219  }
1220 }

References casadi::FmuMemory::omarked_, casadi::FmuInternal::ored_, and casadi::FmuMemory::wrt_.

◆ request_adj() [1/2]

void casadi::FmuInternal::request_adj ( FmuMemory m,
casadi_int  ind 
) const
inherited

Definition at line 1073 of file fmu.cpp.

1073  {
1074  // Request all sensitivities FIXME(@jaeandersson): should use compatible types
1075  casadi_int wrt_id = -1;
1076  for (size_t id : ired_[ind]) {
1077  casadi_int id2 = id;
1078  request_adj(m, 1, &id2, &wrt_id);
1079  }
1080 }
void request_adj(FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
Definition: fmu.cpp:1064

References casadi::FmuInternal::ired_, and casadi::FmuInternal::request_adj().

◆ request_adj() [2/2]

void casadi::FmuInternal::request_adj ( FmuMemory m,
casadi_int  nsens,
const casadi_int *  id,
const casadi_int *  wrt_id 
) const
inherited

Definition at line 1064 of file fmu.cpp.

1065  {
1066  for (casadi_int i = 0; i < nsens; ++i) {
1067  m->imarked_.at(*id) = true;
1068  m->wrt_.at(*id) = *wrt_id++;
1069  id++;
1070  }
1071 }

References casadi::FmuMemory::imarked_, and casadi::FmuMemory::wrt_.

Referenced by casadi::FmuInternal::request_adj().

◆ request_fwd() [1/2]

void casadi::FmuInternal::request_fwd ( FmuMemory m,
casadi_int  ind 
) const
inherited

Definition at line 1285 of file fmu.cpp.

1285  {
1286  // Request all sensitivities FIXME(@jaeandersson): should use compatible types
1287  casadi_int wrt_id = -1;
1288  for (size_t id : ored_[ind]) {
1289  casadi_int id2 = id;
1290  request_fwd(m, 1, &id2, &wrt_id);
1291  }
1292 }
void request_fwd(FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
Definition: fmu.cpp:1276

References casadi::FmuInternal::ored_, and casadi::FmuInternal::request_fwd().

◆ request_fwd() [2/2]

void casadi::FmuInternal::request_fwd ( FmuMemory m,
casadi_int  nsens,
const casadi_int *  id,
const casadi_int *  wrt_id 
) const
inherited

Definition at line 1276 of file fmu.cpp.

1277  {
1278  for (casadi_int i = 0; i < nsens; ++i) {
1279  m->omarked_.at(*id) = true;
1280  m->wrt_.at(*id) = *wrt_id++;
1281  id++;
1282  }
1283 }

References casadi::FmuMemory::omarked_, and casadi::FmuMemory::wrt_.

Referenced by casadi::FmuInternal::request_fwd().

◆ reset()

int casadi::Fmu3::reset ( void *  instance)

Definition at line 265 of file fmu3.cpp.

265  {
266  auto c = static_cast<fmi3Instance>(instance);
267  fmi3Status status = reset_(c);
268  if (status != fmi3OK) {
269  casadi_warning("fmi3Reset failed");
270  return 1;
271  }
272  return 0;
273 }

References reset_.

◆ serialize()

void casadi::FmuInternal::serialize ( SerializingStream s) const
inherited

Definition at line 1371 of file fmu.cpp.

1371  {
1372  serialize_type(s);
1373  serialize_body(s);
1374 }
virtual void serialize_body(SerializingStream &s) const
Definition: fmu.cpp:1380
virtual void serialize_type(SerializingStream &s) const
Definition: fmu.cpp:1376

References casadi::FmuInternal::serialize_body(), and casadi::FmuInternal::serialize_type().

◆ serialize_body()

void casadi::Fmu3::serialize_body ( SerializingStream s) const
overridevirtual

Reimplemented from casadi::FmuInternal.

Definition at line 564 of file fmu3.cpp.

564  {
566 
567  s.version("Fmu3", 1);
568  s.pack("Fmu3::vr_real", vr_real_);
569  s.pack("Fmu3::vr_integer", vr_integer_);
570  s.pack("Fmu3::vr_boolean", vr_boolean_);
571  s.pack("Fmu3::vr_string", vr_string_);
572  s.pack("Fmu3::init_real", init_real_);
573  s.pack("Fmu3::init_integer", init_integer_);
574  s.pack("Fmu3::init_boolean", init_boolean_);
575  s.pack("Fmu3::init_string", init_string_);
576 
577  s.pack("Fmu3::vn_aux_real", vn_aux_real_);
578  s.pack("Fmu3::vn_aux_integer", vn_aux_integer_);
579  s.pack("Fmu3::vn_aux_boolean", vn_aux_boolean_);
580  s.pack("Fmu3::vn_aux_string", vn_aux_string_);
581  s.pack("Fmu3::vr_aux_real", vr_aux_real_);
582  s.pack("Fmu3::vr_aux_integer", vr_aux_integer_);
583  s.pack("Fmu3::vr_aux_boolean", vr_aux_boolean_);
584  s.pack("Fmu3::vr_aux_string", vr_aux_string_);
585 }

References init_boolean_, init_integer_, init_real_, init_string_, casadi::SerializingStream::pack(), casadi::FmuInternal::serialize_body(), casadi::SerializingStream::version(), vn_aux_boolean_, vn_aux_integer_, vn_aux_real_, vn_aux_string_, vr_aux_boolean_, vr_aux_integer_, vr_aux_real_, vr_aux_string_, vr_boolean_, vr_integer_, vr_real_, and vr_string_.

◆ serialize_type()

void casadi::FmuInternal::serialize_type ( SerializingStream s) const
virtualinherited

Definition at line 1376 of file fmu.cpp.

1376  {
1377  s.pack("FmuInternal::type", class_name());
1378 }

References casadi::SharedObjectInternal::class_name(), and casadi::SerializingStream::pack().

Referenced by casadi::FmuInternal::serialize().

◆ set()

void casadi::FmuInternal::set ( FmuMemory m,
size_t  ind,
const double *  value 
) const
inherited

Definition at line 1192 of file fmu.cpp.

1192  {
1193  if (value) {
1194  // Argument is given
1195  for (size_t id : ired_[ind]) {
1196  if (*value != m->ibuf_.at(id)) {
1197  m->ibuf_.at(id) = *value;
1198  m->imarked_.at(id) = true;
1199  }
1200  value++;
1201  }
1202  } else {
1203  // Argument is null - all zeros
1204  for (size_t id : ired_[ind]) {
1205  if (0 != m->ibuf_.at(id)) {
1206  m->ibuf_.at(id) = 0;
1207  m->imarked_.at(id) = true;
1208  }
1209  }
1210  }
1211 }

References casadi::FmuMemory::ibuf_, casadi::FmuMemory::imarked_, and casadi::FmuInternal::ired_.

◆ set_adj() [1/2]

void casadi::FmuInternal::set_adj ( FmuMemory m,
casadi_int  nseed,
const casadi_int *  id,
const double *  v 
) const
inherited

Definition at line 1045 of file fmu.cpp.

1046  {
1047  for (casadi_int i = 0; i < nseed; ++i) {
1048  m->osens_.at(*id) = *v++;
1049  m->omarked_.at(*id) = true;
1050  id++;
1051  }
1052 }

References casadi::FmuMemory::omarked_, and casadi::FmuMemory::osens_.

Referenced by casadi::FmuInternal::set_adj().

◆ set_adj() [2/2]

void casadi::FmuInternal::set_adj ( FmuMemory m,
size_t  ind,
const double *  v 
) const
inherited

Definition at line 1054 of file fmu.cpp.

1054  {
1055  // If seeds are zero, no need to add to seed buffers
1056  if (!v) return;
1057  // Pass all seeds FIXME(@jaeandersson): should use compatible types
1058  for (size_t id : ored_[ind]) {
1059  casadi_int id2 = id;
1060  set_adj(m, 1, &id2, v++);
1061  }
1062 }
void set_adj(FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
Definition: fmu.cpp:1045

References casadi::FmuInternal::ored_, and casadi::FmuInternal::set_adj().

◆ set_fwd() [1/2]

void casadi::FmuInternal::set_fwd ( FmuMemory m,
casadi_int  nseed,
const casadi_int *  id,
const double *  v 
) const
inherited

Definition at line 1257 of file fmu.cpp.

1258  {
1259  for (casadi_int i = 0; i < nseed; ++i) {
1260  m->isens_.at(*id) = *v++;
1261  m->imarked_.at(*id) = true;
1262  id++;
1263  }
1264 }

References casadi::FmuMemory::imarked_, and casadi::FmuMemory::isens_.

Referenced by casadi::FmuInternal::set_fwd().

◆ set_fwd() [2/2]

void casadi::FmuInternal::set_fwd ( FmuMemory m,
size_t  ind,
const double *  v 
) const
inherited

Definition at line 1266 of file fmu.cpp.

1266  {
1267  // If seeds are zero, no need to add to seed buffers
1268  if (!v) return;
1269  // Pass all seeds FIXME(@jaeandersson): should use compatible types
1270  for (size_t id : ired_[ind]) {
1271  casadi_int id2 = id;
1272  set_fwd(m, 1, &id2, v++);
1273  }
1274 }
void set_fwd(FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
Definition: fmu.cpp:1257

References casadi::FmuInternal::ired_, and casadi::FmuInternal::set_fwd().

◆ set_real()

int casadi::Fmu3::set_real ( void *  instance,
const unsigned int *  vr,
size_t  n_vr,
const double *  values,
size_t  n_values 
) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 329 of file fmu3.cpp.

330  {
331  // Set time variable, if any
332  if (has_independent_ && n_vr > 0 && *vr == vr_in_[0]) {
333  // Update FMU time
334  fmi3Status status = set_time_(instance, *values);
335  if (status != fmi3OK) return 1;
336  // Skip when setting remaining variables
337  vr++;
338  n_vr--;
339  values++;
340  n_values--;
341  }
342  // Set remaining variables
343  fmi3Status status = set_float64_(instance, vr, n_vr, values, n_values);
344  return status != fmi3OK;
345 }

References casadi::FmuInternal::has_independent_, set_float64_, set_time_, and casadi::FmuInternal::vr_in_.

◆ set_values()

int casadi::Fmu3::set_values ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 369 of file fmu3.cpp.

369  {
370  auto c = static_cast<fmi3Instance>(instance);
371  // Pass real values before initialization
372  if (!vr_real_.empty()) {
373  fmi3Status status = set_float64_(c, get_ptr(vr_real_), vr_real_.size(),
374  get_ptr(init_real_), init_real_.size());
375  if (status != fmi3OK) {
376  casadi_warning("fmi3SetFloat64 failed");
377  return 1;
378  }
379  }
380  // Pass integer values before initialization (also enums)
381  if (!vr_integer_.empty()) {
382  fmi3Status status = set_int32_(c, get_ptr(vr_integer_), vr_integer_.size(),
384  if (status != fmi3OK) {
385  casadi_warning("fmi3SetInt32 failed");
386  return 1;
387  }
388  }
389  // Pass boolean values before initialization
390  if (!vr_boolean_.empty()) {
391  casadi_error("Broken");
392  // nullptr -> get_ptr(init_boolean_)
393  fmi3Status status = set_boolean_(c, get_ptr(vr_boolean_), vr_boolean_.size(),
394  nullptr, init_boolean_.size());
395  if (status != fmi3OK) {
396  casadi_warning("fmi3SetBoolean failed");
397  return 1;
398  }
399  }
400  // Pass string values before initialization
401  for (size_t k = 0; k < vr_string_.size(); ++k) {
402  fmi3ValueReference vr = vr_string_[k];
403  fmi3String value = init_string_[k].c_str();
404  fmi3Status status = set_string_(c, &vr, 1, &value, 1);
405  if (status != fmi3OK) {
406  casadi_error("fmi3SetString failed for value reference " + str(vr));
407  }
408  }
409  // Successful return
410  return 0;
411 }

References casadi::get_ptr(), init_boolean_, init_integer_, init_real_, init_string_, set_boolean_, set_float64_, set_int32_, set_string_, casadi::str(), vr_boolean_, vr_integer_, vr_real_, and vr_string_.

◆ shared_from_this() [1/2]

B casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::shared_from_this ( )
inlineprotectedinherited

Definition at line 83 of file generic_shared_internal.hpp.

83  {
84  casadi_assert_dev(B::test_cast(static_cast<Internal*>(this)));
85  B ret;
86  ret.own(static_cast<Internal*>(this));
87  return ret;
88  }

◆ shared_from_this() [2/2]

const B casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::shared_from_this ( ) const
inlineprotectedinherited

Definition at line 92 of file generic_shared_internal.hpp.

92  {
93  casadi_assert_dev(B::test_cast(static_cast<const Internal*>(this)));
94  B ret;
95  ret.own(const_cast<Internal*>(static_cast<const Internal*>(this)));
96  return ret;
97  }

◆ system_infix()

std::string casadi::Fmu3::system_infix ( ) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 61 of file fmu3.cpp.

61  {
62  // Architecture
63  std::string arch;
64 #if defined(__arm64__) || defined(__aarch64__)
65  // ARM 64-bit Architecture
66  arch = "aarch64";
67 #elif __arm__
68  if (sizeof(void*) == 4) {
69  // ARM 32-bit Architecture
70  arch = "aarch32";
71  } else {
72  // ARM 64-bit Architecture
73  arch = "aarch64";
74  }
75 #elif defined(__ppc64__) || defined(__powerpc64__)
76  // PowerPC 64-bit Architecture
77  arch = "ppc64";
78 #elif defined(__ppc__) || defined(__powerpc__)
79  // PowerPC 32-bit Architecture
80  arch = "ppc";
81 #else
82  if (sizeof(void*) == 4) {
83  // Intel/AMD x86 32-bit
84  arch = "x86";
85  } else {
86  // Intel/AMD x86 64-bit
87  arch = "x86_64";
88  }
89 #endif
90  // Operating system
91  std::string sys;
92 #if defined(_WIN32)
93  // Microsoft Windows
94  sys = "windows";
95 #elif defined(__APPLE__)
96  // Darwin (macOS, iOS, watchOS, tvOS, audioOS)
97  sys = "darwin";
98 #else
99  // Linux
100  sys = "linux";
101 #endif
102  // Return platform tuple, according to Section 2.5.1.4.1. of the FMI 3 specification
103  return arch + "-" + sys;
104 }

◆ update_discrete_states()

int casadi::Fmu3::update_discrete_states ( void *  instance,
EventMemory eventmem 
) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 305 of file fmu3.cpp.

305  {
306  auto c = static_cast<fmi3Instance>(instance);
307  // Return arguments in FMI types
308  fmi3Boolean discreteStatesNeedUpdate, terminateSimulation, nominalsOfContinuousStatesChanged,
309  valuesOfContinuousStatesChanged, nextEventTimeDefined;
310  fmi3Float64 nextEventTime;
311  // Call FMU
312  fmi3Status status = update_discrete_states_(c, &discreteStatesNeedUpdate, &terminateSimulation,
313  &nominalsOfContinuousStatesChanged, &valuesOfContinuousStatesChanged, &nextEventTimeDefined,
314  &nextEventTime);
315  // Pass to event iteration memory
316  eventmem->discrete_states_need_update = discreteStatesNeedUpdate;
317  eventmem->terminate_simulation = terminateSimulation;
318  eventmem->nominals_of_continuous_states_changed = nominalsOfContinuousStatesChanged;
319  eventmem->values_of_continuous_states_changed = valuesOfContinuousStatesChanged;
320  eventmem->next_event_time_defined = nextEventTimeDefined;
321  eventmem->next_event_time = nextEventTime;
322  return status != fmi3OK;
323 }

References casadi::EventMemory::discrete_states_need_update, casadi::EventMemory::next_event_time, casadi::EventMemory::next_event_time_defined, casadi::EventMemory::nominals_of_continuous_states_changed, casadi::EventMemory::terminate_simulation, update_discrete_states_, and casadi::EventMemory::values_of_continuous_states_changed.

◆ weak()

Extra doc: https://github.com/casadi/casadi/wiki/L_1ai

Definition at line 67 of file generic_shared_internal.hpp.

191  {
192  if (weak_ref_==nullptr) {
193  weak_ref_ = new GenericWeakRef<Shared, Internal>(static_cast<Internal*>(this));
194  }
195  return weak_ref_;
196  }

Member Data Documentation

◆ aux_

std::vector<std::string> casadi::FmuInternal::aux_
protectedinherited

◆ aux_value_

Value casadi::Fmu3::aux_value_

Definition at line 122 of file fmu3.hpp.

Referenced by finalize(), and get_aux().

◆ can_be_instantiated_only_once_per_process_

bool casadi::FmuInternal::can_be_instantiated_only_once_per_process_
protectedinherited

◆ do_evaluation_dance_

bool casadi::FmuInternal::do_evaluation_dance_
protectedinherited

◆ enter_continuous_time_mode_

fmi3EnterContinuousTimeModeTYPE* casadi::Fmu3::enter_continuous_time_mode_

Definition at line 100 of file fmu3.hpp.

Referenced by enter_continuous_time_mode(), Fmu3(), and load_functions().

◆ enter_initialization_mode_

fmi3EnterInitializationModeTYPE* casadi::Fmu3::enter_initialization_mode_

Definition at line 98 of file fmu3.hpp.

Referenced by enter_initialization_mode(), Fmu3(), and load_functions().

◆ exit_initialization_mode_

fmi3ExitInitializationModeTYPE* casadi::Fmu3::exit_initialization_mode_

Definition at line 99 of file fmu3.hpp.

Referenced by exit_initialization_mode(), Fmu3(), and load_functions().

◆ fmutol_

double casadi::FmuInternal::fmutol_
protectedinherited

◆ free_instance_

fmi3FreeInstanceTYPE* casadi::Fmu3::free_instance_

Definition at line 96 of file fmu3.hpp.

Referenced by Fmu3(), free_instance(), and load_functions().

◆ get_adjoint_derivative_

fmi3GetAdjointDerivativeTYPE* casadi::Fmu3::get_adjoint_derivative_

Definition at line 111 of file fmu3.hpp.

Referenced by Fmu3(), get_adjoint_derivative(), and load_functions().

◆ get_boolean_

fmi3GetBooleanTYPE* casadi::Fmu3::get_boolean_

Definition at line 104 of file fmu3.hpp.

Referenced by get_aux_impl(), and load_functions().

◆ get_directional_derivative_

fmi3GetDirectionalDerivativeTYPE* casadi::Fmu3::get_directional_derivative_

Definition at line 110 of file fmu3.hpp.

Referenced by Fmu3(), get_directional_derivative(), and load_functions().

◆ get_float64_

fmi3GetFloat64TYPE* casadi::Fmu3::get_float64_

Definition at line 102 of file fmu3.hpp.

Referenced by Fmu3(), get_aux_impl(), get_real(), and load_functions().

◆ get_int32_

fmi3GetInt32TYPE* casadi::Fmu3::get_int32_

Definition at line 106 of file fmu3.hpp.

Referenced by get_aux_impl(), and load_functions().

◆ get_string_

fmi3GetStringTYPE* casadi::Fmu3::get_string_

Definition at line 108 of file fmu3.hpp.

Referenced by load_functions().

◆ has_independent_

bool casadi::FmuInternal::has_independent_
protectedinherited

◆ hess_sp_

Sparsity casadi::FmuInternal::hess_sp_
protectedinherited

◆ iind_

std::vector<size_t> casadi::FmuInternal::iind_
protectedinherited

◆ iind_map_

std::vector<size_t> casadi::FmuInternal::iind_map_
protectedinherited

◆ init_boolean_

std::vector<fmi3Boolean> casadi::Fmu3::init_boolean_

Definition at line 85 of file fmu3.hpp.

Referenced by Fmu3(), init(), serialize_body(), and set_values().

◆ init_integer_

std::vector<fmi3Int32> casadi::Fmu3::init_integer_

Definition at line 84 of file fmu3.hpp.

Referenced by Fmu3(), init(), serialize_body(), and set_values().

◆ init_real_

std::vector<fmi3Float64> casadi::Fmu3::init_real_

Definition at line 83 of file fmu3.hpp.

Referenced by Fmu3(), init(), serialize_body(), and set_values().

◆ init_string_

std::vector<std::string> casadi::Fmu3::init_string_

Definition at line 86 of file fmu3.hpp.

Referenced by Fmu3(), init(), serialize_body(), and set_values().

◆ instance_name_

std::string casadi::FmuInternal::instance_name_
protectedinherited

◆ instantiate_model_exchange_

fmi3InstantiateModelExchangeTYPE* casadi::Fmu3::instantiate_model_exchange_

Definition at line 95 of file fmu3.hpp.

Referenced by Fmu3(), instantiate(), and load_functions().

◆ instantiation_token_

std::string casadi::FmuInternal::instantiation_token_
protectedinherited

◆ ired_

std::vector<std::vector<size_t> > casadi::FmuInternal::ired_
protectedinherited

◆ jac_sp_

Sparsity casadi::FmuInternal::jac_sp_
protectedinherited

◆ li_

Importer casadi::FmuInternal::li_
protectedinherited

◆ logging_on_

bool casadi::FmuInternal::logging_on_
protectedinherited

◆ max_in_

std::vector<double> casadi::FmuInternal::max_in_
protectedinherited

◆ max_out_

std::vector<double> casadi::FmuInternal::max_out_
protectedinherited

◆ min_in_

std::vector<double> casadi::FmuInternal::min_in_
protectedinherited

◆ min_out_

std::vector<double> casadi::FmuInternal::min_out_
protectedinherited

◆ name_

std::string casadi::FmuInternal::name_
protectedinherited

◆ nominal_in_

std::vector<double> casadi::FmuInternal::nominal_in_
protectedinherited

◆ nominal_out_

std::vector<double> casadi::FmuInternal::nominal_out_
protectedinherited

◆ number_of_event_indicators_

casadi_int casadi::FmuInternal::number_of_event_indicators_
protectedinherited

◆ nx_

size_t casadi::FmuInternal::nx_
protectedinherited

◆ oind_

std::vector<size_t> casadi::FmuInternal::oind_
protectedinherited

◆ oind_map_

std::vector<size_t> casadi::FmuInternal::oind_map_
protectedinherited

◆ ored_

std::vector<std::vector<size_t> > casadi::FmuInternal::ored_
protectedinherited

◆ provides_adjoint_derivatives_

bool casadi::FmuInternal::provides_adjoint_derivatives_
protectedinherited

◆ provides_directional_derivatives_

bool casadi::FmuInternal::provides_directional_derivatives_
protectedinherited

◆ reset_

fmi3ResetTYPE* casadi::Fmu3::reset_

Definition at line 97 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), and reset().

◆ resource_

Resource casadi::FmuInternal::resource_
protectedinherited

◆ resource_loc_

std::string casadi::FmuInternal::resource_loc_
protectedinherited

◆ scheme_

std::map<std::string, std::vector<size_t> > casadi::FmuInternal::scheme_
protectedinherited

◆ scheme_in_

std::vector<std::string> casadi::FmuInternal::scheme_in_
protectedinherited

◆ scheme_out_

std::vector<std::string> casadi::FmuInternal::scheme_out_
protectedinherited

◆ set_boolean_

fmi3SetBooleanTYPE* casadi::Fmu3::set_boolean_

Definition at line 105 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), and set_values().

◆ set_float64_

fmi3SetFloat64TYPE* casadi::Fmu3::set_float64_

Definition at line 103 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), set_real(), and set_values().

◆ set_int32_

fmi3SetInt32TYPE* casadi::Fmu3::set_int32_

Definition at line 107 of file fmu3.hpp.

Referenced by load_functions(), and set_values().

◆ set_string_

fmi3SetStringTYPE* casadi::Fmu3::set_string_

Definition at line 109 of file fmu3.hpp.

Referenced by get_aux_impl(), load_functions(), and set_values().

◆ set_time_

fmi3SetTimeTYPE* casadi::Fmu3::set_time_

Definition at line 101 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), and set_real().

◆ update_discrete_states_

fmi3UpdateDiscreteStatesTYPE* casadi::Fmu3::update_discrete_states_

Definition at line 112 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), and update_discrete_states().

◆ value_in_

std::vector<double> casadi::FmuInternal::value_in_
protectedinherited

◆ vn_aux_boolean_

std::vector<std::string> casadi::Fmu3::vn_aux_boolean_

Definition at line 89 of file fmu3.hpp.

Referenced by finalize(), Fmu3(), get_stats(), init(), init_mem(), and serialize_body().

◆ vn_aux_integer_

std::vector<std::string> casadi::Fmu3::vn_aux_integer_

Definition at line 89 of file fmu3.hpp.

Referenced by finalize(), Fmu3(), get_stats(), init(), init_mem(), and serialize_body().

◆ vn_aux_real_

std::vector<std::string> casadi::Fmu3::vn_aux_real_

Definition at line 89 of file fmu3.hpp.

Referenced by finalize(), Fmu3(), get_stats(), init(), init_mem(), and serialize_body().

◆ vn_aux_string_

std::vector<std::string> casadi::Fmu3::vn_aux_string_

Definition at line 89 of file fmu3.hpp.

Referenced by finalize(), Fmu3(), get_stats(), init(), init_mem(), and serialize_body().

◆ vn_in_

std::vector<std::string> casadi::FmuInternal::vn_in_
protectedinherited

◆ vn_out_

std::vector<std::string> casadi::FmuInternal::vn_out_
protectedinherited

◆ vr_aux_boolean_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_aux_boolean_

Definition at line 90 of file fmu3.hpp.

Referenced by Fmu3(), get_aux_impl(), init(), and serialize_body().

◆ vr_aux_integer_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_aux_integer_

Definition at line 90 of file fmu3.hpp.

Referenced by Fmu3(), get_aux_impl(), init(), and serialize_body().

◆ vr_aux_real_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_aux_real_

Definition at line 90 of file fmu3.hpp.

Referenced by Fmu3(), get_aux_impl(), init(), and serialize_body().

◆ vr_aux_string_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_aux_string_

Definition at line 90 of file fmu3.hpp.

Referenced by Fmu3(), get_aux_impl(), init(), and serialize_body().

◆ vr_boolean_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_boolean_

Definition at line 82 of file fmu3.hpp.

Referenced by Fmu3(), init(), serialize_body(), and set_values().

◆ vr_in_

std::vector<unsigned int> casadi::FmuInternal::vr_in_
protectedinherited

◆ vr_integer_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_integer_

Definition at line 82 of file fmu3.hpp.

Referenced by Fmu3(), init(), serialize_body(), and set_values().

◆ vr_out_

std::vector<unsigned int> casadi::FmuInternal::vr_out_
protectedinherited

◆ vr_real_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_real_

Definition at line 82 of file fmu3.hpp.

Referenced by Fmu3(), init(), serialize_body(), and set_values().

◆ vr_string_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_string_

Definition at line 82 of file fmu3.hpp.

Referenced by Fmu3(), init(), serialize_body(), and set_values().

◆ warning_fired_discrete_states_need_update_

bool casadi::FmuInternal::warning_fired_discrete_states_need_update_
mutableprotectedinherited

◆ warning_fired_next_event_time_defined_

bool casadi::FmuInternal::warning_fired_next_event_time_defined_
mutableprotectedinherited

◆ warning_fired_nominals_of_continuous_states_changed_

bool casadi::FmuInternal::warning_fired_nominals_of_continuous_states_changed_
mutableprotectedinherited

◆ warning_fired_terminate_simulation_

bool casadi::FmuInternal::warning_fired_terminate_simulation_
mutableprotectedinherited

◆ warning_fired_values_of_continuous_states_changed_

bool casadi::FmuInternal::warning_fired_values_of_continuous_states_changed_
mutableprotectedinherited

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