ConOpSys V2970  P004.07
ANVILEX control operating system
rtw_solver.h
Go to the documentation of this file.
1 /*
2  * File: rtw_solver.h
3  *
4  * Abstract:
5  * Type definitions for continuous-time solver support.
6  *
7  */
8 
9 /* Copyright 1990-2017 The MathWorks, Inc. */
10 
11 #ifndef RTW_SOLVER_H__
12 #define RTW_SOLVER_H__
13 
14 #include "rtw_continuous.h"
15 
16 /* =============================================================================
17  * Solver object
18  * =============================================================================
19  */
20 #ifndef NO_FLOATS /* ERT integer-only */
21 /*
22  * Enum for solver tolerance
23  */
24 typedef enum {
25  SL_SOLVER_TOLERANCE_AUTO = 0, /* Set Automatically by Solver */
26  SL_SOLVER_TOLERANCE_LOCAL = 1, /* Set Locally, e.g., by Blocks */
27  SL_SOLVER_TOLERANCE_GLOBAL = 2, /* Set Globally, e.g., by Block Diagram */
28  SL_SOLVER_TOLERANCE_UNDEFINED = 255 /* Signal uninitialized */
30 
31 
32 /*
33  * Enum for jacobian method control
34  */
35 typedef enum {
42 
43 
44 typedef struct _ssSolverInfo_tag {
45  void *rtModelPtr;
46 
48  void *solverData;
49  const char_T *solverName;
53 
59 
66 
69 
73 
74  real_T **dXPtr;
75  time_T **tPtr;
76 
79 
83 
89 
94 
96 
98  boolean_T robustResetMethod; /* user's preference */
99  boolean_T updateJacobianAtReset; /* S-Fcn request (sticky) */
101 
107 
108  const char_T **errStatusPtr;
109 
121 
122 /* Support old name RTWSolverInfo */
124 
125 #define rtsiSetRTModelPtr(S,rtmp) ((S)->rtModelPtr = (rtmp))
126 #define rtsiGetRTModelPtr(S) (S)->rtModelPtr
127 
128 #define rtsiSetSimTimeStepPtr(S,stp) ((S)->simTimeStepPtr = (stp))
129 #define rtsiGetSimTimeStepPtr(S) ((S)->simTimeStepPtr)
130 #define rtsiGetSimTimeStep(S) *((S)->simTimeStepPtr)
131 #define rtsiSetSimTimeStep(S,st) (*((S)->simTimeStepPtr) = (st))
132 
133 #define rtsiSetSolverData(S,sd) ((S)->solverData = (sd))
134 #define rtsiGetSolverData(S) (S)->solverData
135 
136 #define rtsiSetSolverName(S,sn) ((S)->solverName = (sn))
137 #define rtsiGetSolverName(S) (S)->solverName
138 
139 #define rtsiSetVariableStepSolver(S,vs) ((S)->isVariableStepSolver = (vs))
140 #define rtsiIsVariableStepSolver(S) (S)->isVariableStepSolver
141 
142 #define rtsiSetSolverNeedsReset(S,sn) ((S)->solverNeedsReset = (sn))
143 #define rtsiGetSolverNeedsReset(S) (S)->solverNeedsReset
144 
145 #define rtsiSetContTimeOutputInconsistentWithStateAtMajorStep(S,sn) ((S)->CTOutputIncnstWithState = (sn))
146 #define rtsiGetContTimeOutputInconsistentWithStateAtMajorStep(S) (S)->CTOutputIncnstWithState
147 
148 #define rtsiSetBlkStateChange(S,sn) ((S)->CTOutputIncnstWithState = (sn))
149 #define rtsiGetBlkStateChange(S) (S)->CTOutputIncnstWithState
150 
151 #define rtsiSetBlockStateForSolverChangedAtMajorStep(S,sn) ((S)->solverNeedsReset = (sn))
152 #define rtsiGetBlockStateForSolverChangedAtMajorStep(S) (S)->solverNeedsReset
153 
154 #define rtsiSetSolverMode(S,sm) ((S)->solverMode = (sm))
155 #define rtsiGetSolverMode(S) (S)->solverMode
156 
157 #define rtsiSetSolverStopTime(S,st) ((S)->solverStopTime = (st))
158 #define rtsiGetSolverStopTime(S) (S)->solverStopTime
159 
160 #define rtsiSetStepSizePtr(S,ssp) ((S)->stepSizePtr = (ssp))
161 #define rtsiSetStepSize(S,ss) (*((S)->stepSizePtr) = (ss))
162 #define rtsiGetStepSize(S) *((S)->stepSizePtr)
163 
164 #define rtsiSetMinStepSize(S,ss) (((S)->minStepSize = (ss)))
165 #define rtsiGetMinStepSize(S) (S)->minStepSize
166 
167 #define rtsiSetMaxStepSize(S,ss) ((S)->maxStepSize = (ss))
168 #define rtsiGetMaxStepSize(S) (S)->maxStepSize
169 
170 #define rtsiSetFixedStepSize(S,ss) ((S)->fixedStepSize = (ss))
171 #define rtsiGetFixedStepSize(S) (S)->fixedStepSize
172 
173 #define rtsiSetMaxNumMinSteps(S,mns) ((S)->maxNumMinSteps = (mns))
174 #define rtsiGetMaxNumMinSteps(S) (S)->maxNumMinSteps
175 
176 #define rtsiSetSolverMaxOrder(S,smo) ((S)->solverMaxOrder = (smo))
177 #define rtsiGetSolverMaxOrder(S) (S)->solverMaxOrder
178 
179 #define rtsiSetSolverJacobianMethodControl(S,smcm) (ssGetSolverInfo(S)->solverJacobianMethodControl = (smcm))
180 #define rtsiGetSolverJacobianMethodControl(S) ssGetSolverInfo(S)->solverJacobianMethodControl
181 
182 #define rtsiSetSolverShapePreserveControl(S,smcm) (ssGetSolverInfo(S)->solverShapePreserveControl = (smcm))
183 #define rtsiGetSolverShapePreserveControl(S) ssGetSolverInfo(S)->solverShapePreserveControl
184 
185 #define rtsiSetSolverConsecutiveZCsStepRelTol(S,scr) (ssGetSolverInfo(S)->solverConsecutiveZCsStepRelTol = (scr))
186 #define rtsiGetSolverConsecutiveZCsStepRelTol(S) ssGetSolverInfo(S)->solverConsecutiveZCsStepRelTol
187 
188 #define rtsiSetSolverMaxConsecutiveZCs(S,smcz) (ssGetSolverInfo(S)->solverMaxConsecutiveZCs = (smcz))
189 #define rtsiGetSolverMaxConsecutiveZCs(S) ssGetSolverInfo(S)->solverMaxConsecutiveZCs
190 
191 #define rtsiSetSolverMaxConsecutiveMinStep(S,smcm) (ssGetSolverInfo(S)->solverMaxConsecutiveMinStep = (smcm))
192 #define rtsiGetSolverMaxConsecutiveMinStep(S) ssGetSolverInfo(S)->solverMaxConsecutiveMinStep
193 
194 #define rtsiSetSolverExtrapolationOrder(S,seo) ((S)->solverExtrapolationOrder = (seo))
195 #define rtsiGetSolverExtrapolationOrder(S) (S)->solverExtrapolationOrder
196 
197 #define rtsiSetSolverNumberNewtonIterations(S,nni) ((S)->solverNumberNewtonIterations = (nni))
198 #define rtsiGetSolverNumberNewtonIterations(S) (S)->solverNumberNewtonIterations
199 
200 #define rtsiSetSolverRefineFactor(S,smo) ((S)->solverRefineFactor = (smo))
201 #define rtsiGetSolverRefineFactor(S) (S)->solverRefineFactor
202 
203 #define rtsiSetSolverRelTol(S,smo) ((S)->solverRelTol = (smo))
204 #define rtsiGetSolverRelTol(S) (S)->solverRelTol
205 
206 #define rtsiSetSolverMassMatrixType(S,type) ((S)->massMatrixType = (type))
207 #define rtsiGetSolverMassMatrixType(S) (S)->massMatrixType
208 
209 #define rtsiSetSolverMassMatrixNzMax(S,nzMax) ((S)->massMatrixNzMax = (nzMax))
210 #define rtsiGetSolverMassMatrixNzMax(S) (S)->massMatrixNzMax
211 
212 #define rtsiSetSolverMassMatrixIr(S,ir) ((S)->massMatrixIr = (ir))
213 #define rtsiGetSolverMassMatrixIr(S) (S)->massMatrixIr
214 
215 #define rtsiSetSolverMassMatrixJc(S,jc) ((S)->massMatrixJc = (jc))
216 #define rtsiGetSolverMassMatrixJc(S) (S)->massMatrixJc
217 
218 #define rtsiSetSolverMassMatrixPr(S,pr) ((S)->massMatrixPr = (pr))
219 #define rtsiGetSolverMassMatrixPr(S) (S)->massMatrixPr
220 
221 #define rtsiSetdXPtr(S,dxp) ((S)->dXPtr = (dxp))
222 #define rtsiSetdX(S,dx) (*((S)->dXPtr) = (dx))
223 #define rtsiGetdX(S) *((S)->dXPtr)
224 
225 #define rtsiSetTPtr(S,tp) ((S)->tPtr = (tp))
226 #define rtsiSetT(S,t) ((*((S)->tPtr))[0] = (t))
227 #define rtsiGetT(S) (*((S)->tPtr))[0]
228 
229 #define rtsiSetContStatesPtr(S,cp) ((S)->contStatesPtr = (cp))
230 #define rtsiGetContStates(S) *((S)->contStatesPtr)
231 
232 #define rtsiSetNumContStatesPtr(S,cp) ((S)->numContStatesPtr = (cp))
233 #define rtsiGetNumContStates(S) *((S)->numContStatesPtr)
234 
235 #define rtsiSetNumPeriodicContStatesPtr(S,cp) ((S)->numPeriodicContStatesPtr = (cp))
236 #define rtsiGetNumPeriodicContStates(S) *((S)->numPeriodicContStatesPtr)
237 
238 #define rtsiSetPeriodicContStateIndicesPtr(S,cp) ((S)->periodicContStateIndicesPtr = (cp))
239 #define rtsiGetPeriodicContStateIndices(S) *((S)->periodicContStateIndicesPtr)
240 
241 #define rtsiSetPeriodicContStateRangesPtr(S,cp) ((S)->periodicContStateRangesPtr = (cp))
242 #define rtsiGetPeriodicContStateRanges(S) *((S)->periodicContStateRangesPtr)
243 
244 #define rtsiSetErrorStatusPtr(S,esp) ((S)->errStatusPtr = (esp))
245 #define rtsiSetErrorStatus(S,es) (*((S)->errStatusPtr) = (es))
246 #define rtsiGetErrorStatus(S) *((S)->errStatusPtr)
247 
248 #define rtsiSetModelMethodsPtr(S,mmp) ((S)->modelMethodsPtr = (mmp))
249 #define rtsiGetModelMethodsPtr(S) (S)->modelMethodsPtr
250 
251 #define rtsiSetSolverComputingJacobian(S,val) ((S)->isComputingJacobian = (val))
252 #define rtsiIsSolverComputingJacobian(S) (S)->isComputingJacobian
253 
254 #define rtsiSetSolverOutputComputed(S,val) ((S)->isOutputMethodComputed = (val))
255 #define rtsiIsSolverOutputComputed(S) (S)->isOutputMethodComputed
256 
257 #endif /* !NO_FLOATS */
258 
259 #endif /* RTW_SOLVER_H__ */
ssMatrixType
Definition: rtw_continuous.h:21
SimTimeStep
Definition: rtw_continuous.h:35
SolverMode
Definition: rtw_continuous.h:28
ssSolverInfo RTWSolverInfo
Definition: rtw_solver.h:123
SL_SolverToleranceControlFlag_T
Definition: rtw_solver.h:24
@ SL_SOLVER_TOLERANCE_AUTO
Definition: rtw_solver.h:25
@ SL_SOLVER_TOLERANCE_LOCAL
Definition: rtw_solver.h:26
@ SL_SOLVER_TOLERANCE_GLOBAL
Definition: rtw_solver.h:27
@ SL_SOLVER_TOLERANCE_UNDEFINED
Definition: rtw_solver.h:28
struct _ssSolverInfo_tag ssSolverInfo
slJmBdControl
Definition: rtw_solver.h:35
@ SL_JM_BD_SPARSE_PERTURBATION
Definition: rtw_solver.h:37
@ SL_JM_BD_AUTO
Definition: rtw_solver.h:36
@ SL_JM_BD_FULL_PERTURBATION
Definition: rtw_solver.h:38
@ SL_JM_BD_SPARSE_ANALYTICAL
Definition: rtw_solver.h:39
@ SL_JM_BD_FULL_ANALYTICAL
Definition: rtw_solver.h:40
char char_T
Definition: rtwtypes.h:71
unsigned char uint8_T
Definition: rtwtypes.h:50
double real_T
Definition: rtwtypes.h:64
unsigned char boolean_T
Definition: rtwtypes.h:66
double time_T
Definition: rtwtypes.h:65
int int_T
Definition: rtwtypes.h:67
Definition: rtw_continuous.h:62
Definition: rtw_solver.h:44
boolean_T isAtLeftPostOfContZcEvent
Definition: rtw_solver.h:91
uint8_T * zcSignalAttrib
Definition: rtw_solver.h:86
uint8_T * zcEventsVector
Definition: rtw_solver.h:85
uint8_T * reserved
Definition: rtw_solver.h:88
boolean_T consistencyChecking
Definition: rtw_solver.h:100
boolean_T robustResetMethod
Definition: rtw_solver.h:98
real_T unused_real_T_1
Definition: rtw_solver.h:72
boolean_T isComputingJacobian
Definition: rtw_solver.h:115
int_T maxNumMinSteps
Definition: rtw_solver.h:62
boolean_T isOutputMethodComputed
Definition: rtw_solver.h:119
real_T * massMatrixPr
Definition: rtw_solver.h:106
SimTimeStep * simTimeStepPtr
Definition: rtw_solver.h:47
int_T zeroCrossAlgorithm
Definition: rtw_solver.h:112
int_T zcSignalVectorLength
Definition: rtw_solver.h:87
int_T maskedZcDiagnostic
Definition: rtw_solver.h:118
time_T maxStepSize
Definition: rtw_solver.h:57
ssMatrixType massMatrixType
Definition: rtw_solver.h:102
slJmBdControl solverJacobianMethodControl
Definition: rtw_solver.h:116
int_T solverRefineFactor
Definition: rtw_solver.h:70
time_T fixedStepSize
Definition: rtw_solver.h:58
boolean_T foundContZcEvents
Definition: rtw_solver.h:90
int_T solverShapePreserveControl
Definition: rtw_solver.h:60
real_T * zcSignalVector
Definition: rtw_solver.h:84
boolean_T isAtRightPostOfContZcEvent
Definition: rtw_solver.h:92
real_T ** dXPtr
Definition: rtw_solver.h:74
int_T solverExtrapolationOrder
Definition: rtw_solver.h:67
time_T minStepSize
Definition: rtw_solver.h:56
const char_T * solverName
Definition: rtw_solver.h:49
RTWRTModelMethodsInfo * modelMethodsPtr
Definition: rtw_solver.h:110
time_T ** tPtr
Definition: rtw_solver.h:75
time_T * stepSizePtr
Definition: rtw_solver.h:55
real_T zcThreshold
Definition: rtw_solver.h:111
int_T * massMatrixJc
Definition: rtw_solver.h:105
boolean_T stateProjection
Definition: rtw_solver.h:97
void * rtModelPtr
Definition: rtw_solver.h:45
int_T * numPeriodicContStatesPtr
Definition: rtw_solver.h:80
boolean_T solverNeedsReset
Definition: rtw_solver.h:51
int_T * numContStatesPtr
Definition: rtw_solver.h:77
int_T solverMaxConsecutiveZCs
Definition: rtw_solver.h:65
boolean_T adaptiveZcDetection
Definition: rtw_solver.h:93
int_T consecutiveZCsError
Definition: rtw_solver.h:113
real_T solverConsecutiveZCsStepRelTol
Definition: rtw_solver.h:64
time_T solverStopTime
Definition: rtw_solver.h:54
int_T massMatrixNzMax
Definition: rtw_solver.h:103
int_T solverNumberNewtonIterations
Definition: rtw_solver.h:68
int_T ** periodicContStateIndicesPtr
Definition: rtw_solver.h:81
real_T solverRelTol
Definition: rtw_solver.h:71
boolean_T CTOutputIncnstWithState
Definition: rtw_solver.h:114
int_T numZcSignals
Definition: rtw_solver.h:95
real_T ** contStatesPtr
Definition: rtw_solver.h:78
boolean_T updateJacobianAtReset
Definition: rtw_solver.h:99
boolean_T isVariableStepSolver
Definition: rtw_solver.h:50
int_T solverMaxOrder
Definition: rtw_solver.h:63
int_T ignoredZcDiagnostic
Definition: rtw_solver.h:117
const char_T ** errStatusPtr
Definition: rtw_solver.h:108
real_T ** periodicContStateRangesPtr
Definition: rtw_solver.h:82
SolverMode solverMode
Definition: rtw_solver.h:52
int_T * massMatrixIr
Definition: rtw_solver.h:104
int_T solverMaxConsecutiveMinStep
Definition: rtw_solver.h:61
void * solverData
Definition: rtw_solver.h:48