Flow123d  3.9.0-960b954f9
linsys_PERMON.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file linsys_PERMON.hh
15  * @brief PERMON QP solvers and FETI
16  * @author Jakub Kruzik
17  */
18 
19 #ifndef LA_LINSYS_PERMON_HH_
20 #define LA_LINSYS_PERMON_HH_
21 
22 #include <functional> // for unary_function
23 #include <string> // for string
24 #include <vector> // for vector
25 #include "la/linsys_PETSC.hh" // for LinSys
26 #include "permonqps.h" // for QPS and whole PERMON/PETSc stack
27 
28 class Distribution;
29 namespace Input {
30  class Record;
31  namespace Type {
32  class Record;
33  }
34 }
35 namespace la {
36  class BddcmlWrapper;
37 }
38 
40 {
41 
42 public:
44 
45  static const Input::Type::Record & get_input_type();
46 
47  LinSys_PERMON(const Distribution * rows_ds, const std::string &params = "");
48 
49  /**
50  * Copy constructor.
51  */
52  LinSys_PERMON( LinSys_PERMON &other );
53 
54  void set_inequality(Mat matrix_ineq, Vec ineq);
55 
56  LinSys_PETSC::SolveInfo solve() override;
57 
58  /**
59  * Returns information on absolute solver accuracy
60  */
61  inline double get_absolute_accuracy() override {
62  return a_tol_;
63  };
64 
65  void view(string text="") override;
66 
67  double get_solution_precision() override;
68 
69  double compute_residual() override;
70 
71  ~LinSys_PERMON( );
72 
73 private:
74  /// Registrar of class to factory
75  static const int registrar;
76 
77  // make a pointer to the data array out of a std::vector
78  template<typename T>
80  {
81  if ( array.size() ) return &(array[0]);
82  return PETSC_NULL;
83  }
84 
85  // PetscScalar to double casting functor
86  struct PetscScalar2Double_ : public std::unary_function< PetscScalar, double >
87  {
88  double operator()( PetscScalar arg )
89  {
90  return static_cast<double>( arg );
91  }
92  };
93 
94 protected:
95 
96  Mat matrix_ineq_; //!< PETSc matrix of inequality constraint.
97  Vec ineq_; //!< PETSc vector of inequality constraint.
98 
99  QP system;
100  QPS solver;
101 };
102 
103 #endif /* LA_LINSYS_PERMON_HH_ */
LinSys_PERMON::solver
QPS solver
Definition: linsys_PERMON.hh:100
LinSys_PERMON::get_input_type
static const Input::Type::Record & get_input_type()
Definition: linsys_PERMON.cc:32
LinSys_PERMON::system
QP system
Definition: linsys_PERMON.hh:99
LinSys_PERMON::PetscScalar2Double_
Definition: linsys_PERMON.hh:86
LinSys
Definition: la_linsys_new.hh:169
LinSys_PERMON::solve
LinSys_PETSC::SolveInfo solve() override
Definition: linsys_PERMON.cc:82
Input
Abstract linear system class.
Definition: balance.hh:40
LinSys_PERMON::makePetscPointer_
T * makePetscPointer_(std::vector< T > &array)
Definition: linsys_PERMON.hh:79
LinSys::SolveInfo
Definition: linsys.hh:104
LinSys_PERMON::get_absolute_accuracy
double get_absolute_accuracy() override
Definition: linsys_PERMON.hh:61
LinSys_PERMON::matrix_ineq_
Mat matrix_ineq_
PETSc matrix of inequality constraint.
Definition: linsys_PERMON.hh:96
Armor::array
Array< double > array
Definition: armor.hh:890
LinSys_PETSC
Definition: linsys_PETSC.hh:43
std::vector
Definition: doxy_dummy_defs.hh:7
linsys_PETSC.hh
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
LinSys_PERMON::get_solution_precision
double get_solution_precision() override
Definition: linsys_PERMON.cc:236
LinSys_PERMON
Definition: linsys_PERMON.hh:39
LinSys_PERMON::registrar
static const int registrar
Registrar of class to factory.
Definition: linsys_PERMON.hh:75
LinSys_PERMON::LinSys_PERMON
LinSys_PERMON(const Distribution *rows_ds, const std::string &params="")
Definition: linsys_PERMON.cc:61
LinSys_PERMON::view
void view(string text="") override
Definition: linsys_PERMON.cc:174
Distribution
Definition: distribution.hh:50
LinSys::a_tol_
double a_tol_
absolute tolerance of linear solver
Definition: linsys.hh:664
LinSys_PERMON::PetscScalar2Double_::operator()
double operator()(PetscScalar arg)
Definition: linsys_PERMON.hh:88
LinSys_PERMON::compute_residual
double compute_residual() override
Definition: linsys_PERMON.cc:242
la
Definition: bddcml_wrapper.hh:41
LinSys_PERMON::set_inequality
void set_inequality(Mat matrix_ineq, Vec ineq)
Definition: linsys_PERMON.cc:75
LinSys_PERMON::~LinSys_PERMON
~LinSys_PERMON()
Definition: linsys_PERMON.cc:228
Armor::Array::size
unsigned int size() const
Definition: armor.hh:728
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
fmt::arg
internal::NamedArg< char > arg(StringRef name, const T &arg)
Definition: format.h:3291
LinSys_PERMON::FactoryBaseType
LinSys FactoryBaseType
Definition: linsys_PERMON.hh:43
LinSys_PERMON::ineq_
Vec ineq_
PETSc vector of inequality constraint.
Definition: linsys_PERMON.hh:97