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