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.
feti_dynamic_coupling_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: Peter Wilson
11 //
12 
13 #if !defined(KRATOS_FETI_DYNAMIC_COUPLING_UTILITIES_H_INCLUDED)
14 #define KRATOS_FETI_DYNAMIC_COUPLING_UTILITIES_H_INCLUDED
15 
16 // System includes
17 
18 // External includes
19 
20 // Project includes
21 #include "includes/define.h"
22 #include "includes/model_part.h"
25 
26 
27 namespace Kratos
28 {
29  template<class TSparseSpace, class TDenseSpace>
30  class KRATOS_API(CO_SIMULATION_APPLICATION) FetiDynamicCouplingUtilities
31  {
32  public:
33  typedef std::size_t SizeType;
34  typedef std::size_t IndexType;
35 
36  typedef Node NodeType;
37  typedef typename NodeType::Pointer NodePointerType;
39  typedef typename GeometryType::Pointer GeometryPointerType;
40 
44 
47 
49  static constexpr double numerical_limit = std::numeric_limits<double>::epsilon();
50 
51  enum class SolverIndex { Origin, Destination };
52  enum class EquilibriumVariable { Displacement, Velocity, Acceleration};
53 
54  FetiDynamicCouplingUtilities(ModelPart & rInterfaceOrigin, ModelPart & rInterFaceDestination,
55  const Parameters JsonParameters);
56 
57  void SetOriginAndDestinationDomainsWithInterfaceModelParts(ModelPart& rInterfaceOrigin,
58  ModelPart& rInterFaceDestination);
59 
60  void SetEffectiveStiffnessMatrixImplicit(SparseMatrixType& rK, const SolverIndex iSolverIndex);
61 
63  {
64  if (iSolverIndex == SolverIndex::Origin) mSubTimestepIndex = 1;
65  };
66 
67  void SetMappingMatrix(SparseMatrixType& rMappingMatrix)
68  {
69  mpMappingMatrix = &rMappingMatrix;
70  };
71 
73  {
74  mpSolver = pSolver;
75  }
76 
77  void SetOriginInitialKinematics();
78 
79  void EquilibrateDomains();
80 
81  private:
82  ModelPart& mrOriginInterfaceModelPart;
83  ModelPart& mrDestinationInterfaceModelPart;
84 
85  ModelPart* mpOriginDomain = nullptr;
86  ModelPart* mpDestinationDomain = nullptr;
87 
88  SparseMatrixType* mpKOrigin = nullptr;
89  SparseMatrixType* mpKDestination = nullptr;
90 
91  SparseMatrixType* mpMappingMatrix = nullptr;
92  SparseMatrixType* mpMappingMatrixForce = nullptr;
93 
94  // Origin quantities
95  DenseVectorType mInitialOriginInterfaceKinematics;
96  DenseVectorType mFinalOriginInterfaceKinematics;
97  SparseMatrixType mProjectorOrigin;
98  SparseMatrixType mUnitResponseOrigin;
99 
100  // Quantities to store for a linear system
101  SparseMatrixType mCondensationMatrix;
102  SparseMatrixType mUnitResponseDestination;
103  SparseMatrixType mProjectorDestination;
104  bool mIsLinearSetupComplete = false;
105 
106  EquilibriumVariable mEquilibriumVariable = EquilibriumVariable::Velocity;
107 
108  LinearSolverSharedPointerType mpSolver = nullptr;
109 
110  bool mIsImplicitOrigin;
111  bool mIsImplicitDestination;
112  const Parameters mParameters;
113  bool mIsLinear = false;
114  SolverIndex mLagrangeDefinedOn = SolverIndex::Destination;
115 
116  IndexType mSubTimestepIndex = 1;
117  IndexType mTimestepRatio;
118 
119  const bool mIsCheckEquilibrium = true; // normally true
120 
121  void CalculateUnbalancedInterfaceFreeKinematics(DenseVectorType& rUnbalancedKinematics, const bool IsEquilibriumCheck = false);
122 
123  void GetInterfaceQuantity(ModelPart& rInterface, const Variable< array_1d<double, 3> >& rVariable,
124  DenseVectorType& rContainer, const SizeType nDOFs);
125 
126  void GetInterfaceQuantity(ModelPart& rInterface, const Variable<double>& rVariable,
127  DenseVectorType& rContainer, const SizeType nDOFs);
128 
129  void GetExpandedMappingMatrix(SparseMatrixType& rExpandedMappingMat, const SizeType nDOFs);
130 
131  void ComposeProjector(SparseMatrixType& rProjector, const SolverIndex solverIndex);
132 
133  void DetermineDomainUnitAccelerationResponse(SparseMatrixType* pK,
134  const SparseMatrixType& rProjector, SparseMatrixType& rUnitResponse, const SolverIndex solverIndex);
135 
136  void DetermineDomainUnitAccelerationResponseExplicit(SparseMatrixType& rUnitResponse,
137  const SparseMatrixType& rProjector, ModelPart& rDomain, const SolverIndex solverIndex);
138 
139  void DetermineDomainUnitAccelerationResponseImplicit(SparseMatrixType& rUnitResponse,
140  const SparseMatrixType& rProjector, SparseMatrixType* pK, const SolverIndex solverIndex);
141 
142  void CalculateCondensationMatrix(SparseMatrixType& rCondensationMatrix,
143  const SparseMatrixType& rOriginUnitResponse, const SparseMatrixType& rDestinationUnitResponse,
144  const SparseMatrixType& rOriginProjector, const SparseMatrixType& rDestinationProjector);
145 
146  void DetermineLagrangianMultipliers(DenseVectorType& rLagrangeVec,
147  SparseMatrixType& rCondensationMatrix, DenseVectorType& rUnbalancedKinematics);
148 
149  void ApplyCorrectionQuantities(DenseVectorType& rLagrangeVec,
150  const SparseMatrixType& rUnitResponse, const SolverIndex solverIndex);
151 
152  void AddCorrectionToDomain(ModelPart* pDomain,
153  const Variable< array_1d<double, 3> >& rVariable,
154  const DenseVectorType& rCorrection, const bool IsImplicit);
155 
156  void WriteLagrangeMultiplierResults(const DenseVectorType& rLagrange);
157 
158  void ApplyMappingMatrixToProjector(SparseMatrixType& rProjector, const SizeType DOFs);
159 
160  void PrintInterfaceKinematics(const Variable< array_1d<double, 3> >& rVariable, const SolverIndex solverIndex);
161 
162  Variable< array_1d<double, 3> >& GetEquilibriumVariable();
163 
164  }; // namespace FetiDynamicCouplingUtilities.
165 
166 } // namespace Kratos.
167 
168 #endif // KRATOS_FETI_DYNAMIC_COUPLING_UTILITIES_H_INCLUDED defined
Definition: feti_dynamic_coupling_utilities.h:31
void SetLinearSolver(LinearSolverSharedPointerType pSolver)
Definition: feti_dynamic_coupling_utilities.h:72
std::size_t IndexType
Definition: feti_dynamic_coupling_utilities.h:34
void SetMappingMatrix(SparseMatrixType &rMappingMatrix)
Definition: feti_dynamic_coupling_utilities.h:67
Geometry< NodeType > GeometryType
Definition: feti_dynamic_coupling_utilities.h:38
Node NodeType
Definition: feti_dynamic_coupling_utilities.h:36
TSparseSpace::MatrixType SparseMatrixType
Definition: feti_dynamic_coupling_utilities.h:41
TDenseSpace::MatrixType DenseMatrixType
Definition: feti_dynamic_coupling_utilities.h:42
Kratos::shared_ptr< LinearSolverType > LinearSolverSharedPointerType
Definition: feti_dynamic_coupling_utilities.h:46
SolverIndex
Definition: feti_dynamic_coupling_utilities.h:51
TDenseSpace::VectorType DenseVectorType
Definition: feti_dynamic_coupling_utilities.h:43
void SetEffectiveStiffnessMatrixExplicit(const SolverIndex iSolverIndex)
Definition: feti_dynamic_coupling_utilities.h:62
LinearSolver< TSparseSpace, TDenseSpace > LinearSolverType
Definition: feti_dynamic_coupling_utilities.h:45
EquilibriumVariable
Definition: feti_dynamic_coupling_utilities.h:52
NodeType::Pointer NodePointerType
Definition: feti_dynamic_coupling_utilities.h:37
GeometryType::Pointer GeometryPointerType
Definition: feti_dynamic_coupling_utilities.h:39
std::size_t SizeType
Definition: feti_dynamic_coupling_utilities.h:33
Geometry base class.
Definition: geometry.h:71
Base class for all the linear solvers in Kratos.
Definition: linear_solver.h:65
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
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
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43