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

dg: add the number of evaluating points on dataCacheMap

parent ac707cca
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ void dgAlgorithm::residualVolume ( //dofManager &dof, // the DOF manager (maybe ...@@ -40,7 +40,7 @@ void dgAlgorithm::residualVolume ( //dofManager &dof, // the DOF manager (maybe
fullMatrix<double> Fuvw[3] = {fullMatrix<double> ( group.getNbIntegrationPoints(), group.getNbElements() * nbFields), fullMatrix<double> Fuvw[3] = {fullMatrix<double> ( group.getNbIntegrationPoints(), group.getNbElements() * nbFields),
fullMatrix<double> (group.getNbIntegrationPoints(), group.getNbElements() * nbFields), fullMatrix<double> (group.getNbIntegrationPoints(), group.getNbElements() * nbFields),
fullMatrix<double> (group.getNbIntegrationPoints(), group.getNbElements() * nbFields)}; fullMatrix<double> (group.getNbIntegrationPoints(), group.getNbElements() * nbFields)};
dataCacheMap cacheMap; dataCacheMap cacheMap(group.getNbIntegrationPoints());
dataCacheElement &cacheElement = cacheMap.getElement(); dataCacheElement &cacheElement = cacheMap.getElement();
// provided dataCache // provided dataCache
cacheMap.provideData("UVW").set(group.getIntegrationPointsMatrix()); cacheMap.provideData("UVW").set(group.getIntegrationPointsMatrix());
...@@ -146,7 +146,8 @@ void dgAlgorithm::residualInterface ( //dofManager &dof, // the DOF manager (may ...@@ -146,7 +146,8 @@ void dgAlgorithm::residualInterface ( //dofManager &dof, // the DOF manager (may
fullMatrix<double> NormalFluxQP ( group.getNbIntegrationPoints(), nbFaces*nbFields*2); fullMatrix<double> NormalFluxQP ( group.getNbIntegrationPoints(), nbFaces*nbFields*2);
// create one dataCache for each side // create one dataCache for each side
dataCacheMap cacheMapLeft, cacheMapRight; dataCacheMap cacheMapLeft(group.getNbIntegrationPoints());
dataCacheMap cacheMapRight(group.getNbIntegrationPoints());
// data this algorithm provide to the cache map (we can maybe move each data to a separate function but // data this algorithm provide to the cache map (we can maybe move each data to a separate function but
// I think It's easier like this) // I think It's easier like this)
...@@ -310,7 +311,7 @@ void dgAlgorithm::residualBoundary ( //dofManager &dof, // the DOF manager (mayb ...@@ -310,7 +311,7 @@ void dgAlgorithm::residualBoundary ( //dofManager &dof, // the DOF manager (mayb
// ----- 2 ---- compute normal fluxes at integration points // ----- 2 ---- compute normal fluxes at integration points
fullMatrix<double> NormalFluxQP ( group.getNbIntegrationPoints(), group.getNbElements()*nbFields); fullMatrix<double> NormalFluxQP ( group.getNbIntegrationPoints(), group.getNbElements()*nbFields);
dataCacheMap cacheMapLeft; dataCacheMap cacheMapLeft(group.getNbIntegrationPoints());
// provided dataCache // provided dataCache
cacheMapLeft.provideData("UVW").set(group.getIntegrationPointsMatrix()); cacheMapLeft.provideData("UVW").set(group.getIntegrationPointsMatrix());
dataCacheDouble &solutionQPLeft = cacheMapLeft.provideData("Solution"); dataCacheDouble &solutionQPLeft = cacheMapLeft.provideData("Solution");
......
...@@ -4,10 +4,10 @@ class dgBoundaryConditionOutsideValue : public dgBoundaryCondition { ...@@ -4,10 +4,10 @@ class dgBoundaryConditionOutsideValue : public dgBoundaryCondition {
dgConservationLaw &_claw; dgConservationLaw &_claw;
std::string _outsideValueFunctionName; std::string _outsideValueFunctionName;
class term : public dataCacheDouble { class term : public dataCacheDouble {
dataCacheMap cacheMapRight; // new cacheMap to pass to the Riemann solver
dataCacheDouble &solutionRight; dataCacheDouble &solutionRight;
dataCacheDouble &solutionLeft; dataCacheDouble &solutionLeft;
dataCacheDouble &outsideValue; dataCacheDouble &outsideValue;
dataCacheMap cacheMapRight; // new cacheMap to pass to the Riemann solver
dataCacheDouble *riemannSolver; dataCacheDouble *riemannSolver;
dgConservationLaw &_claw; dgConservationLaw &_claw;
public: public:
...@@ -15,6 +15,7 @@ class dgBoundaryConditionOutsideValue : public dgBoundaryCondition { ...@@ -15,6 +15,7 @@ class dgBoundaryConditionOutsideValue : public dgBoundaryCondition {
solutionRight(cacheMapRight.provideData("Solution")), solutionRight(cacheMapRight.provideData("Solution")),
solutionLeft(cacheMapLeft.get("Solution",this)), solutionLeft(cacheMapLeft.get("Solution",this)),
outsideValue(cacheMapLeft.get(outsideValueFunctionName,this)), outsideValue(cacheMapLeft.get(outsideValueFunctionName,this)),
cacheMapRight(cacheMapLeft.getNbEvaluationPoints()),
_claw(claw) _claw(claw)
{ {
riemannSolver=_claw.newRiemannSolver(cacheMapLeft,cacheMapRight); riemannSolver=_claw.newRiemannSolver(cacheMapLeft,cacheMapRight);
...@@ -26,9 +27,11 @@ class dgBoundaryConditionOutsideValue : public dgBoundaryCondition { ...@@ -26,9 +27,11 @@ class dgBoundaryConditionOutsideValue : public dgBoundaryCondition {
_value = fullMatrix<double>(solutionLeft().size1(),_claw.nbFields()); _value = fullMatrix<double>(solutionLeft().size1(),_claw.nbFields());
} }
solutionRight.set(outsideValue()); solutionRight.set(outsideValue());
for(int i=0;i<_value.size1(); i++) if(riemannSolver){
for(int j=0;j<_value.size2(); j++) for(int i=0;i<_value.size1(); i++)
_value(i,j) = (*riemannSolver)(i,j*2); for(int j=0;j<_value.size2(); j++)
_value(i,j) = (*riemannSolver)(i,j*2);
}
} }
}; };
public: public:
......
...@@ -85,11 +85,10 @@ class functionXYZ : public function { ...@@ -85,11 +85,10 @@ class functionXYZ : public function {
dataCacheElement &_element; dataCacheElement &_element;
dataCacheDouble &_uvw; dataCacheDouble &_uvw;
public: public:
data(dataCacheMap *m) : data(dataCacheMap *m) :
dataCacheDouble(m->getNbEvaluationPoints(),3),
_element(m->getElement(this)), _uvw(m->get("UVW", this)) _element(m->getElement(this)), _uvw(m->get("UVW", this))
{ {}
_value = fullMatrix<double> (_uvw().size1(), 3);
}
void _eval() void _eval()
{ {
for(int i = 0; i < _uvw().size1(); i++){ for(int i = 0; i < _uvw().size1(); i++){
...@@ -113,15 +112,12 @@ class functionConstant : public function { ...@@ -113,15 +112,12 @@ class functionConstant : public function {
private : private :
class data : public dataCacheDouble { class data : public dataCacheDouble {
const functionConstant *_function; const functionConstant *_function;
dataCacheDouble &_uvw;
public: public:
data(const functionConstant * function,dataCacheMap *m) :_uvw(m->get("UVW",this)){ data(const functionConstant * function,dataCacheMap *m):
dataCacheDouble(m->getNbEvaluationPoints(),function->_source.size1()){
_function = function; _function = function;
} }
void _eval() { void _eval() {
if(_value.size1()!=_uvw().size1()){
_value=fullMatrix<double>(_uvw().size1(),_function->_source.size1());
}
for(int i=0;i<_value.size1();i++) for(int i=0;i<_value.size1();i++)
for(int j=0;j<_function->_source.size1();j++) for(int j=0;j<_function->_source.size1();j++)
_value(i,j)=_function->_source(j,0); _value(i,j)=_function->_source(j,0);
......
...@@ -97,6 +97,8 @@ class dataCacheDouble : public dataCache { ...@@ -97,6 +97,8 @@ class dataCacheDouble : public dataCache {
} }
return _value; return _value;
} }
dataCacheDouble(){};
dataCacheDouble(int size1, int size2):_value(size1,size2){};
virtual ~dataCacheDouble(){}; virtual ~dataCacheDouble(){};
}; };
...@@ -133,6 +135,7 @@ class dataCacheElement : public dataCache { ...@@ -133,6 +135,7 @@ class dataCacheElement : public dataCache {
// more explanation at the head of this file // more explanation at the head of this file
class dataCacheMap { class dataCacheMap {
private: private:
int _nbEvaluationPoints;
// keep track of the current element and all the dataCaches that // keep track of the current element and all the dataCaches that
// depend on it // depend on it
dataCacheElement _cacheElement; dataCacheElement _cacheElement;
...@@ -140,7 +143,7 @@ class dataCacheMap { ...@@ -140,7 +143,7 @@ class dataCacheMap {
class providedDataDouble : public dataCacheDouble class providedDataDouble : public dataCacheDouble
// for data provided by the algorithm and that does not have an _eval function // for data provided by the algorithm and that does not have an _eval function
// (typically "UVW") this class is not stricly necessary, we could write // (typically "UVW") this class is not stricly necessary, we could write
// a function for each case but I think it's more practical like this // a function for each case
{ {
void _eval() {throw;}; void _eval() {throw;};
public: public:
...@@ -152,6 +155,8 @@ class dataCacheMap { ...@@ -152,6 +155,8 @@ class dataCacheMap {
dataCacheDouble &get(const std::string &functionName, dataCache *caller=0); dataCacheDouble &get(const std::string &functionName, dataCache *caller=0);
dataCacheElement &getElement(dataCache *caller=0); dataCacheElement &getElement(dataCache *caller=0);
dataCacheDouble &provideData(std::string name); dataCacheDouble &provideData(std::string name);
dataCacheMap(int nbEvaluationPoints):_nbEvaluationPoints(nbEvaluationPoints){}
inline int getNbEvaluationPoints(){return _nbEvaluationPoints;}
~dataCacheMap(); ~dataCacheMap();
}; };
#endif #endif
...@@ -12,30 +12,27 @@ class functionLua : public function { ...@@ -12,30 +12,27 @@ class functionLua : public function {
int _nbCol; int _nbCol;
private: private:
class data : public dataCacheDouble{ class data : public dataCacheDouble{
private: private:
dataCacheDouble &_uvw;
const functionLua *_function; const functionLua *_function;
std::vector<dataCacheDouble *> _dependencies; std::vector<dataCacheDouble *> _dependencies;
public: public:
data(const functionLua *f, dataCacheMap *m) data(const functionLua *f, dataCacheMap *m):
: _function(f),_uvw(m->get("UVW",this)) dataCacheDouble(m->getNbEvaluationPoints(),f->_nbCol),
_function(f)
{ {
_dependencies.resize ( _function->_dependenciesName.size()); _dependencies.resize ( _function->_dependenciesName.size());
for (int i=0;i<_function->_dependenciesName.size();i++) for (int i=0;i<_function->_dependenciesName.size();i++)
_dependencies[i] = &m->get(_function->_dependenciesName[i],this); _dependencies[i] = &m->get(_function->_dependenciesName[i],this);
} }
void _eval() void _eval()
{ {
if(_value.size1()!=_uvw().size1() || _value.size2() != _function->_nbCol){
_value=fullMatrix<double>(_uvw().size1(),_function->_nbCol);
}
lua_getfield(_function->_L, LUA_GLOBALSINDEX, _function->_luaFunctionName.c_str()); lua_getfield(_function->_L, LUA_GLOBALSINDEX, _function->_luaFunctionName.c_str());
for (int i=0;i< _dependencies.size();i++){ for (int i=0;i< _dependencies.size();i++){
const fullMatrix<double> *data = &(*_dependencies[i])(); const fullMatrix<double> *data = &(*_dependencies[i])();
lua_pushlightuserdata (_function->_L, (void*) data); lua_pushlightuserdata (_function->_L, (void*) data);
} }
lua_pushlightuserdata (_function->_L, &_value); lua_pushlightuserdata (_function->_L, &_value);
lua_call(_function->_L,_dependencies.size()+1,0); /* call Lua function */ lua_call(_function->_L,_dependencies.size()+1,0); /* call Lua function */
} }
}; };
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment