LCOV - code coverage report
Current view: top level - ugbase/bridge/algebra_bridges - eigensolver_bridge.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.9 % 32 31
Test Date: 2025-09-21 23:31:46 Functions: 100.0 % 4 4

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2011-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Martin Rupp
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : // extern headers
      34              : #include <iostream>
      35              : #include <sstream>
      36              : #include <string>
      37              : 
      38              : // include bridge
      39              : #include "bridge/bridge.h"
      40              : #include "bridge/util.h"
      41              : #include "bridge/util_algebra_dependent.h"
      42              : 
      43              : #include "lib_algebra/lib_algebra.h"
      44              : 
      45              : using namespace std;
      46              : 
      47              : 
      48              : #include "../../lib_algebra/operator/eigensolver/power_method.h"
      49              : #include "lib_algebra/operator/eigensolver/pinvit.h"
      50              : #include "lib_algebra/operator/preconditioner/operator_inverse_iterator.h"
      51              : 
      52              : namespace ug{
      53              : namespace bridge{
      54              : namespace Eigensolver{
      55              : 
      56              : /**
      57              :  * \defgroup eigensolver_bridge Eigensolver Bridge
      58              :  * \ingroup algebra_bridge
      59              :  * \{
      60              :  */
      61              : 
      62              : /**
      63              :  * Class exporting the functionality. All functionality that is to
      64              :  * be used in scripts or visualization must be registered here.
      65              :  */
      66              : struct Functionality
      67              : {
      68              : 
      69              : /**
      70              :  * Function called for the registration of Algebra dependent parts.
      71              :  * All Functions and Classes depending on Algebra
      72              :  * are to be placed here when registering. The method is called for all
      73              :  * available Algebra types, based on the current build options.
      74              :  *
      75              :  * @param reg                           registry
      76              :  * @param parentGroup           group for sorting of functionality
      77              :  */
      78              : template <typename TAlgebra>
      79            3 : static void Algebra(Registry& reg, string grp)
      80              : {
      81            3 :         string suffix = GetAlgebraSuffix<TAlgebra>();
      82            3 :         string tag = GetAlgebraTag<TAlgebra>();
      83              : 
      84              : #ifdef LAPACK_AVAILABLE
      85              :         {
      86              :                 string name = string("EigenSolver").append(suffix);
      87              :                 typedef PINVIT<TAlgebra> T;
      88              :                 typedef DebugWritingObject<TAlgebra> TBase;
      89              :                 reg.add_class_<T, TBase>(name, grp)
      90              :                         .add_constructor()
      91              :                         .add_method("add_vector", &T::add_vector, "", "vector")
      92              :                         .add_method("set_preconditioner", &T::set_preconditioner, "", "Preconditioner")
      93              :                         .add_method("set_linear_operator_A", &T::set_linear_operator_A,   "", "LinearOperatorA")
      94              :                         .add_method("set_linear_operator_B", &T::set_linear_operator_B,   "", "LinearOperatorB")
      95              :                         .add_method("set_max_iterations", &T::set_max_iterations, "", "precision")
      96              :                         .add_method("num_eigenvalues", &T::num_eigenvalues, "number of eigenvalues")
      97              :                         .add_method("get_eigenvalue", &T::get_eigenvalue, "eigenvalue i", "i")
      98              :                         .add_method("set_precision", &T::set_precision, "", "precision")
      99              :                         .add_method("set_abort_on_frequencies_converged_linear_elasticity", &T::set_abort_on_frequencies_converged_linear_elasticity, "", "")
     100              :                         .add_method("set_relative_precision", &T::set_relative_precision, "", "precision")
     101              :                         .add_method("get_eigenvector", &T::get_eigenvector, "eigenvector i", "i")
     102              :                         .add_method("set_print_eigenvalues_and_defect", &T::set_print_eigenvalues_and_defect, "", "b")
     103              :                         .add_method("set_print_projected_eigenvectors", &T::set_print_projected_eigenvectors, "", "b")
     104              :                         .add_method("set_print_projected_eigenvalues", &T::set_print_projected_eigenvalues, "", "b")
     105              :                         .add_method("set_print_projected_eigenproblem", &T::set_print_projected_eigenproblem, "", "b")
     106              :                         .add_method("set_additional_eigenvectors_to_keep", &T::set_additional_eigenvectors_to_keep, "", "i", "additional i smallest ritz-eigenvectors are added to the test space")
     107              :                         .add_method("set_use_additional_corrections", &T::set_use_additional_corrections, "", "b")
     108              :                         .add_method("set_debug_calc_projected_eigenvalues", &T::set_debug_calc_projected_eigenvalues, "", "b")
     109              :                         .add_method("set_print_used_testvectors", &T::set_print_used_testvectors, "", "b")
     110              :                         .add_method("set_pinvit", &T::set_pinvit, "", "iPINVIT", "1 = preconditioned inverse block iteration, 2 = preconditioned block gradient descent, 3 = LOBPCG")
     111              :                         .add_method("set_linear_dependent_eps", &T::set_linear_dependent_eps)
     112              :                         .add_method("set_laplacian", &T::set_laplacian)
     113              :                         .add_method("get_max_deflection_of_a_mode", &T::get_max_deflection_of_a_mode, "maximal deflection of a mode", "composed mode and eigenvectors,")
     114              :                         .add_method("set_store_defects", &T::set_store_defects)
     115              :                         .add_method("set_store_lambdas", &T::set_store_lambdas)
     116              :                         .add_method("get_defect", &T::get_defect)
     117              :                         .add_method("get_lambda", &T::get_lambda)
     118              :                         .add_method("get_iterations", &T::get_iterations)
     119              :                         .add_method("apply", &T::apply);
     120              : 
     121              : 
     122              : 
     123              : 
     124              :                 reg.add_class_to_group(name, "EigenSolver", tag);
     125              :         }
     126              : #endif
     127              :         {
     128            3 :                 string name = string("OperatorInverseIterator").append(suffix);
     129              :                 typedef typename TAlgebra::vector_type vector_type;
     130              :                 typedef ILinearIterator<vector_type> TBase;
     131              :                 typedef OperatorInverseIterator<TAlgebra> T;
     132            9 :                 reg.add_class_<T, TBase>(name, grp)
     133            6 :                         .template add_constructor<void (*)(SmartPtr<ILinearOperatorInverse<vector_type>  >)>( "opInv")
     134            3 :                         .set_construct_as_smart_pointer(true);
     135            9 :                 reg.add_class_to_group(name, "OperatorInverseIterator", tag);
     136              :         }
     137              : 
     138              :         {
     139            3 :                 string name = string("PowerMethod").append(suffix);
     140              :                 typedef PowerMethod<TAlgebra> T;
     141            9 :                 reg.add_class_<T>(name, grp)
     142            3 :                         .add_constructor()
     143            9 :                         .add_method("set_solver", &T::set_solver, "", "Solver")
     144           12 :                         .add_method("set_linear_operator_A", &T::set_linear_operator_A,   "", "LinearOperatorA")
     145           12 :                         .add_method("set_linear_operator_B", &T::set_linear_operator_B,   "", "LinearOperatorB")
     146           12 :                         .add_method("set_start_vector", &T::set_start_vector, "", "start vector")
     147           12 :                         .add_method("set_max_iterations", &T::set_max_iterations, "", "iterations")
     148           12 :                         .add_method("set_precision", &T::set_precision, "", "precision")
     149           12 :                         .add_method("calculate_max_eigenvalue", &T::calculate_max_eigenvalue, "", "")
     150           12 :                         .add_method("calculate_min_eigenvalue", &T::calculate_min_eigenvalue, "", "")
     151           12 :                         .add_method("get_max_eigenvalue", &T::get_max_eigenvalue, "", "")
     152           12 :                         .add_method("get_min_eigenvalue", &T::get_min_eigenvalue, "", "")
     153           12 :                         .add_method("get_iterations", &T::get_iterations)
     154           12 :                         .add_method("print_matrix_A", &T::print_matrix_A, "", "")
     155           12 :                         .add_method("print_matrix_B", &T::print_matrix_B, "", "")
     156            9 :                         .add_method("print_eigenvector", &T::print_eigenvector, "", "");
     157            9 :                 reg.add_class_to_group(name, "PowerMethod", tag);
     158              :         }
     159            3 : }
     160              : }; // end Functionality
     161              : 
     162              : // end group eigensolver_bridge
     163              : /// \}
     164              : 
     165              : }// end Eigensolver
     166              : 
     167              : 
     168              : /// \addtogroup eigensolver_bridge
     169            1 : void RegisterBridge_Eigensolver(Registry& reg, string grp)
     170              : {
     171            1 :         grp.append("/Algebra/Solver");
     172              :         typedef Eigensolver::Functionality Functionality;
     173              : 
     174              :         try{
     175            1 :                 RegisterAlgebraDependent<Functionality>(reg,grp);
     176              :         }
     177            0 :         UG_REGISTRY_CATCH_THROW(grp);
     178            1 : }
     179              : 
     180              : } // namespace bridge
     181              : } // namespace ug
        

Generated by: LCOV version 2.0-1