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_close_nodes_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: anonymous $
46 // Date: $Date: 2007-11-06 12:34:26 $
47 // Revision: $Revision: 1.3 $
48 //
49 //
50 
51 #if !defined(KRATOS_MARK_CLOSE_NODES_PROCESS_INCLUDED )
52 #define KRATOS_MARK_CLOSE_NODES_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"
75 
76 
77 namespace Kratos
78 {
79 
82 
86 
87 
91 
95 
99 
101 
108  : public Process
109 {
110 public:
113 
116 
120 
123  : mr_model_part(model_part)
124  {
125  }
126 
129  {
130  }
131 
132 
136 
137 
138 
139 
143 
144  void MarkCloseNodes(const double admissible_distance_factor)
145  {
146  KRATOS_TRY
147 
148  double fact2 = admissible_distance_factor*admissible_distance_factor;
149  for(ModelPart::NodesContainerType::iterator in = mr_model_part.NodesBegin(); in!=mr_model_part.NodesEnd(); in++)
150  {
151  if(in->FastGetSolutionStepValue(IS_STRUCTURE) == 0) //if it is not a wall node i can erase
152  {
153  double hnode2 = in->FastGetSolutionStepValue(NODAL_H);
154  hnode2 *= hnode2; //take the square
155 
156  //loop on neighbours and erase if they are too close
157  for( GlobalPointersVector< Node >::iterator i = in->GetValue(NEIGHBOUR_NODES).begin();
158  i != in->GetValue(NEIGHBOUR_NODES).end(); i++)
159  {
160  if(i->Is(TO_ERASE) == false) //we can erase the current node only if the neighb is not to be erased
161  {
162  double dx = i->X() - in->X();
163  double dy = i->Y() - in->Y();
164  double dz = i->Z() - in->Z();
165 
166  double dist2 = dx*dx + dy*dy + dz*dz;
167 
168  if(dist2 < fact2 * hnode2)
169  in->Set(TO_ERASE, true);
170  }
171  }
172  }
173  }
174  /*
175  this was my old version. now Riccardos version is implemented
176  for(ModelPart::NodesContainerType::iterator in = mr_model_part.NodesBegin() ;
177  in != mr_model_part.NodesEnd() ; ++in)
178  {
179 
180  const double& X0 = in->X(); const double& Y0 = in->Y();
181  KRATOS_WATCH("ENTERED MARKING CLOSE NODES FUCNTION!");
182 
183  for( GlobalPointersVector< Node >::iterator i = in->GetValue(NEIGHBOUR_NODES).begin();
184  i != in->GetValue(NEIGHBOUR_NODES).end(); i++)
185  {
186  const double& X1 = i->X(); const double& Y1 = i->Y();
187  const double& dist_sq = (X1-X0)*(X1-X0)+(Y1-Y0)*(Y1-Y0);
188  //if (dist_sq<(i->GetValue(NODAL_H))*(i->GetValue(NODAL_H)) && in->GetId()>i->GetId())
189  if (dist_sq<0.005 && in->GetId()>i->GetId())
190  {
191  if (i->FastGetSolutionStepValue(IS_STRUCTURE)==false)
192  {
193  i->Is(TO_ERASE)= true;
194  KRATOS_WATCH("ERASING NODE!!!!!!");
195  KRATOS_WATCH(in->GetId());
196  }
197 
198  }
199 
200  }
201 
202 
203  }
204  */
205 
206  KRATOS_CATCH("")
207  }
208 
209 
213 
214 
218 
219 
223 
225  std::string Info() const override
226  {
227  return "MarkCloseNodesProcess";
228  }
229 
231  void PrintInfo(std::ostream& rOStream) const override
232  {
233  rOStream << "MarkCloseNodesProcess";
234  }
235 
237  void PrintData(std::ostream& rOStream) const override
238  {
239  }
240 
241 
245 
246 
248 
249 protected:
252 
253 
257 
258 
262 
263 
267 
268 
272 
273 
277 
278 
282 
283 
285 
286 private:
289 
290 
294  ModelPart& mr_model_part;
295 
299 
300 
304 
305 
309 
310 
314 
315 
319 
321 // MarkCloseNodesProcess& operator=(MarkCloseNodesProcess const& rOther);
322 
324 // MarkCloseNodesProcess(MarkCloseNodesProcess const& rOther);
325 
326 
328 
329 }; // Class MarkCloseNodesProcess
330 
332 
335 
336 
340 
341 
343 inline std::istream& operator >> (std::istream& rIStream,
344  MarkCloseNodesProcess& rThis);
345 
347 inline std::ostream& operator << (std::ostream& rOStream,
348  const MarkCloseNodesProcess& rThis)
349 {
350  rThis.PrintInfo(rOStream);
351  rOStream << std::endl;
352  rThis.PrintData(rOStream);
353 
354  return rOStream;
355 }
357 
358 
359 } // namespace Kratos.
360 
361 #endif // KRATOS_MARK_CLOSE_NODES_PROCESS_INCLUDED defined
362 
363 
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
Short class definition.
Definition: mark_close_nodes_process.h:109
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mark_close_nodes_process.h:237
~MarkCloseNodesProcess() override
Destructor.
Definition: mark_close_nodes_process.h:128
KRATOS_CLASS_POINTER_DEFINITION(MarkCloseNodesProcess)
Pointer definition of PushStructureProcess.
MarkCloseNodesProcess(ModelPart &model_part)
Default constructor.
Definition: mark_close_nodes_process.h:122
std::string Info() const override
Turn back information as a string.
Definition: mark_close_nodes_process.h:225
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: mark_close_nodes_process.h:231
void MarkCloseNodes(const double admissible_distance_factor)
Definition: mark_close_nodes_process.h:144
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
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
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
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
integer i
Definition: TensorModule.f:17