MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
ModuleFMU Class Reference

#include <module-FMU.h>

Inheritance diagram for ModuleFMU:
Collaboration diagram for ModuleFMU:

Public Member Functions

 ModuleFMU (unsigned uLabel, const DofOwner *pDO, DataManager *pDM, MBDynParser &HP)
 
virtual ~ModuleFMU (void)
 
virtual void Output (OutputHandler &OH) const
 
virtual void WorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
SubVectorHandlerAssRes (SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
unsigned int iGetNumPrivData (void) const
 
unsigned int iGetPrivDataIdx (const char *s) const
 
doublereal dGetPrivData (unsigned int i) const
 
int iGetNumConnectedNodes (void) const
 
void GetConnectedNodes (std::vector< const Node * > &connectedNodes) const
 
void SetValue (DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph)
 
std::ostream & Restart (std::ostream &out) const
 
virtual unsigned int iGetInitialNumDof (void) const
 
virtual void InitialWorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
VariableSubMatrixHandlerInitialAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
SubVectorHandlerInitialAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr)
 
unsigned int iGetNumDof (void) const
 
DofOrder::Order GetDofType (unsigned int i) const
 
DofOrder::Order GetEqType (unsigned int i) const
 
- Public Member Functions inherited from Elem
 Elem (unsigned int uL, flag fOut)
 
virtual ~Elem (void)
 
