From 4626524e8faaff69fe851004d0c5fd779ea53356 Mon Sep 17 00:00:00 2001 From: Wenqing Wang <wenqing.wang@ufz.de> Date: Fri, 18 Aug 2017 14:16:32 +0200 Subject: [PATCH] [Coupling] Removed term coupling term from NumLib/ODESolver --- NumLib/ODESolver/NonlinearSolver.cpp | 18 ++++++------- NumLib/ODESolver/NonlinearSolver.h | 26 +++---------------- NumLib/ODESolver/NonlinearSystem.h | 13 ++-------- NumLib/ODESolver/ODESystem.h | 11 ++------ NumLib/ODESolver/TimeDiscretizedODESystem.cpp | 10 +++---- NumLib/ODESolver/TimeDiscretizedODESystem.h | 12 ++------- 6 files changed, 21 insertions(+), 69 deletions(-) diff --git a/NumLib/ODESolver/NonlinearSolver.cpp b/NumLib/ODESolver/NonlinearSolver.cpp index 1becfac4277..96c899ee320 100644 --- a/NumLib/ODESolver/NonlinearSolver.cpp +++ b/NumLib/ODESolver/NonlinearSolver.cpp @@ -21,14 +21,13 @@ namespace NumLib { void NonlinearSolver<NonlinearSolverTag::Picard>::assemble( - GlobalVector const& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term) const + GlobalVector const& x) const { - _equation_system->assemble(x, coupling_term); + _equation_system->assemble(x); } bool NonlinearSolver<NonlinearSolverTag::Picard>::solve( - GlobalVector& x, ProcessLib::StaggeredCouplingTerm const& coupling_term, + GlobalVector& x, std::function<void(unsigned, GlobalVector const&)> const& postIterationCallback) { namespace LinAlg = MathLib::LinAlg; @@ -59,7 +58,7 @@ bool NonlinearSolver<NonlinearSolverTag::Picard>::solve( BaseLib::RunTime time_assembly; time_assembly.start(); - sys.assemble(x, coupling_term); + sys.assemble(x); sys.getA(A); sys.getRhs(rhs); INFO("[time] Assembly took %g s.", time_assembly.elapsed()); @@ -159,17 +158,16 @@ bool NonlinearSolver<NonlinearSolverTag::Picard>::solve( } void NonlinearSolver<NonlinearSolverTag::Newton>::assemble( - GlobalVector const& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term) const + GlobalVector const& x) const { - _equation_system->assemble(x, coupling_term); + _equation_system->assemble(x); // TODO if the equation system would be reset to nullptr after each // assemble() or solve() call, the user would be forced to set the // equation every time and could not forget it. } bool NonlinearSolver<NonlinearSolverTag::Newton>::solve( - GlobalVector& x, ProcessLib::StaggeredCouplingTerm const& coupling_term, + GlobalVector& x, std::function<void(unsigned, GlobalVector const&)> const& postIterationCallback) { namespace LinAlg = MathLib::LinAlg; @@ -202,7 +200,7 @@ bool NonlinearSolver<NonlinearSolverTag::Newton>::solve( BaseLib::RunTime time_assembly; time_assembly.start(); - sys.assemble(x, coupling_term); + sys.assemble(x); sys.getResidual(x, res); sys.getJacobian(J); INFO("[time] Assembly took %g s.", time_assembly.elapsed()); diff --git a/NumLib/ODESolver/NonlinearSolver.h b/NumLib/ODESolver/NonlinearSolver.h index 76fe29f29df..c725de023ae 100644 --- a/NumLib/ODESolver/NonlinearSolver.h +++ b/NumLib/ODESolver/NonlinearSolver.h @@ -22,11 +22,6 @@ namespace BaseLib class ConfigTree; } -namespace ProcessLib -{ - struct StaggeredCouplingTerm; -} - // TODO Document in the ODE solver lib, which matrices and vectors that are // passed around as method arguments are guaranteed to be of the right size // (and zeroed out) and which are not. @@ -47,27 +42,18 @@ public: * * \param x the state at which the equation system will be * assembled. - * \param coupling_term the coupled term including the reference of the - * coupled processes and solutions of the equations of - * the coupled processes. */ - virtual void assemble(GlobalVector const& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term - ) const = 0; + virtual void assemble(GlobalVector const& x) const = 0; /*! Assemble and solve the equation system. * * \param x in: the initial guess, out: the solution. - * \param coupling_term the coupled term including the reference of the - * coupled processes and solutions of the equations of - * the coupled processes. * \param postIterationCallback called after each iteration if set. * * \retval true if the equation system could be solved * \retval false otherwise */ virtual bool solve(GlobalVector& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term, std::function<void(unsigned, GlobalVector const&)> const& postIterationCallback) = 0; @@ -117,12 +103,9 @@ public: _convergence_criterion = &conv_crit; } - void assemble(GlobalVector const& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term - ) const override; + void assemble(GlobalVector const& x) const override; bool solve(GlobalVector& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term, std::function<void(unsigned, GlobalVector const&)> const& postIterationCallback) override; @@ -176,12 +159,9 @@ public: _convergence_criterion = &conv_crit; } - void assemble(GlobalVector const& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term - ) const override; + void assemble(GlobalVector const& x) const override; bool solve(GlobalVector& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term, std::function<void(unsigned, GlobalVector const&)> const& postIterationCallback) override; diff --git a/NumLib/ODESolver/NonlinearSystem.h b/NumLib/ODESolver/NonlinearSystem.h index e7cffb1755c..edfa53160ee 100644 --- a/NumLib/ODESolver/NonlinearSystem.h +++ b/NumLib/ODESolver/NonlinearSystem.h @@ -12,11 +12,6 @@ #include "EquationSystem.h" #include "Types.h" -namespace ProcessLib -{ - struct StaggeredCouplingTerm; -} - namespace NumLib { //! \addtogroup ODESolver @@ -41,9 +36,7 @@ public: //! Assembles the linearized equation system at the point \c x. //! The linearized system is \f$A(x) \cdot x = b(x)\f$. Here the matrix //! \f$A(x)\f$ and the vector \f$b(x)\f$ are assembled. - virtual void assemble(GlobalVector const& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term - ) = 0; + virtual void assemble(GlobalVector const& x) = 0; /*! Writes the residual at point \c x to \c res. * @@ -82,9 +75,7 @@ public: //! Assembles the linearized equation system at the point \c x. //! The linearized system is \f$J(x) \cdot \Delta x = (x)\f$. Here the //! residual vector \f$r(x)\f$ and its Jacobian \f$J(x)\f$ are assembled. - virtual void assemble(GlobalVector const& x, - ProcessLib::StaggeredCouplingTerm const& coupling_term - ) = 0; + virtual void assemble(GlobalVector const& x) = 0; //! Writes the linearized equation system matrix to \c A. //! \pre assemble() must have been called before. diff --git a/NumLib/ODESolver/ODESystem.h b/NumLib/ODESolver/ODESystem.h index 598252c5940..b362403f9b5 100644 --- a/NumLib/ODESolver/ODESystem.h +++ b/NumLib/ODESolver/ODESystem.h @@ -15,11 +15,6 @@ #include "EquationSystem.h" #include "Types.h" -namespace ProcessLib -{ -struct StaggeredCouplingTerm; -} - namespace NumLib { //! \addtogroup ODESolver @@ -52,8 +47,7 @@ public: //! Assemble \c M, \c K and \c b at the provided state (\c t, \c x). virtual void assemble( const double t, GlobalVector const& x, GlobalMatrix& M, GlobalMatrix& K, - GlobalVector& b, - ProcessLib::StaggeredCouplingTerm const& coupling_term) = 0; + GlobalVector& b) = 0; using Index = MathLib::MatrixVectorTraits<GlobalMatrix>::Index; @@ -126,8 +120,7 @@ public: virtual void assembleWithJacobian( const double t, GlobalVector const& x, GlobalVector const& xdot, const double dxdot_dx, const double dx_dx, GlobalMatrix& M, - GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac, - ProcessLib::StaggeredCouplingTerm const& coupling_term) = 0; + GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac) = 0; }; //! @} diff --git a/NumLib/ODESolver/TimeDiscretizedODESystem.cpp b/NumLib/ODESolver/TimeDiscretizedODESystem.cpp index 0684b2657f4..a1b6f29685c 100644 --- a/NumLib/ODESolver/TimeDiscretizedODESystem.cpp +++ b/NumLib/ODESolver/TimeDiscretizedODESystem.cpp @@ -67,8 +67,7 @@ TimeDiscretizedODESystem< void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton>:: - assemble(const GlobalVector& x_new_timestep, - ProcessLib::StaggeredCouplingTerm const& coupling_term) + assemble(const GlobalVector& x_new_timestep) { namespace LinAlg = MathLib::LinAlg; @@ -86,7 +85,7 @@ void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear, _Jac->setZero(); _ode.assembleWithJacobian(t, x_curr, xdot, dxdot_dx, dx_dx, *_M, *_K, *_b, - *_Jac, coupling_term); + *_Jac); LinAlg::finalizeAssembly(*_M); LinAlg::finalizeAssembly(*_K); @@ -176,8 +175,7 @@ TimeDiscretizedODESystem< void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Picard>:: - assemble(const GlobalVector& x_new_timestep, - ProcessLib::StaggeredCouplingTerm const& coupling_term) + assemble(const GlobalVector& x_new_timestep) { namespace LinAlg = MathLib::LinAlg; @@ -188,7 +186,7 @@ void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear, _K->setZero(); _b->setZero(); - _ode.assemble(t, x_curr, *_M, *_K, *_b, coupling_term); + _ode.assemble(t, x_curr, *_M, *_K, *_b); LinAlg::finalizeAssembly(*_M); LinAlg::finalizeAssembly(*_K); diff --git a/NumLib/ODESolver/TimeDiscretizedODESystem.h b/NumLib/ODESolver/TimeDiscretizedODESystem.h index 122803064fa..cb408e6ee71 100644 --- a/NumLib/ODESolver/TimeDiscretizedODESystem.h +++ b/NumLib/ODESolver/TimeDiscretizedODESystem.h @@ -16,12 +16,6 @@ #include "ODESystem.h" #include "TimeDiscretization.h" - -namespace ProcessLib -{ - struct StaggeredCouplingTerm; -} - namespace NumLib { //! \addtogroup ODESolver @@ -86,8 +80,7 @@ public: ~TimeDiscretizedODESystem() override; - void assemble(const GlobalVector& x_new_timestep, - ProcessLib::StaggeredCouplingTerm const& coupling_term) + void assemble(const GlobalVector& x_new_timestep) override; void getResidual(GlobalVector const& x_new_timestep, @@ -180,8 +173,7 @@ public: ~TimeDiscretizedODESystem() override; - void assemble(const GlobalVector& x_new_timestep, - ProcessLib::StaggeredCouplingTerm const& coupling_term) + void assemble(const GlobalVector& x_new_timestep) override; void getA(GlobalMatrix& A) const override -- GitLab