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.
preconditioner.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_PRECONDITIONER_H_INCLUDED )
15 #define KRATOS_PRECONDITIONER_H_INCLUDED
16 
17 // System includes
18 #include <string>
19 #include <iostream>
20 
21 // External includes
22 
23 // Project includes
24 #include "includes/define.h"
25 #include "includes/model_part.h"
26 
27 namespace Kratos
28 {
29 
32 
36 
40 
44 
48 
50 
73 template<class TSparseSpaceType, class TDenseSpaceType>
75 {
76 public:
79 
82 
84 
86 
88 
92 
95 
97  Preconditioner(const Preconditioner& Other) {}
98 
100  virtual ~Preconditioner() {}
101 
102 
106 
109  {
110  return *this;
111  }
112 
116 
123  virtual void Initialize(SparseMatrixType& rA, VectorType& rX, VectorType& rB) {}
124 
126  {
129 
130  TDenseSpaceType::GetColumn(0,rX, x);
131  TDenseSpaceType::GetColumn(0,rB, b);
132 
133  Initialize(rA, x, b);
134  }
135 
145  {
146  }
147 
155  {
156  }
157 
162  virtual void Clear()
163  {
164  }
165 
173  {
174  return false;
175  }
176 
183  virtual void ProvideAdditionalData(
184  SparseMatrixType& rA,
185  VectorType& rX,
186  VectorType& rB,
187  typename ModelPart::DofsArrayType& rdof_set,
188  ModelPart& r_model_part
189  )
190  {}
191 
192  virtual void Mult(SparseMatrixType& rA, VectorType& rX, VectorType& rY)
193  {
194  VectorType z = rX;
195  ApplyRight(z);
196  TSparseSpaceType::Mult(rA,z, rY);
197  ApplyLeft(rY);
198  }
199 
201  {
202  VectorType z = rX;
206  }
207 
209  {
210  return rX;
211  }
212 
214  {
215  return rX;
216  }
217 
223  {
224 // KRATOS_THROW_ERROR(std::logic_error,
225 // " virtual TVectorType& ApplyTransposeLeft(TVectorType& rX)",
226 // "This preconditioner dosn't have ApplyTransposeLeft defined.", "");
227  return rX;
228  }
229 
231  {
232 // KRATOS_THROW_ERROR(std::logic_error,
233 // " virtual TVectorType& ApplyTransposeRight(TVectorType& rX)",
234 // "This preconditioner dosn't have ApplyTransposeRight defined.", "");
235  return rX;
236  }
237 
239  {
240  return rX;
241  }
242 
243  /* The method Finalize is used to recover the value of rX.
244  In principle, it is enough to multiply by the right preconditioner.
245  See the diagoinal preconditioner for a nontrivial example. */
247  {
248  return ApplyRight(rX);
249  }
250 
254 
255 
259 
260 
264 
266  virtual std::string Info() const
267  {
268  return "Preconditioner";
269  }
270 
272  virtual void PrintInfo(std::ostream& rOStream) const
273  {
274  rOStream << "Preconditioner";
275  }
276 
278  virtual void PrintData(std::ostream& rOStream) const
279  {
280  }
281 
282 
286 
287 
289 
290 protected:
293 
294 
298 
299 
303 
304 
308 
309 
313 
314 
318 
319 
323 
324 
326 
327 private:
330 
331 
335 
336 
340 
341 
345 
346 
350 
351 
355 
356 
360 
361 
363 
364 }; // Class Preconditioner
365 
367 
370 
371 
375 
376 
378 template<class TSparseSpaceType, class TDenseSpaceType>
379 inline std::istream& operator >> (std::istream& IStream,
381 {
382  return IStream;
383 }
384 
386 template<class TSparseSpaceType, class TDenseSpaceType>
387 inline std::ostream& operator << (std::ostream& OStream,
389 {
390  rThis.PrintInfo(OStream);
391  OStream << std::endl;
392  rThis.PrintData(OStream);
393 
394  return OStream;
395 }
397 
398 } // namespace Kratos.
399 
400 #endif // KRATOS_PRECONDITIONER_H_INCLUDED defined
401 
402 
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
Preconditioner class.
Definition: preconditioner.h:75
TSparseSpaceType::VectorType VectorType
Definition: preconditioner.h:85
virtual void FinalizeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB)
Definition: preconditioner.h:154
KRATOS_CLASS_POINTER_DEFINITION(Preconditioner)
Pointer definition of Preconditioner.
virtual void Mult(SparseMatrixType &rA, VectorType &rX, VectorType &rY)
Definition: preconditioner.h:192
virtual VectorType & ApplyRight(VectorType &rX)
Definition: preconditioner.h:213
virtual ~Preconditioner()
Destructor.
Definition: preconditioner.h:100
virtual VectorType & ApplyTransposeLeft(VectorType &rX)
Definition: preconditioner.h:222
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: preconditioner.h:278
virtual bool AdditionalPhysicalDataIsNeeded()
Definition: preconditioner.h:172
virtual void Clear()
Definition: preconditioner.h:162
virtual VectorType & Finalize(VectorType &rX)
Definition: preconditioner.h:246
Preconditioner()
Default constructor.
Definition: preconditioner.h:94
TDenseSpaceType::MatrixType DenseMatrixType
Definition: preconditioner.h:87
virtual void Initialize(SparseMatrixType &rA, VectorType &rX, VectorType &rB)
Definition: preconditioner.h:123
virtual VectorType & ApplyLeft(VectorType &rX)
Definition: preconditioner.h:208
virtual std::string Info() const
Turn back information as a string.
Definition: preconditioner.h:266
virtual void TransposeMult(SparseMatrixType &rA, VectorType &rX, VectorType &rY)
Definition: preconditioner.h:200
virtual void ProvideAdditionalData(SparseMatrixType &rA, VectorType &rX, VectorType &rB, typename ModelPart::DofsArrayType &rdof_set, ModelPart &r_model_part)
Definition: preconditioner.h:183
Preconditioner(const Preconditioner &Other)
Copy constructor.
Definition: preconditioner.h:97
TSparseSpaceType::MatrixType SparseMatrixType
Definition: preconditioner.h:83
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: preconditioner.h:272
virtual VectorType & ApplyTransposeRight(VectorType &rX)
Definition: preconditioner.h:230
Preconditioner & operator=(const Preconditioner &Other)
Assignment operator.
Definition: preconditioner.h:108
virtual void Initialize(SparseMatrixType &rA, DenseMatrixType &rX, DenseMatrixType &rB)
Definition: preconditioner.h:125
virtual VectorType & ApplyInverseRight(VectorType &rX)
Definition: preconditioner.h:238
virtual void InitializeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB)
Definition: preconditioner.h:144
z
Definition: GenerateWind.py:163
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
void TransposeMult(SparseSpaceType &dummy, SparseSpaceType::MatrixType &rA, SparseSpaceType::VectorType &rX, SparseSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:104
void Mult(TSpaceType &dummy, typename TSpaceType::MatrixType &rA, typename TSpaceType::VectorType &rX, typename TSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:98
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::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
x
Definition: sensitivityMatrix.py:49