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.
apply_chimera_process.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 //
8 // License: BSD License
9 // Kratos default license: kratos/license.txt
10 //
11 // Authors: Aditya Ghantasala, https://github.com/adityaghantasala
12 // Navaneeth K Narayanan
13 // Rishith Ellath Meethal
14 //
15 
16 
17 #if !defined(KRATOS_APPLY_CHIMERA_H_INCLUDED)
18 #define KRATOS_APPLY_CHIMERA_H_INCLUDED
19 
20 // System includes
21 #include <unordered_map>
22 
23 // External includes
24 
25 // Project includes
26 #include "includes/define.h"
28 #include "includes/model_part.h"
29 #include "processes/process.h"
31 
32 // Application includes
36 
37 namespace Kratos {
38 
41 
45 
49 
53 
57 
68 template <int TDim>
69 class KRATOS_API(CHIMERA_APPLICATION) ApplyChimera : public Process {
70 public:
73 
79  typedef std::vector<IndexType> ConstraintIdsVectorType;
82  typedef std::vector<MasterSlaveConstraintContainerType> MasterSlaveContainerVectorType;
84  typedef typename PointLocatorType::Pointer PointLocatorPointerType;
86 
88 
92 
99  explicit ApplyChimera(ModelPart& rMainModelPart, Parameters iParameters);
100 
102  virtual ~ApplyChimera()=default;
103 
107 
111 
112  void SetEchoLevel(int EchoLevel);
113 
114  void SetReformulateEveryStep(bool Reformulate);
115 
116  virtual void ExecuteInitializeSolutionStep() override;
117 
118  virtual void ExecuteFinalizeSolutionStep() override;
119 
120  virtual std::string Info() const override;
121 
123  virtual void PrintInfo(std::ostream& rOStream) const override;
124 
126  virtual void PrintData(std::ostream& rOStream) const override;
127 
131 
133 
134 protected:
137 
144  std::unordered_map<IndexType, ConstraintIdsVectorType> mNodeIdToConstraintIdsMap;
147  std::map<std::string, PointLocatorPointerType> mPointLocatorsMap;
149 
150  // Modelpart names which are generated here
151  const std::string mModifiedName = "ChimeraModified";
152  const std::string mBoundaryName = "ChimeraBoundary";
153  const std::string mHoleName = "ChimeraHole";
157 
161 
166  virtual void DoChimeraLoop();
167 
175  virtual void FormulateChimera(const Parameters BackgroundParam,
176  const Parameters PatchParameters,
178 
187  void CreateConstraintIds(std::vector<int>& rIdVector,
188  const IndexType NumberOfConstraintsRequired);
197  virtual void ApplyContinuityWithMpcs(ModelPart& rBoundaryModelPart,
198  PointLocatorType& pBinLocator);
199 
214  template <typename TVariableType>
215  void AddMasterSlaveRelation(MasterSlaveConstraintContainerType& rMasterSlaveContainer,
216  const LinearMasterSlaveConstraint& rCloneConstraint,
217  unsigned int ConstraintId,
218  NodeType& rMasterNode,
219  TVariableType& rMasterVariable,
220  NodeType& rSlaveNode,
221  TVariableType& rSlaveVariable,
222  const double Weight,
223  const double Constant = 0.0);
224 
240  template <typename TVariableType>
241  void ApplyContinuityWithElement(Geometry<NodeType>& rGeometry,
242  NodeType& rBoundaryNode,
243  Vector& rShapeFuncWeights,
244  TVariableType& rVariable,
245  unsigned int StartIndex,
246  std::vector<int>& rConstraintIdVector,
247  MasterSlaveConstraintContainerType& rMsContainer);
248 
256  void ReserveMemoryForConstraintContainers(ModelPart& rModelPart,
257  MasterSlaveContainerVectorType& rContainerVector);
258 
265  int RemoveExistingConstraintsForNode(ModelPart::NodeType& rBoundaryNode);
266 
279  void AddConstraintsToModelpart(ModelPart& rModelPart,
280  MasterSlaveContainerVectorType& rContainerVector);
281 
294  void FormulateConstraints(ModelPart& rBoundaryModelPart,
295  PointLocatorType& rBinLocator,
296  MasterSlaveContainerVectorType& rVelocityMasterSlaveContainerVector,
297  MasterSlaveContainerVectorType& rPressureMasterSlaveContainerVector);
301 
305 
309 
311 
312 private:
315 
319 
323 
327 
335  ModelPart& ExtractPatchBoundary(const Parameters PatchParameters,
336  ModelPart& rBackgroundBoundaryModelpart,
337  const ChimeraHoleCuttingUtility::Domain DomainType);
338 
344  PointLocatorPointerType GetPointLocator(ModelPart& rModelPart);
345 
357  bool SearchNode(PointLocatorType& rBinLocator,
358  NodeType& rNodeToFind,
359  Element::Pointer& prHostElement,
360  Vector& rWeights);
361 
374  void MakeConstraints(NodeType& rNodeToFind,
375  Element::Pointer& rHostElement,
376  Vector& rWeights,
377  MasterSlaveConstraintContainerType& rVelocityMsConstraintsVector,
378  MasterSlaveConstraintContainerType& rPressureMsConstraintsVector,
379  std::vector<int>& rConstraintIdVector,
380  const IndexType StartConstraintId);
384 
388 
392 
394 }; // Class ApplyChimera
395 
396 } // namespace Kratos.
397 
398 #endif // KRATOS_APPLY_CHIMERA_H_INCLUDED defined
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: periodic_interface_process.hpp:55
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
This class contains methods applies the continuity between the patch and background using linear mast...
Definition: apply_chimera_process.h:69
KRATOS_CLASS_POINTER_DEFINITION(ApplyChimera)
ModelPart::MasterSlaveConstraintContainerType MasterSlaveConstraintContainerType
Definition: apply_chimera_process.h:81
int mNumberOfLevels
Definition: apply_chimera_process.h:142
std::vector< IndexType > ConstraintIdsVectorType
Definition: apply_chimera_process.h:79
Kratos::Variable< double > VariableType
Definition: apply_chimera_process.h:78
ModelPart::NodeType NodeType
Definition: apply_chimera_process.h:77
bool mIsFormulated
Definition: apply_chimera_process.h:148
std::unordered_map< IndexType, ConstraintIdsVectorType > mNodeIdToConstraintIdsMap
Definition: apply_chimera_process.h:144
BinBasedFastPointLocator< TDim > PointLocatorType
Definition: apply_chimera_process.h:83
ModelPart::NodesContainerType NodesContainerType
Definition: apply_chimera_process.h:85
PointLocatorType::Pointer PointLocatorPointerType
Definition: apply_chimera_process.h:84
ModelPart::IndexType IndexType
Definition: apply_chimera_process.h:76
Parameters mParameters
Definition: apply_chimera_process.h:143
ModelPart & mrMainModelPart
Definition: apply_chimera_process.h:141
std::vector< MasterSlaveConstraintContainerType > MasterSlaveContainerVectorType
Definition: apply_chimera_process.h:82
int mEchoLevel
Definition: apply_chimera_process.h:145
ModelPart::MasterSlaveConstraintType MasterSlaveConstraintType
Definition: apply_chimera_process.h:80
virtual ~ApplyChimera()=default
Destructor.
std::map< std::string, PointLocatorPointerType > mPointLocatorsMap
Definition: apply_chimera_process.h:147
bool mReformulateEveryStep
Definition: apply_chimera_process.h:146
This class is designed to allow the fast location of MANY points on the top of a 3D mesh.
Definition: binbased_fast_point_locator.h:68
Domain
Definition: hole_cutting_utility.h:70
Geometry base class.
Definition: geometry.h:71
This class allows to add a master-slave constraint which is of the form SlaveDofVector = T * MasterDo...
Definition: linear_master_slave_constraint.h:58
A class that implements the interface for different master-slave constraints to be applied on a syste...
Definition: master_slave_constraint.h:76
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
std::size_t IndexType
Pointer definition of ModelPart.
Definition: model_part.h:105
MeshType::MasterSlaveConstraintContainerType MasterSlaveConstraintContainerType
Definition: model_part.h:219
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
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
The base class for all processes in Kratos.
Definition: process.h:49
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
void SetEchoLevel(const int EchoLevel)
Definition: add_custom_io_to_python.cpp:344
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21