LCOV - code coverage report
Current view: top level - /builds/ug4-project/ugcore/ug4-new/plugins/Limex - newton_limex.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 2 0
Test Date: 2026-06-01 23:54:59 Functions: 0.0 % 3 0

            Line data    Source code
       1              : /*
       2              :  * SPDX-FileCopyrightText:  Copyright (c) 2010-2015:  G-CSC, Goethe University Frankfurt
       3              :  * SPDX-License-Identifier: LicenseRef-UG4-LGPL-3.0
       4              :  *
       5              :  * Author: Markus Breit,
       6              :  *         but largely copied from ugcore Newton implementation by Andreas Vogel
       7              :  * 
       8              :  * This file is part of UG4.
       9              :  * 
      10              :  * UG4 is free software: you can redistribute it and/or modify it under the
      11              :  * terms of the GNU Lesser General Public License version 3 (as published by the
      12              :  * Free Software Foundation) with the following additional attribution
      13              :  * requirements (according to LGPL/GPL v3 §7):
      14              :  * 
      15              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      16              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (2) The following notice must be displayed at a prominent place in the
      19              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      20              :  * 
      21              :  * (3) The following bibliography is recommended for citation and must be
      22              :  * preserved in all covered files:
      23              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      24              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      25              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      26              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      27              :  *   flexible software system for simulating pde based models on high performance
      28              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      29              :  * 
      30              :  * This program is distributed in the hope that it will be useful,
      31              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      32              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      33              :  * GNU Lesser General Public License for more details.
      34              :  */
      35              : 
      36              : #ifndef UG_PLUGINS__LIMEX__NEWTON_LIMEX
      37              : #define UG_PLUGINS__LIMEX__NEWTON_LIMEX
      38              : 
      39              : #include "lib_algebra/operator/interface/operator_inverse.h"
      40              : #include "lib_algebra/operator/interface/linear_operator_inverse.h"
      41              : #include "lib_algebra/operator/debug_writer.h"
      42              : 
      43              : #include "lib_disc/assemble_interface.h"
      44              : #include "lib_disc/operator/non_linear_operator/assembled_non_linear_operator.h"
      45              : #include "lib_disc/operator/linear_operator/assembled_linear_operator.h"
      46              : 
      47              : 
      48              : namespace ug {
      49              : 
      50              : /// Newton solver for assembling-based discretizations solved using Limex
      51              : template <typename TAlgebra>
      52              : class LimexNewtonSolver
      53              :         :       public IOperatorInverse<typename TAlgebra::vector_type>
      54              :                 //public DebugWritingObject<TAlgebra>
      55              : {
      56              :         public:
      57              :                 /// algebra type
      58              :                 typedef TAlgebra algebra_type;
      59              : 
      60              :                 /// vector type
      61              :                 typedef typename TAlgebra::vector_type vector_type;
      62              : 
      63              :                 /// matrix type
      64              :                 typedef typename TAlgebra::matrix_type matrix_type;
      65              : 
      66              :         public:
      67              :                 /// default constructor
      68              :                 LimexNewtonSolver();
      69              : 
      70              :                 /// constructor setting operator
      71              :                 LimexNewtonSolver(SmartPtr<IOperator<vector_type> > N);
      72              : 
      73              :                 /// constructor using assembling
      74              :                 LimexNewtonSolver(SmartPtr<IAssemble<TAlgebra> > spAss);
      75              : 
      76              :                 /// sets the linear solver
      77            0 :                 void set_linear_solver(SmartPtr<ILinearOperatorInverse<vector_type> > LinearSolver)
      78            0 :                 {m_spLinearSolver = LinearSolver;}
      79              : 
      80              :                 /// This operator inverts the operator N: Y -> X
      81              :                 virtual bool init(SmartPtr<IOperator<vector_type> > N);
      82              : 
      83              :                 /// prepare operator
      84              :                 virtual bool prepare(vector_type& u);
      85              : 
      86              :                 /// apply operator, i.e. N^{-1}(0) = u
      87              :                 virtual bool apply(vector_type& u);
      88              : 
      89              :                 /**
      90              :                  * @brief Returns information about configuration parameters.
      91              :                  * This should return necessary information about parameters and possibly
      92              :                  * calling config_string of subcomponents.
      93              :                  *
      94              :                  * @returns std::string  necessary information about configuration parameters
      95              :                  */
      96              :                 virtual std::string config_string() const;
      97              : 
      98              :                 /// prints average linear solver convergence
      99              :                 number linear_solver_rate() const;
     100              : 
     101              :                 /// information on linear solver convergence
     102              :                 int linear_solver_steps() const;
     103              : 
     104              :         private:
     105              :                 /// help functions for debug output
     106              :                 /// @{
     107              :                 void write_debug(const vector_type& vec, const char* filename);
     108              :                 void write_debug(const matrix_type& mat, const char* filename);
     109              :                 /// @}
     110              : 
     111              :         private:
     112              :                 /// linear solver
     113              :                 SmartPtr<ILinearOperatorInverse<vector_type> > m_spLinearSolver;
     114              : 
     115              : 
     116              :                 /// assembling routine
     117              :                 SmartPtr<AssembledOperator<algebra_type> > m_N;
     118              : 
     119              :                 /// jacobi operator
     120              :                 SmartPtr<AssembledLinearOperator<algebra_type> > m_J;
     121              : 
     122              :                 /// assembling
     123              :                 SmartPtr<IAssemble<TAlgebra> > m_spAss;
     124              : 
     125              : 
     126              :                 /// convergence history of linear solver
     127              :                 /// @{
     128              :                 size_t m_linSolverSteps;
     129              :                 number m_linSolverRate;
     130              :                 /// @}
     131              : };
     132              : 
     133              : }       // namespace ug
     134              : 
     135              : #include "newton_limex_impl.h"
     136              : 
     137              : #endif  // UG_PLUGINS__LIMEX__NEWTON_LIMEX
        

Generated by: LCOV version 2.0-1