From 43461e66bfe0f4bdf5d8484213fe23d11f8bec3d Mon Sep 17 00:00:00 2001 From: Laura Pfeiffer <laura.pfeiffer@kit.edu> Date: Mon, 29 Jul 2024 11:59:17 +0200 Subject: [PATCH] try next iterate of adaptive version --- src/coupled/solvers/SegregatedSolver.cpp | 28 +++++++++++++++++++----- src/coupled/solvers/SegregatedSolver.hpp | 5 +++++ tools/solving/CoupledHoreka.py | 4 ++-- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/coupled/solvers/SegregatedSolver.cpp b/src/coupled/solvers/SegregatedSolver.cpp index d225774f6..92f6ad19d 100644 --- a/src/coupled/solvers/SegregatedSolver.cpp +++ b/src/coupled/solvers/SegregatedSolver.cpp @@ -272,9 +272,11 @@ bool adaptiveSegregatedSolver::Step(IElphyAssemble &elphyAssemble, IElasticity & elphyAssemble.ResetTime(mechAssemble.Time(), mechAssemble.LastTStep(), elphyDeltaTime); double gammaInfNorm=elphyAssemble.InftyNormOnVertices(v_stretch(elphyValues)); + vout(2)<<"gammaInfNorm "<<gammaInfNorm<<endl; int elphyStepCounter=0; - if (gammaInfNorm<=0.00001) { - while (elphyStepCounter != elphySteps && gammaInfNorm <= 0.00001) { + double minGammaInfNorm =0.00001; + if (gammaInfNorm<minGammaInfNorm) { + while (elphyStepCounter != elphySteps && gammaInfNorm < minGammaInfNorm) { //while (!elphyAssemble.IsFinished()) { elphySolver->printSolverNameInStep(elphyAssemble, ongoingElphyStep); elphySolver->Step(elphyAssemble, elphyValues); @@ -283,15 +285,31 @@ bool adaptiveSegregatedSolver::Step(IElphyAssemble &elphyAssemble, IElasticity & ongoingElphyStep += 1; elphyStepCounter += 1; } - //}else if(0.0<gammaInfNorm<0.5*maxGammaInfNorm) { - + }else if(minGammaInfNorm<=gammaInfNorm && gammaInfNorm<factorMaxGammaInfnorm*maxGammaInfNorm) { + + int numberOfInbetweenTimSteps=int(log2(elphySteps))-1; + vout(2)<<" numberOfInbetweenTimSteps "<<numberOfInbetweenTimSteps; + for (int i=0;i<numberOfInbetweenTimSteps;i++){ + double leftboundary= (double(i)/double(numberOfInbetweenTimSteps))*factorMaxGammaInfnorm*maxGammaInfNorm+minGammaInfNorm; + double rightboundary= (double(i+1)/double(numberOfInbetweenTimSteps))*factorMaxGammaInfnorm*maxGammaInfNorm; + vout(2)<<" leftboundary "<<leftboundary<<" rightboundary "<<rightboundary; + if ( leftboundary< gammaInfNorm && gammaInfNorm<= rightboundary){ + vout(2)<<" i "<<i<<" number steps "<<int(elphySteps/(pow(2,i+1)))<<endl; + while (elphyStepCounter !=int(elphySteps/(pow(2,i+1)))) { + elphySolver->printSolverNameInStep(elphyAssemble, ongoingElphyStep); + elphySolver->Step(elphyAssemble, elphyValues); + ongoingElphyStep += 1; + elphyStepCounter += 1; + } + break; + } + } }else{ elphySolver->printSolverNameInStep(elphyAssemble, ongoingElphyStep); elphySolver->Step(elphyAssemble, elphyValues); ongoingElphyStep += 1; elphyStepCounter=1; } - // Projects stretch from elphy to mech cardiacTransfer->Project(u_stretch(mechValues), v_stretch(elphyValues)); mechAssemble.UpdateStretch(u_stretch(mechValues)); diff --git a/src/coupled/solvers/SegregatedSolver.hpp b/src/coupled/solvers/SegregatedSolver.hpp index 98f88cdcc..621dac683 100644 --- a/src/coupled/solvers/SegregatedSolver.hpp +++ b/src/coupled/solvers/SegregatedSolver.hpp @@ -99,12 +99,17 @@ class adaptiveSegregatedSolver: public SegregatedSolver { double elphyDeltaTime{0.0}; double maxGammaInfNorm{0.0}; int oldEplpyStepCounter{0}; + double factorMaxGammaInfnorm{0.8}; public: explicit adaptiveSegregatedSolver(std::unique_ptr<ElphySolver> &&eSolver, std::unique_ptr<ElastodynamicTimeIntegrator> &&mSolver,int eSteps = -1) : SegregatedSolver(std::move(eSolver),std::move(mSolver),eSteps) { + if(elphySteps<=2){ + Exit("The difference between MechDeltaTime and ElphyDeltaTime is to small for the adaptive scheme!") + } Config::Get("ElphyDeltaTime", elphyDeltaTime); Config::Get("MaximalGammaInf", maxGammaInfNorm); + Config::Get("FactorMaximalGammaInf",factorMaxGammaInfnorm); oldEplpyStepCounter=elphySteps; }; diff --git a/tools/solving/CoupledHoreka.py b/tools/solving/CoupledHoreka.py index 584bea052..f0aa90389 100644 --- a/tools/solving/CoupledHoreka.py +++ b/tools/solving/CoupledHoreka.py @@ -211,10 +211,10 @@ def startAll(): def startAdaptiveTimeStep(): lL=[2] - tL=[0] + tL=[0,2] nL=['SI'] sdt=0.0004 - startJobs(lL,tL,nL,sdt,'adaptive/',{'Mesh':'TestBiventricleSimpleExcitation_smooth','ElphyProblem':'DeformedBiventricleCoarse','EndTime':0.6,'MechDeltaTime':0.0016,'AdaptiveTimeStepForMech':'true',}) + startJobs(lL,tL,nL,sdt,'adaptive/',{'Mesh':'TestBiventricleSimpleExcitation_smooth','ElphyProblem':'DeformedBiventricleCoarse','EndTime':0.15,'MechDeltaTime':0.0016,'AdaptiveTimeStepForMech':'true','MaximalGammaInf':0.3,'FactorMaximalGammaInf':0.8}) def startFixedMechTimeStep(): lL=[2] -- GitLab