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

cleaning

parent 2bcacf23
No related branches found
No related tags found
No related merge requests found
...@@ -104,6 +104,7 @@ static void reportErrors(lua_State *L, int status) ...@@ -104,6 +104,7 @@ static void reportErrors(lua_State *L, int status)
if ( status!=0 ) { if ( status!=0 ) {
std::cerr << "-- " << lua_tostring(L, -1) << std::endl; std::cerr << "-- " << lua_tostring(L, -1) << std::endl;
lua_pop(L, 1); // remove error message lua_pop(L, 1); // remove error message
exit(1); //we need this for automatic test
} }
} }
......
...@@ -160,6 +160,32 @@ class luaStack<std::vector<type > >{ ...@@ -160,6 +160,32 @@ class luaStack<std::vector<type > >{
return name+luaStack<type>::getName(); return name+luaStack<type>::getName();
} }
}; };
template<class type>
class luaStack<std::vector<type > &>{
public:
static std::vector<type> get(lua_State *L, int ia){
std::vector<type> v;
size_t size=lua_objlen(L,ia);
v.resize(size);
for(size_t i=0;i<size;i++){
lua_rawgeti(L, ia, i+1);
v[i]=luaStack<type>::get(L,-1);
lua_pop(L,1);
}
return v;
}
static void push(lua_State *L, const std::vector<type>& v){
lua_createtable(L, v.size(), 0);
for(size_t i=0;i<v.size;i++){
luaStack<type>::push(L,v[i]);
lua_rawseti(L, 2, i+1);
}
}
static std::string getName(){
std::string name="vector of ";
return name+luaStack<type>::getName();
}
};
template<> template<>
class luaStack<double>{ class luaStack<double>{
......
...@@ -270,7 +270,7 @@ dgResidualInterface::dgResidualInterface (const dgConservationLaw &claw): ...@@ -270,7 +270,7 @@ dgResidualInterface::dgResidualInterface (const dgConservationLaw &claw):
void dgResidualInterface::compute1Group ( //dofManager &dof, // the DOF manager (maybe useless here) void dgResidualInterface::compute1Group ( //dofManager &dof, // the DOF manager (maybe useless here)
dgGroupOfFaces &group, dgGroupOfFaces &group,
const fullMatrix<double> &solution, // solution !! at faces nodes const fullMatrix<double> &solution, // solution !! at faces nodes
const std::vector<const fullMatrix<double>*> & solutionOnElements, const std::vector<const fullMatrix<double>*> solutionOnElements,
fullMatrix<double> &residual // residual !! at faces nodes fullMatrix<double> &residual // residual !! at faces nodes
) )
{ {
...@@ -450,7 +450,7 @@ void dgResidual::registerBindings (binding *b) ...@@ -450,7 +450,7 @@ void dgResidual::registerBindings (binding *b)
mb = cb->addMethod("computeAndMap1Group",&dgResidualInterface::computeAndMap1Group); mb = cb->addMethod("computeAndMap1Group",&dgResidualInterface::computeAndMap1Group);
mb->setDescription("compute the residual for one group given a dgDofContainer solution"); mb->setDescription("compute the residual for one group given a dgDofContainer solution");
mb->setArgNames("group", "solution", "residual", NULL); mb->setArgNames("group", "solution", "residual", NULL);
// mb = cb->addMethod("compute1Group", &dgResidualInterface::compute1Group); mb = cb->addMethod("compute1Group", &dgResidualInterface::compute1Group);
//mb->setDescription("compute the residual for one group given fullMatrices with the solution at faces nodes and at element nodes"); mb->setDescription("compute the residual for one group given fullMatrices with the solution at faces nodes and at element nodes");
//mb->setArgNames("group", "solutionFaces", "solutionOnElements", "residual", NULL); mb->setArgNames("group", "solutionFaces", "solutionOnElements", "residual", NULL);
} }
...@@ -35,7 +35,7 @@ class dgResidualInterface { ...@@ -35,7 +35,7 @@ class dgResidualInterface {
void compute1Group ( //dofManager &dof, // the DOF manager (maybe useless here) void compute1Group ( //dofManager &dof, // the DOF manager (maybe useless here)
dgGroupOfFaces &group, dgGroupOfFaces &group,
const fullMatrix<double> &solution, // solution !! at faces nodes const fullMatrix<double> &solution, // solution !! at faces nodes
const std::vector<const fullMatrix<double>*> & solutionOnElements, const std::vector<const fullMatrix<double>*> solutionOnElements,
fullMatrix<double> &residual // residual !! at faces nodes fullMatrix<double> &residual // residual !! at faces nodes
); );
void computeAndMap1Group (dgGroupOfFaces &faces, dgDofContainer &solution, dgDofContainer &residual); void computeAndMap1Group (dgGroupOfFaces &faces, dgDofContainer &solution, dgDofContainer &residual);
......
...@@ -112,8 +112,6 @@ dgRungeKuttaMultirate::dgRungeKuttaMultirate(dgGroupCollection* gc,dgConservatio ...@@ -112,8 +112,6 @@ dgRungeKuttaMultirate::dgRungeKuttaMultirate(dgGroupCollection* gc,dgConservatio
} }
for(int iGroup=0;iGroup<gc->getNbFaceGroups();iGroup++){ for(int iGroup=0;iGroup<gc->getNbFaceGroups();iGroup++){
dgGroupOfFaces *gf=gc->getFaceGroup(iGroup); dgGroupOfFaces *gf=gc->getFaceGroup(iGroup);
/*if(gf->getNbGroupOfConnections()!=2)
continue;*/
for(int i=0;i<gf->getNbGroupOfConnections();i++){ for(int i=0;i<gf->getNbGroupOfConnections();i++){
const dgGroupOfElements *ge = &gf->getGroupOfConnections(i).getGroupOfElements(); const dgGroupOfElements *ge = &gf->getGroupOfConnections(i).getGroupOfElements();
if(ge->getIsInnerMultirateBuffer()){ if(ge->getIsInnerMultirateBuffer()){
...@@ -126,23 +124,6 @@ dgRungeKuttaMultirate::dgRungeKuttaMultirate(dgGroupCollection* gc,dgConservatio ...@@ -126,23 +124,6 @@ dgRungeKuttaMultirate::dgRungeKuttaMultirate(dgGroupCollection* gc,dgConservatio
} }
} }
} }
/*for(int iGroup=0;iGroup<gc->getNbFaceGroups();iGroup++){
dgGroupOfFaces *gf=gc->getFaceGroup(iGroup);
if(gf->getNbGroupOfConnections()!=1)
continue;
const dgGroupOfElements *ge[1];
ge[0]=&gf->getGroupOfConnections(0).getGroupOfElements();
for(int i=0;i<1;i++){
if(ge[i]->getIsInnerMultirateBuffer()){
_innerBufferGroupsOfElements[ge[i]->getMultirateExponent()].second.push_back(gf);
}
else if(ge[i]->getIsOuterMultirateBuffer()){
_outerBufferGroupsOfElements[ge[i]->getMultirateExponent()].second.push_back(gf);
}else{
_bulkGroupsOfElements[ge[i]->getMultirateExponent()].second.push_back(gf);
}
}
}*/
// Removing duplicate entries // Removing duplicate entries
for(int iExp=0;iExp<=_maxExponent;iExp++){ for(int iExp=0;iExp<=_maxExponent;iExp++){
std::vector<dgGroupOfFaces*>*v[3]; std::vector<dgGroupOfFaces*>*v[3];
......
...@@ -7,11 +7,61 @@ ...@@ -7,11 +7,61 @@
#include "dgDofContainer.h" #include "dgDofContainer.h"
#include "dgGroupOfElements.h" #include "dgGroupOfElements.h"
#include "GModel.h" #include "GModel.h"
#if defined(HAVE_DLOPEN) #if defined(HAVE_DLOPEN)
#include "dlfcn.h" #include "dlfcn.h"
#endif #endif
class functionNew : public function{
protected :
std::vector<function*> dep;
virtual void call (fullMatrix<double> &res) {throw;}
virtual void call (const fullMatrix<double> &arg0, const fullMatrix<double> &res) {throw;};
virtual void call (const fullMatrix<double> &arg0, const fullMatrix<double> &arg1, const fullMatrix<double> &res) {throw;};
virtual void call (const fullMatrix<double> &arg0, const fullMatrix<double> &arg1, const fullMatrix<double> &arg2, fullMatrix<double> &res) {throw;};
virtual void call (const fullMatrix<double> &arg0, const fullMatrix<double> &arg1, const fullMatrix<double> &arg2, const fullMatrix<double> &arg3, fullMatrix<double> &res) {throw;};
virtual void call (const fullMatrix<double> &arg0, const fullMatrix<double> &arg1, const fullMatrix<double> &arg2, const fullMatrix<double> &arg3, const fullMatrix<double> &arg4, fullMatrix<double> &res) {throw;};
virtual void call (const fullMatrix<double> &arg0, const fullMatrix<double> &arg1, const fullMatrix<double> &arg2, const fullMatrix<double> &arg3, const fullMatrix<double> &arg4, const fullMatrix<double> &arg5, fullMatrix<double> &res) {throw;};
public :
virtual void call (fullMatrix<double> &res, std::vector<const fullMatrix<double>*> &depM) {
switch (dep.size()) {
case 0 : call(res); break;
case 1 : call(*depM[0], res); break;
case 2 : call(*depM[0], *depM[1], res); break;
case 3 : call(*depM[0], *depM[1], *depM[2], res); break;
case 4 : call(*depM[0], *depM[1], *depM[2], *depM[3], res); break;
case 5 : call(*depM[0], *depM[1], *depM[2], *depM[3], *depM[4], res); break;
case 6 : call(*depM[0], *depM[1], *depM[2], *depM[3], *depM[4], *depM[5], res); break;
default : Msg::Error("function are not implemented for %i arguments\n", dep.size());
}
}
int _nbCol;
class data : public dataCacheDouble {
functionNew *_function;
std::vector<dataCacheDouble *> _dependencies;
std::vector<const fullMatrix<double> *> _depM;
public:
data(functionNew *f, dataCacheMap *m):
dataCacheDouble(*m,1,f->_nbCol)
{
_function = f;
_dependencies.resize ( _function->dep.size());
_depM.resize (_function->dep.size());
for (int i=0;i<_function->dep.size();i++)
_dependencies[i] = &m->get(_function->dep[i],this);
}
void _eval()
{
for(int i=0;i<_dependencies.size(); i++)
_depM[i] = &(*_dependencies[i])();
_function->call(_value, _depM);
}
};
dataCacheDouble *newDataCache(dataCacheMap *m)
{
return new data(this, m);
}
};
// dataCache members // dataCache members
dataCache::dataCache(dataCacheMap *cacheMap) : _valid(false) { dataCache::dataCache(dataCacheMap *cacheMap) : _valid(false) {
cacheMap->addDataCache(this); //this dataCache can be deleted when the dataCacheMap is deleted cacheMap->addDataCache(this); //this dataCache can be deleted when the dataCacheMap is deleted
...@@ -395,7 +445,6 @@ void dataCacheDouble::resize() { ...@@ -395,7 +445,6 @@ void dataCacheDouble::resize() {
_value = fullMatrix<double>(_nRowByPoint==0?1:_nRowByPoint*_cacheMap.getNbEvaluationPoints(),_value.size2()); _value = fullMatrix<double>(_nRowByPoint==0?1:_nRowByPoint*_cacheMap.getNbEvaluationPoints(),_value.size2());
} }
#if defined(HAVE_DLOPEN)
//functionC //functionC
class functionC : public function { class functionC : public function {
void (*callback)(void); void (*callback)(void);
...@@ -455,6 +504,7 @@ class functionC : public function { ...@@ -455,6 +504,7 @@ class functionC : public function {
} }
}; };
public: public:
#if defined(HAVE_DLOPEN)
functionC (std::string file, std::string symbol, int nbCol, std::vector<const function *> dependencies): functionC (std::string file, std::string symbol, int nbCol, std::vector<const function *> dependencies):
_dependenciesF(dependencies),_nbCol(nbCol) _dependenciesF(dependencies),_nbCol(nbCol)
{ {
...@@ -470,12 +520,12 @@ class functionC : public function { ...@@ -470,12 +520,12 @@ class functionC : public function {
_name = oss.str(); _name = oss.str();
function::add(_name,this); function::add(_name,this);
} }
#endif
dataCacheDouble *newDataCache(dataCacheMap *m) dataCacheDouble *newDataCache(dataCacheMap *m)
{ {
return new data(this,m); return new data(this,m);
} }
}; };
#endif
#include "Bindings.h" #include "Bindings.h"
......
...@@ -187,12 +187,6 @@ class dataCacheMap { ...@@ -187,12 +187,6 @@ class dataCacheMap {
_toResize.insert(data); _toResize.insert(data);
} }
public: public:
// dg Part
//list of dgDofContainer that have to be evaluated, this not work as a function as it depends on the algorithm
std::map<dgDofContainer*,dataCacheDouble*> fields;
//list of dgDofContainer whom gradient are needed
std::map<dgDofContainer*,dataCacheDouble*> gradientFields;
// end dg Part
dataCacheDouble *_solution, *_solutionGradient, *_parametricCoordinates, *_normals; dataCacheDouble *_solution, *_solutionGradient, *_parametricCoordinates, *_normals;
dataCacheDouble &getSolution(dataCacheDouble *caller); dataCacheDouble &getSolution(dataCacheDouble *caller);
dataCacheDouble &getSolutionGradient(dataCacheDouble *caller); dataCacheDouble &getSolutionGradient(dataCacheDouble *caller);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment