HermesCommon  3.0
algebra_mixins.h
Go to the documentation of this file.
1 // This file is part of HermesCommon
2 //
3 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
4 // Email: hpfem-group@unr.edu, home page: http://www.hpfem.org/.
5 //
6 // Hermes2D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published
8 // by the Free Software Foundation; either version 2 of the License,
9 // or (at your option) any later version.
10 //
11 // Hermes2D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Hermes2D; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef __HERMES_COMMON_ALGEBRA_MIXINS_H
23 #define __HERMES_COMMON_ALGEBRA_MIXINS_H
24 
25 #include "common.h"
26 #include "util/compat.h"
27 #include "algebra_utilities.h"
28 #include "exceptions.h"
29 
30 namespace Hermes
31 {
32  namespace Algebra
33  {
34  template<typename Scalar> class SparseMatrix;
35  template<typename Scalar> class Vector;
36 
37  namespace Mixins
38  {
41  template<typename Scalar>
42  class HERMES_API MatrixRhsOutput
43  {
44  public:
48 
50  void process_matrix_output(Hermes::Algebra::SparseMatrix<Scalar>* matrix, int iteration);
51  void process_matrix_output(Hermes::Algebra::SparseMatrix<Scalar>* matrix);
52 
54  void process_vector_output(Hermes::Algebra::Vector<Scalar>* rhs, int iteration);
55  void process_vector_output(Hermes::Algebra::Vector<Scalar>* rhs);
56 
60  void output_matrix(bool only_last_iteration = true, int firstIterations = -1);
62  void set_print_zero_matrix_entries(bool to_set);
66  void set_matrix_filename(std::string name);
69  void set_matrix_varname(std::string name);
72  void set_matrix_export_format(Hermes::Algebra::MatrixExportFormat format);
75  void set_matrix_number_format(char* number_format);
76 
80  void output_rhs(bool only_last_iteration = true, int firstIterations = -1);
84  void set_rhs_filename(std::string name);
87  void set_rhs_varname(std::string name);
90  void set_rhs_export_format(Hermes::Algebra::MatrixExportFormat format);
93  void set_rhs_number_format(char* number_format);
94 
95  protected:
96  bool print_matrix_zero_values;
97  bool output_matrixOn;
98  bool only_lastMatrixIteration;
99  int output_matrixIterations;
100  std::string matrixFilename;
101  std::string matrixVarname;
103  char* matrix_number_format;
104 
105  bool output_rhsOn;
106  bool only_lastRhsIteration;
107  int output_rhsIterations;
108  std::string RhsFilename;
109  std::string RhsVarname;
111  char* rhs_number_format;
112  };
113 
116  template<typename Scalar>
117  class HERMES_API MatrixRhsImportExport
118  {
119  public:
125  virtual void export_to_file(const char* filename, const char* var_name, Algebra::MatrixExportFormat fmt, char* number_format = "%lf") = 0;
126  void export_to_file(std::string filename, const char* var_name, Algebra::MatrixExportFormat fmt, char* number_format = "%lf");
127  void export_to_file(std::string filename, std::string var_name, Algebra::MatrixExportFormat fmt, char* number_format = "%lf");
128 
133  virtual void import_from_file(const char* filename, const char* var_name, Algebra::MatrixExportFormat fmt) { throw Hermes::Exceptions::MethodNotOverridenException("MatrixRhsImportExport<Scalar>::import_from_file"); };
134  void import_from_file(std::string filename, const char* var_name, Algebra::MatrixExportFormat fmt);
135  void import_from_file(std::string filename, std::string var_name, Algebra::MatrixExportFormat fmt);
136  };
137  }
138  }
139 }
140 #endif
General namespace for the Hermes library.
General (abstract) vector representation in Hermes.
virtual void import_from_file(const char *filename, const char *var_name, Algebra::MatrixExportFormat fmt)
General (abstract) sparse matrix representation in Hermes.
MatrixExportFormat
Format of file matrix and vector output.
Utilities for all Algebra code.
File containing definition of exceptions classes.
File containing platform compatibility layer, especially for Win / MSVC.
Method is not overriden and should be.
Definition: exceptions.h:201
File containing common definitions, and basic global enums etc. for HermesCommon. ...