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.
trilinos_partitioned_fsi_utilities.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: Ruben Źorrilla
11 // Jordi Cotela
12 //
13 
14 #if !defined(KRATOS_TRILINOS_PARTITIONED_FSI_UTILITIES_H )
15 #define KRATOS_TRILINOS_PARTITIONED_FSI_UTILITIES_H
16 
17 
18 
19 // System includes
20 #include <string>
21 #include <iostream>
22 
23 
24 // External includes
25 #include "Epetra_MpiComm.h"
26 #include "Epetra_Map.h"
27 #include "Epetra_Vector.h"
28 
29 // Project includes
30 #include "includes/define.h"
31 
32 #include "../FSIApplication/custom_utilities/partitioned_fsi_utilities.hpp"
33 
34 namespace Kratos
35 {
38 
41 
45 
49 
53 
57 
59 
60  template< class TSpace, class TValueType, unsigned int TDim >
61  class TrilinosPartitionedFSIUtilities : public PartitionedFSIUtilities<TSpace,TValueType,TDim>
62  {
63  public:
66 
69 
70  typedef typename TSpace::VectorType VectorType;
71  typedef typename TSpace::MatrixType MatrixType;
72 
73  typedef typename TSpace::VectorPointerType VectorPointerType;
74  typedef typename TSpace::MatrixPointerType MatrixPointerType;
75 
79 
81  TrilinosPartitionedFSIUtilities(const Epetra_MpiComm& EpetraCommunicator):
82  mrEpetraComm(EpetraCommunicator)
83  {}
84 
86  virtual ~TrilinosPartitionedFSIUtilities() override {}
87 
88 
92 
93 
97 
98  VectorPointerType SetUpInterfaceVector(ModelPart& rInterfaceModelPart) override
99  {
100  // Initialize Epetra_Map for the vector
101  int NumLocalInterfaceDofs = rInterfaceModelPart.GetCommunicator().LocalMesh().NumberOfNodes() * TDim;
102  int NumGlobalInterfaceDofs = rInterfaceModelPart.GetCommunicator().GetDataCommunicator().SumAll(NumLocalInterfaceDofs);
103  int IndexBase = 0; // 0 for C-style vectors, 1 for Fortran numbering
104  Epetra_Map InterfaceMap(NumGlobalInterfaceDofs,NumLocalInterfaceDofs,IndexBase,mrEpetraComm);
105 
106  // Create new vector using given map
107  VectorPointerType p_int_vect = Kratos::make_shared<Epetra_FEVector>(InterfaceMap);
108 
109  // Set interface vector to zero
110  p_int_vect->PutScalar(0.0);
111 
112  return p_int_vect;
113  }
114 
118 
119 
123 
124 
128 
129 
133 
134 
136 
137  protected:
140 
141 
145 
146 
150 
151 
155 
156  virtual void SetLocalValue(VectorType& rVector, int LocalRow, double Value) const override
157  {
158  // Note: We don't go through TSpace because TrilinosSpace forces a GlobalAssemble after each SetValue
159  rVector.ReplaceMyValue(LocalRow,0,Value);
160  }
161 
162  virtual double GetLocalValue(const VectorType& rVector, int LocalRow) const override
163  {
164  return rVector[0][LocalRow];
165  }
166 
167 
171 
172 
176 
177 
181 
182 
184 
185  private:
188 
189 
193 
194  const Epetra_MpiComm& mrEpetraComm;
195 
196 
200 
201 
205 
206 
210 
211 
215 
216 
220 
223 
226 
227 
229 
230  }; // Class TrilinosPartitionedFSIUtilities
231 
233 
236 
237 
241 
242 
244 
245 } // namespace Kratos.
246 
247 #endif // KRATOS_TRILINOS_PARTITIONED_FSI_UTILITIES_H defined
virtual const DataCommunicator & GetDataCommunicator() const
Definition: communicator.cpp:340
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
SizeType NumberOfNodes() const
Definition: mesh.h:259
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Communicator & GetCommunicator()
Definition: model_part.h:1821
Definition: partitioned_fsi_utilities.hpp:67
TSpace::VectorPointerType VectorPointerType
Definition: partitioned_fsi_utilities.hpp:78
TSpace::VectorType VectorType
Definition: partitioned_fsi_utilities.hpp:75
Trilinos version of the partitioned FSI tools.
Definition: trilinos_partitioned_fsi_utilities.h:62
KRATOS_CLASS_POINTER_DEFINITION(TrilinosPartitionedFSIUtilities)
Pointer definition of TrilinosPartitionedFSIUtilities.
TrilinosPartitionedFSIUtilities(const Epetra_MpiComm &EpetraCommunicator)
Default constructor.
Definition: trilinos_partitioned_fsi_utilities.h:81
virtual double GetLocalValue(const VectorType &rVector, int LocalRow) const override
Definition: trilinos_partitioned_fsi_utilities.h:162
TSpace::VectorPointerType VectorPointerType
Definition: trilinos_partitioned_fsi_utilities.h:73
VectorPointerType SetUpInterfaceVector(ModelPart &rInterfaceModelPart) override
Definition: trilinos_partitioned_fsi_utilities.h:98
TSpace::MatrixPointerType MatrixPointerType
Definition: trilinos_partitioned_fsi_utilities.h:74
TSpace::MatrixType MatrixType
Definition: trilinos_partitioned_fsi_utilities.h:71
TSpace::VectorType VectorType
Definition: trilinos_partitioned_fsi_utilities.h:70
virtual ~TrilinosPartitionedFSIUtilities() override
Destructor.
Definition: trilinos_partitioned_fsi_utilities.h:86
virtual void SetLocalValue(VectorType &rVector, int LocalRow, double Value) const override
Definition: trilinos_partitioned_fsi_utilities.h:156
Vector VectorType
Definition: geometrical_transformation_utilities.h:56
Matrix MatrixType
Definition: geometrical_transformation_utilities.h:55
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21