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.
mark_bad_elements_process.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3 KratosULFApplication
4 A library based on:
5 Kratos
6 A General Purpose Software for Multi-Physics Finite Element Analysis
7 Version 1.0 (Released on march 05, 2007).
8 
9 Copyright 2007
10 Pooyan Dadvand, Riccardo Rossi, Pawel Ryzhakov
11 pooyan@cimne.upc.edu
12 rrossi@cimne.upc.edu
13 - CIMNE (International Center for Numerical Methods in Engineering),
14 Gran Capita' s/n, 08034 Barcelona, Spain
15 
16 
17 Permission is hereby granted, free of charge, to any person obtaining
18 a copy of this software and associated documentation files (the
19 "Software"), to deal in the Software without restriction, including
20 without limitation the rights to use, copy, modify, merge, publish,
21 distribute, sublicense and/or sell copies of the Software, and to
22 permit persons to whom the Software is furnished to do so, subject to
23 the following condition:
24 
25 Distribution of this code for any commercial purpose is permissible
26 ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNERS.
27 
28 The above copyright notice and this permission notice shall be
29 included in all copies or substantial portions of the Software.
30 
31 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
34 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
35 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
36 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
37 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 
39 ==============================================================================
40 */
41 
42 
43 //
44 // Project Name: Kratos
45 // Last Modified by: $Author: rrossi $
46 // Date: $Date: 2007-03-06 10:30:32 $
47 // Revision: $Revision: 1.2 $
48 //
49 // this process marks distorted fluid elements and their direct neighbours
50 
51 #if !defined(KRATOS_MARK_BAD_ELEMENTS_PROCESS_INCLUDED )
52 #define KRATOS_MARK_BAD_ELEMENTS_PROCESS_INCLUDED
53 
54 
55 
56 // System includes
57 #include <string>
58 #include <iostream>
59 #include <algorithm>
60 
61 // External includes
62 
63 
64 // Project includes
65 #include "includes/define.h"
66 #include "processes/process.h"
67 #include "includes/node.h"
68 #include "includes/element.h"
69 #include "includes/model_part.h"
70 #include "custom_utilities/geometry_utilities2D.h"
72 
73 
74 namespace Kratos
75 {
76 
79 
83 
84 
88 
92 
96 
98 
104 class MarkBadElementsProcess
105  : public Process
106 {
107 public:
110 
113 
117 
120  : mr_model_part(model_part)
121  {
122  }
123 
126 
127 
131 
132  void operator()()
133  {
134  Execute();
135  }
136 
137 
141 
142  void Execute() override
143  {
144  KRATOS_TRY
145  for(ModelPart::ElementsContainerType::const_iterator im = mr_model_part.ElementsBegin(); in!=mr_model_part.ElementsEnd(); in++)
146  {
147  double x0 = im.X();
148  double x1 = im.X();
149  double x2 = pgeom[2].X();
150 
151  double y0 = pgeom[0].Y();
152  double y1 = pgeom[1].Y();
153  double y2 = pgeom[2].Y();
154 
155  /*if( ((y0<-0.1) || (y1<-0.1 ) || (y2<-0.1 )) && (x0>1.1 || x1>1.1 || x2>1.1 ))
156  {
157  return false;
158  }*/
159 
160  msJ(0,0)=2.0*(x1-x0);
161  msJ(0,1)=2.0*(y1-y0);
162  msJ(1,0)=2.0*(x2-x0);
163  msJ(1,1)=2.0*(y2-y0);
164 
165 
166  double detJ = msJ(0,0)*msJ(1,1)-msJ(0,1)*msJ(1,0);
167 
168  msJinv(0,0) = msJ(1,1);
169  msJinv(0,1) = -msJ(0,1);
170  msJinv(1,0) = -msJ(1,0);
171  msJinv(1,1) = msJ(0,0);
172 
173  bounded_matrix<double,2,2> check;
174 
175 
176  if(detJ < 1e-12)
177  {
178  //std::cout << "detJ = " << detJ << std::endl;
180  pgeom[0].GetSolutionStepValue(IS_BOUNDARY) = 1;
181  pgeom[1].GetSolutionStepValue(IS_BOUNDARY) = 1;
182  pgeom[2].GetSolutionStepValue(IS_BOUNDARY) = 1;
183  return false;
184  }
185 
186  else
187  {
188 
189  double x0_2 = x0*x0 + y0*y0;
190  double x1_2 = x1*x1 + y1*y1;
191  double x2_2 = x2*x2 + y2*y2;
192 
193  //finalizing the calculation of the inverted matrix
194  //std::cout<<"MATR INV"<<MatrixInverse(msJ)<<std::endl;
195  msJinv /= detJ;
196  //calculating the RHS
197  ms_rhs[0] = (x1_2 - x0_2);
198  ms_rhs[1] = (x2_2 - x0_2);
199 
200  //calculate position of the center
201  noalias(msc) = prod(msJinv,ms_rhs);
202 
203  double radius = sqrt(pow(msc[0]-x0,2)+pow(msc[1]-y0,2));
204 
205  //calculate average h
206  double h;
207  h = pgeom[0].FastGetSolutionStepValue(NODAL_H);
208  h += pgeom[1].FastGetSolutionStepValue(NODAL_H);
209  h += pgeom[2].FastGetSolutionStepValue(NODAL_H);
210  h *= 0.333333333;
211  if (radius < h*alpha_param)
212  {
213  return true;
214  }
215  else
216  {
217  return false;
218  }
219  }
220 
221  }
222 
223  KRATOS_CATCH("")
224  }
225 
226 
230 
231 
235 
236 
240 
242  std::string Info() const override
243  {
244  return "MarkBadElementsProcess";
245  }
246 
248  void PrintInfo(std::ostream& rOStream) const override
249  {
250  rOStream << "MarkBadElementsProcess";
251  }
252 
254  void PrintData(std::ostream& rOStream) const override
255  {
256  }
257 
258 
262 
263 
265 
266 protected:
269 
270 
274 
275 
279 
280 
284 
285 
289 
290 
294 
295 
299 
300 
302 
303 private:
306 
307 
311  ModelPart& mr_model_part;
312 
316 
317 
321 
322 
326 
327 
331 
332 
336 
338 // MarkBadElementsProcess& operator=(MarkBadElementsProcess const& rOther);
339 
341 // MarkBadElementsProcess(MarkBadElementsProcess const& rOther);
342 
343 
345 
346 }; // Class MarkBadElementsProcess
347 
349 
352 
353 
357 
358 
360 inline std::istream& operator >> (std::istream& rIStream,
361  MarkBadElementsProcess& rThis);
362 
364 inline std::ostream& operator << (std::ostream& rOStream,
365  const MarkBadElementsProcess& rThis)
366 {
367  rThis.PrintInfo(rOStream);
368  rOStream << std::endl;
369  rThis.PrintData(rOStream);
370 
371  return rOStream;
372 }
374 
375 
376 } // namespace Kratos.
377 
378 #endif // KRATOS_MARK_BAD_ELEMENTS_PROCESS_INCLUDED defined
379 
380 
Short class definition.
Definition: mark_bad_elements_process.h:106
void operator()()
Definition: mark_bad_elements_process.h:132
MarkBadElementsProcess(ModelPart &model_part)
Default constructor.
Definition: mark_bad_elements_process.h:119
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mark_bad_elements_process.h:254
std::string Info() const override
Turn back information as a string.
Definition: mark_bad_elements_process.h:242
KRATOS_CLASS_POINTER_DEFINITION(MarkBadElementsProcess)
Pointer definition of PushStructureProcess.
~MarkBadElementsProcess() override
Destructor.
Definition: mark_bad_elements_process.h:125
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: mark_bad_elements_process.h:144
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: mark_bad_elements_process.h:248
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
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
im
Definition: GenerateCN.py:100
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
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
h
Definition: generate_droplet_dynamics.py:91
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
float radius
Definition: mesh_to_mdpa_converter.py:18
e
Definition: run_cpp_mpi_tests.py:31