Commit 63d0fb3f authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Preprocessor: implement STEADY_STATE operator with "use_dll" and "block"

options (closes #98)
parent 5490f1bb
......@@ -299,7 +299,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
<< " % // Simulation type "
<< BlockSim(simulation_type) << " //" << endl
<< " % ////////////////////////////////////////////////////////////////////////" << endl;
output << " global options_;" << endl;
output << " global options_ oo_;" << endl;
//The Temporary terms
if (simulation_type == EVALUATE_BACKWARD || simulation_type == EVALUATE_FORWARD)
{
......@@ -1447,7 +1447,7 @@ DynamicModel::writeDynamicCFile(const string &dynamic_basename, const int order)
mDynamicModelFile << "/* The gateway routine */" << endl
<< "void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])" << endl
<< "{" << endl
<< " double *y, *x, *params;" << endl
<< " double *y, *x, *params, *steady_state;" << endl
<< " double *residual, *g1, *v2, *v3;" << endl
<< " int nb_row_x, it_;" << endl
<< endl
......@@ -1505,8 +1505,9 @@ DynamicModel::writeDynamicCFile(const string &dynamic_basename, const int order)
<< " v3 = mxGetPr(plhs[3]);" << endl
<< " }" << endl
<< endl
<< " steady_state = mxGetPr(mxGetField(mexGetVariable(\"global\", \"oo_\"), 0, \"steady_state\"));" << endl
<< " /* Call the C subroutines. */" << endl
<< " Dynamic(y, x, nb_row_x, params, it_, residual, g1, v2, v3);" << endl
<< " Dynamic(y, x, nb_row_x, params, steady_state, it_, residual, g1, v2, v3);" << endl
<< "}" << endl;
mDynamicModelFile.close();
}
......@@ -2108,7 +2109,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll) const
}
else
{
DynamicOutput << "void Dynamic(double *y, double *x, int nb_row_x, double *params, int it_, double *residual, double *g1, double *v2, double *v3)" << endl
DynamicOutput << "void Dynamic(double *y, double *x, int nb_row_x, double *params, double *steady_state, int it_, double *residual, double *g1, double *v2, double *v3)" << endl
<< "{" << endl
<< " double lhs, rhs;" << endl
<< endl
......
......@@ -582,8 +582,12 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << "oo_.steady_state(" << tsid + 1 << ")";
break;
case oMatlabDynamicSteadyStateOperator:
case oMatlabDynamicSparseSteadyStateOperator:
output << "oo_.steady_state(" << tsid + 1 << ")";
break;
case oCDynamicSteadyStateOperator:
output << "steady_state[" << tsid << "]";
break;
case oSteadyStateFile:
output << "ys_(" << tsid + 1 << ")";
break;
......@@ -1457,11 +1461,11 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
new_output_type = oLatexDynamicSteadyStateOperator;
break;
case oCDynamicModel:
cerr << "Steady State Operator not implemented for oCDynamicModel." << endl;
exit(EXIT_FAILURE);
new_output_type = oCDynamicSteadyStateOperator;
break;
case oMatlabDynamicModelSparse:
cerr << "Steady State Operator not implemented for oMatlabDynamicModelSparse." << endl;
exit(EXIT_FAILURE);
new_output_type = oMatlabDynamicSparseSteadyStateOperator;
break;
default:
new_output_type = output_type;
break;
......
......@@ -60,17 +60,18 @@ typedef map<pair<int, vector<expr_t> >, int> deriv_node_temp_terms_t;
//! Possible types of output when writing ExprNode(s)
enum ExprNodeOutputType
{
oMatlabStaticModel, //!< Matlab code, static model declarations
oMatlabDynamicModel, //!< Matlab code, dynamic model declarations
oMatlabStaticModelSparse, //!< Matlab code, static block decomposed mode declaration
oMatlabDynamicModelSparse, //!< Matlab code, dynamic block decomposed mode declaration
oCDynamicModel, //!< C code, dynamic model declarations
oMatlabStaticModel, //!< Matlab code, static model
oMatlabDynamicModel, //!< Matlab code, dynamic model
oMatlabStaticModelSparse, //!< Matlab code, static block decomposed model
oMatlabDynamicModelSparse, //!< Matlab code, dynamic block decomposed model
oCDynamicModel, //!< C code, dynamic model
oMatlabOutsideModel, //!< Matlab code, outside model block (for example in initval)
oLatexStaticModel, //!< LaTeX code, static model declarations
oLatexDynamicModel, //!< LaTeX code, dynamic model declarations
oLatexDynamicSteadyStateOperator, //!< LaTeX code, dynamic model steady state declarations
oMatlabDynamicSteadyStateOperator, //!< Matlab code, dynamic model steady state declarations
oMatlabDynamicModelSparseSteadyStateOperator, //!< Matlab code, dynamic block decomposed model steady state declarations
oLatexStaticModel, //!< LaTeX code, static model
oLatexDynamicModel, //!< LaTeX code, dynamic model
oLatexDynamicSteadyStateOperator, //!< LaTeX code, dynamic model, inside a steady state operator
oMatlabDynamicSteadyStateOperator, //!< Matlab code, dynamic model, inside a steady state operator
oMatlabDynamicSparseSteadyStateOperator, //!< Matlab code, dynamic block decomposed model, inside a steady state operator
oCDynamicSteadyStateOperator, //!< C code, dynamic model, inside a steady state operator
oSteadyStateFile //!< Matlab code, in the generated steady state file
};
......@@ -80,10 +81,10 @@ enum ExprNodeOutputType
|| (output_type) == oMatlabStaticModelSparse \
|| (output_type) == oMatlabDynamicModelSparse \
|| (output_type) == oMatlabDynamicSteadyStateOperator \
|| (output_type) == oMatlabDynamicModelSparseSteadyStateOperator \
|| (output_type) == oMatlabDynamicSparseSteadyStateOperator \
|| (output_type) == oSteadyStateFile)
#define IS_C(output_type) ((output_type) == oCDynamicModel)
#define IS_C(output_type) ((output_type) == oCDynamicModel || (output_type) == oCDynamicSteadyStateOperator)
#define IS_LATEX(output_type) ((output_type) == oLatexStaticModel \
|| (output_type) == oLatexDynamicModel \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment