From 3977d3651278b3fd178252eadd9335a0d0e42dca Mon Sep 17 00:00:00 2001 From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be> Date: Mon, 15 Mar 2010 14:06:42 +0000 Subject: [PATCH] function : replce provideData by specific method (provideSolution,...), this is the first step to remove all the getName and refer to functions by pointer and not by string (and later merge dataCacheDouble and function in order to simplify fnction writing) --- Solver/TESTCASES/Stommel.lua | 2 +- Solver/dgAlgorithm.cpp | 4 ++-- Solver/dgConservationLaw.cpp | 4 ++-- Solver/dgDofContainer.cpp | 2 +- Solver/dgFunctionIntegrator.cpp | 4 ++-- Solver/dgLimiter.cpp | 2 +- Solver/dgResidual.cpp | 28 ++++++++++++++-------------- Solver/function.cpp | 26 ++++++++++++++++++++------ Solver/function.h | 5 ++++- 9 files changed, 47 insertions(+), 30 deletions(-) diff --git a/Solver/TESTCASES/Stommel.lua b/Solver/TESTCASES/Stommel.lua index e9537dd968..04fba32a3a 100644 --- a/Solver/TESTCASES/Stommel.lua +++ b/Solver/TESTCASES/Stommel.lua @@ -18,7 +18,7 @@ void coriolis (fullMatrix<double> &sol, fullMatrix<double> &xyz) { ]] if (Msg.getCommRank() == 0 ) then - cfile = io.popen("g++ -O3 -pipe -m32 -shared -o tmp.dylib -I ../../Numeric -I../../Common -I../../build/Common -x c++ - ","w"); + cfile = io.popen("g++-4.2 -O3 -pipe -m32 -shared -o tmp.dylib -I ../../Numeric -I../../Common -I../../build/Common -x c++ - ","w"); cfile:write("#include\"fullMatrix.h\"\nextern \"C\" {") cfile:write(CFunctions) cfile:write("}") diff --git a/Solver/dgAlgorithm.cpp b/Solver/dgAlgorithm.cpp index 6de8e415a0..1740a28e99 100644 --- a/Solver/dgAlgorithm.cpp +++ b/Solver/dgAlgorithm.cpp @@ -82,8 +82,8 @@ void dgAlgorithm::computeElementaryTimeSteps ( //dofManager &dof, // the DOF man const int nbFields = claw.getNbFields(); dataCacheMap cacheMap; cacheMap.setNbEvaluationPoints(group.getNbIntegrationPoints()); - dataCacheDouble &sol = cacheMap.provideData("Solution",1,nbFields); - dataCacheDouble &UVW = cacheMap.provideData("UVW",1,3); + dataCacheDouble &sol = cacheMap.provideSolution(nbFields); + dataCacheDouble &UVW = cacheMap.provideParametricCoordinates(); UVW.set(group.getIntegrationPointsMatrix()); dataCacheElement &cacheElement = cacheMap.getElement(); // provided dataCache diff --git a/Solver/dgConservationLaw.cpp b/Solver/dgConservationLaw.cpp index 85f74c9f60..de184a8a2a 100644 --- a/Solver/dgConservationLaw.cpp +++ b/Solver/dgConservationLaw.cpp @@ -11,7 +11,7 @@ class dgBoundaryConditionOutsideValue : public dgBoundaryCondition { public: term(dgConservationLaw *claw, dataCacheMap &cacheMapLeft,const std::string outsideValueFunctionName): dataCacheDouble(cacheMapLeft, 1, claw->getNbFields()), - solutionRight(cacheMapRight.provideData("Solution",1,claw->getNbFields())), + solutionRight(cacheMapRight.provideSolution(claw->getNbFields())), outsideValue(cacheMapLeft.get(outsideValueFunctionName,this)), _claw(claw) { @@ -51,7 +51,7 @@ class dgBoundaryConditionOutsideValue : public dgBoundaryCondition { public: maximumDiffusivity(dgConservationLaw *claw, dataCacheMap &cacheMapLeft,const std::string outsideValueFunctionName): dataCacheDouble(cacheMapLeft, 1, claw->getNbFields()), - solutionRight(cacheMapRight.provideData("Solution",1,claw->getNbFields())), + solutionRight(cacheMapRight.provideSolution(claw->getNbFields())), outsideValue(cacheMapLeft.get(outsideValueFunctionName,this)), _claw(claw) { diff --git a/Solver/dgDofContainer.cpp b/Solver/dgDofContainer.cpp index 6270552d01..645b42ec6d 100644 --- a/Solver/dgDofContainer.cpp +++ b/Solver/dgDofContainer.cpp @@ -226,7 +226,7 @@ void dgDofContainer::L2Projection(std::string functionName){ dataCacheMap cacheMap; cacheMap.setNbEvaluationPoints(group.getNbIntegrationPoints()); dataCacheElement &cacheElement = cacheMap.getElement(); - cacheMap.provideData("UVW",1,3).set(group.getIntegrationPointsMatrix()); + cacheMap.provideParametricCoordinates().set(group.getIntegrationPointsMatrix()); dataCacheDouble &sourceTerm = cacheMap.get(functionName); fullMatrix<double> source; for (int iElement=0 ; iElement<group.getNbElements() ;++iElement) { diff --git a/Solver/dgFunctionIntegrator.cpp b/Solver/dgFunctionIntegrator.cpp index 58822d6b87..f04677d184 100644 --- a/Solver/dgFunctionIntegrator.cpp +++ b/Solver/dgFunctionIntegrator.cpp @@ -11,8 +11,8 @@ dgFunctionIntegrator::dgFunctionIntegrator(std::string fName):_fName(fName){} void dgFunctionIntegrator::compute(dgDofContainer *sol,fullMatrix<double> &result){ int nbFields=sol->getNbFields(); dataCacheMap cacheMap; - dataCacheDouble &UVW=cacheMap.provideData("UVW", 1, 3); - dataCacheDouble &solutionQPe=cacheMap.provideData("Solution", 1, nbFields); + dataCacheDouble &UVW=cacheMap.provideParametricCoordinates(); + dataCacheDouble &solutionQPe=cacheMap.provideSolution(nbFields); dataCacheElement &cacheElement=cacheMap.getElement(); function *f=function::get(_fName); dataCacheDouble *F=f->newDataCache(&cacheMap); diff --git a/Solver/dgLimiter.cpp b/Solver/dgLimiter.cpp index 2bce19da12..7a88ead065 100644 --- a/Solver/dgLimiter.cpp +++ b/Solver/dgLimiter.cpp @@ -111,7 +111,7 @@ int dgSlopeLimiter::apply ( dgDofContainer *solution) dataCacheMap cacheMap; cacheMap.setNbEvaluationPoints(egroup->getNbNodes());//nbdofs for each element - dataCacheDouble &solutionE = cacheMap.provideData("Solution",1,nbFields); + dataCacheDouble &solutionE = cacheMap.provideSolution(nbFields); dataCacheElement &cacheElement = cacheMap.getElement(); dataCacheDouble *solutionEClipped = _claw->newClipToPhysics(cacheMap); if (solutionEClipped){ diff --git a/Solver/dgResidual.cpp b/Solver/dgResidual.cpp index 57005f39e7..02cecb65bd 100644 --- a/Solver/dgResidual.cpp +++ b/Solver/dgResidual.cpp @@ -11,9 +11,9 @@ dgResidualVolume::dgResidualVolume(const dgConservationLaw &claw): _claw(claw), _nbFields(_claw.getNbFields()), _cacheElement(_cacheMap->getElement()), - _UVW(_cacheMap->provideData("UVW", 1, 3)), - _solutionQPe(_cacheMap->provideData("Solution", 1, _nbFields)), - _gradientSolutionQPe(_cacheMap->provideData("SolutionGradient", 3, _nbFields)), + _UVW(_cacheMap->provideParametricCoordinates()), + _solutionQPe(_cacheMap->provideSolution(_nbFields)), + _gradientSolutionQPe(_cacheMap->provideSolutionGradient(_nbFields)), _sourceTerm(_claw.newSourceTerm(*_cacheMap)), _convectiveFlux(_claw.newConvectiveFlux(*_cacheMap)), _diffusiveFlux(_claw.newDiffusiveFlux(*_cacheMap)) @@ -268,13 +268,13 @@ dgResidualInterface::dgResidualInterface (const dgConservationLaw &claw) : _nbFields(claw.getNbFields()), _cacheElementLeft(_cacheMapLeft->getElement()), _cacheElementRight(_cacheMapRight->getElement()), - _uvwLeft(_cacheMapLeft->provideData("UVW",1,3)), - _uvwRight(_cacheMapRight->provideData("UVW",1,3)), - _solutionQPLeft(_cacheMapLeft->provideData("Solution",1,_nbFields)), - _solutionQPRight(_cacheMapRight->provideData("Solution",1,_nbFields)), - _gradientSolutionLeft(_cacheMapLeft->provideData("SolutionGradient",3,_nbFields)), - _gradientSolutionRight(_cacheMapRight->provideData("SolutionGradient",3,_nbFields)), - _normals(_cacheMapLeft->provideData("Normals",1,1)), + _uvwLeft(_cacheMapLeft->provideParametricCoordinates()), + _uvwRight(_cacheMapRight->provideParametricCoordinates()), + _solutionQPLeft(_cacheMapLeft->provideSolution(_nbFields)), + _solutionQPRight(_cacheMapRight->provideSolution(_nbFields)), + _gradientSolutionLeft(_cacheMapLeft->provideSolutionGradient(_nbFields)), + _gradientSolutionRight(_cacheMapRight->provideSolutionGradient(_nbFields)), + _normals(_cacheMapLeft->provideNormals()), _riemannSolver(claw.newRiemannSolver(*_cacheMapLeft,*_cacheMapRight)), _diffusiveFluxLeft(claw.newDiffusiveFlux(*_cacheMapLeft)), _diffusiveFluxRight(claw.newDiffusiveFlux(*_cacheMapRight)), @@ -418,10 +418,10 @@ void dgResidualBoundary::compute1Group( cacheMapLeft.setNbEvaluationPoints(group.getNbIntegrationPoints()); const fullMatrix<double> &DPsiLeftDx = left.getDPsiDx(); // provided dataCache - dataCacheDouble &uvw=cacheMapLeft.provideData("UVW",1,3); - dataCacheDouble &solutionQPLeft = cacheMapLeft.provideData("Solution",1,nbFields); - dataCacheDouble &gradientSolutionLeft = cacheMapLeft.provideData("SolutionGradient",3,nbFields); - dataCacheDouble &normals = cacheMapLeft.provideData("Normals",1,1); + dataCacheDouble &uvw=cacheMapLeft.provideParametricCoordinates(); + dataCacheDouble &solutionQPLeft = cacheMapLeft.provideSolution(nbFields); + dataCacheDouble &gradientSolutionLeft = cacheMapLeft.provideSolutionGradient(nbFields); + dataCacheDouble &normals = cacheMapLeft.provideNormals(); dataCacheElement &cacheElementLeft = cacheMapLeft.getElement(); // required data // inviscid diff --git a/Solver/function.cpp b/Solver/function.cpp index 1bd3041b8a..9d4ce36541 100644 --- a/Solver/function.cpp +++ b/Solver/function.cpp @@ -72,13 +72,27 @@ dataCacheDouble &dataCacheMap::get(const std::string &functionName, dataCache *c r->addMeAsDependencyOf(caller); return *r; } - -dataCacheDouble &dataCacheMap::provideData(std::string name,int nRowByPoints, int nCol) +dataCacheDouble &dataCacheMap::provideSolution(int nbFields) +{ + dataCacheDouble *r = new providedDataDouble(*this,1, nbFields); + _cacheDoubleMap["Solution"] = r; + return *r; +} +dataCacheDouble &dataCacheMap::provideSolutionGradient(int nbFields){ + dataCacheDouble *r = new providedDataDouble(*this,3, nbFields); + _cacheDoubleMap["SolutionGradient"] = r; + return *r; +} +dataCacheDouble &dataCacheMap::provideParametricCoordinates() +{ + dataCacheDouble *r = new providedDataDouble(*this,1, 3); + _cacheDoubleMap["UVW"] = r; + return *r; +} +dataCacheDouble &dataCacheMap::provideNormals() { - if (_cacheDoubleMap[name] != NULL) - throw; - dataCacheDouble *r = new providedDataDouble(*this,nRowByPoints, nCol); - _cacheDoubleMap[name] = r; + dataCacheDouble *r = new providedDataDouble(*this,1, 3); + _cacheDoubleMap["Normals"] = r; return *r; } diff --git a/Solver/function.h b/Solver/function.h index c7ea127f06..f87ae98e78 100644 --- a/Solver/function.h +++ b/Solver/function.h @@ -194,10 +194,13 @@ class dataCacheMap { //list of dgDofContainer whom gradient are needed std::map<dgDofContainer*,dataCacheDouble*> gradientFields; // end dg Part + dataCacheDouble &provideSolution(int nbFields); + dataCacheDouble &provideSolutionGradient(int nbFields); + dataCacheDouble &provideParametricCoordinates(); + dataCacheDouble &provideNormals(); dataCacheDouble &get(const std::string &functionName, dataCache *caller=0); dataCacheElement &getElement(dataCache *caller=0); - dataCacheDouble &provideData(std::string name, int nRowByPoints, int nCol); dataCacheMap(){ _cacheElement = new dataCacheElement(this); _nbEvaluationPoints = 0; -- GitLab