Flow123d  master-f44eb46
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_ */
unsigned int size() const
Definition: armor.hh:728
Record type proxy class.
Definition: type_record.hh:182
static const int registrar
Registrar of class to factory.
void view(string text="") override
LinSys_PERMON(const Distribution *rows_ds, const std::string &params="")
Mat matrix_ineq_
PETSc matrix of inequality constraint.
double get_solution_precision() override
double get_absolute_accuracy() override
LinSys_PETSC::SolveInfo solve() override
T * makePetscPointer_(std::vector< T > &array)
static const Input::Type::Record & get_input_type()
Vec ineq_
PETSc vector of inequality constraint.
double compute_residual() override
LinSys FactoryBaseType
void set_inequality(Mat matrix_ineq, Vec ineq)
double a_tol_
absolute tolerance of linear solver
Definition: linsys.hh:666
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
Array< double > array
Definition: armor.hh:890
Abstract linear system class.
Definition: balance.hh:40
internal::NamedArg< char > arg(StringRef name, const T &arg)
Definition: format.h:3291
double operator()(PetscScalar arg)