From f8d3af7405a18a4a071e073d883c8f33387219f4 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 7 Aug 2019 10:38:37 +0200 Subject: [PATCH] added: linear parameter in SIMExplicitRK set this to mark operator as linear. this disables repeated assembly, and reuses factorization if a LU solver is utilized. --- Apps/Common/SIMExplicitRK.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Apps/Common/SIMExplicitRK.h b/Apps/Common/SIMExplicitRK.h index 6fb590a6..0b588f83 100644 --- a/Apps/Common/SIMExplicitRK.h +++ b/Apps/Common/SIMExplicitRK.h @@ -13,6 +13,7 @@ #ifndef SIM_EXPLICIT_RK_H_ #define SIM_EXPLICIT_RK_H_ +#include "SIMenums.h" #include "TimeIntUtils.h" #include "TimeStep.h" @@ -109,12 +110,16 @@ public: time.t = tp.time.t+tp.time.dt*(RK.c[i]-1.0); solver.updateDirichlet(time.t, &dum); solver.applyDirichlet(tmp); - if (!solver.assembleSystem(time, Vectors(1, tmp))) + if (!solver.assembleSystem(time, Vectors(1, tmp), + !linear || (tp.step == 1 && i == 0))) return false; // solve Mu = Au + f if (!solver.solveSystem(stages[i])) return false; + + if (linear) + solver.setMode(SIM::RHS_ONLY); } // finally construct solution as weighted stages @@ -168,10 +173,14 @@ public: return solver.deSerialize(data); } + //! \brief Mark operator as linear to avoid repeated assembly and factorization. + void setLinear(bool enable) { linear = enable; } + protected: Solver& solver; //!< Reference to simulator RKTableaux RK; //!< Tableaux of Runge-Kutta coefficients bool alone; //!< If true, this is a standalone solver + bool linear = false; //!< If true, this is a linear equation }; }