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.
periodic_interface_process.hpp
Go to the documentation of this file.
1 // KRATOS___
2 // // ) )
3 // // ___ ___
4 // // ____ //___) ) // ) )
5 // // / / // // / /
6 // ((____/ / ((____ ((___/ / MECHANICS
7 //
8 // License: geo_mechanics_application/license.txt
9 //
10 // Main authors: Ignasi de Pouplana,
11 // Vahid Galavi
12 //
13 
14 #pragma once
15 
16 #include "includes/kratos_flags.h"
18 #include "processes/process.h"
20 #include "utilities/math_utils.h"
22 
24 
25 namespace Kratos
26 {
27 
29 {
30 
31 public:
32 
34 
36  Parameters rParameters ) : Process(Flags()) , mrModelPart(model_part)
37  {
39 
40  //only include validation with c++11 since raw_literals do not exist in c++03
41  Parameters default_parameters( R"(
42  {
43  "model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME",
44  "dimension": 2,
45  "stress_limit": 100.0e6
46  } )" );
47 
48  // Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them
49  // So that an error is thrown if they don't exist
50  rParameters["model_part_name"];
51 
52  // Now validate agains defaults -- this also ensures no type mismatch
53  rParameters.ValidateAndAssignDefaults(default_parameters);
54 
55  mDimension = rParameters["dimension"].GetInt();
56  mStressLimit = rParameters["stress_limit"].GetDouble();
57 
58  KRATOS_CATCH("");
59  }
60 
63  ~PeriodicInterfaceProcess() override = default;
64 
67  void ExecuteInitialize() override
68  {
70 
71  block_for_each(mrModelPart.Conditions(), [&](Condition& rCondition) {
72  Condition::GeometryType& rGeom = rCondition.GetGeometry();
73 
74  rCondition.Set(PERIODIC,true);
75 
76  rGeom[0].FastGetSolutionStepValue(PERIODIC_PAIR_INDEX) = rGeom[1].Id();
77  rGeom[1].FastGetSolutionStepValue(PERIODIC_PAIR_INDEX) = rGeom[0].Id();
78  });
79  VariableUtils{}.SetFlag(ACTIVE, false, mrModelPart.Elements());
80 
81  KRATOS_CATCH("")
82  }
83 
86  {
88 
89  if (mrModelPart.NumberOfConditions() > 0) {
90  SizeType StressTensorSize = STRESS_TENSOR_SIZE_2D;
91  if (mDimension == N_DIM_3D) StressTensorSize = STRESS_TENSOR_SIZE_3D;
92 
93  block_for_each(mrModelPart.Conditions(), [&StressTensorSize](Condition& rCondition) {
94  Condition::GeometryType& rGeom = rCondition.GetGeometry();
95 
96  Matrix NodalStressMatrix(StressTensorSize, StressTensorSize);
97  noalias(NodalStressMatrix) = 0.5 * ( rGeom[0].FastGetSolutionStepValue(NODAL_CAUCHY_STRESS_TENSOR)
98  + rGeom[1].FastGetSolutionStepValue(NODAL_CAUCHY_STRESS_TENSOR) );
99  Vector PrincipalStresses(StressTensorSize);
100  noalias(PrincipalStresses) = SolidMechanicsMathUtilities<double>::EigenValuesDirectMethod(NodalStressMatrix);
101 
102  // Check whether the principal stress S1 at the node is higher than the prescribed limit to activate the joints
103  if (PrincipalStresses[0] >= mStressLimit) {
104  rCondition.Set(PERIODIC,false);
105  rGeom[0].FastGetSolutionStepValue(PERIODIC_PAIR_INDEX) = 0;
106  rGeom[1].FastGetSolutionStepValue(PERIODIC_PAIR_INDEX) = 0;
107 
108  GlobalPointersVector<Element>& rE = rGeom[0].GetValue(NEIGHBOUR_ELEMENTS);
109  for (unsigned int ie = 0; ie < rE.size(); ie++) {
110  #pragma omp critical
111  {
112  rE[ie].Set(ACTIVE,true);
113  }
114  }
115  }
116  });
117  }
118 
119  KRATOS_CATCH("")
120  }
121 
123  std::string Info() const override
124  {
125  return "PeriodicInterfaceProcess";
126  }
127 
128 private:
129  ModelPart& mrModelPart;
130  int mDimension;
131  double mStressLimit;
132 
133 }
134 
136 inline std::istream& operator >> (std::istream& rIStream,
137  PeriodicInterfaceProcess& rThis);
138 
140 inline std::ostream& operator << (std::ostream& rOStream,
141  const PeriodicInterfaceProcess& rThis)
142 {
143  rThis.PrintInfo(rOStream);
144  rOStream << std::endl;
145  rThis.PrintData(rOStream);
146 
147  return rOStream;
148 }
149 
150 }
PeriodicInterfaceProcess(ModelPart &model_part, Parameters rParameters)
Definition: periodic_interface_process.hpp:5
Base class for all Conditions.
Definition: condition.h:59
Definition: flags.h:58
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
SizeType NumberOfConditions(IndexType ThisIndex=0) const
Definition: model_part.h:1218
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
Definition: periodic_interface_process.hpp:29
void ExecuteInitialize() override
Definition: periodic_interface_process.hpp:67
KRATOS_CLASS_POINTER_DEFINITION(PeriodicInterfaceProcess)
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:123
~PeriodicInterfaceProcess() override=default
PeriodicInterfaceProcess(const PeriodicInterfaceProcess &)=delete
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: periodic_interface_process.hpp:165
PeriodicInterfaceProcess(ModelPart &model_part, Parameters rParameters)
Definition: periodic_interface_process.hpp:35
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: periodic_interface_process.hpp:85
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: periodic_interface_process.hpp:171
The base class for all processes in Kratos.
Definition: process.h:49
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetFlag(const Flags &rFlag, const bool FlagValue, TContainerType &rContainer)
Sets a flag according to a given status over a given container.
Definition: variable_utils.h:900
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::ostream & operator<<(std::ostream &rOStream, const PeriodicInterfaceProcess &rThis)
output stream function
Definition: periodic_interface_process.hpp:140
constexpr SizeType STRESS_TENSOR_SIZE_3D
Definition: geo_mechanics_application_constants.h:38
constexpr SizeType N_DIM_3D
Definition: geo_mechanics_application_constants.h:25
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
std::istream & operator>>(std::istream &rIStream, PeriodicInterfaceProcess &rThis)
input stream function
constexpr SizeType STRESS_TENSOR_SIZE_2D
Definition: geo_mechanics_application_constants.h:37
model_part
Definition: face_heat.py:14