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.
autoslip_inlet.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3 Kratos Fluid Dynamics Application
4 Kratos
5 A General Purpose Software for Multi-Physics Finite Element Analysis
6 Version 1.0 (Released on march 05, 2007).
7 
8 Copyright 2007
9 Pooyan Dadvand, Riccardo Rossi
10 pooyan@cimne.upc.edu
11 rrossi@cimne.upc.edu
12 CIMNE (International Center for Numerical Methods in Engineering),
13 Gran Capita' s/n, 08034 Barcelona, Spain
14 
15 Permission is hereby granted, free of charge, to any person obtaining
16 a copy of this software and associated documentation files (the
17 "Software"), to deal in the Software without restriction, including
18 without limitation the rights to use, copy, modify, merge, publish,
19 distribute, sublicense and/or sell copies of the Software, and to
20 permit persons to whom the Software is furnished to do so, subject to
21 the following condition:
22 
23 Distribution of this code for any commercial purpose is permissible
24 ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNER.
25 
26 The above copyright notice and this permission notice shall be
27 included in all copies or substantial portions of the Software.
28 
29 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
32 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
33 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
34 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
35 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 
37 ==============================================================================
38  */
39 
40 #ifndef KRATOS_MONOLITHIC_AUTOSLIP_INLET_CONDITION_H
41 #define KRATOS_MONOLITHIC_AUTOSLIP_INLET_CONDITION_H
42 
43 // System includes
44 #include <string>
45 #include <iostream>
46 
47 
48 // External includes
49 
50 
51 // Project includes
52 #include "includes/define.h"
53 #include "includes/serializer.h"
54 #include "includes/condition.h"
55 #include "includes/process_info.h"
56 
57 // Application includes
58 
59 namespace Kratos
60 {
63 
66 
70 
74 
78 
82 
84 
85 //template< unsigned int TDim, unsigned int TNumNodes = TDim >
87 {
88 public:
91 
94 
95  typedef Node NodeType;
96 
98 
100 
102 
104 
106 
107  typedef std::size_t IndexType;
108 
109  typedef std::size_t SizeType;
110 
111  typedef std::vector<std::size_t> EquationIdVectorType;
112 
113  typedef std::vector< Dof<double>::Pointer > DofsVectorType;
114 
116 
120 
122 
126  Condition(NewId)
127  {
128  }
129 
131 
136  const NodesArrayType& ThisNodes):
137  Condition(NewId,ThisNodes)
138  {
139  }
140 
142 
147  GeometryType::Pointer pGeometry):
148  Condition(NewId,pGeometry)
149  {
150  }
151 
153 
159  GeometryType::Pointer pGeometry,
160  PropertiesType::Pointer pProperties):
161  Condition(NewId,pGeometry,pProperties)
162  {
163  }
164 
167  Condition(rOther)
168  {
169  }
170 
172  virtual ~MonolithicAutoSlipInlet3D() override {}
173 
174 
178 
181  {
182  Condition::operator=(rOther);
183 
184  return *this;
185  }
186 
190 
192 
197  virtual Condition::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes, PropertiesType::Pointer pProperties) const override
198  {
199  return Condition::Pointer(new MonolithicAutoSlipInlet3D(NewId, GetGeometry().Create(ThisNodes), pProperties));
200  }
201 
202 
204 
207  virtual void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix,
208  VectorType& rRightHandSideVector,
209  const ProcessInfo& rCurrentProcessInfo) override;
210 
211 
213 
216  virtual void CalculateRightHandSide(VectorType& rRightHandSideVector,
217  const ProcessInfo& rCurrentProcessInfo) override;
218 
219 
220 
222 
226  virtual void EquationIdVector(EquationIdVectorType& rResult,
227  const ProcessInfo& rCurrentProcessInfo) const override;
228 
229 
231 
235  virtual void GetDofList(DofsVectorType& ConditionDofList,
236  const ProcessInfo& CurrentProcessInfo) const override;
237 
238 
240 
244  virtual void GetFirstDerivativesVector(Vector& Values, int Step = 0) override
245  {
246  const SizeType LocalSize = (TDim + 1) * TNumNodes;
247  unsigned int LocalIndex = 0;
248 
249  if (Values.size() != LocalSize)
250  Values.resize(LocalSize, false);
251 
252  for (unsigned int iNode = 0; iNode < TNumNodes; ++iNode)
253  {
254  array_1d<double,3>& rVelocity = this->GetGeometry()[iNode].FastGetSolutionStepValue(VELOCITY, Step);
255  for (unsigned int d = 0; d < TDim; ++d)
256  Values[LocalIndex++] = rVelocity[d];
257  Values[LocalIndex++] = this->GetGeometry()[iNode].FastGetSolutionStepValue(PRESSURE, Step);
258  }
259  }
260 
261 
263 
267  virtual void GetSecondDerivativesVector(Vector& Values, int Step = 0) override
268  {
269  const SizeType LocalSize = (TDim + 1) * TNumNodes;
270  unsigned int LocalIndex = 0;
271 
272  if (Values.size() != LocalSize)
273  Values.resize(LocalSize, false);
274 
275  for (unsigned int iNode = 0; iNode < TNumNodes; ++iNode)
276  {
277  array_1d<double,3>& rVelocity = this->GetGeometry()[iNode].FastGetSolutionStepValue(ACCELERATION, Step);
278  for (unsigned int d = 0; d < TDim; ++d)
279  Values[LocalIndex++] = rVelocity[d];
280  Values[LocalIndex++] = 0.0; // No value on pressure positions
281  }
282  }
283 
284 
286  std::vector<array_1d<double, 3 > >& rValues,
287  const ProcessInfo& rCurrentProcessInfo) override;
288 
289 
290 
291  virtual void GetValueOnIntegrationPoints(const Variable<double>& rVariable,
292  std::vector<double>& rValues,
293  const ProcessInfo& rCurrentProcessInfo) override;
294 
295 
297  std::vector<array_1d<double, 6 > >& rValues,
298  const ProcessInfo& rCurrentProcessInfo) override;
299 
300  virtual void GetValueOnIntegrationPoints(const Variable<Vector>& rVariable,
301  std::vector<Vector>& rValues,
302  const ProcessInfo& rCurrentProcessInfo) override;
303 
304 
305  virtual void GetValueOnIntegrationPoints(const Variable<Matrix>& rVariable,
306  std::vector<Matrix>& rValues,
307  const ProcessInfo& rCurrentProcessInfo) override;
308 
309 
313 
314 
318 
319 
323 
325  virtual std::string Info() const override
326  {
327  std::stringstream buffer;
328  buffer << "MonolithicAutoSlipInlet3D" << TDim << "D";
329  return buffer.str();
330  }
331 
333  virtual void PrintInfo(std::ostream& rOStream) const override
334  {
335  rOStream << "MonolithicAutoSlipInlet3D";
336  }
337 
339  virtual void PrintData(std::ostream& rOStream) const override {}
340 
341 
345 
346 
348 
349 protected:
352 
353 
357 
358 
362 
363 
367 
369 
373  virtual void ApplyWallLaw(MatrixType& rLocalMatrix,
374  VectorType& rLocalVector,
375  ProcessInfo& rCurrentProcessInfo)
376  {
377  GeometryType& rGeometry = this->GetGeometry();
378  const size_t BlockSize = TDim + 1;
379  const double NodalFactor = 1.0 / double(TDim);
380 
381  double area = NodalFactor * rGeometry.DomainSize();
382  // DomainSize() is the way to ask the geometry's length/area/volume (whatever is relevant for its dimension) without asking for the number of spatial dimensions first
383 
384  for(size_t itNode = 0; itNode < rGeometry.PointsNumber(); ++itNode)
385  {
386  const NodeType& rConstNode = rGeometry[itNode];
387  const double y = rConstNode.GetValue(Y_WALL); // wall distance to use in stress calculation
388  if( y > 0.0 && rConstNode.Is(SLIP) )
389  {
390  array_1d<double,3> Vel = rGeometry[itNode].FastGetSolutionStepValue(VELOCITY);
391  const array_1d<double,3>& VelMesh = rGeometry[itNode].FastGetSolutionStepValue(MESH_VELOCITY);
392  Vel -= VelMesh;
393  const double Ikappa = 1.0/0.41; // inverse of Von Karman's kappa
394  const double B = 5.2;
395  const double limit_yplus = 10.9931899; // limit between linear and log regions
396 
397  const double rho = rGeometry[itNode].FastGetSolutionStepValue(DENSITY);
398  const double nu = rGeometry[itNode].FastGetSolutionStepValue(VISCOSITY);
399 
400  double wall_vel = 0.0;
401  for (size_t d = 0; d < TDim; d++)
402  {
403  wall_vel += Vel[d]*Vel[d];
404  }
405  wall_vel = sqrt(wall_vel);
406 
407  if (wall_vel > 1e-12) // do not bother if velocity is zero
408  {
409 
410  // linear region
411  double utau = sqrt(wall_vel * nu / y);
412  double yplus = y * utau / nu;
413 
414  // log region
415  if (yplus > limit_yplus)
416  {
417 
418  // wall_vel / utau = 1/kappa * log(yplus) + B
419  // this requires solving a nonlinear problem:
420  // f(utau) = utau*(1/kappa * log(y*utau/nu) + B) - wall_vel = 0
421  // note that f'(utau) = 1/kappa * log(y*utau/nu) + B + 1/kappa
422 
423  unsigned int iter = 0;
424  double dx = 1e10;
425  const double tol = 1e-6;
426  double uplus = Ikappa * log(yplus) + B;
427 
428  while(iter < 100 && fabs(dx) > tol * utau)
429  {
430  // Newton-Raphson iteration
431  double f = utau * uplus - wall_vel;
432  double df = uplus + Ikappa;
433  dx = f/df;
434 
435  // Update variables
436  utau -= dx;
437  yplus = y * utau / nu;
438  uplus = Ikappa * log(yplus) + B;
439  ++iter;
440  }
441  if (iter == 100)
442  {
443  std::cout << "Warning: wall condition Newton-Raphson did not converge. Residual is " << dx << std::endl;
444  }
445  }
446  const double Tmp = area * utau * utau * rho / wall_vel;
447  for (size_t d = 0; d < TDim; d++)
448  {
449  size_t k = itNode*BlockSize+d;
450  rLocalVector[k] -= Vel[d] * Tmp;
451  rLocalMatrix(k,k) += Tmp;
452  }
453  }
454  }
455  }
456  }
457 
458 
460 
461 
462  void ApplyNeumannCondition(MatrixType &rLocalMatrix, VectorType &rLocalVector);
463 
464 
468 
469 
473 
474 
478 
479 
481 
482 private:
485 
486 
490 
491 
495 
496  friend class Serializer;
497 
498  virtual void save(Serializer& rSerializer) const
499  {
501  }
502 
503  virtual void load(Serializer& rSerializer)
504  {
506  }
507 
511 
512 
516 
517 
521 
522 
526 
527 
531 
532 
534 
535 }; // Class MonolithicAutoSlipInlet3D
536 
537 
539 
542 
543 
547 
548 
550 inline std::istream& operator >> (std::istream& rIStream,
552 {
553  return rIStream;
554 }
555 
557 template< unsigned int TDim, unsigned int TNumNodes >
558 inline std::ostream& operator << (std::ostream& rOStream,
560 {
561  rThis.PrintInfo(rOStream);
562  rOStream << std::endl;
563  rThis.PrintData(rOStream);
564 
565  return rOStream;
566 }
567 
569 
571 
572 
573 } // namespace Kratos.
574 
575 #endif // KRATOS_MONOLITHIC_WALL_CONDITION_H
Base class for all Conditions.
Definition: condition.h:59
std::size_t SizeType
Definition: condition.h:94
Condition & operator=(Condition const &rOther)
Assignment operator.
Definition: condition.h:181
std::size_t IndexType
Definition: flags.h:74
bool Is(Flags const &rOther) const
Definition: flags.h:274
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
virtual double DomainSize() const
This method calculate and return length, area or volume of this geometry depending to it's dimension.
Definition: geometry.h:1371
This object defines an indexed object.
Definition: indexed_object.h:54
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
Implements a wall condition for the PFEM2 formulation.
Definition: autoslip_inlet.h:87
std::vector< std::size_t > EquationIdVectorType
Definition: autoslip_inlet.h:111
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: autoslip_inlet.h:339
std::size_t IndexType
Definition: autoslip_inlet.h:107
void ApplyNeumannCondition(MatrixType &rLocalMatrix, VectorType &rLocalVector)
virtual void GetValueOnIntegrationPoints(const Variable< Matrix > &rVariable, std::vector< Matrix > &rValues, const ProcessInfo &rCurrentProcessInfo) override
PointerVectorSet< Dof< double >, IndexedObject > DofsArrayType
Definition: autoslip_inlet.h:115
virtual void GetValueOnIntegrationPoints(const Variable< array_1d< double, 6 > > &rVariable, std::vector< array_1d< double, 6 > > &rValues, const ProcessInfo &rCurrentProcessInfo) override
MonolithicAutoSlipInlet3D(IndexType NewId, const NodesArrayType &ThisNodes)
Constructor using an array of nodes.
Definition: autoslip_inlet.h:135
Geometry< NodeType > GeometryType
Definition: autoslip_inlet.h:99
virtual void ApplyWallLaw(MatrixType &rLocalMatrix, VectorType &rLocalVector, ProcessInfo &rCurrentProcessInfo)
Commpute the wall stress and add corresponding terms to the system contributions.
Definition: autoslip_inlet.h:373
MonolithicAutoSlipInlet3D(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constructor using Properties.
Definition: autoslip_inlet.h:158
Properties PropertiesType
Definition: autoslip_inlet.h:97
std::vector< Dof< double >::Pointer > DofsVectorType
Definition: autoslip_inlet.h:113
virtual void GetValueOnIntegrationPoints(const Variable< Vector > &rVariable, std::vector< Vector > &rValues, const ProcessInfo &rCurrentProcessInfo) override
Vector VectorType
Definition: autoslip_inlet.h:103
std::size_t SizeType
Definition: autoslip_inlet.h:109
MonolithicAutoSlipInlet3D & operator=(MonolithicAutoSlipInlet3D const &rOther)
Assignment operator.
Definition: autoslip_inlet.h:180
void CalculateNormal(array_1d< double, 3 > &An)
Definition: autoslip_inlet.cpp:81
virtual void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Provides the global indices for each one of this element's local rows.
Definition: autoslip_inlet_3d.cpp:63
virtual void GetFirstDerivativesVector(Vector &Values, int Step=0) override
Returns VELOCITY_X, VELOCITY_Y, (VELOCITY_Z,) PRESSURE for each node.
Definition: autoslip_inlet.h:244
Matrix MatrixType
Definition: autoslip_inlet.h:105
MonolithicAutoSlipInlet3D(MonolithicAutoSlipInlet3D const &rOther)
Copy constructor.
Definition: autoslip_inlet.h:166
KRATOS_CLASS_POINTER_DEFINITION(MonolithicAutoSlipInlet3D)
Pointer definition of MonolithicAutoSlipInlet3D.
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: autoslip_inlet.h:333
virtual ~MonolithicAutoSlipInlet3D() override
Destructor.
Definition: autoslip_inlet.h:172
Node NodeType
Definition: autoslip_inlet.h:95
MonolithicAutoSlipInlet3D(IndexType NewId=0)
Default constructor.
Definition: autoslip_inlet.h:125
MonolithicAutoSlipInlet3D(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor using Geometry.
Definition: autoslip_inlet.h:146
virtual void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Return local contributions of the correct size, filled with zeros (for compatibility with time scheme...
Definition: autoslip_inlet_3d.cpp:9
Geometry< NodeType >::PointsArrayType NodesArrayType
Definition: autoslip_inlet.h:101
virtual Condition::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create a new MonolithicAutoSlipInlet3D object.
Definition: autoslip_inlet.h:197
virtual std::string Info() const override
Turn back information as a string.
Definition: autoslip_inlet.h:325
virtual void GetValueOnIntegrationPoints(const Variable< double > &rVariable, std::vector< double > &rValues, const ProcessInfo &rCurrentProcessInfo) override
virtual void GetDofList(DofsVectorType &ConditionDofList, const ProcessInfo &CurrentProcessInfo) const override
Returns a list of the element's Dofs.
Definition: autoslip_inlet_3d.cpp:82
virtual void GetSecondDerivativesVector(Vector &Values, int Step=0) override
Returns ACCELERATION_X, ACCELERATION_Y, (ACCELERATION_Z,) 0 for each node.
Definition: autoslip_inlet.h:267
virtual void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Return local right hand side of the correct size, filled with zeros (for compatibility with time sche...
Definition: autoslip_inlet_3d.cpp:49
virtual void GetValueOnIntegrationPoints(const Variable< array_1d< double, 3 > > &rVariable, std::vector< array_1d< double, 3 > > &rValues, const ProcessInfo &rCurrentProcessInfo) override
This class defines the node.
Definition: node.h:65
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: node.h:466
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
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
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
f
Definition: generate_convection_diffusion_explicit_element.py:112
rho
Definition: generate_droplet_dynamics.py:86
int tol
Definition: hinsberg_optimization.py:138
nu
Definition: isotropic_damage_automatic_differentiation.py:135
def load(f)
Definition: ode_solve.py:307
int d
Definition: ode_solve.py:397
int k
Definition: quadrature.py:595
B
Definition: sensitivityMatrix.py:76
e
Definition: run_cpp_mpi_tests.py:31