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.
manage_isolated_nodes_process.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosPfemApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: July 2018 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_MANAGE_ISOLATED_NODES_PROCESS_H_INCLUDED)
11 #define KRATOS_MANAGE_ISOLATED_NODES_PROCESS_H_INCLUDED
12 
13 
14 // System includes
15 
16 // External includes
17 
18 // Project includes
19 #include "includes/model_part.h"
21 #include "processes/process.h"
23 
24 namespace Kratos
25 {
26 
29 
32 {
33 public:
37 
40 
44 
45  ManageIsolatedNodesProcess(ModelPart& rModelPart) : Process(Flags()) , mrModelPart(rModelPart)
46  {
47  }
48 
51 
52 
56 
58  void operator()()
59  {
60  Execute();
61  }
62 
66 
67 
69  void Execute() override
70  {
71  }
72 
75  void ExecuteInitialize() override
76  {
77  }
78 
81  void ExecuteBeforeSolutionLoop() override
82  {
84 
85  double Radius = 0.0;
86  //BOUNDARY flag must be set in model part nodes
87  mBoundingBox = SpatialBoundingBox(mrModelPart,Radius,0.1);
88 
89  KRATOS_CATCH("")
90  }
91 
92 
95  {
97 
98  const int nnodes = mrModelPart.Nodes().size();
99 
100  if (nnodes != 0)
101  {
102  ModelPart::NodesContainerType::iterator it_begin =
103  mrModelPart.NodesBegin();
104 
105  #pragma omp parallel for
106  for (int i = 0; i < nnodes; ++i)
107  {
108  ModelPart::NodesContainerType::iterator it = it_begin + i;
109 
110  if( it->Is(ISOLATED) || (it->Is(RIGID) && (it->IsNot(SOLID) && it->IsNot(FLUID))) ){
111 
112  if(it->SolutionStepsDataHas(PRESSURE)){
113  it->FastGetSolutionStepValue(PRESSURE,0) = 0.0;
114  it->FastGetSolutionStepValue(PRESSURE,1) = 0.0;
115  }
116  if(it->SolutionStepsDataHas(PRESSURE_VELOCITY)){
117  it->FastGetSolutionStepValue(PRESSURE_VELOCITY,0) = 0.0;
118  it->FastGetSolutionStepValue(PRESSURE_VELOCITY,1) = 0.0;
119  }
120  if(it->SolutionStepsDataHas(PRESSURE_ACCELERATION)){
121  it->FastGetSolutionStepValue(PRESSURE_ACCELERATION,0) = 0.0;
122  it->FastGetSolutionStepValue(PRESSURE_ACCELERATION,1) = 0.0;
123  }
124 
125  }
126  }
127  }
128 
129  KRATOS_CATCH("")
130  }
131 
134  {
135  KRATOS_TRY
136 
137  const int nnodes = mrModelPart.Nodes().size();
138  const double TimeStep = mrModelPart.GetProcessInfo()[DELTA_TIME];
139  if (nnodes != 0)
140  {
141  this->SetSemiIsolatedNodes(mrModelPart);
142 
143  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin();
144 
145  #pragma omp parallel for
146  for (int i = 0; i < nnodes; ++i)
147  {
148  ModelPart::NodesContainerType::iterator it = it_begin + i;
149 
150  if( it->Is(ISOLATED) ){
151  if(it->SolutionStepsDataHas(VOLUME_ACCELERATION)){
152  const array_1d<double,3>& VolumeAcceleration = it->FastGetSolutionStepValue(VOLUME_ACCELERATION);
153  noalias(it->FastGetSolutionStepValue(ACCELERATION)) = VolumeAcceleration;
154  }
155  // std::cout<<"PRE POSITION "<<it->Coordinates()<<" ACCELERATION "<<it->FastGetSolutionStepValue(ACCELERATION)<<std::endl;
156  // std::cout<<"DISPLACEMENT "<<it->FastGetSolutionStepValue(DISPLACEMENT)<<" VELOCITY "<<it->FastGetSolutionStepValue(VELOCITY)<<std::endl;
157 
158  noalias(it->FastGetSolutionStepValue(VELOCITY)) = it->FastGetSolutionStepValue(VELOCITY,1) + it->FastGetSolutionStepValue(ACCELERATION)*TimeStep;
159  noalias(it->Coordinates()) -= it->FastGetSolutionStepValue(DISPLACEMENT);
160  noalias(it->FastGetSolutionStepValue(DISPLACEMENT)) = it->FastGetSolutionStepValue(DISPLACEMENT,1) + it->FastGetSolutionStepValue(VELOCITY)*TimeStep + 0.5*it->FastGetSolutionStepValue(ACCELERATION)*TimeStep*TimeStep;
161  noalias(it->Coordinates()) += it->FastGetSolutionStepValue(DISPLACEMENT);
162 
163  // std::cout<<"POST POSITION "<<it->Coordinates()<<" ACCELERATION "<<it->FastGetSolutionStepValue(ACCELERATION)<<std::endl;
164  // std::cout<<"DISPLACEMENT "<<it->FastGetSolutionStepValue(DISPLACEMENT)<<" VELOCITY "<<it->FastGetSolutionStepValue(VELOCITY)<<std::endl;
165 
166  //std::cout<<" ISOLATED Node ["<<it->Id()<<"] Displacement"<<it->FastGetSolutionStepValue(DISPLACEMENT)<<std::endl;
167 
168  if( !mBoundingBox.IsInside( it->Coordinates() ) ){
169  it->Set(TO_ERASE);
170  std::cout<<" ISOLATED to erase "<<std::endl;
171  }
172  }
173  else if( it->Is(VISITED) ){
174 
175  if(it->SolutionStepsDataHas(VOLUME_ACCELERATION)){
176  const array_1d<double,3>& VolumeAcceleration = it->FastGetSolutionStepValue(VOLUME_ACCELERATION);
177  noalias(it->FastGetSolutionStepValue(ACCELERATION)) = VolumeAcceleration;
178  }
179 
180  noalias(it->FastGetSolutionStepValue(VELOCITY)) = 0.5 * (it->FastGetSolutionStepValue(VELOCITY) + it->FastGetSolutionStepValue(VELOCITY,1) + it->FastGetSolutionStepValue(ACCELERATION)*TimeStep);
181  noalias(it->Coordinates()) -= it->FastGetSolutionStepValue(DISPLACEMENT);
182  noalias(it->FastGetSolutionStepValue(DISPLACEMENT)) = 0.5 * (it->FastGetSolutionStepValue(DISPLACEMENT) + it->FastGetSolutionStepValue(DISPLACEMENT,1) + it->FastGetSolutionStepValue(VELOCITY)*TimeStep + 0.5*it->FastGetSolutionStepValue(ACCELERATION)*TimeStep*TimeStep);
183  noalias(it->Coordinates()) += it->FastGetSolutionStepValue(DISPLACEMENT);
184 
185  }
186  }
187 
188  this->ResetSemiIsolatedNodes(mrModelPart);
189 
190  }
191 
192  KRATOS_CATCH("")
193  }
194 
195 
197  void ExecuteBeforeOutputStep() override
198  {
199  }
200 
201 
203  void ExecuteAfterOutputStep() override
204  {
205  }
206 
207 
210  void ExecuteFinalize() override
211  {
212  }
213 
214 
218 
219 
223 
224 
228 
230  std::string Info() const override
231  {
232  return "ManageIsolatedNodesProcess";
233  }
234 
236  void PrintInfo(std::ostream& rOStream) const override
237  {
238  rOStream << "ManageIsolatedNodesProcess";
239  }
240 
242  void PrintData(std::ostream& rOStream) const override
243  {
244  }
245 
246 
251 
252 protected:
253 
262 
265 
279 
280 private:
281 
287 
288  ModelPart& mrModelPart;
289 
290  SpatialBoundingBox mBoundingBox;
291 
298 
299  void SetSemiIsolatedNodes(ModelPart& rModelPart)
300  {
301 
302  const int nnodes = mrModelPart.Nodes().size();
303 
304  if (nnodes != 0)
305  {
306  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin();
307 
308  #pragma omp parallel for
309  for (int i = 0; i < nnodes; ++i)
310  {
311  ModelPart::NodesContainerType::iterator it = it_begin + i;
312 
313  if( it->Is(FREE_SURFACE) ){
314 
315  NodeWeakPtrVectorType& nNodes = it->GetValue(NEIGHBOUR_NODES);
316  unsigned int rigid = 0;
317  for(auto& i_nnodes : nNodes)
318  {
319  if(i_nnodes.Is(RIGID))
320  ++rigid;
321  }
322  if( rigid == nNodes.size() )
323  it->Set(VISITED,true);
324  }
325  }
326  }
327 
328 
329  }
330 
331  void ResetSemiIsolatedNodes(ModelPart& rModelPart)
332  {
333 
334  const int nnodes = mrModelPart.Nodes().size();
335 
336  if (nnodes != 0)
337  {
338  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin();
339 
340  #pragma omp parallel for
341  for (int i = 0; i < nnodes; ++i)
342  {
343  ModelPart::NodesContainerType::iterator it = it_begin + i;
344 
345  if(it->Is(VISITED))
346  it->Set(VISITED,false);
347  }
348  }
349 
350  }
351 
352 
356 
358  ManageIsolatedNodesProcess& operator=(ManageIsolatedNodesProcess const& rOther);
359 
360 
370 
371 }; // Class ManageIsolatedNodesProcess
372 
373 
375 
378 
379 
383 
384 
386 inline std::istream& operator >> (std::istream& rIStream,
388 
390 inline std::ostream& operator << (std::ostream& rOStream,
391  const ManageIsolatedNodesProcess& rThis)
392 {
393  rThis.PrintInfo(rOStream);
394  rOStream << std::endl;
395  rThis.PrintData(rOStream);
396 
397  return rOStream;
398 }
400 
401 
402 } // namespace Kratos.
403 
404 #endif // KRATOS_MANAGE_ISOLATED_NODES_PROCESS_H_INCLUDED defined
Definition: flags.h:58
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
Process for managing the time integration of variables for isolated nodes.
Definition: manage_isolated_nodes_process.hpp:32
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: manage_isolated_nodes_process.hpp:133
void ExecuteFinalize() override
Definition: manage_isolated_nodes_process.hpp:210
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: manage_isolated_nodes_process.hpp:242
void ExecuteInitialize() override
Definition: manage_isolated_nodes_process.hpp:75
std::string Info() const override
Turn back information as a string.
Definition: manage_isolated_nodes_process.hpp:230
GlobalPointersVector< Node > NodeWeakPtrVectorType
Definition: manage_isolated_nodes_process.hpp:36
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: manage_isolated_nodes_process.hpp:58
ManageIsolatedNodesProcess(ModelPart &rModelPart)
Definition: manage_isolated_nodes_process.hpp:45
virtual ~ManageIsolatedNodesProcess()
Destructor.
Definition: manage_isolated_nodes_process.hpp:50
void ExecuteBeforeOutputStep() override
this function will be executed at every time step BEFORE writing the output
Definition: manage_isolated_nodes_process.hpp:197
void ExecuteBeforeSolutionLoop() override
Definition: manage_isolated_nodes_process.hpp:81
void ExecuteAfterOutputStep() override
this function will be executed at every time step AFTER writing the output
Definition: manage_isolated_nodes_process.hpp:203
KRATOS_CLASS_POINTER_DEFINITION(ManageIsolatedNodesProcess)
Pointer definition of ManageIsolatedNodesProcess.
void Execute() override
Execute method is used to execute the ManageIsolatedNodesProcess algorithms.
Definition: manage_isolated_nodes_process.hpp:69
void ExecuteInitializeSolutionStep() override
this function will be executed at every time step BEFORE performing the solve phase
Definition: manage_isolated_nodes_process.hpp:94
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: manage_isolated_nodes_process.hpp:236
ManageIsolatedNodesProcess(ManageIsolatedNodesProcess const &rOther)
Copy constructor.
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
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
The base class for all processes in Kratos.
Definition: process.h:49
Short class definition.
Definition: spatial_bounding_box.hpp:48
virtual bool IsInside(const PointType &rPoint, double &rCurrentTime, double Radius=0)
Definition: spatial_bounding_box.hpp:604
#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
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17