Project: | Siconos |
---|---|
Internal Release Number: | 1.0 |
Last update: | September 15, 2005 |
Related Documents: |
What for? | To provide a user plug-in system for specific functions |
---|---|
Feature sets: | F-2.005 and F-2.200 |
Sources directory name: | Kernel/src/utils/SiconosSharedLibrary, Kernel/src/plugin |
Plug-in is a set of functions, compiled with a C++ compiler (but with extern
"C" before the header of the function, for names
compatibility). It must be supplied as a
dynamical library, to allow the platform to load it and use its
functions. Thus, parameters and returned values of function of plugins
must be C
types (no C++ objects or STL containers).
For Integrators using a FORTRAN routine with a plugin
function as a parameter, a specific class method is used. It convert C
to FORTRAN and conversely (g2f.h features).
void (*computeMassPtr)(unsigned int* sizeOfq, const double* time,double* qPtr, double* massPtr, double* param);and a public method:
void computeMass(const double &, SimpleVector *);During computation, when mass is required, one will use computeMass, which calls computeMassPtr which is linked to user external plug-in.
LagrangianDS lds = new LagrangianDS( ... ) ;Then, in nameOfPlugin.cpp, in definition of function nameOfFext, param is available as an in-out parameter.
SimpleVector* parameters = new SimpleVector(2);
// ... set values for parameters
lds->setParametersList(parameter,2) // 3rd plug-in corresponds to FExt
lds->setComputeFExtFunction("nameOfPlugin.so", "nameOfFExt");
void (*vectorFieldPtr) (unsigned int* sizeOfX, const double* time, const double* x, double* xdot, double* param);and its jacobian:
void (*computeJacobianXPtr) (unsigned int* sizeOfX, const double* time,
const double* x, double* jacobianXPtr, double* param);
void (*computeUPtr) (unsigned int* sizeOfU, unsigned int* sizeOfX,
const double* time, double* x, double* xDot, double* U, double* param);
void (*computeTPtr) (unsigned int* sizeOfU, unsigned int* sizeOfX, const double* x, double* T, double* param);
void (*computeAPtr)(unsigned int* sizeOfA, double* APtr, const double* time);
void (*computeBPtr)(unsigned int* sizeOfB, double* bPtr, const double* time);
void (*computeMassPtr)(unsigned int* sizeOfq, const double* time, const double* q, double* mass, double* param);
void (*computeNNLPtr)(unsigned int* sizeOfq, const double* q,and its jacobian compare to q and dq/dt:
const double* velocity, double* NNL, double* param);
void (*computeJacobianQNNLPtr)(unsigned int* sizeOfq, const double* q,
const double* velocity, double* jacob, double* param);
void (*computeJacobianVelocityNNLPtr)(unsigned int* sizeOfq, const double* q,
const double* velocity, double* jacob, double* param);
void (*computeFIntPtr)(unsigned int* sizeOfq, const double* time, const double* q,and its jacobian compare to q and dq/dt:
const double* velocity, double* fInt, double* param);
void (*computeJacobianQFIntPtr)(unsigned int* sizeOfq, const double* time,
const double* q, const double* velocity, double* jacob, double* param);
void (*computeJacobianVelocityFIntPtr)(unsigned int* sizeOfq, const double* time,
const double* q, const double* velocity, double* jacob, double* param);
void (*computeFExtPtr)(unsigned int* sizeOfq, const double* time,
double* fExt, double* param);
void (*computeOutputPtr)(const unsigned int* sizeOfX, const double* x, const double* time,
const unsigned int* sizeOfY, const double* lambda, const unsigned int* sizeOfU, const double* u,
double* y, double* param);
void (*computeInputPtr)(const unsigned int* sizeOfY, const double* lambda, const double* time,
double* r, double* param);
void (*h0Ptr)(const unsigned int* sizeOfQ, const double* q, const unsigned int* sizeOfY,and
double* y, double* param);
void (*G0Ptr)(const unsigned int* sizeOfQ, const double* q, const unsigned int* sizeOfY,
double* G0, double* param);
void (*h1Ptr)(const unsigned int* sizeOfQ, const double* q, const double time,and
const unsigned int* sizeOfY, double* y, double* param);
void (*G10Ptr)(const unsigned int* sizeOfQ, const double* q, const double time,
const unsigned int* sizeOfY, double* y, double* param);
void (*G11Ptr)(const unsigned int* sizeOfQ, const double* q, const double time,
const unsigned int* sizeOfY, double* y, double* param);
void (*h2Ptr)(const unsigned int* sizeOfQ, const double* q, const double * lambda,and
const unsigned int* sizeOfY, double* y, double* param);
void (*G20Ptr)(const unsigned int* sizeOfQ, const double* q, const double * lambda,
const unsigned int* sizeOfY, double* y, double* param);
void (*G21Ptr)(const unsigned int* sizeOfQ, const double* q, const double * lambda,
const unsigned int* sizeOfY, double* y, double* param);
f is a plugin function and is plugged to vectorField
function pointer to the platform.
is a plugin function and is plugged
to computeJacobianX function pointer to the platform.
Functions f and
are in this case
very simple and directly supplied by internal methods of LinearDS
class. These methods are plugged to the platform during the
initialisation phase instead of plugin functions. During computation,
integrator I dedicated to
DynamicalSystem class
calls f et
functions. It
can therefore integrate a LinearDS object since required functions are
supplied by the class and respect plugin functions signatures.
In a general manner, any class
derivated from another
which
uses plugin system must use plugin functions too, or supply internal
functions which can be plugged instead.