From 5e7bcf3251bb9818a325f47cd7aac854817f4b07 Mon Sep 17 00:00:00 2001 From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be> Date: Mon, 23 May 2011 09:48:44 +0000 Subject: [PATCH] dg : coordinates function again --- Solver/function.cpp | 37 +++++++++++++++++++++++++++++++++++++ Solver/function.h | 8 ++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Solver/function.cpp b/Solver/function.cpp index a2dda164a9..af9d8e5701 100644 --- a/Solver/function.cpp +++ b/Solver/function.cpp @@ -224,6 +224,19 @@ const function * dataCacheMap::_translate(const function *f) const 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; } @@ -749,3 +762,27 @@ functionC::functionC (std::string file, std::string symbol, int nbCol, Msg::Error("Cannot construct functionC without dlopen"); #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(); +} diff --git a/Solver/function.h b/Solver/function.h index d8896a7c15..baf1312735 100644 --- a/Solver/function.h +++ b/Solver/function.h @@ -72,6 +72,7 @@ class function { static functionConstant *getTime(); static functionConstant *getDT(); static function *getSolution(); + static function *getCoordinates(); static function *getSolutionGradient(); static function *getNormals(); void printDep() @@ -197,7 +198,7 @@ class dataCacheDouble { }; class dataCacheMap { - const function *_functionSolution, *_functionSolutionGradient; + const function *_functionSolution, *_functionSolutionGradient, *_functionCoordinates; //handle function solution and funciton solution gradient //we should get rid of them const function * _translate (const function *) const; @@ -211,7 +212,7 @@ class dataCacheMap { std::vector<dataCacheDouble*> _toInvalidateOnElement; MElement *_element; dataCacheMap() { - _functionSolution = _functionSolutionGradient = NULL; + _functionSolution = _functionSolutionGradient = _functionCoordinates = NULL; _nbEvaluationPoints = 0; _parent=NULL; } @@ -258,6 +259,9 @@ class dataCacheMap { m->_nbEvaluationPoints = 0; return m; } + inline void setFunctionCoordinates(const function *functionCoordinates) { + _functionCoordinates = functionCoordinates; + } inline void setSolutionFunction(const function *functionSolution, const function *functionSolutionGradient) { _functionSolution = functionSolution; _functionSolutionGradient = functionSolutionGradient; -- GitLab