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 
105  : public Process
106 {
107 public:
110 
113 
117 
120  : mr_model_part(model_part)
121  {
122  }
123 
126  {
127  }
128 
129 
133 
134  void operator()()
135  {
136  Execute();
137  }
138 
139 
143 
144  void Execute() override
145  {
146  KRATOS_TRY
147  for(ModelPart::ElementsContainerType::const_iterator im = mr_model_part.ElementsBegin(); im!=mr_model_part.ElementsEnd(); im++)
148  {
149  double x0 = im.X();
150  double x1 = im.X();
151  double x2 = pgeom[2].X();
152 
153  double y0 = pgeom[0].Y();
154  double y1 = pgeom[1].Y();
155  double y2 = pgeom[2].Y();
156 
157  /*if( ((y0<-0.1) || (y1<-0.1 ) || (y2<-0.1 )) && (x0>1.1 || x1>1.1 || x2>1.1 ))
158  {
159  return false;
160  }*/
161 
162  msJ(0,0)=2.0*(x1-x0);
163  msJ(0,1)=2.0*(y1-y0);
164  msJ(1,0)=2.0*(x2-x0);
165  msJ(1,1)=2.0*(y2-y0);
166 
167 
168  double detJ = msJ(0,0)*msJ(1,1)-msJ(0,1)*msJ(1,0);
169 
170  msJinv(0,0) = msJ(1,1);
171  msJinv(0,1) = -msJ(0,1);
172  msJinv(1,0) = -msJ(1,0);
173  msJinv(1,1) = msJ(0,0);
174 
176 
177 
178  if(detJ < 1e-12)
179  {
180  //std::cout << "detJ = " << detJ << std::endl;
182  pgeom[0].GetSolutionStepValue(IS_BOUNDARY) = 1;
183  pgeom[1].GetSolutionStepValue(IS_BOUNDARY) = 1;
184  pgeom[2].GetSolutionStepValue(IS_BOUNDARY) = 1;
185  return false;
186  }
187 
188  else
189  {
190 
191  double x0_2 = x0*x0 + y0*y0;
192  double x1_2 = x1*x1 + y1*y1;
193  double x2_2 = x2*x2 + y2*y2;
194 
195  //finalizing the calculation of the inverted matrix
196  //std::cout<<"MATR INV"<<MatrixInverse(msJ)<<std::endl;
197  msJinv /= detJ;
198  //calculating the RHS
199  ms_rhs[0] = (x1_2 - x0_2);
200  ms_rhs[1] = (x2_2 - x0_2);
201 
202  //calculate position of the center
203  noalias(msc) = prod(msJinv,ms_rhs);
204 
205  double radius = sqrt(pow(msc[0]-x0,2)+pow(msc[1]-y0,2));
206 
207  //calculate average h
208  double h;
209  h = pgeom[0].FastGetSolutionStepValue(NODAL_H);
210  h += pgeom[1].FastGetSolutionStepValue(NODAL_H);
211  h += pgeom[2].FastGetSolutionStepValue(NODAL_H);
212  h *= 0.333333333;
213  if (radius < h*alpha_param)
214  {
215  return true;
216  }
217  else
218  {
219  return false;
220  }
221  }
222 
223  }
224 
225  KRATOS_CATCH("")
226  }
227 
228 
232 
233 
237 
238 
242 
244  std::string Info() const override
245  {
246  return "MarkBadElementsProcess";
247  }
248 
250  void PrintInfo(std::ostream& rOStream) const override
251  {
252  rOStream << "MarkBadElementsProcess";
253  }
254 
256  void PrintData(std::ostream& rOStream) const override
257  {
258  }
259 
260 
264 
265 
267 
268 protected:
271 
272 
276 
277 
281 
282 
286 
287 
291 
292 
296 
297 
301 
302 
304 
305 private:
308 
309 
313  ModelPart& mr_model_part;
314 
318 
319 
323 
324 
328 
329 
333 
334 
338 
340 // MarkBadElementsProcess& operator=(MarkBadElementsProcess const& rOther);
341 
343 // MarkBadElementsProcess(MarkBadElementsProcess const& rOther);
344 
345 
347 
348 }; // Class MarkBadElementsProcess
349 
351 
354 
355 
359 
360 
362 inline std::istream& operator >> (std::istream& rIStream,
363  MarkBadElementsProcess& rThis);
364 
366 inline std::ostream& operator << (std::ostream& rOStream,
367  const MarkBadElementsProcess& rThis)
368 {
369  rThis.PrintInfo(rOStream);
370  rOStream << std::endl;
371  rThis.PrintData(rOStream);
372 
373  return rOStream;
374 }
376 
377 
378 } // namespace Kratos.
379 
380 #endif // KRATOS_MARK_BAD_ELEMENTS_PROCESS_INCLUDED defined
381 
382 
Definition: amatrix_interface.h:41
Short class definition.
Definition: mark_bad_elements_process.h:106
void operator()()
Definition: mark_bad_elements_process.h:134
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:256
std::string Info() const override
Turn back information as a string.
Definition: mark_bad_elements_process.h:244
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:250
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
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
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