Skip to content
Snippets Groups Projects
Commit fc849336 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

adjust bindings of linearSystemPetsc, dg: implicit.lua works anew

parent b1ae2e41
No related branches found
No related tags found
No related merge requests found
......@@ -123,11 +123,11 @@ static void reportErrors(lua_State *L, int status)
}
}
const char *colorRed = "\033[1;31m";
const char *colorGreen = "\033[1;32m";
const char *colorBlue = "\033[1;34m";
const char *colorDefault = "\033[0m";
const char *colorBold = "\033[1m";
static const char *colorRed = "\033[1;31m";
static const char *colorGreen = "\033[1;32m";
static const char *colorBlue = "\033[1;34m";
static const char *colorDefault = "\033[0m";
static const char *colorBold = "\033[1m";
static void printMethod(std::string name, luaMethodBinding *mb, bool isConstructor=false)
{
......
......@@ -1227,13 +1227,12 @@ class classBinding {
lua_setmetatable(L, methods); // setmetatable(methods, mt)
lua_pop(L, 2); // drop metatable and method table
}
template<typename parentType>
void setParentClass()
{
void setParentClassName(const std::string parentClassName) {
if(_parent)
Msg::Error("Multiple inheritance not implemented in lua bindings "
"for class %s", _className.c_str());
std::string parentClassName = className<parentType>::get();
if(_b->classes.find(parentClassName) == _b->classes.end())
Msg::Error("Unknown class %s", parentClassName.c_str());
_parent = _b->classes[parentClassName];
_parent->children.insert(this);
lua_getglobal(_b->L, _className.c_str());
......@@ -1244,6 +1243,11 @@ class classBinding {
// mt.__index = global[_parentClassName] // this is the inheritance bit
lua_pop(_b->L, 2);
}
template<typename parentType>
void setParentClass()
{
setParentClassName(className<parentType>::get());
}
void setDescription(std::string description){ _description = description; }
inline const std::string getDescription() const { return _description; }
inline classBinding *getParent() const { return _parent; }
......
......@@ -8,7 +8,7 @@
template<>
void linearSystem<double>::registerBindings(binding *b){
classBinding *cb = b->addClass<linearSystem<double> >("linearSystem");
classBinding *cb = b->addClass<linearSystem<double> >("linearSystemDouble");
cb->setDescription("An abstraction of a linear system Ax = b.");
methodBinding *cm;
cm = cb->addMethod("systemSolve", &linearSystem<double>::systemSolve);
......@@ -34,6 +34,11 @@ void linearSystem<double>::registerBindings(binding *b){
cm->setDescription ("A new Lapack based <double> solver");
cm->setArgNames(NULL);
cb->setParentClass<linearSystem<double> >();
// block
cb = b->addClass<linearSystem<fullMatrix<double> > >("linearSystemFullMatrixDouble");
cb->setDescription("An abstraction of a linear system Ax = b.");
cm = cb->addMethod("systemSolve", &linearSystem<fullMatrix<double> >::systemSolve);
cm->setDescription("compute x = A^{-1}b");
#ifdef HAVE_PETSC
linearSystemPETScRegisterBindings (b);
#endif
......
......@@ -107,21 +107,13 @@ void linearSystemPETScRegisterBindings(binding *b)
cm->setDescription ("A new PETSc<PetscScalar> solver");
cb->setParentClass<linearSystem<PetscScalar> >();
cm->setArgNames(NULL);
cm = cb->addMethod("systemSolve", &linearSystem<fullMatrix<PetscScalar> >::systemSolve);
cm->setDescription("compute x = A^{-1}b");
cb = b->addClass<linearSystem<fullMatrix<double> > >("linearSystemBlock");
cb->setDescription("A linear system solver with blocks");
cb = b->addClass<linearSystemPETSc<fullMatrix<PetscScalar> > >("linearSystemPETScBlock");
cb->setDescription("A linear system solver, based on PETSc");
cm = cb->setConstructor<linearSystemPETSc<fullMatrix<PetscScalar> >, int>();
cm->setDescription ("A new PETScBlock<PetscScalar> solver (we probably should get rid of the blockSize argument)");
cb->setParentClass<linearSystem<fullMatrix<PetscScalar> > >();
cm->setArgNames("blockSize", NULL);
cm = cb->addMethod("systemSolve", &linearSystem<fullMatrix<PetscScalar> >::systemSolve);
cm->setDescription("compute x = A^{-1}b");
#endif // FIXME
#endif // FIXME
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment