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

dg : dgBoundaryConditionOutsideValue as term

parent e8c73978
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,16 @@ dataCacheDouble::dataCacheDouble(dataCacheMap *m, function *f): ...@@ -42,6 +42,16 @@ dataCacheDouble::dataCacheDouble(dataCacheMap *m, function *f):
_nRowByPoint=1; _nRowByPoint=1;
m->addDataCacheDouble(this, f->isInvalitedOnElement()); m->addDataCacheDouble(this, f->isInvalitedOnElement());
_function = f; _function = f;
for(int i=0; i<f->_childrenCache.size(); i++) {
dataCacheMap *m2 = m->newChild();
m->addSecondaryCache(m2);
}
_substitutions.resize(f->_substitutedFunctions.size());
for(int i=0; i<f->_substitutedFunctions.size(); i++) {
function::substitutedFunction s = f->_substitutedFunctions[i];
_substitutions[i].first = &m->getSecondaryCache(s.iMap)->substitute(s.f0);
_substitutions[i].second = &m->get(s.f1,this);
}
_dependencies.resize ( _function->arguments.size()); _dependencies.resize ( _function->arguments.size());
for (unsigned int i=0;i<_function->arguments.size();i++) { for (unsigned int i=0;i<_function->arguments.size();i++) {
int iCache = _function->arguments[i]->iMap; int iCache = _function->arguments[i]->iMap;
...@@ -55,6 +65,9 @@ void dataCacheDouble::resize() { ...@@ -55,6 +65,9 @@ void dataCacheDouble::resize() {
} }
void dataCacheDouble::_eval() { void dataCacheDouble::_eval() {
for(unsigned int i=0;i<_substitutions.size(); i++){
_substitutions[i].first->set() = (*_substitutions[i].second)();
}
for(unsigned int i=0;i<_dependencies.size(); i++){ for(unsigned int i=0;i<_dependencies.size(); i++){
_function->arguments[i]->val.setAsProxy((*_dependencies[i])()); _function->arguments[i]->val.setAsProxy((*_dependencies[i])());
} }
......
...@@ -34,6 +34,7 @@ class dataCacheDouble; ...@@ -34,6 +34,7 @@ class dataCacheDouble;
// An abstract interface to functions // An abstract interface to functions
// more explanation at the head of this file // more explanation at the head of this file
class function { class function {
public :
class argument { class argument {
//iMap is the id of the dataCacheMap, e.g. on interfaces //iMap is the id of the dataCacheMap, e.g. on interfaces
public: public:
...@@ -45,10 +46,15 @@ class function { ...@@ -45,10 +46,15 @@ class function {
f = f_; f = f_;
} }
}; };
class substitutedFunction {
public:
int iMap;
const function *f0, *f1; // f1 replaces f0
};
int _nbCol; int _nbCol;
bool _invalidatedOnElement; bool _invalidatedOnElement;
protected : std::vector<int> _childrenCache;
public : std::vector<substitutedFunction> _substitutedFunctions;
virtual void call (dataCacheMap *m, fullMatrix<double> &res)=0; virtual void call (dataCacheMap *m, fullMatrix<double> &res)=0;
std::vector<argument*> arguments; std::vector<argument*> arguments;
const fullMatrix<double> &addArgument(const function *f, int iMap = 0) { const fullMatrix<double> &addArgument(const function *f, int iMap = 0) {
...@@ -57,6 +63,16 @@ class function { ...@@ -57,6 +63,16 @@ class function {
arguments.push_back(new argument(iMap, f)); arguments.push_back(new argument(iMap, f));
return arguments.back()->val; return arguments.back()->val;
} }
void addChildDataCacheMap(int parent) {
_childrenCache.push_back(parent);
}
void substituteFunction( int iMap, const function *f0, const function *f1) {
substitutedFunction s;
s.iMap= iMap;
s.f0 = f0;
s.f1 = f1;
_substitutedFunctions.push_back(s);
}
virtual ~function(); virtual ~function();
static void registerBindings(binding *b); static void registerBindings(binding *b);
function(int nbCol, bool invalidatedOnElement = true); function(int nbCol, bool invalidatedOnElement = true);
...@@ -97,6 +113,7 @@ public : ...@@ -97,6 +113,7 @@ public :
return (_iDependOn.find(&other)!=_iDependOn.end()); return (_iDependOn.find(&other)!=_iDependOn.end());
} }
std::vector<dataCacheDouble*> _dependencies; std::vector<dataCacheDouble*> _dependencies;
std::vector<std::pair<dataCacheDouble*, dataCacheDouble*> > _substitutions;
int _nRowByPoint; int _nRowByPoint;
function *_function; function *_function;
...@@ -147,7 +164,7 @@ class dgDataCacheMap; ...@@ -147,7 +164,7 @@ class dgDataCacheMap;
// more explanation at the head of this file // more explanation at the head of this file
class dataCacheMap { class dataCacheMap {
friend class dataCacheDouble; friend class dataCacheDouble;
protected: public:
dataCacheMap *_parent; dataCacheMap *_parent;
std::list<dataCacheMap*> _children; std::list<dataCacheMap*> _children;
std::vector<dataCacheMap*> _secondaryCaches; std::vector<dataCacheMap*> _secondaryCaches;
...@@ -163,7 +180,6 @@ class dataCacheMap { ...@@ -163,7 +180,6 @@ class dataCacheMap {
if(invalidatedOnElement) if(invalidatedOnElement)
_toInvalidateOnElement.insert(data); _toInvalidateOnElement.insert(data);
} }
public:
void printList() { void printList() {
for(std::set<dataCacheDouble*>::iterator it = _toInvalidateOnElement.begin(); it!= _toInvalidateOnElement.end(); it++) for(std::set<dataCacheDouble*>::iterator it = _toInvalidateOnElement.begin(); it!= _toInvalidateOnElement.end(); it++)
printf("%p\n",*it); printf("%p\n",*it);
...@@ -199,10 +215,12 @@ class dataCacheMap { ...@@ -199,10 +215,12 @@ class dataCacheMap {
_nbEvaluationPoints = 0; _nbEvaluationPoints = 0;
_parent=NULL; _parent=NULL;
} }
void setParent(dataCacheMap *parent) { virtual dataCacheMap *newChild() {
_parent = parent; dataCacheMap *m = new dataCacheMap();
_parent->_children.push_back(this); m->_parent = this;
_nbEvaluationPoints = 0; _children.push_back(m);
m->_nbEvaluationPoints = 0;
return m;
} }
void setNbEvaluationPoints(int nbEvaluationPoints); void setNbEvaluationPoints(int nbEvaluationPoints);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment