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

dg : coordinates function again

parent 0583e024
No related branches found
No related tags found
No related merge requests found
...@@ -224,6 +224,19 @@ const function * dataCacheMap::_translate(const function *f) const ...@@ -224,6 +224,19 @@ const function * dataCacheMap::_translate(const function *f) const
Msg::Error ("solution function gradient has not been set"); Msg::Error ("solution function gradient has not been set");
} }
} }
if (f == function::getCoordinates()) {
f = _functionCoordinates;
if (f == NULL) {
dataCacheMap *parent = _parent;
while (parent) {
f = parent->_functionCoordinates;
if (f) break;
parent = parent->_parent;
}
if (f == NULL)
Msg::Error ("function coordinates has not been set");
}
}
return f; return f;
} }
...@@ -749,3 +762,27 @@ functionC::functionC (std::string file, std::string symbol, int nbCol, ...@@ -749,3 +762,27 @@ functionC::functionC (std::string file, std::string symbol, int nbCol,
Msg::Error("Cannot construct functionC without dlopen"); Msg::Error("Cannot construct functionC without dlopen");
#endif #endif
} }
class functionCoordinates : public function {
static functionCoordinates *_instance;
functionCoordinates() : function(3) {};
public:
void call(dataCacheMap *m, fullMatrix<double> &sol)
{
Msg::Error("A function requires the coordinates but this algorithm does "
"not provide the coordinates");
throw;
}
static functionCoordinates *get()
{
if(!_instance)
_instance = new functionCoordinates();
return _instance;
}
};
functionCoordinates *functionCoordinates::_instance = NULL;
function *function::getCoordinates()
{
return functionCoordinates::get();
}
...@@ -72,6 +72,7 @@ class function { ...@@ -72,6 +72,7 @@ class function {
static functionConstant *getTime(); static functionConstant *getTime();
static functionConstant *getDT(); static functionConstant *getDT();
static function *getSolution(); static function *getSolution();
static function *getCoordinates();
static function *getSolutionGradient(); static function *getSolutionGradient();
static function *getNormals(); static function *getNormals();
void printDep() void printDep()
...@@ -197,7 +198,7 @@ class dataCacheDouble { ...@@ -197,7 +198,7 @@ class dataCacheDouble {
}; };
class dataCacheMap { class dataCacheMap {
const function *_functionSolution, *_functionSolutionGradient; const function *_functionSolution, *_functionSolutionGradient, *_functionCoordinates;
//handle function solution and funciton solution gradient //handle function solution and funciton solution gradient
//we should get rid of them //we should get rid of them
const function * _translate (const function *) const; const function * _translate (const function *) const;
...@@ -211,7 +212,7 @@ class dataCacheMap { ...@@ -211,7 +212,7 @@ class dataCacheMap {
std::vector<dataCacheDouble*> _toInvalidateOnElement; std::vector<dataCacheDouble*> _toInvalidateOnElement;
MElement *_element; MElement *_element;
dataCacheMap() { dataCacheMap() {
_functionSolution = _functionSolutionGradient = NULL; _functionSolution = _functionSolutionGradient = _functionCoordinates = NULL;
_nbEvaluationPoints = 0; _nbEvaluationPoints = 0;
_parent=NULL; _parent=NULL;
} }
...@@ -258,6 +259,9 @@ class dataCacheMap { ...@@ -258,6 +259,9 @@ class dataCacheMap {
m->_nbEvaluationPoints = 0; m->_nbEvaluationPoints = 0;
return m; return m;
} }
inline void setFunctionCoordinates(const function *functionCoordinates) {
_functionCoordinates = functionCoordinates;
}
inline void setSolutionFunction(const function *functionSolution, const function *functionSolutionGradient) { inline void setSolutionFunction(const function *functionSolution, const function *functionSolutionGradient) {
_functionSolution = functionSolution; _functionSolution = functionSolution;
_functionSolutionGradient = functionSolutionGradient; _functionSolutionGradient = functionSolutionGradient;
......
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