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 //
2 // Project Name: KratosPoromechanicsApplication $
3 // Last modified by: $Author: Ignasi de Pouplana $
4 // Date: $Date: June 2016 $
5 // Revision: $Revision: 1.0 $
6 //
7 
8 #if !defined(KRATOS_PERIODIC_INTERFACE_PROCESS )
9 #define KRATOS_PERIODIC_INTERFACE_PROCESS
10 
11 #include "includes/kratos_flags.h"
13 #include "processes/process.h"
14 #include "custom_utilities/solid_mechanics_math_utilities.hpp"
15 #include "utilities/math_utils.h"
16 
18 
19 namespace Kratos
20 {
21 
22 class PeriodicInterfaceProcess : public Process
23 {
24 
25 public:
26 
28 
30 
33  Parameters rParameters
35  {
37 
38  //only include validation with c++11 since raw_literals do not exist in c++03
39  Parameters default_parameters( R"(
40  {
41  "model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME",
42  "dimension": 2,
43  "stress_limit": 100.0e6
44  } )" );
45 
46  // Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them
47  // So that an error is thrown if they don't exist
48  rParameters["model_part_name"];
49 
50  // Now validate agains defaults -- this also ensures no type mismatch
51  rParameters.ValidateAndAssignDefaults(default_parameters);
52 
53  mDimension = rParameters["dimension"].GetInt();
54  mStressLimit = rParameters["stress_limit"].GetDouble();
55 
56  KRATOS_CATCH("");
57  }
58 
60 
63 
65 
67  void Execute() override
68  {
69  }
70 
73  void ExecuteInitialize() override
74  {
75  KRATOS_TRY;
76 
77  int NCons = static_cast<int>(mr_model_part.Conditions().size());
78  ModelPart::ConditionsContainerType::iterator con_begin = mr_model_part.ConditionsBegin();
79 
80  #pragma omp parallel for
81  for(int i = 0; i < NCons; i++)
82  {
83  ModelPart::ConditionsContainerType::iterator itCond = con_begin + i;
84  Condition::GeometryType& rGeom = itCond->GetGeometry();
85 
86  itCond->Set(PERIODIC,true);
87 
88  rGeom[0].FastGetSolutionStepValue(PERIODIC_PAIR_INDEX) = rGeom[1].Id();
89  rGeom[1].FastGetSolutionStepValue(PERIODIC_PAIR_INDEX) = rGeom[0].Id();
90  }
91 
92  int NElems = static_cast<int>(mr_model_part.Elements().size());
93  ModelPart::ElementsContainerType::iterator el_begin = mr_model_part.ElementsBegin();
94 
95  #pragma omp parallel for
96  for(int i = 0; i < NElems; i++)
97  {
98  ModelPart::ElementsContainerType::iterator itElem = el_begin + i;
99  itElem->Set(ACTIVE,false);
100  }
101 
102  KRATOS_CATCH("");
103  }
104 
107  {
108  KRATOS_TRY;
109 
110  int NCons = static_cast<int>(mr_model_part.Conditions().size());
111  ModelPart::ConditionsContainerType::iterator con_begin = mr_model_part.ConditionsBegin();
112 
113  #pragma omp parallel for
114  for(int i = 0; i < NCons; i++)
115  {
116  ModelPart::ConditionsContainerType::iterator itCond = con_begin + i;
117  Condition::GeometryType& rGeom = itCond->GetGeometry();
118 
119  Matrix NodalStressMatrix(3,3);
120  noalias(NodalStressMatrix) = 0.5 * ( rGeom[0].FastGetSolutionStepValue(NODAL_EFFECTIVE_STRESS_TENSOR)
121  + rGeom[1].FastGetSolutionStepValue(NODAL_EFFECTIVE_STRESS_TENSOR) );
122  Vector PrincipalStresses(mDimension);
123  if(mDimension == 2)
124  {
125  PrincipalStresses[0] = 0.5*(NodalStressMatrix(0,0)+NodalStressMatrix(1,1)) +
126  sqrt(0.25*(NodalStressMatrix(0,0)-NodalStressMatrix(1,1))*(NodalStressMatrix(0,0)-NodalStressMatrix(1,1)) +
127  NodalStressMatrix(0,1)*NodalStressMatrix(0,1));
128  PrincipalStresses[1] = 0.5*(NodalStressMatrix(0,0)+NodalStressMatrix(1,1)) -
129  sqrt(0.25*(NodalStressMatrix(0,0)-NodalStressMatrix(1,1))*(NodalStressMatrix(0,0)-NodalStressMatrix(1,1)) +
130  NodalStressMatrix(0,1)*NodalStressMatrix(0,1));
131  }
132  else
133  {
135  }
136 
137  // Check whether the principal stress S1 at the node is higher than the prescribed limit to activate the joints
138  if (PrincipalStresses[0] >= mStressLimit)
139  {
140  itCond->Set(PERIODIC,false);
141  rGeom[0].FastGetSolutionStepValue(PERIODIC_PAIR_INDEX) = 0;
142  rGeom[1].FastGetSolutionStepValue(PERIODIC_PAIR_INDEX) = 0;
143 
144  GlobalPointersVector<Element>& rE = rGeom[0].GetValue(NEIGHBOUR_ELEMENTS);
145  for(unsigned int ie = 0; ie < rE.size(); ie++)
146  {
147  #pragma omp critical
148  {
149  rE[ie].Set(ACTIVE,true);
150  }
151  }
152  }
153  }
154 
155  KRATOS_CATCH("");
156  }
157 
159  std::string Info() const override
160  {
161  return "PeriodicInterfaceProcess";
162  }
163 
165  void PrintInfo(std::ostream& rOStream) const override
166  {
167  rOStream << "PeriodicInterfaceProcess";
168  }
169 
171  void PrintData(std::ostream& rOStream) const override
172  {
173  }
174 
176 
177 protected:
178 
180 
182  int mDimension;
183  double mStressLimit;
184 
186 
187 private:
188 
191 
193  //PeriodicInterfaceProcess(PeriodicInterfaceProcess const& rOther);
194 
195 }; // Class PeriodicInterfaceProcess
196 
198 inline std::istream& operator >> (std::istream& rIStream,
199  PeriodicInterfaceProcess& rThis);
200 
202 inline std::ostream& operator << (std::ostream& rOStream,
203  const PeriodicInterfaceProcess& rThis)
204 {
205  rThis.PrintInfo(rOStream);
206  rOStream << std::endl;
207  rThis.PrintData(rOStream);
208 
209  return rOStream;
210 }
211 
212 } // namespace Kratos.
213 
214 #endif /* KRATOS_PERIODIC_INTERFACE_PROCESS defined */
PeriodicInterfaceProcess(ModelPart &model_part, Parameters rParameters)
Definition: periodic_interface_process.hpp:5
Definition: flags.h:58
Geometry base class.
Definition: geometry.h:71
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
size_type size() const
Definition: global_pointers_vector.h:307
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
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:73
ModelPart & mr_model_part
Member Variables.
Definition: periodic_interface_process.hpp:181
KRATOS_CLASS_POINTER_DEFINITION(PeriodicInterfaceProcess)
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
void Execute() override
Execute method is used to execute the PeriodicInterfaceProcess algorithms.
Definition: periodic_interface_process.hpp:67
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:159
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: periodic_interface_process.hpp:165
PeriodicInterfaceProcess(ModelPart &model_part, Parameters rParameters)
Constructor.
Definition: periodic_interface_process.hpp:32
~PeriodicInterfaceProcess() override
Destructor.
Definition: periodic_interface_process.hpp:62
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: periodic_interface_process.hpp:106
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
static Vector EigenValuesDirectMethod(const Matrix &A)
Definition: solid_mechanics_math_utilities.hpp:243
#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::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
model_part
Definition: face_heat.py:14
PrincipalStresses
Definition: isotropic_damage_automatic_differentiation.py:221
integer i
Definition: TensorModule.f:17