From ab2bfed8033692ef7d80bfdb0229d85f91f9301c Mon Sep 17 00:00:00 2001 From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be> Date: Wed, 24 Mar 2010 10:09:17 +0000 Subject: [PATCH] remove dataCacheElement --- Solver/dgAlgorithm.cpp | 4 +--- Solver/dgDofContainer.cpp | 3 +-- Solver/dgFunctionIntegrator.cpp | 3 +-- Solver/dgLimiter.cpp | 1 - Solver/dgResidual.cpp | 7 +++---- Solver/dgResidual.h | 1 - Solver/function.cpp | 10 +--------- Solver/function.h | 31 +++++++++++++------------------ 8 files changed, 20 insertions(+), 40 deletions(-) diff --git a/Solver/dgAlgorithm.cpp b/Solver/dgAlgorithm.cpp index 11c6ef297f..0654da1299 100644 --- a/Solver/dgAlgorithm.cpp +++ b/Solver/dgAlgorithm.cpp @@ -85,7 +85,6 @@ void dgAlgorithm::computeElementaryTimeSteps ( //dofManager &dof, // the DOF man dataCacheDouble &sol = cacheMap.provideSolution(nbFields); dataCacheDouble &UVW = cacheMap.provideParametricCoordinates(); UVW.set(group.getIntegrationPointsMatrix()); - dataCacheElement &cacheElement = cacheMap.getElement(); // provided dataCache dataCacheDouble *maxConvectiveSpeed = claw.newMaxConvectiveSpeed(cacheMap); dataCacheDouble *maximumDiffusivity = claw.newMaximumDiffusivity(cacheMap); @@ -100,8 +99,7 @@ void dgAlgorithm::computeElementaryTimeSteps ( //dofManager &dof, // the DOF man DT.resize(group.getNbElements()); for (int iElement=0 ; iElement<group.getNbElements() ;++iElement) { sol.setAsProxy(solution, iElement*nbFields, nbFields); - MElement *e = group.getElement(iElement); - cacheElement.set(e); + cacheMap.setElement(group.getElement(iElement)); const double L = group.getInnerRadius(iElement); double spectralRadius = 0.0; if (maximumDiffusivity){ diff --git a/Solver/dgDofContainer.cpp b/Solver/dgDofContainer.cpp index a7d17cf3bf..2e599a6ec2 100644 --- a/Solver/dgDofContainer.cpp +++ b/Solver/dgDofContainer.cpp @@ -229,12 +229,11 @@ void dgDofContainer::L2Projection(const function *f){ fullMatrix<double> Source = fullMatrix<double> (group.getNbIntegrationPoints(),group.getNbElements() * _nbFields); dataCacheMap cacheMap; cacheMap.setNbEvaluationPoints(group.getNbIntegrationPoints()); - dataCacheElement &cacheElement = cacheMap.getElement(); cacheMap.provideParametricCoordinates().set(group.getIntegrationPointsMatrix()); dataCacheDouble &sourceTerm = cacheMap.get(f); fullMatrix<double> source; for (int iElement=0 ; iElement<group.getNbElements() ;++iElement) { - cacheElement.set(group.getElement(iElement)); + cacheMap.setElement(group.getElement(iElement)); source.setAsProxy(Source, iElement*_nbFields, _nbFields); for (int iPt =0; iPt< group.getNbIntegrationPoints(); iPt++) { const double detJ = group.getDetJ (iElement, iPt); diff --git a/Solver/dgFunctionIntegrator.cpp b/Solver/dgFunctionIntegrator.cpp index 9c269a0c9e..130a7fab5a 100644 --- a/Solver/dgFunctionIntegrator.cpp +++ b/Solver/dgFunctionIntegrator.cpp @@ -13,7 +13,6 @@ void dgFunctionIntegrator::compute(dgDofContainer *sol,fullMatrix<double> &resul dataCacheMap cacheMap; dataCacheDouble &UVW=cacheMap.provideParametricCoordinates(); dataCacheDouble &solutionQPe=cacheMap.provideSolution(nbFields); - dataCacheElement &cacheElement=cacheMap.getElement(); dataCacheDouble &F=cacheMap.get(_f); int nbRowResult=result.size1(); result.scale(0.0); @@ -26,7 +25,7 @@ void dgFunctionIntegrator::compute(dgDofContainer *sol,fullMatrix<double> &resul group.getCollocationMatrix().mult(solProxy , solutionQP); fullMatrix<double> IPMatrix = group.getIntegrationPointsMatrix(); for (int iElement=0 ; iElement<group.getNbElements() ;++iElement) { - cacheElement.set(group.getElement(iElement)); + cacheMap.setElement(group.getElement(iElement)); solutionQPe.setAsProxy(solutionQP, iElement*nbFields, nbFields ); for (int iPt =0; iPt< group.getNbIntegrationPoints(); iPt++) { const double detJ = group.getDetJ (iElement, iPt); diff --git a/Solver/dgLimiter.cpp b/Solver/dgLimiter.cpp index d97e0cc999..fab0d9d96e 100644 --- a/Solver/dgLimiter.cpp +++ b/Solver/dgLimiter.cpp @@ -115,7 +115,6 @@ int dgSlopeLimiter::apply ( dgDofContainer *solution) dataCacheMap cacheMap; cacheMap.setNbEvaluationPoints(egroup->getNbNodes());//nbdofs for each element dataCacheDouble &solutionE = cacheMap.provideSolution(nbFields); - dataCacheElement &cacheElement = cacheMap.getElement(); dataCacheDouble *solutionEClipped = _claw->newClipToPhysics(cacheMap); if (solutionEClipped){ for (int iElement=0 ; iElement<egroup->getNbElements() ;++iElement) { diff --git a/Solver/dgResidual.cpp b/Solver/dgResidual.cpp index 3ef7ab80e8..3b147ec38a 100644 --- a/Solver/dgResidual.cpp +++ b/Solver/dgResidual.cpp @@ -10,7 +10,6 @@ dgResidualVolume::dgResidualVolume(const dgConservationLaw &claw): _cacheMap(new dataCacheMap), _claw(claw), _nbFields(_claw.getNbFields()), - _cacheElement(_cacheMap->getElement()), _UVW(_cacheMap->provideParametricCoordinates()), _solutionQPe(_cacheMap->provideSolution(_nbFields)), _gradientSolutionQPe(_cacheMap->provideSolutionGradient(_nbFields)), @@ -62,7 +61,7 @@ void dgResidualVolume::compute1Group(dgGroupOfElements &group, fullMatrix<double gradSolProxy.setAsShapeProxy(_gradientSolutionQPe.set(),group.getNbIntegrationPoints()*3, _nbFields); dPsiDx.mult(dofs, gradSolProxy); } - _cacheElement.set(group.getElement(iElement)); + _cacheMap->setElement(group.getElement(iElement)); if(_convectiveFlux || _diffusiveFlux) { // ----- 2.3.3 --- compute fluxes in UVW coordinates for (int iUVW=0;iUVW<group.getDimUVW();iUVW++) { @@ -156,7 +155,7 @@ void dgResidualVolume::compute1GroupWithJacobian(dgGroupOfElements &group, fullM gradSolProxy.setAsShapeProxy(_gradientSolutionQPe.set(),group.getNbIntegrationPoints()*3, _nbFields); dPsiDx.mult(dofs, gradSolProxy); } - _cacheElement.set(group.getElement(iElement)); + _cacheMap->setElement(group.getElement(iElement)); if(_convectiveFlux || _diffusiveFlux) { // ----- 2.3.3 --- compute fluxes in UVW coordinates for (int iUVW=0;iUVW<group.getDimUVW();iUVW++) { @@ -321,7 +320,7 @@ void dgResidualInterface::compute1Group ( //dofManager &dof, // the DOF manager for (int iFace=0 ; iFace < nbFaces ; ++iFace) { for (int i=0; i<nbConnections; i++) { // B1 ) adjust the proxies for this element - caches[i].getElement().set(connections[i]->getElement(iFace)); + caches[i].setElement(connections[i]->getElement(iFace)); caches[i].getParametricCoordinates(NULL).setAsProxy(connections[i]->getIntegrationPointsOnElement(iFace)); caches[i].getSolution(NULL).setAsProxy(solutionQP, (iFace*nbConnections+i)*_nbFields, _nbFields); caches[i].getNormals(NULL).setAsProxy(connections[i]->getNormals(), iFace*group.getNbIntegrationPoints(), group.getNbIntegrationPoints()); diff --git a/Solver/dgResidual.h b/Solver/dgResidual.h index e4a13d2ff3..ed3097f7c0 100644 --- a/Solver/dgResidual.h +++ b/Solver/dgResidual.h @@ -16,7 +16,6 @@ class dgResidualVolume { dataCacheMap *_cacheMap; const dgConservationLaw &_claw; int _nbFields; - dataCacheElement &_cacheElement; dataCacheDouble &_UVW, &_solutionQPe, &_gradientSolutionQPe; dataCacheDouble *_sourceTerm, *_convectiveFlux, *_diffusiveFlux; public: diff --git a/Solver/function.cpp b/Solver/function.cpp index 8955b1dcdc..05b62507a6 100644 --- a/Solver/function.cpp +++ b/Solver/function.cpp @@ -35,7 +35,6 @@ class function::data : public dataCacheDouble { { _function = f; _m = m; - _m->getElement(this); _dependencies.resize ( _function->dep.size()); _depM.resize (_function->dep.size()); for (int i=0;i<_function->dep.size();i++) @@ -72,13 +71,6 @@ void dataCache::addMeAsDependencyOf (dataCache *newDep) //dataCacheMap members -dataCacheElement &dataCacheMap::getElement(dataCache *caller) -{ - if(caller) - _cacheElement.addMeAsDependencyOf(caller); - return _cacheElement; -} - static dataCacheDouble &returnDataCacheDouble(dataCacheDouble *data, dataCache *caller) { if(data==NULL) throw; @@ -175,7 +167,7 @@ class functionCoordinates : public function { const fullMatrix<double> &uvw = m->getParametricCoordinates(NULL)(); for(int i = 0; i < uvw.size1(); i++){ SPoint3 p; - m->getElement(NULL)()->pnt(uvw(i, 0), uvw(i, 1), uvw(i, 2), p); + m->getElement()->pnt(uvw(i, 0), uvw(i, 1), uvw(i, 2), p); xyz(i, 0) = p.x(); xyz(i, 1) = p.y(); xyz(i, 2) = p.z(); diff --git a/Solver/function.h b/Solver/function.h index 890b038dd3..099d9ebe35 100644 --- a/Solver/function.h +++ b/Solver/function.h @@ -145,20 +145,6 @@ class function { dataCacheDouble *newDataCache(dataCacheMap *m); }; -// A special node in the dependency tree for which all the leafs -// depend on the given element -class dataCacheElement : public dataCache { - private: - MElement *_element; - public: - void set(MElement *ele){ - _invalidateDependencies(); - _element=ele; - }; - inline MElement *operator () () { return _element; } - dataCacheElement(dataCacheMap *map):dataCache(map){} -}; - // more explanation at the head of this file class dataCacheMap { friend class dataCache; @@ -176,18 +162,22 @@ class dataCacheMap { public: providedDataDouble(dataCacheMap &map, int nRowByPoints, int ncol):dataCacheDouble(map,nRowByPoints,ncol) { _valid=true; + map._toInvalidateOnElement.erase(this); } }; std::set<dataCache*> _toDelete; std::set<dataCacheDouble*> _toResize; + std::set<dataCacheDouble*> _toInvalidateOnElement; + + MElement *_element; - dataCacheElement _cacheElement; protected: void addDataCache(dataCache *data){ _toDelete.insert(data); } void addDataCacheDouble(dataCacheDouble *data){ _toResize.insert(data); + _toInvalidateOnElement.insert(data); } public: dataCacheDouble *_solution, *_solutionGradient, *_parametricCoordinates, *_normals; @@ -201,9 +191,14 @@ class dataCacheMap { dataCacheDouble &provideNormals(); dataCacheDouble &get(const function *f, dataCache *caller=0); - dataCacheElement &getElement(dataCache *caller=0); - dataCacheMap():_cacheElement(this){ - _toDelete.erase(&_cacheElement); + inline void setElement(MElement *element) { + _element=element; + for(std::set<dataCacheDouble*>::iterator it = _toInvalidateOnElement.begin(); it!= _toInvalidateOnElement.end(); it++) { + (*it)->_valid=false; + } + } + inline MElement *getElement() {return _element;} + dataCacheMap(){ _normals = _solution = _solutionGradient = _parametricCoordinates = 0; _nbEvaluationPoints = 0; } -- GitLab