virtual std::ostream & DescribeDof (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeDof (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual std::ostream & DescribeEq (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeEq (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual void AssMats (VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual bool bInverseDynamics (void) const
 
void SetInverseDynamicsFlags (unsigned uIDF)
 
unsigned GetInverseDynamicsFlags (void) const
 
bool bIsErgonomy (void) const
 
bool bIsRightHandSide (void) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual SubVectorHandlerAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr, const VectorHandler &XPrimePrimeCurr, InverseDynamics::Order iOrder=InverseDynamics::INVERSE_DYNAMICS)
 
virtual int GetNumConnectedNodes (void) const
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 
- Public Member Functions inherited from SimulationEntity
 SimulationEntity (void)
 
virtual ~SimulationEntity (void)
 
virtual bool bIsValidIndex (unsigned int i) const
 
virtual HintParseHint (DataManager *pDM, const char *s) const
 
virtual void BeforePredict (VectorHandler &, VectorHandler &, VectorHandler &, VectorHandler &) const
 
virtual void AfterPredict (VectorHandler &X, VectorHandler &XP)
 
virtual void Update (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void DerivativesUpdate (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void Update (const VectorHandler &XCurr, InverseDynamics::Order iOrder)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP, const VectorHandler &XPP)
 
virtual std::ostream & OutputAppend (std::ostream &out) const
 
virtual void ReadInitialState (MBDynParser &HP)
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void OutputPrepare (OutputHandler &OH)
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from UserDefinedElem
 UserDefinedElem (unsigned uLabel, const DofOwner *pDO)
 
virtual ~UserDefinedElem (void)
 
bool NeedsAirProperties (void) const
 
void NeedsAirProperties (bool yesno)
 
virtual Elem::Type GetElemType (void) const
 
virtual AerodynamicElem::Type GetAerodynamicElemType (void) const
 
- Public Member Functions inherited from InitialAssemblyElem
 InitialAssemblyElem (unsigned int uL, flag fOut)
 
virtual ~InitialAssemblyElem (void)
 
- Public Member Functions inherited from SubjectToInitialAssembly
 SubjectToInitialAssembly (void)
 
virtual ~SubjectToInitialAssembly (void)
 
- Public Member Functions inherited from AerodynamicElem
 AerodynamicElem (unsigned int uL, const DofOwner *pDO, flag fOut)
 
virtual ~AerodynamicElem (void)
 
virtual const InducedVelocitypGetInducedVelocity (void) const
 
- Public Member Functions inherited from ElemWithDofs
 ElemWithDofs (unsigned int uL, const DofOwner *pDO, flag fOut)
 
virtual ~ElemWithDofs (void)
 
- Public Member Functions inherited from DofOwnerOwner
 DofOwnerOwner (const DofOwner *pDO)
 
virtual ~DofOwnerOwner ()
 
virtual const DofOwnerpGetDofOwner (void) const
 
virtual integer iGetFirstIndex (void) const
 
virtual void SetInitialValue (VectorHandler &X)
 
- Public Member Functions inherited from AirPropOwner
 AirPropOwner (void)
 
virtual ~AirPropOwner (void)
 
virtual void PutAirProperties (const AirProperties *pAP)
 
virtual flag fGetAirVelocity (Vec3 &Velocity, const Vec3 &X) const
 
virtual doublereal dGetAirDensity (const Vec3 &X) const
 
virtual doublereal dGetAirPressure (const Vec3 &X) const
 
virtual doublereal dGetAirTemperature (const Vec3 &X) const
 
virtual doublereal dGetSoundSpeed (const Vec3 &X) const
 
virtual bool GetAirProps (const Vec3 &X, doublereal &rho, doublereal &c, doublereal &p, doublereal &T) const
 
- Public Member Functions inherited from ElemGravityOwner
 ElemGravityOwner (unsigned int uL, flag fOut)
 
virtual ~ElemGravityOwner (void)
 
virtual doublereal dGetM (void) const
 
Vec3 GetS (void) const
 
Mat3x3 GetJ (void) const
 
Vec3 GetB (void) const
 
Vec3 GetG (void) const
 
- Public Member Functions inherited from GravityOwner
 GravityOwner (void)
 
virtual ~GravityOwner (void)
 
void PutGravity (const Gravity *pG)
 
virtual bool bGetGravity (const Vec3 &X, Vec3 &Acc) const
 

Public Attributes

fmu::SimulationTypes SIMTYPE
 

Private Types

typedef std::map< std::string,
const DriveCaller * > 
strDriveCon
 
typedef std::map< int, const
PrivDriveCaller * > 
intDriveCon
 

Private Attributes

fmumodel
 
char FMUlocation [1000]
 
const char * simType
 
double currTime
 
double initialTime
 
double timeStep
 
double endTime
 
fmi_import_context_t * context
 
fmi_version_enu_t version
 
jm_callbacks callbacks
 
jm_status_enu_t status
 
strDriveCon drivesContainer
 
intDriveCon privDrivesIndex
 
int numOfContinousStates
 
int numOfEventIndicators
 
DataManagerpDM
 
intstatesOrder
 
double * currState
 
double * stateDerivatives
 
intjacobianInputVector
 
boolprivDriveArray
 
int privDriveLength
 
bool directionalFlag
 
double * seedVector
 

Additional Inherited Members

- Public Types inherited from Elem
enum  Type {
  UNKNOWN = -1, AIRPROPERTIES = 0, INDUCEDVELOCITY, AUTOMATICSTRUCTURAL,
  GRAVITY, BODY, JOINT, JOINT_REGULARIZATION,
  BEAM, PLATE, FORCE, INERTIA,
  ELECTRICBULK, ELECTRIC, THERMAL, HYDRAULIC,
  BULK, LOADABLE, DRIVEN, EXTERNAL,
  AEROMODAL, AERODYNAMIC, GENEL, SOCKETSTREAM_OUTPUT,
  RTAI_OUTPUT = SOCKETSTREAM_OUTPUT, LASTELEMTYPE
}
 
- Public Types inherited from SimulationEntity
typedef std::vector< Hint * > Hints
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 
- Public Types inherited from AerodynamicElem
enum  Type {
  UNKNOWN = -1, INDUCEDVELOCITY = 0, AEROMODAL, AERODYNAMICBODY,
  AERODYNAMICBEAM, AERODYNAMICEXTERNAL, AERODYNAMICEXTERNALMODAL, AERODYNAMICLOADABLE,
  AIRCRAFTINSTRUMENTS, GENERICFORCE, LASTAEROTYPE
}
 
- Protected Member Functions inherited from ElemGravityOwner
virtual Vec3 GetS_int (void) const
 
virtual Mat3x3 GetJ_int (void) const
 
virtual Vec3 GetB_int (void) const
 
virtual Vec3 GetG_int (void) const
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 
- Protected Attributes inherited from UserDefinedElem
bool needsAirProperties
 
- Protected Attributes inherited from AirPropOwner
const AirPropertiespAirProperties
 
- Protected Attributes inherited from GravityOwner
GravitypGravity
 

Detailed Description

Definition at line 56 of file module-FMU.h.

Member Typedef Documentation

typedef std::map<int, const PrivDriveCaller*> ModuleFMU::intDriveCon
private

Definition at line 74 of file module-FMU.h.

typedef std::map<std::string, const DriveCaller *> ModuleFMU::strDriveCon
private

Definition at line 73 of file module-FMU.h.

Constructor & Destructor Documentation

ModuleFMU::ModuleFMU ( unsigned  uLabel,
const DofOwner pDO,
DataManager pDM,
MBDynParser HP 
)

Unzip the fmu

Get the version and context

SIMTYPE specific work

Definition at line 47 of file module-FMU.cc.

References callbacks, fmu::CheckInput(), context, fmu::COSIM, currState, currTime, Solver::dGetInitialTimeStep(), DataManager::dGetTime(), directionalFlag, drivesContainer, endTime, fmu::EventIndicatorInit(), fmi_zip_unzip(), FMUlocation, DataManager::fReadOutput(), MBDynParser::GetDriveCaller(), fmu::GetNumOfContinousStates(), fmu::GetNumOfEventIndicators(), HighParser::GetReal(), fmu::GetRefValueFromString(), DataManager::GetSolver(), HighParser::GetString(), HighParser::GetStringWithDelims(), fmu::IMPORT, fmu::ImportCreateDLL(), fmu::Initialize(), fmu::InitializeAsSlave(), initialTime, HighParser::IsArg(), HighParser::IsKeyWord(), HighParser::IsStringWithDelims(), jacobianInputVector, Elem::LOADABLE, MBDYN_EXCEPT_ARGS, model, numOfContinousStates, numOfEventIndicators, fmu::parseXML(), privDriveLength, privDrivesIndex, seedVector, fmu::setCallBackFunction(), ToBeOutput::SetOutputFlag(), setup_callbacks(), simType, SIMTYPE, stateDerivatives, status, fmu::SupportsDirectionalDerivatives(), timeStep, UncompressLocation(), and version.

50 : Elem(uLabel, flag(0)),
52 pDM(pDM)
53 {
54 /* Reading from the input file */
55  if (HP.IsKeyWord("help")) {
56  silent_cout("help text here" << std::endl);
57 
58  if (!HP.IsArg()) {
59  throw NoErr(MBDYN_EXCEPT_ARGS);
60  }
61  }
62 
63  strcpy(FMUlocation, HP.GetStringWithDelims());
64 
65  std::string UClocation;
66  UClocation = UncompressLocation(FMUlocation);
67 
68  if(HP.IsKeyWord("type")){
69  simType = HP.GetString();
70  if (!strcmp(simType, "cosimulation")){
72  }
73  else if (!strcmp(simType, "import")){
75  }
76  else {
77  silent_cout("Unsupported Simulation Type. "
78  "Available options:\n"
79  "cosimulation\n"
80  "import model\n"
81  "Exiting...");
82  }
83  } else {
84  silent_cerr("keyword \"type\" expected");
86  }
87 
88  double relativeTolerance;
89  if(HP.IsKeyWord("tolerance")){
90  relativeTolerance = HP.GetReal();
91  } else {
92  relativeTolerance = 0.001;
93  }
94 
95  while(HP.IsStringWithDelims()){
96  const char* temp = HP.GetStringWithDelims();
97  drivesContainer[temp] = HP.GetDriveCaller();
98  }
99 
101 /* End of reading from input file */
102 
103  if(SIMTYPE == fmu::COSIM){
104  silent_cout("Model defined as co-simulation.\n");
105  } else if ( SIMTYPE == fmu::IMPORT ){
106  silent_cout("Model defined as import.\n");
107  }
108 
110 
112  status = fmi_zip_unzip(FMUlocation, UClocation.c_str(), &callbacks);
113 
114  if(status==jm_status_error){
115  silent_cerr("Failed to uncompress FMU. Exiting\n");
117  }
118  else
119  silent_cout("FMU uncompressed successfully \n");
120 
122  context = fmi_import_allocate_context(&callbacks);
123  version = fmi_import_get_fmi_version(context, FMUlocation, UClocation.c_str());
124 
125  if(version == 1){
126  model = new fmu1(context, SIMTYPE);
127  } else if (version == 2){
128  model = new fmu2(context, SIMTYPE);
129  }
130 
131  silent_cout("Version "<<version<<"\n");
132  model->parseXML(context, UClocation.c_str());
135 
136  currTime = pDM->dGetTime();
138  endTime = (pDM->GetSolver())->dGetFinalTime();
139 
141 
143 
144  if(SIMTYPE == fmu::IMPORT){
145 
146  double dTol = pDM->GetSolver()->dGetTolerance();
147  model->Initialize(dTol, currTime, relativeTolerance);
151  currState = new double[numOfContinousStates];
153 
154 
155  } else if (SIMTYPE == fmu::COSIM ) {
156 
157  model->InitializeAsSlave(UClocation.c_str(), initialTime, endTime);
158  silent_cout("Initialized as slave\n");
160 
161  }
162 
164  jacobianInputVector = new int[drivesContainer.size()];
165  privDriveLength = 0;
166  int k = 0;
167 
168  for (strDriveCon::iterator i = drivesContainer.begin(); i != drivesContainer.end(); i++){
169 
170  if(!(model->CheckInput(i->first))){
171  silent_cout("Variable "<<i->first<<" is not of type input\n");
172  delete i->second;
173  drivesContainer.erase(i->first);
174  } else {
175  if (dynamic_cast<const PrivDriveCaller*>(i->second) != NULL){
177  privDrivesIndex[privDriveLength] = dynamic_cast<const PrivDriveCaller*>(i->second);
178  privDriveLength ++;
179  }
180  k++;
181  }
182 
183  if (drivesContainer.size() == 0){
184  silent_cout("No FMU input was defined in input file. \n");
185  break;
186  }
187  }
188 
189  if ( directionalFlag){
191  }
192 
193 }
flag fReadOutput(MBDynParser &HP, const T &t) const
Definition: dataman.h:1064
Definition: mbdynFMI.h:115
void setup_callbacks(jm_callbacks *callbacks)
virtual int GetNumOfEventIndicators(void)=0
virtual void InitializeAsSlave(const char *, double, double)=0
double endTime
Definition: module-FMU.h:65
long int flag
Definition: mbdyn.h:43
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
double * seedVector
Definition: module-FMU.h:90
doublereal dGetTime(void) const
Definition: dataman2.cc:165
fmu::SimulationTypes SIMTYPE
Definition: module-FMU.h:129
fmi_version_enu_t version
Definition: module-FMU.h:68
int numOfEventIndicators
Definition: module-FMU.h:79
char FMUlocation[1000]
Definition: module-FMU.h:60
jm_callbacks callbacks
Definition: module-FMU.h:70
double timeStep
Definition: module-FMU.h:64
double initialTime
Definition: module-FMU.h:63
virtual void EventIndicatorInit(void)=0
strDriveCon drivesContainer
Definition: module-FMU.h:75
DataManager * pDM
Definition: module-FMU.h:80
jm_status_enu_t status
Definition: module-FMU.h:71
virtual bool SupportsDirectionalDerivatives()=0
std::string UncompressLocation(const char *location)
double * currState
Definition: module-FMU.h:83
double currTime
Definition: module-FMU.h:62
virtual int GetRefValueFromString(const char *s)=0
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
virtual const char * GetStringWithDelims(enum Delims Del=DEFAULTDELIM, bool escape=true)
Definition: parser.cc:1228
unsigned int uLabel
Definition: withlab.h:44
jm_status_enu_t fmi_zip_unzip(const char *zip_file_path, const char *output_folder, jm_callbacks *callbacks)
Uncompress a zip file.
virtual void ImportCreateDLL(void)=0
Definition: except.h:79
fmu * model
Definition: module-FMU.h:59
virtual void Initialize(double dTol, double time, double rTol)=0
virtual std::string GetString(const std::string &sDefVal)
Definition: parser.cc:1074
fmi_import_context_t * context
Definition: module-FMU.h:67
int numOfContinousStates
Definition: module-FMU.h:78
virtual bool IsArg(void)
Definition: parser.cc:807
virtual bool IsStringWithDelims(enum Delims Del=DEFAULTDELIM)
Definition: parser.cc:1210
int privDriveLength
Definition: module-FMU.h:87
intDriveCon privDrivesIndex
Definition: module-FMU.h:76
Definition: mbdynFMI.h:179
UserDefinedElem(unsigned uLabel, const DofOwner *pDO)
Definition: userelem.cc:152
const Solver * GetSolver(void) const
Definition: dataman.h:343
const char * simType
Definition: module-FMU.h:61
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
virtual bool CheckInput(const std::string)=0
virtual void SetOutputFlag(flag f=flag(1))
Definition: output.cc:896
virtual void parseXML(fmi_import_context_t *context, const char *dirPath)=0
Elem(unsigned int uL, flag fOut)
Definition: elem.cc:41
virtual void setCallBackFunction()=0
virtual doublereal dGetInitialTimeStep(void) const
Definition: solver.h:417
virtual int GetNumOfContinousStates(void)=0
int * jacobianInputVector
Definition: module-FMU.h:85
bool directionalFlag
Definition: module-FMU.h:89
double * stateDerivatives
Definition: module-FMU.h:84
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function:

ModuleFMU::~ModuleFMU ( void  )
virtual

Definition at line 195 of file module-FMU.cc.

References currState, directionalFlag, drivesContainer, fmu::IMPORT, jacobianInputVector, model, numOfContinousStates, seedVector, SIMTYPE, and stateDerivatives.

196 {
197  delete model;
198 
199  if(directionalFlag){
200  delete[] seedVector;
201  }
202 
203  delete[] jacobianInputVector;
204 
206  delete[] currState;
207  delete[] stateDerivatives;
208  }
209 
210  for (strDriveCon::iterator i = drivesContainer.begin(); i != drivesContainer.end(); i++){
211  delete (i->second);
212  drivesContainer.erase(i);
213  }
214 }
double * seedVector
Definition: module-FMU.h:90
fmu::SimulationTypes SIMTYPE
Definition: module-FMU.h:129
strDriveCon drivesContainer
Definition: module-FMU.h:75
double * currState
Definition: module-FMU.h:83
fmu * model
Definition: module-FMU.h:59
int numOfContinousStates
Definition: module-FMU.h:78
int * jacobianInputVector
Definition: module-FMU.h:85
bool directionalFlag
Definition: module-FMU.h:89
double * stateDerivatives
Definition: module-FMU.h:84

Member Function Documentation

VariableSubMatrixHandler & ModuleFMU::AssJac ( VariableSubMatrixHandler WorkMat,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 254 of file module-FMU.cc.

References currState, FullMatrixHandler::dGetCoef(), DofOrder::DIFFERENTIAL, directionalFlag, fmu::GetDirectionalDerivatives(), GetDofType(), DofOwnerOwner::iGetFirstIndex(), fmu::IMPORT, FullSubMatrixHandler::IncCoef(), jacobianInputVector, model, numOfContinousStates, privDriveLength, privDrivesIndex, FullSubMatrixHandler::PutColIndex(), FullSubMatrixHandler::PutRowIndex(), FullMatrixHandler::Reset(), FullMatrixHandler::Resize(), FullSubMatrixHandler::ResizeReset(), seedVector, VariableSubMatrixHandler::SetFull(), VariableSubMatrixHandler::SetNullMatrix(), and SIMTYPE.

258 {
259  WorkMat.SetNullMatrix();
260 #ifdef DEBUG
261  silent_cout(__func__);
262 #endif
263 
265  FullSubMatrixHandler &WM = WorkMat.SetFull();
266 
268  integer iFirstIndex = iGetFirstIndex();
269  {
270  int i = 1;
271  for ( i=1; i<=numOfContinousStates ; i++){
272  WM.PutRowIndex(i, iFirstIndex + i);
273  WM.PutColIndex(i, iFirstIndex + i);
274  }
275 
276  for (int j = 0; j <privDriveLength; j++){
277  WM.PutColIndex(i, privDrivesIndex[j]->iGetIndex()+1);
278  i++;
279  }
280  }
281 
282  if (directionalFlag){
283  FullMatrixHandler jacobian;
284  jacobian.Resize(numOfContinousStates,numOfContinousStates + privDriveLength);
285  jacobian.Reset();
286 
287 
288  for (int i=0; i<numOfContinousStates; i++){
289  seedVector[i] = currState[i];
290  }
291 
292  for (int i=0; i<privDriveLength; i++){
294  }
295 
296  model->GetDirectionalDerivatives(&jacobian, jacobianInputVector, privDriveLength, seedVector);
297  for (int i=1; i<=numOfContinousStates; i++){
298  WM.IncCoef(i, i, 1);
299  for(int j=1; j<=numOfContinousStates; j++){
300  WM.IncCoef(i, j, -dCoef*jacobian.dGetCoef(i, j));
301  }
302 
303  for(int j=numOfContinousStates+1; j<=numOfContinousStates + privDriveLength; j++){
304  if(privDrivesIndex[j-numOfContinousStates]->iGetSE()->
305  GetDofType(privDrivesIndex[i-numOfContinousStates]->iGetIndex()+1)
307  WM.IncCoef(i, j, -dCoef*jacobian.dGetCoef(i, j));
308  else
309  WM.IncCoef(i, j, -jacobian.dGetCoef(i, j));
310  }
311  }
312 
313  } else {
314  for(int i=1; i<=numOfContinousStates; i++){
315  WM.IncCoef(i, i, 1.);
316  }
317  }
318  }
319 
320  return WorkMat;
321 }
void PutColIndex(integer iSubCol, integer iCol)
Definition: submat.h:325
double * seedVector
Definition: module-FMU.h:90
FullSubMatrixHandler & SetFull(void)
Definition: submat.h:1168
DofOrder::Order GetDofType(unsigned int i) const
Definition: module-FMU.cc:452
fmu::SimulationTypes SIMTYPE
Definition: module-FMU.h:129
virtual void GetDirectionalDerivatives(FullMatrixHandler *, int *, int, double *)=0
virtual void Resize(integer iNewRows, integer iNewCols)
Definition: fullmh.cc:174
void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:683
virtual const doublereal & dGetCoef(integer iRow, integer iCol) const
Definition: fullmh.h:214
double * currState
Definition: module-FMU.h:83
void SetNullMatrix(void)
Definition: submat.h:1159
virtual void ResizeReset(integer, integer)
Definition: submat.cc:182
fmu * model
Definition: module-FMU.h:59
int numOfContinousStates
Definition: module-FMU.h:78
void PutRowIndex(integer iSubRow, integer iRow)
Definition: submat.h:311
int privDriveLength
Definition: module-FMU.h:87
intDriveCon privDrivesIndex
Definition: module-FMU.h:76
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
long int integer
Definition: colamd.c:51
void Reset(void)
Definition: fullmh.cc:44
int * jacobianInputVector
Definition: module-FMU.h:85
bool directionalFlag
Definition: module-FMU.h:89

Here is the call graph for this function:

SubVectorHandler & ModuleFMU::AssRes ( SubVectorHandler WorkVec,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 324 of file module-FMU.cc.

References fmu::COSIM, fmu::CSPropogate(), currState, currTime, DataManager::dGetTime(), drivesContainer, fmu::GetStateDerivatives(), DofOwnerOwner::iGetFirstIndex(), fmu::IMPORT, model, numOfContinousStates, pDM, VectorHandler::PutCoef(), SubVectorHandler::PutRowIndex(), VectorHandler::ResizeReset(), fmu::SetStates(), fmu::SetTime(), fmu::SetValuesByVariable(), SIMTYPE, stateDerivatives, and timeStep.

328 {
329 
330  WorkVec.ResizeReset(0);
331 #ifdef DEBUG
332  silent_cout(__func__);
333 #endif
334  for (strDriveCon::iterator i = drivesContainer.begin(); i != drivesContainer.end(); i++){
335  model->SetValuesByVariable(i->first, (i->second)->dGet());
336  }
337 
338  if(SIMTYPE == fmu::IMPORT){
340  if (currTime != pDM->dGetTime()){
341 
342  currTime = pDM->dGetTime();
343 
344  int iFirstIndex = iGetFirstIndex();
345 
346  //Get Current States
347  for (int i=0; i<numOfContinousStates; i++){
348  currState[i] = XCurr(iFirstIndex + i + 1);
349  }
350 
353 // model->CheckInterrupts(currTime);
354 
356  }
357 
358  //Get Index of the elements
359  integer iFirstIndex = iGetFirstIndex();
360 
361  //Set Index to WorkVec
362  for (int i=1; i<=numOfContinousStates; i++){
363  WorkVec.PutRowIndex(i, iFirstIndex + i);
364  }
365 
366  //Set WorkVec with the difference in the XPrimCurr - FMUDerivative
367  for (int i=1; i<=numOfContinousStates; i++){
368  WorkVec.PutCoef(i, (stateDerivatives[i-1] - XPrimeCurr(i + iFirstIndex)));
369  }
370  }
371 
372  if (SIMTYPE==fmu::COSIM){
374  }
375 
376  return WorkVec;
377 }
virtual void SetValuesByVariable(const std::string, double)=0
virtual void GetStateDerivatives(double *)=0
virtual void ResizeReset(integer)
Definition: vh.cc:55
virtual void CSPropogate(double tcur, double dt)=0
doublereal dGetTime(void) const
Definition: dataman2.cc:165
fmu::SimulationTypes SIMTYPE
Definition: module-FMU.h:129
double timeStep
Definition: module-FMU.h:64
virtual void SetTime(double time)=0
strDriveCon drivesContainer
Definition: module-FMU.h:75
DataManager * pDM
Definition: module-FMU.h:80
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
double * currState
Definition: module-FMU.h:83
double currTime
Definition: module-FMU.h:62
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
fmu * model
Definition: module-FMU.h:59
int numOfContinousStates
Definition: module-FMU.h:78
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
long int integer
Definition: colamd.c:51
virtual void SetStates(double *states)=0
double * stateDerivatives
Definition: module-FMU.h:84

Here is the call graph for this function:

doublereal ModuleFMU::dGetPrivData ( unsigned int  i) const
virtual

Reimplemented from SimulationEntity.

Definition at line 401 of file module-FMU.cc.

References fmu::GetStateFromRefValue(), and model.

402 {
403  return model->GetStateFromRefValue(i-1);
404 }
virtual double GetStateFromRefValue(unsigned int i)=0
fmu * model
Definition: module-FMU.h:59

Here is the call graph for this function:

void ModuleFMU::GetConnectedNodes ( std::vector< const Node * > &  connectedNodes) const
virtual

Reimplemented from Elem.

Definition at line 413 of file module-FMU.cc.

References NO_OP.

414 {
415  NO_OP;
416 }
#define NO_OP
Definition: myassert.h:74
DofOrder::Order ModuleFMU::GetDofType ( unsigned int  i) const
virtual

Reimplemented from Elem.

Definition at line 452 of file module-FMU.cc.

References DofOrder::DIFFERENTIAL.

Referenced by AssJac().

453 {
454  return DofOrder::DIFFERENTIAL;
455 }
DofOrder::Order ModuleFMU::GetEqType ( unsigned int  i) const
virtual

Reimplemented from SimulationEntity.

Definition at line 233 of file module-FMU.cc.

References DofOrder::DIFFERENTIAL.

234 {
235  return DofOrder::DIFFERENTIAL;
236 }
unsigned int ModuleFMU::iGetInitialNumDof ( void  ) const
virtual

Implements SubjectToInitialAssembly.

Definition at line 459 of file module-FMU.cc.

460 {
461  return 0;
462 }
int ModuleFMU::iGetNumConnectedNodes ( void  ) const

Definition at line 407 of file module-FMU.cc.

408 {
409  return 0;
410 }
unsigned int ModuleFMU::iGetNumDof ( void  ) const
virtual

Reimplemented from Elem.

Definition at line 442 of file module-FMU.cc.

References fmu::IMPORT, numOfContinousStates, and SIMTYPE.

443 {
444  if (SIMTYPE == fmu::IMPORT){
445  return numOfContinousStates;
446  }
447  // the only other possibility is fmu::COSIM, with 0 Dofs
448  return 0;
449 }
fmu::SimulationTypes SIMTYPE
Definition: module-FMU.h:129
int numOfContinousStates
Definition: module-FMU.h:78
unsigned int ModuleFMU::iGetNumPrivData ( void  ) const
virtual

Reimplemented from SimulationEntity.

Definition at line 380 of file module-FMU.cc.

References fmu::GetNumOfVar(), and model.

381 {
382  return model->GetNumOfVar();
383 }
fmu * model
Definition: module-FMU.h:59
virtual int GetNumOfVar(void)=0

Here is the call graph for this function:

unsigned int ModuleFMU::iGetPrivDataIdx ( const char *  s) const
virtual

Reimplemented from SimulationEntity.

Definition at line 386 of file module-FMU.cc.

References fmu::GetRefValueFromString(), and model.

387 {
388  unsigned int idx = 0;
389 
390 #ifdef DEBUG
391  silent_cout(__func__);
392 #endif
393 
394  idx = model->GetRefValueFromString(s);
395  idx = idx + 1;
396 
397  return idx;
398 }
virtual int GetRefValueFromString(const char *s)=0
fmu * model
Definition: module-FMU.h:59

Here is the call graph for this function:

VariableSubMatrixHandler & ModuleFMU::InitialAssJac ( VariableSubMatrixHandler WorkMat,
const VectorHandler XCurr 
)
virtual

Implements SubjectToInitialAssembly.

Definition at line 475 of file module-FMU.cc.

References ASSERT, and VariableSubMatrixHandler::SetNullMatrix().

478 {
479  // should not be called, since initial workspace is empty
480  ASSERT(0);
481 
482  WorkMat.SetNullMatrix();
483 
484  return WorkMat;
485 }
void SetNullMatrix(void)
Definition: submat.h:1159
#define ASSERT(expression)
Definition: colamd.c:977

Here is the call graph for this function:

SubVectorHandler & ModuleFMU::InitialAssRes ( SubVectorHandler WorkVec,
const VectorHandler XCurr 
)
virtual

Implements SubjectToInitialAssembly.

Definition at line 488 of file module-FMU.cc.

References ASSERT, and VectorHandler::ResizeReset().

491 {
492  // should not be called, since initial workspace is empty
493  ASSERT(0);
494 
495  WorkVec.ResizeReset(0);
496 
497  return WorkVec;
498 }
virtual void ResizeReset(integer)
Definition: vh.cc:55
#define ASSERT(expression)
Definition: colamd.c:977

Here is the call graph for this function:

void ModuleFMU::InitialWorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements SubjectToInitialAssembly.

Definition at line 465 of file module-FMU.cc.

468 {
469  *piNumRows = 0;
470  *piNumCols = 0;
471 
472 }
void ModuleFMU::Output ( OutputHandler OH) const
virtual

Reimplemented from ToBeOutput.

Definition at line 218 of file module-FMU.cc.

References ToBeOutput::bToBeOutput(), currState, OutputHandler::Loadable(), and numOfContinousStates.

219 {
220  if (bToBeOutput()) {
221  std::ostream& out = OH.Loadable();
222 
223  for(int i = 0; i < numOfContinousStates; ++i){
224  out << std::setw(4) << currState[i] << " ";
225  }
226 
227  out<<std::endl;
228  }
229 }
virtual bool bToBeOutput(void) const
Definition: output.cc:890
double * currState
Definition: module-FMU.h:83
std::ostream & Loadable(void) const
Definition: output.h:506
int numOfContinousStates
Definition: module-FMU.h:78

Here is the call graph for this function:

std::ostream & ModuleFMU::Restart ( std::ostream &  out) const
virtual

Implements Elem.

Definition at line 436 of file module-FMU.cc.

437 {
438  return out << "# ModuleFMU: not implemented" << std::endl;
439 }
void ModuleFMU::SetValue ( DataManager pDM,
VectorHandler X,
VectorHandler XP,
SimulationEntity::Hints ph 
)
virtual

Reimplemented from SimulationEntity.

Definition at line 419 of file module-FMU.cc.

References currState, fmu::GetStateDerivatives(), fmu::GetStates(), DofOwnerOwner::iGetFirstIndex(), fmu::IMPORT, model, numOfContinousStates, SIMTYPE, and stateDerivatives.

422 {
423 
424  if(SIMTYPE == fmu::IMPORT){
427  for (int i=0; i<numOfContinousStates; i++){
428  X(iGetFirstIndex() + i + 1) = currState[i];
429  XP(iGetFirstIndex() + i + 1) = stateDerivatives[i];
430  }
431  }
432 
433 }
virtual void GetStateDerivatives(double *)=0
virtual void GetStates(double *)=0
fmu::SimulationTypes SIMTYPE
Definition: module-FMU.h:129
double * currState
Definition: module-FMU.h:83
fmu * model
Definition: module-FMU.h:59
int numOfContinousStates
Definition: module-FMU.h:78
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double * stateDerivatives
Definition: module-FMU.h:84

Here is the call graph for this function:

void ModuleFMU::WorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements Elem.

Definition at line 241 of file module-FMU.cc.

References fmu::IMPORT, numOfContinousStates, privDriveLength, and SIMTYPE.

242 {
243  if(SIMTYPE == fmu::IMPORT){
244  *piNumRows = numOfContinousStates;
245  *piNumCols = numOfContinousStates + privDriveLength;
246  } else {
247  *piNumCols = 0;
248  *piNumRows = 0;
249  }
250 }
fmu::SimulationTypes SIMTYPE
Definition: module-FMU.h:129
int numOfContinousStates
Definition: module-FMU.h:78
int privDriveLength
Definition: module-FMU.h:87

Member Data Documentation

jm_callbacks ModuleFMU::callbacks
private

Definition at line 70 of file module-FMU.h.

Referenced by ModuleFMU().

fmi_import_context_t* ModuleFMU::context
private

Definition at line 67 of file module-FMU.h.

Referenced by ModuleFMU().

double* ModuleFMU::currState
private

Definition at line 83 of file module-FMU.h.

Referenced by AssJac(), AssRes(), ModuleFMU(), Output(), SetValue(), and ~ModuleFMU().

double ModuleFMU::currTime
private

Definition at line 62 of file module-FMU.h.

Referenced by AssRes(), and ModuleFMU().

bool ModuleFMU::directionalFlag
private

Definition at line 89 of file module-FMU.h.

Referenced by AssJac(), ModuleFMU(), and ~ModuleFMU().

strDriveCon ModuleFMU::drivesContainer
private

Definition at line 75 of file module-FMU.h.

Referenced by AssRes(), ModuleFMU(), and ~ModuleFMU().

double ModuleFMU::endTime
private

Definition at line 65 of file module-FMU.h.

Referenced by ModuleFMU().

char ModuleFMU::FMUlocation[1000]
private

Definition at line 60 of file module-FMU.h.

Referenced by ModuleFMU().

double ModuleFMU::initialTime
private

Definition at line 63 of file module-FMU.h.

Referenced by ModuleFMU().

int* ModuleFMU::jacobianInputVector
private

Definition at line 85 of file module-FMU.h.

Referenced by AssJac(), ModuleFMU(), and ~ModuleFMU().

fmu* ModuleFMU::model
private
int ModuleFMU::numOfContinousStates
private

Definition at line 78 of file module-FMU.h.

Referenced by AssJac(), AssRes(), iGetNumDof(), ModuleFMU(), Output(), SetValue(), WorkSpaceDim(), and ~ModuleFMU().

int ModuleFMU::numOfEventIndicators
private

Definition at line 79 of file module-FMU.h.

Referenced by ModuleFMU().

DataManager* ModuleFMU::pDM
private

Definition at line 80 of file module-FMU.h.

Referenced by AssRes().

bool* ModuleFMU::privDriveArray
private

Definition at line 86 of file module-FMU.h.

int ModuleFMU::privDriveLength
private

Definition at line 87 of file module-FMU.h.

Referenced by AssJac(), ModuleFMU(), and WorkSpaceDim().

intDriveCon ModuleFMU::privDrivesIndex
private

Definition at line 76 of file module-FMU.h.

Referenced by AssJac(), and ModuleFMU().

double* ModuleFMU::seedVector
private

Definition at line 90 of file module-FMU.h.

Referenced by AssJac(), ModuleFMU(), and ~ModuleFMU().

const char* ModuleFMU::simType
private

Definition at line 61 of file module-FMU.h.

Referenced by ModuleFMU().

fmu::SimulationTypes ModuleFMU::SIMTYPE

Definition at line 129 of file module-FMU.h.

Referenced by AssJac(), AssRes(), iGetNumDof(), ModuleFMU(), SetValue(), WorkSpaceDim(), and ~ModuleFMU().

double* ModuleFMU::stateDerivatives
private

Definition at line 84 of file module-FMU.h.

Referenced by AssRes(), ModuleFMU(), SetValue(), and ~ModuleFMU().

int* ModuleFMU::statesOrder
private

Definition at line 82 of file module-FMU.h.

jm_status_enu_t ModuleFMU::status
private

Definition at line 71 of file module-FMU.h.

Referenced by ModuleFMU().

double ModuleFMU::timeStep
private

Definition at line 64 of file module-FMU.h.

Referenced by AssRes(), and ModuleFMU().

fmi_version_enu_t ModuleFMU::version
private

Definition at line 68 of file module-FMU.h.

Referenced by ModuleFMU().


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