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.
check_skin_process.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 #ifndef KRATOS_VERIFY_WATERTIGHTNESS_PROCESS_H
14 #define KRATOS_VERIFY_WATERTIGHTNESS_PROCESS_H
15 
16 // System includes
17 #include <unordered_map>
18 
19 // External includes
20 
21 // Project includes
22 #include "includes/define.h"
23 #include "includes/model_part.h"
24 #include "processes/process.h"
25 #include "includes/key_hash.h"
26 
27 namespace Kratos
28 {
29 
39  : public Process
40 {
41 public:
44 
47 
49  typedef std::size_t IndexType;
50 
54 
57  ModelPart& rModelPart,
58  const Flags Options
59  ): Process(Options),
60  mrModelPart(rModelPart)
61  {
62  }
63 
65  ~CheckSkinProcess() override {}
66 
70 
72  void operator()()
73  {
74  Execute();
75  }
76 
80 
81 
85  void Execute() override
86  {
87  KRATOS_TRY;
88 
89  KRATOS_ERROR_IF(mrModelPart.Conditions().size() == 0 && mrModelPart.Elements().size() != 0) << "The number of conditions is zero and the number of elements is not, hence the skin can not envelope the domain" << std::endl;
90 
91  typedef std::unordered_map<DenseVector<IndexType>, IndexType, KeyHasherRange<DenseVector<IndexType>>, KeyComparorRange<DenseVector<IndexType>> > hashmap;
92  hashmap edge_map;
93 
95 
96  // Add 1 to the counter for every edge find in the model part
97  for (auto& r_cond : mrModelPart.Conditions()) {
98  const auto edges = r_cond.GetGeometry().GenerateEdges();
99 
100  for(IndexType edge=0; edge<edges.size(); edge++) {
101  for(IndexType i=0; i<edges[edge].size(); i++) {
102  ids[i] = edges[edge][i].Id();
103  }
104 
105  //*** THE ARRAY OF IDS MUST BE ORDERED!!! ***
106  std::sort(ids.begin(), ids.end());
107 
108  edge_map[ids] += 1;
109  }
110  }
111 
112  // Now loop over the entire edge map.
113  // All values shall have a value of 2
114  // If that is not the case throw an error
115  for(auto it=edge_map.begin(); it!=edge_map.end(); ++it) {
116  if(it->second > 2) {
117  KRATOS_ERROR << "ERROR OVERLAPPING CONDITIONS IN SKIN FOUND : " << std::endl << "The edge between nodes " << it->first[0] << " and " << it->first[1] << std::endl << " belongs to an overlapping condition " << std::endl;
118  } else if(it->second < 2) {
119  KRATOS_ERROR << "ERROR NON CLOSED SKIN " << std::endl << "The edge between nodes " << it->first[0] << " and " << it->first[1] << std::endl << " only appears once, hence it belongs to a non watertight boundary " << std::endl;
120  }
121  }
122 
123  KRATOS_INFO("CheckSkinProcess") << "Checked " << edge_map.size() << " edges in the skin. No gap or overlap found " << std::endl;
124 
125  KRATOS_CATCH("");
126  }
127 
131 
132 
136 
137 
141 
143  std::string Info() const override
144  {
145  return "CheckSkinProcess";
146  }
147 
149  void PrintInfo(std::ostream& rOStream) const override
150  {
151  rOStream << "CheckSkinProcess";
152  }
153 
155  void PrintData(std::ostream& rOStream) const override
156  {
157  this->PrintInfo(rOStream);
158  }
159 
163 
165 private:
168 
172 
173  ModelPart& mrModelPart;
174 
178 
182 
184  CheckSkinProcess& operator=(CheckSkinProcess const& rOther);
185 
187  CheckSkinProcess(CheckSkinProcess const& rOther);
188 
190 
191 }; // Class Process
192 
194 
197 
201 
203 inline std::istream& operator >> (std::istream& rIStream,
204  CheckSkinProcess& rThis);
205 
207 inline std::ostream& operator << (std::ostream& rOStream,
208  const CheckSkinProcess& rThis)
209 {
210  rThis.PrintInfo(rOStream);
211  rOStream << std::endl;
212  rThis.PrintData(rOStream);
213 
214  return rOStream;
215 }
217 
218 
219 
220 } // namespace Kratos
221 
222 
223 #endif // KRATOS_VERIFY_WATERTIGHTNESS_PROCESS_H
This function verifies that the skin has no holes nor overlapped geometries this is accomplished by s...
Definition: check_skin_process.h:40
std::string Info() const override
Turn back information as a string.
Definition: check_skin_process.h:143
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: check_skin_process.h:149
std::size_t IndexType
The index type definition.
Definition: check_skin_process.h:49
CheckSkinProcess(ModelPart &rModelPart, const Flags Options)
Constructor for CheckSkinProcess Process.
Definition: check_skin_process.h:56
KRATOS_CLASS_POINTER_DEFINITION(CheckSkinProcess)
Pointer definition of Process.
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: check_skin_process.h:72
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: check_skin_process.h:155
~CheckSkinProcess() override
Destructor.
Definition: check_skin_process.h:65
void Execute() override
Check elements to make sure that their jacobian is positive and conditions to ensure that their face ...
Definition: check_skin_process.h:85
Definition: flags.h:58
std::size_t IndexType
Definition: flags.h:74
Definition: amatrix_interface.h:41
iterator end()
Definition: amatrix_interface.h:243
iterator begin()
Definition: amatrix_interface.h:241
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
The base class for all processes in Kratos.
Definition: process.h:49
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_INFO(label)
Definition: logger.h:250
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::unordered_multimap< DenseVector< int >, std::vector< Condition::Pointer >, KeyHasherRange< DenseVector< int > >, KeyComparorRange< DenseVector< int > >> hashmap
Definition: find_neighbour_elements_of_conditions_process.hpp:24
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
integer i
Definition: TensorModule.f:17
This is a key comparer of general pourpose between two classes.
Definition: key_hash.h:100
This is a hasher of general pourpose.
Definition: key_hash.h:138