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.
nodal_update_utilities.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ \.
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Original author: Ruben Zorrilla
9 //
10 
11 #if !defined( KRATOS_NODAL_UPDATE_UTILITIES )
12 #define KRATOS_NODAL_UPDATE_UTILITIES
13 
14 
15 /* System includes */
16 #include <set>
17 
18 /* External includes */
19 
20 /* Project includes */
21 #include "includes/define.h"
22 #include "includes/variables.h"
24 #include "includes/fsi_variables.h"
25 #include "containers/array_1d.h"
26 #include "includes/model_part.h"
27 #include "includes/communicator.h"
29 #include "utilities/openmp_utils.h"
31 
32 
33 namespace Kratos
34 {
35 
58 template <unsigned int TDim>
60 {
61 
62 public:
63 
69  //~ /** Counted pointer of ClassName */
80 
94  virtual ~NodalUpdateBaseClass() {}
95 
105  virtual void UpdateMeshTimeDerivatives(ModelPart& rModelPart,
106  const double timeStep) {
107  KRATOS_ERROR << "Calling the nodal update base class UpdateMeshTimeDerivatives() method. Call the proper time scheme derived one.";
108  }
109 
114  virtual void SetMeshTimeDerivativesOnInterface(ModelPart& rInterfaceModelPart) {
115  auto& rLocalMesh = rInterfaceModelPart.GetCommunicator().LocalMesh();
116  ModelPart::NodeIterator local_mesh_nodes_begin = rLocalMesh.NodesBegin();
117  #pragma omp parallel for firstprivate(local_mesh_nodes_begin)
118  for(int k=0; k<static_cast<int>(rLocalMesh.NumberOfNodes()); ++k)
119  {
120  ModelPart::NodeIterator it_node = local_mesh_nodes_begin+k;
121 
122  array_1d<double, 3>& v_node = it_node->FastGetSolutionStepValue(VELOCITY); // Current step interface velocity
123  noalias(v_node) = it_node->FastGetSolutionStepValue(MESH_VELOCITY); // Set the current interface velocity as the mesh velocity;
124  }
125 
126  rInterfaceModelPart.GetCommunicator().SynchronizeVariable(VELOCITY);
127  }
128 
131 protected:
132 
166 private:
167 
204 }; /* Class NodalUpdateBaseClass */
205 
206 
210 template <unsigned int TDim>
212 {
213 
214 public:
215 
221  //~ /** Counted pointer of ClassName */
231  NodalUpdateNewmark(const double BossakAlpha = -0.3) {
232  const double bossak_f = 0.0;
233  const double bossak_beta = 0.25;
234  const double bossak_gamma = 0.5;
235 
236  mBossakBeta = std::pow((1.0 + bossak_f - BossakAlpha), 2) * bossak_beta;
237  mBossakGamma = bossak_gamma + bossak_f - BossakAlpha;
238  }
239 
240 
254  virtual ~NodalUpdateNewmark() {}
255 
266  const double timeStep) override{
267 
268  auto& rLocalMesh = rModelPart.GetCommunicator().LocalMesh();
269  ModelPart::NodeIterator local_mesh_nodes_begin = rLocalMesh.NodesBegin();
270  #pragma omp parallel for firstprivate(local_mesh_nodes_begin)
271  for(int k = 0; k < static_cast<int>(rLocalMesh.NumberOfNodes()); ++k) {
272  const ModelPart::NodeIterator it_node = local_mesh_nodes_begin+k;
273 
274  const array_1d<double, 3>& umesh_n = it_node->FastGetSolutionStepValue(MESH_DISPLACEMENT, 1); // Previous step mesh displacement
275  const array_1d<double, 3>& vmesh_n = it_node->FastGetSolutionStepValue(MESH_VELOCITY, 1); // Previous step mesh velocity
276  const array_1d<double, 3>& amesh_n = it_node->FastGetSolutionStepValue(MESH_ACCELERATION, 1); // Previous step mesh acceleration
277 
278  const array_1d<double, 3>& umesh_n1 = it_node->FastGetSolutionStepValue(MESH_DISPLACEMENT); // Current step mesh displacement
279  array_1d<double, 3>& vmesh_n1 = it_node->FastGetSolutionStepValue(MESH_VELOCITY); // Current step mesh velocity (to be updated)
280  array_1d<double, 3>& amesh_n1 = it_node->FastGetSolutionStepValue(MESH_ACCELERATION); // Current step mesh acceleration (to be updated)
281 
282  const double const_u = mBossakGamma / (timeStep * mBossakBeta);
283  const double const_v = 1.0 - mBossakGamma / mBossakBeta;
284  const double const_a = timeStep * (1.0 - mBossakGamma / (2.0 * mBossakBeta));
285 
286  for (unsigned int d=0; d<TDim; ++d) {
287  vmesh_n1[d] = const_u * (umesh_n1[d] - umesh_n[d]) + const_v * vmesh_n[d] + const_a * amesh_n[d];
288  amesh_n1[d] = (1.0 / (timeStep * mBossakGamma)) * (vmesh_n1[d] - vmesh_n[d]) - ((1 - mBossakGamma) / mBossakGamma) * amesh_n[d];
289  }
290  }
291 
292  rModelPart.GetCommunicator().SynchronizeVariable(MESH_VELOCITY);
293  rModelPart.GetCommunicator().SynchronizeVariable(MESH_ACCELERATION);
294 
295  }
296 
299 protected:
300 
309  double mBossakBeta;
310  double mBossakGamma;
311 
336 private:
337 
374 }; /* Class NodalUpdateNewmark */
375 
384 } /* namespace Kratos.*/
385 
386 #endif /* KRATOS_PARTITIONED_FSI_UTILITIES defined */
virtual bool SynchronizeVariable(Variable< int > const &rThisVariable)
Definition: communicator.cpp:357
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
NodeIterator NodesBegin()
Definition: mesh.h:326
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Communicator & GetCommunicator()
Definition: model_part.h:1821
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
Definition: nodal_update_utilities.h:60
NodalUpdateBaseClass(const NodalUpdateBaseClass &Other)
virtual void UpdateMeshTimeDerivatives(ModelPart &rModelPart, const double timeStep)
Definition: nodal_update_utilities.h:105
virtual void SetMeshTimeDerivativesOnInterface(ModelPart &rInterfaceModelPart)
Definition: nodal_update_utilities.h:114
KRATOS_CLASS_POINTER_DEFINITION(NodalUpdateBaseClass)
virtual ~NodalUpdateBaseClass()
Definition: nodal_update_utilities.h:94
NodalUpdateBaseClass()
Definition: nodal_update_utilities.h:79
Definition: nodal_update_utilities.h:212
NodalUpdateNewmark(const NodalUpdateNewmark &Other)
double mBossakBeta
Definition: nodal_update_utilities.h:309
double mBossakGamma
Definition: nodal_update_utilities.h:310
virtual ~NodalUpdateNewmark()
Definition: nodal_update_utilities.h:254
NodalUpdateNewmark(const double BossakAlpha=-0.3)
Definition: nodal_update_utilities.h:231
void UpdateMeshTimeDerivatives(ModelPart &rModelPart, const double timeStep) override
Definition: nodal_update_utilities.h:265
KRATOS_CLASS_POINTER_DEFINITION(NodalUpdateNewmark)
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int d
Definition: ode_solve.py:397
int k
Definition: quadrature.py:595