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.
rve_periodicity_utility.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: Riccardo Rossi
11 //
12 
13 #if !defined (KRATOS_RVE_PERIODICITY_UTILITY_H_INCLUDED)
14 #define KRATOS_RVE_PERIODICITY_UTILITY_H_INCLUDED
15 
16 // System includes
17 
18 // External includes
19 #include <tuple>
20 
21 // Project includes
22 #include "includes/define.h"
23 #include "includes/model_part.h"
25 
26 namespace Kratos
27 {
32 
40 class KRATOS_API(KRATOS_CORE) RVEPeriodicityUtility
41 {
42  public:
45 
48 
50  typedef std::size_t IndexType;
51 
53  typedef std::tuple<std::vector<IndexType>, std::vector<double>, Vector> DataTupletype;
54 
57 
59  typedef std::vector< DofType::Pointer > DofPointerVectorType;
60 
62  typedef Node NodeType;
63 
66 
70 
73  ModelPart& rDestinationModelPart,
74  std::size_t EchoLevel = 0
75  ) : mrModelPart(rDestinationModelPart)
76  , mEchoLevel(EchoLevel)
77  {
78  }
79 
82 
84  virtual ~RVEPeriodicityUtility() = default;
85 
89 
92 
96 
106  void AssignPeriodicity(ModelPart& rMasterModelPart,
107  ModelPart& rSlaveModelPart,
108  const Matrix& rStrainTensor,
109  const Vector& rDirection,
110  const double SearchTolerance = 1.0e-6
111  );
112 
116  void Finalize(const Variable<array_1d<double, 3>>& rVariable);
117 
121 
123  virtual std::string Info() const
124  {
125  std::stringstream buffer;
126  buffer << "RVEPeriodicityUtility";
127  return buffer.str();
128  }
129 
131  virtual void PrintInfo(std::ostream& rOStream) const
132  {
133  rOStream << "RVEPeriodicityUtility";
134  }
135 
137  virtual void PrintData(std::ostream& rOStream) const {}
138 
140 
141  protected:
144 
154  void AppendIdsAndWeights(
155  std::map<IndexType, DataTupletype>& rAux,
156  const IndexType MasterId,
157  const double MasterWeight,
158  std::vector<IndexType>& rFinalMastersIds,
159  std::vector<double>& rFinalMastersWeights,
160  Vector& rFinalT
161  );
162 
164 
165 private:
168 
169  ModelPart& mrModelPart;
170 
171  std::map<IndexType, DataTupletype> mAuxPairings;
172 
173  std::size_t mEchoLevel = 0;
174 
178 
188  MasterSlaveConstraint::Pointer GenerateConstraint(
189  IndexType& rConstraintId,
190  const DoubleVariableType& rVar,
191  NodeType::Pointer pSlaveNode,
192  const std::vector<IndexType>& rMasterIds,
193  const Matrix& rRelationMatrix,
194  const Vector& rTranslationVector
195  );
196 
197  template<std::size_t TDim>
198  void AuxiliaryAssignPeriodicity(
199  ModelPart& rMasterModelPart,
200  ModelPart& rSlaveModelPart,
201  const Matrix& rStrainTensor,
202  const Vector& rDirection,
203  const double SearchTolerance = 1.0e-6);
204 
206 
207 }; // Class RVEPeriodicityUtility
208 
212 
214 inline std::istream &operator>>(std::istream& rIStream,
215  RVEPeriodicityUtility& rThis)
216 {
217  return rIStream;
218 }
219 
221 inline std::ostream &operator<<(std::ostream& rOStream,
222  const RVEPeriodicityUtility& rThis)
223 {
224  rThis.PrintInfo(rOStream);
225  rOStream << std::endl;
226  rThis.PrintData(rOStream);
227 
228  return rOStream;
229 }
231 
233 
234 } // namespace Kratos.
235 
236 #endif // KRATOS_RVE_PERIODICITY_UTILITY_H_INCLUDED defined
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
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 defines a class to define periodic BC to a RVE.
Definition: rve_periodicity_utility.h:41
virtual ~RVEPeriodicityUtility()=default
Destructor.
KRATOS_CLASS_POINTER_DEFINITION(RVEPeriodicityUtility)
Pointer definition of RVEPeriodicityUtility.
virtual std::string Info() const
Turn back information as a string.
Definition: rve_periodicity_utility.h:123
Node NodeType
Definition of the node.
Definition: rve_periodicity_utility.h:62
Dof< double > DofType
The DoF type definition.
Definition: rve_periodicity_utility.h:56
RVEPeriodicityUtility(ModelPart &rDestinationModelPart, std::size_t EchoLevel=0)
Default constructor.
Definition: rve_periodicity_utility.h:72
std::size_t IndexType
Definition of the index type.
Definition: rve_periodicity_utility.h:50
RVEPeriodicityUtility(RVEPeriodicityUtility const &rOther)=delete
Copy constructor.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: rve_periodicity_utility.h:131
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: rve_periodicity_utility.h:137
RVEPeriodicityUtility & operator=(RVEPeriodicityUtility const &rOther)=delete
Assignment operator.
std::vector< DofType::Pointer > DofPointerVectorType
The DoF pointer vector type definition.
Definition: rve_periodicity_utility.h:59
std::tuple< std::vector< IndexType >, std::vector< double >, Vector > DataTupletype
Definition of the data tuple type.
Definition: rve_periodicity_utility.h:53
Variable< double > DoubleVariableType
Definition of the component of variable type.
Definition: rve_periodicity_utility.h:65
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
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