KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
reorderer.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Pooyan Dadvand
11 //
12 //
13 
14 #if !defined(KRATOS_REORDERER_H_INCLUDED )
15 #define KRATOS_REORDERER_H_INCLUDED
16 
17 // System includes
18 #include <string>
19 #include <iostream>
20 #include <vector>
21 
22 // External includes
23 
24 // Project includes
25 #include "includes/define.h"
26 
27 namespace Kratos
28 {
31 
35 
39 
43 
47 
49 
58 template<class TSparseSpaceType, class TDenseSpaceType>
59 class Reorderer
60 {
61 public:
64 
67 
69 
71 
73 
74  typedef unsigned int IndexType;
75 
76  typedef unsigned int SizeType;
77 
78  typedef std::vector<IndexType> IndexVectorType;
79 
83 
85  Reorderer() {}
86 
88  Reorderer(Reorderer const& rOther) {}
89 
91  virtual ~Reorderer() {}
92 
93 
97 
99  Reorderer& operator=(Reorderer const& rOther)
100  {
101  return *this;
102  }
103 
104 
108 
109  virtual void Initialize(SparseMatrixType& rA, VectorType& rX, VectorType& rB)
110  {
112  }
113 
114  virtual void Reorder(SparseMatrixType& rA, VectorType& rX, VectorType& rB)
115  {
116  }
117 
119  {
120  }
121 
123  {
125 
126  if(mIndexPermutation.size() != size)
127  mIndexPermutation.resize(size);
128 
129  for(SizeType i = 0 ; i < size ; i++)
130  mIndexPermutation[i] = i;
131 
132  return mIndexPermutation;
133  }
134 
138 
140  {
141  return mIndexPermutation;
142  }
143 
147 
148 
152 
154  virtual std::string Info() const
155  {
156  return "Reorderer";
157  }
158 
160  virtual void PrintInfo(std::ostream& rOStream) const
161  {
162  rOStream << "Reorderer";
163  }
164 
166  virtual void PrintData(std::ostream& rOStream) const
167  {
168  }
169 
170 
174 
175 
177 
178 protected:
181 
182 
186 
187 
191 
192 
196 
197 
201 
202 
206 
207 
211 
212 
214 
215 private:
218 
219 
223 
224  IndexVectorType mIndexPermutation;
225 
226 
230 
231 
235 
236 
240 
241 
245 
246 
250 
251 
253 
254 }; // Class Reorderer
255 
257 
260 
261 
265 
266 
268 template<class TSparseSpaceType, class TDenseSpaceType>
269 inline std::istream& operator >> (std::istream& rIStream,
271 
273 template<class TSparseSpaceType, class TDenseSpaceType>
274 inline std::ostream& operator << (std::ostream& rOStream,
276 {
277  rThis.PrintInfo(rOStream);
278  rOStream << std::endl;
279  rThis.PrintData(rOStream);
280 
281  return rOStream;
282 }
284 
285 
286 } // namespace Kratos.
287 
288 #endif // KRATOS_REORDERER_H_INCLUDED defined
289 
290 
Base class for all reorderer objects in Kratos used in linear solvers.
Definition: reorderer.h:60
virtual ~Reorderer()
Destructor.
Definition: reorderer.h:91
TSparseSpaceType::VectorType VectorType
Definition: reorderer.h:70
unsigned int SizeType
Definition: reorderer.h:76
unsigned int IndexType
Definition: reorderer.h:74
TSparseSpaceType::MatrixType SparseMatrixType
Definition: reorderer.h:68
virtual void Initialize(SparseMatrixType &rA, VectorType &rX, VectorType &rB)
Definition: reorderer.h:109
virtual IndexVectorType & CalculateIndexPermutation(SparseMatrixType &rA, IndexType InitialIndex=IndexType())
Definition: reorderer.h:122
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: reorderer.h:160
virtual std::string Info() const
Turn back information as a string.
Definition: reorderer.h:154
std::vector< IndexType > IndexVectorType
Definition: reorderer.h:78
KRATOS_CLASS_POINTER_DEFINITION(Reorderer)
Pointer definition of Reorderer.
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: reorderer.h:166
Reorderer & operator=(Reorderer const &rOther)
Assignment operator.
Definition: reorderer.h:99
virtual void Reorder(SparseMatrixType &rA, VectorType &rX, VectorType &rB)
Definition: reorderer.h:114
virtual IndexVectorType & GetIndexPermutation()
Definition: reorderer.h:139
TDenseSpaceType::MatrixType DenseMatrixType
Definition: reorderer.h:72
Reorderer()
Default constructor.
Definition: reorderer.h:85
virtual void InverseReorder(SparseMatrixType &rA, VectorType &rX, VectorType &rB)
Definition: reorderer.h:118
Reorderer(Reorderer const &rOther)
Copy constructor.
Definition: reorderer.h:88
Vector VectorType
Definition: geometrical_transformation_utilities.h:56
Matrix MatrixType
Definition: geometrical_transformation_utilities.h:55
TSpaceType::IndexType Size1(TSpaceType &dummy, typename TSpaceType::MatrixType const &rM)
Definition: add_strategies_to_python.cpp:117
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::vector< IndexType > IndexVectorType
Index vector.
Definition: mmg_io.h:63
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
integer i
Definition: TensorModule.f:17