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.
dpg_vms.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Kazem Kamran
11 //
12 
13 #if !defined(KRATOS_TWO_FLUID_DPGVMS_H_INCLUDED )
14 #define KRATOS_TWO_FLUID_DPGVMS_H_INCLUDED
15 // System includes
16 #include <string>
17 #include <iostream>
18 // External includes
19 // Project includes
20 #include "containers/array_1d.h"
21 #include "includes/define.h"
22 #include "custom_elements/vms.h"
23 #include "includes/serializer.h"
24 #include "utilities/geometry_utilities.h"
27 // Application includes
29 #include "vms.h"
30 namespace Kratos
31 {
48 template< unsigned int TDim,
49  unsigned int TNumNodes = TDim + 1 >
50 class DPGVMS : public VMS<TDim, TNumNodes>
51 {
52 public:
62  typedef Node NodeType;
72  typedef Vector VectorType;
74  typedef std::size_t IndexType;
75  typedef std::size_t SizeType;
76  typedef std::vector<std::size_t> EquationIdVectorType;
77  typedef std::vector< Dof<double>::Pointer > DofsVectorType;
82  //Constructors.
84 
87  DPGVMS(IndexType NewId = 0) :
88  ElementBaseType(NewId)
89  {
90  }
92 
96  DPGVMS(IndexType NewId, const NodesArrayType& ThisNodes) :
97  ElementBaseType(NewId, ThisNodes)
98  {
99  }
101 
105  DPGVMS(IndexType NewId, GeometryType::Pointer pGeometry) :
106  ElementBaseType(NewId, pGeometry)
107  {
108  }
110 
115  DPGVMS(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) :
116  ElementBaseType(NewId, pGeometry, pProperties)
117  {
118  }
120  ~DPGVMS() override
121  {
122  }
130 
137  Element::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes,
138  PropertiesType::Pointer pProperties) const override
139  {
140  return Kratos::make_intrusive<DPGVMS>(NewId, (this->GetGeometry()).Create(ThisNodes), pProperties);
141  }
142 
144 
149  Element::Pointer Create(
150  IndexType NewId,
151  GeometryType::Pointer pGeom,
152  PropertiesType::Pointer pProperties) const override
153  {
154  return Kratos::make_intrusive< DPGVMS >(NewId,pGeom,pProperties);
155  }
156 
158 
160  void InitializeSolutionStep(const ProcessInfo &rCurrentProcessInfo) override
161  {
162 // for (unsigned int jj = 0; jj < 4; jj++){
163 // this->GetGeometry()[jj].FastGetSolutionStepValue(WET_VOLUME ) = 0.0;
164 // this->GetGeometry()[jj].FastGetSolutionStepValue(CUTTED_AREA ) = 0.0;
165 // }
166  }
167 
169 
171  void InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override
172  {
173  // Calculate this element's geometric parameters
174  double Area;
177  GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Area);
178  //get position of the cut surface
179  Vector distances(TNumNodes);
180  Matrix Nenriched(6, 1);
181  Vector volumes(6);
182  Matrix coords(TNumNodes, TDim);
183  Matrix Ngauss(6, TNumNodes);
184  Vector signs(6);
185  std::vector< Matrix > gauss_gradients(6);
186  //fill coordinates
187  for (unsigned int i = 0; i < TNumNodes; i++)
188  {
189  const array_1d<double, 3 > & xyz = this->GetGeometry()[i].Coordinates();
190  volumes[i] = 0.0;
191  distances[i] = this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE);
192  for (unsigned int j = 0; j < TDim; j++)
193  coords(i, j) = xyz[j];
194  }
195  this->GetValue(AUX_INDEX) = 0.0;
196  for (unsigned int i = 0; i < 6; i++)
197  gauss_gradients[i].resize(1, TDim, false);
198 
199  array_1d<double,6> edge_areas;
200  unsigned int ndivisions = EnrichmentUtilities::CalculateTetrahedraEnrichedShapeFuncions(coords, DN_DX, distances, volumes, Ngauss, signs, gauss_gradients, Nenriched,edge_areas);
201 
202  if(ndivisions == 1)
203  this->is_cutted = 0;
204  else{
205  this->is_cutted = 1;
206  this->GetValue(AUX_INDEX) = 1.0;
207  }
208  }
209 
210 
212 
221  void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix,
222  VectorType& rRightHandSideVector,
223  const ProcessInfo& rCurrentProcessInfo) override
224  {
225 // this->IsCutted();
226  unsigned int LocalSize = (TDim + 1) * TNumNodes;
227 
228  if( this->is_cutted == 1)
229  {
230  LocalSize += 1;
231  // Check sizes and initialize matrix
232  if (rLeftHandSideMatrix.size1() != LocalSize)
233  rLeftHandSideMatrix.resize(LocalSize, LocalSize, false);
234 
235  noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize, LocalSize);
236  this->CalculateRightHandSide(rRightHandSideVector, rCurrentProcessInfo);
237  }
238  else
239  {
240  // Check sizes and initialize matrix
241  if (rLeftHandSideMatrix.size1() != LocalSize)
242  rLeftHandSideMatrix.resize(LocalSize, LocalSize, false);
243 
244  noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize, LocalSize);
245  ElementBaseType::CalculateRightHandSide(rRightHandSideVector, rCurrentProcessInfo);
246 
247  }
248 
249  }
250 
251 
253 
262  void CalculateRightHandSide(VectorType& rRightHandSideVector,
263  const ProcessInfo& rCurrentProcessInfo) override
264  {
265  if( this->is_cutted == 1)
266  {
267  unsigned int LocalSize = (TDim + 1) * TNumNodes + 1;
268 
269 
270  // Check sizes and initialize
271  if (rRightHandSideVector.size() != LocalSize)
272  rRightHandSideVector.resize(LocalSize, false);
273  noalias(rRightHandSideVector) = ZeroVector(LocalSize);
274  // Calculate this element's geometric parameters
275  double Area;
278  GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Area);
279  //get position of the cut surface
280  Vector distances(TNumNodes);
281  Matrix Nenriched(6, 1);
282  Vector volumes(6);
283  Matrix coords(TNumNodes, TDim);
284  Matrix Ngauss(6, TNumNodes);
285  Vector signs(6);
286  std::vector< Matrix > gauss_gradients(6);
287  //fill coordinates
288  for (unsigned int i = 0; i < TNumNodes; i++)
289  {
290  const array_1d<double, 3 > & xyz = this->GetGeometry()[i].Coordinates();
291  volumes[i] = 0.0;
292  distances[i] = this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE);
293  for (unsigned int j = 0; j < TDim; j++)
294  coords(i, j) = xyz[j];
295  }
296  for (unsigned int i = 0; i < 6; i++)
297  gauss_gradients[i].resize(1, TDim, false);
298 
299  array_1d<double,6> edge_areas;
300  unsigned int ndivisions = EnrichmentUtilities::CalculateTetrahedraEnrichedShapeFuncions(coords, DN_DX, distances, volumes, Ngauss, signs, gauss_gradients, Nenriched,edge_areas);
301  //do integration
302  for (unsigned int igauss = 0; igauss < ndivisions; igauss++)
303  {
304  //assigning the gauss data
305  for (unsigned int k = 0; k < TNumNodes; k++)
306  N[k] = Ngauss(igauss, k);
307  double wGauss = volumes[igauss];
308  // Calculate this element's fluid properties
309  double Density;
310  this->EvaluateInPoint(Density, DENSITY, N);
311  // Calculate Momentum RHS contribution
312  this->AddMomentumRHS(rRightHandSideVector, Density, N, wGauss);
313  // For OSS: Add projection of residuals to RHS
314  // if (rCurrentProcessInfo[OSS_SWITCH] == 1)
315  // {
316  // array_1d<double, 3 > AdvVel;
317  // this->GetAdvectiveVel(AdvVel, N);
318  // double KinViscosity;
319  // this->EvaluateInPoint(KinViscosity, VISCOSITY, N);
320  // double Viscosity;
321  // this->GetEffectiveViscosity(Density, KinViscosity, N, DN_DX, Viscosity, rCurrentProcessInfo);
322  // // Calculate stabilization parameters
323  // double TauOne, TauTwo;
324  // // if (ndivisions == 1)
325  // this->CalculateTau(TauOne, TauTwo, AdvVel, Area, Density, Viscosity, rCurrentProcessInfo);
326  // // else
327  // // {
328  // // TauOne = 0.0;
329  // // TauTwo = 0.0;
330  // // }
331  // // this->CalculateTau(TauOne, TauTwo, AdvVel, Area, Viscosity, rCurrentProcessInfo);
332  // this->AddProjectionToRHS(rRightHandSideVector, AdvVel, Density, TauOne, TauTwo, N, DN_DX, wGauss, rCurrentProcessInfo[DELTA_TIME]);
333  // }
334  }
335  }
336  else
337  ElementBaseType::CalculateRightHandSide(rRightHandSideVector, rCurrentProcessInfo);
338 
339  }
341 
348  void CalculateMassMatrix(MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo) override
349  {
350 // this->IsCutted();
351  if( this->is_cutted == 0)
352  ElementBaseType::CalculateMassMatrix(rMassMatrix, rCurrentProcessInfo);
353  else
354  {
355  const unsigned int LocalSize = (TDim + 1) * TNumNodes + 1;
356  // Resize and set to zero
357  if (rMassMatrix.size1() != LocalSize)
358  rMassMatrix.resize(LocalSize, LocalSize, false);
359  rMassMatrix = ZeroMatrix(LocalSize, LocalSize);
360  // Get the element's geometric parameters
361  double Area;
364  GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Area);
365  //get position of the cut surface
366  Vector distances(TNumNodes);
367  Matrix Nenriched(6, 1);
368  Vector volumes(6);
369  Matrix coords(TNumNodes, TDim);
370  Matrix Ngauss(6, TNumNodes);
371  Vector signs(6);
372  std::vector< Matrix > gauss_gradients(6);
373  //fill coordinates
374  for (unsigned int i = 0; i < TNumNodes; i++)
375  {
376  const array_1d<double, 3 > & xyz = this->GetGeometry()[i].Coordinates();
377  volumes[i] = 0.0;
378  distances[i] = this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE);
379  for (unsigned int j = 0; j < TDim; j++)
380  coords(i, j) = xyz[j];
381  }
382  for (unsigned int i = 0; i < 6; i++)
383  gauss_gradients[i] = ZeroMatrix(1,TDim);//.resize(1, TDim, false);
384 
385  array_1d<double,6> edge_areas;
386  unsigned int ndivisions = EnrichmentUtilities::CalculateTetrahedraEnrichedShapeFuncions(coords, DN_DX, distances, volumes, Ngauss, signs, gauss_gradients, Nenriched,edge_areas);
387  //mass matrix
388  for (unsigned int igauss = 0; igauss < ndivisions; igauss++)
389  {
390  //assigning the gauss data
391  for (unsigned int k = 0; k < TNumNodes; k++)
392  N[k] = Ngauss(igauss, k);
393  double wGauss = volumes[igauss];
394  // Calculate this element's fluid properties
395  double Density;
396  this->EvaluateInPoint(Density, DENSITY, N);
397  // Consisten Mass Matrix
398  this->AddConsistentMassMatrixContribution(rMassMatrix, N, Density, wGauss);
399  }
400  this->LumpMassMatrix(rMassMatrix);
401 
402  //stabilization terms
403  for (unsigned int igauss = 0; igauss < ndivisions; igauss++)
404  {
405  //assigning the gauss data
406  for (unsigned int k = 0; k < TNumNodes; k++)
407  N[k] = Ngauss(igauss, k);
408  double wGauss = volumes[igauss];
409  // Calculate this element's fluid properties
410  double Density;
411  this->EvaluateInPoint(Density, DENSITY, N);
412  /* For ASGS: add dynamic stabilization terms.
413  * These terms are not used in OSS, as they belong to the finite element
414  * space and cancel out with their projections.
415  */
416  if (rCurrentProcessInfo[OSS_SWITCH] != 1)
417  {
418  double ElemSize = this->ElementSize(Area);
419  double Viscosity = this->EffectiveViscosity(Density,N,DN_DX,ElemSize, rCurrentProcessInfo);
420 
421  // Get Advective velocity
422  array_1d<double, 3 > AdvVel;
423  this->GetAdvectiveVel(AdvVel, N);
424 
425  // Calculate stabilization parameters
426  double TauOne, TauTwo;
427  this->CalculateTau(TauOne, TauTwo, AdvVel, ElemSize, Density, Viscosity, rCurrentProcessInfo);
428 
429  // Add dynamic stabilization terms ( all terms involving a delta(u) )
430  this->AddMassStabTerms(rMassMatrix, Density, AdvVel, TauOne, N, DN_DX, wGauss,gauss_gradients[igauss]);
431  }
432  }
433  }
434  }
436 
445  VectorType& rRightHandSideVector,
446  const ProcessInfo& rCurrentProcessInfo) override
447  {
448 // this->IsCutted();
449  if( this->is_cutted == 0){
450  ElementBaseType::CalculateLocalVelocityContribution(rDampingMatrix, rRightHandSideVector, rCurrentProcessInfo);
451 
452  //compute boundary term
453  int boundary_nodes = 0;
454  //unsigned int inside_index = -1;
455  for (unsigned int i = 0; i < TNumNodes; i++)
456  {
457  double nd_flag = this->GetGeometry()[i].FastGetSolutionStepValue(FLAG_VARIABLE);
458  if (nd_flag == 5.0)
459  boundary_nodes++;
460  //else
461  //inside_index = i;
462  }
463 
464 
465  /* if(boundary_nodes == TDim)
466  {
467  // Get this element's geometric properties
468  double Volume;
469  array_1d<double, TNumNodes> N;
470  BoundedMatrix<double, TNumNodes, TDim> DN_DX;
471  GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Volume);
472 
473 
474  BoundedMatrix<double, 16, 16 > boundary_damp_matrix;
475  noalias(boundary_damp_matrix) = ZeroMatrix(16,16);
476  array_1d<double,3> face_normal;
477  face_normal[0] = -DN_DX(inside_index,0);
478  face_normal[1] = -DN_DX(inside_index,1);
479  face_normal[2] = -DN_DX(inside_index,2);
480  const double fn = norm_2(face_normal);
481  face_normal/= fn;
482  double face_area = 3.0*Volume*fn;
483 
484 // int LocalIndex = 0;
485 // for (unsigned int iNode = 0; iNode < TNumNodes; ++iNode)
486 // {
487 // const double& pnode = this->GetGeometry()[iNode].FastGetSolutionStepValue(PRESSURE); // Pressure Dof
488 // for (unsigned int d = 0; d < TDim; ++d) // Velocity Dofs
489 // {
490 // if(iNode != inside_index)
491 // rRightHandSideVector[LocalIndex] -= pnode*face_normal[d]*face_area/3.0 ;
492 // ++LocalIndex;
493 // }
494 // ++LocalIndex;
495 // }
496 
497 // int LocalIndex = 0;
498 // double pface = 0.0;
499 // for (unsigned int iNode = 0; iNode < TNumNodes; ++iNode)
500 // {
501 // const double& pnode = this->GetGeometry()[iNode].FastGetSolutionStepValue(PRESSURE); // Pressure Dof
502 // if(iNode != inside_index) pface += pnode;
503 // }
504 // pface/=3.0;
505 //
506 // for (unsigned int iNode = 0; iNode < TNumNodes; ++iNode)
507 // {
508 // for (unsigned int d = 0; d < TDim; ++d) // Velocity Dofs
509 // {
510 // if(iNode != inside_index)
511 // rRightHandSideVector[LocalIndex] -= pface*face_normal[d]*face_area/3.0 ;
512 // ++LocalIndex;
513 // }
514 // ++LocalIndex;
515 // }
516  AddBoundaryTerm(boundary_damp_matrix, DN_DX, N, face_normal, face_area, Volume, rCurrentProcessInfo);
517 
518  VectorType U = ZeroVector(16);
519  int LocalIndex = 0;
520 
521  for (unsigned int iNode = 0; iNode < TNumNodes; ++iNode)
522  {
523  array_1d< double, 3 > & rVel = this->GetGeometry()[iNode].FastGetSolutionStepValue(VELOCITY);
524  for (unsigned int d = 0; d < TDim; ++d) // Velocity Dofs
525  {
526  U[LocalIndex] = rVel[d];
527  ++LocalIndex;
528  }
529  U[LocalIndex] = this->GetGeometry()[iNode].FastGetSolutionStepValue(PRESSURE); // Pressure Dof
530  ++LocalIndex;
531  }
532  noalias(rRightHandSideVector) -= prod(boundary_damp_matrix, U);
533  noalias(rDampingMatrix) += boundary_damp_matrix;
534  } */
535  }
536  else
537  {
538  const unsigned int LocalSize = (TDim + 1) * TNumNodes + 1;
539  // Resize and set to zero the matrix
540  // Note that we don't clean the RHS because it will already contain body force (and stabilization) contributions
541  if (rDampingMatrix.size1() != LocalSize)
542  rDampingMatrix.resize(LocalSize, LocalSize, false);
543  noalias(rDampingMatrix) = ZeroMatrix(LocalSize, LocalSize);
544  // Get this element's geometric properties
545  double Area;
547 
549  GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Area);
550  //get position of the cut surface
551  Vector distances(TNumNodes);
552  Matrix Nenriched(6, 1);
553  Vector volumes(6);
554  Matrix coords(TNumNodes, TDim);
555  Matrix Ngauss(6, TNumNodes);
556  Vector signs(6);
557  std::vector< Matrix > gauss_gradients(6);
558  //fill coordinates
559  for (unsigned int i = 0; i < TNumNodes; i++)
560  {
561  const array_1d<double, 3 > & xyz = this->GetGeometry()[i].Coordinates();
562  volumes[i] = 0.0;
563  distances[i] = this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE);
564  for (unsigned int j = 0; j < TDim; j++)
565  coords(i, j) = xyz[j];
566  }
567  for (unsigned int i = 0; i < 6; i++)
568  gauss_gradients[i] = ZeroMatrix(1,TDim);
569 
570  array_1d<double,6> edge_areas;
571  unsigned int ndivisions = EnrichmentUtilities::CalculateTetrahedraEnrichedShapeFuncions(coords, DN_DX, distances, volumes, Ngauss, signs, gauss_gradients, Nenriched,edge_areas);
572 // Vector enrichment_terms_vertical = ZeroVector(LocalSize);
573 // Vector enrichment_terms_horizontal = ZeroVector(LocalSize);
574 // double enrichment_diagonal = 0.0;
575 // double enriched_rhs = 0.0;
577 
578  //double positive_volume = 0.0;
579  //double negative_volume = 0.0;
580  //do integration
581  for (unsigned int igauss = 0; igauss < ndivisions; igauss++)
582  {
583  //assigning the gauss data
584  for (unsigned int k = 0; k < TNumNodes; k++)
585  N[k] = Ngauss(igauss, k);
586  const double wGauss = volumes[igauss];
587  // if(signs[igauss] > 0)
588  // positive_volume += wGauss;
589  // else
590  // negative_volume += wGauss;
591  // Calculate this element's fluid properties
592  double Density;
593  this->EvaluateInPoint(Density, DENSITY, N);
594 
595  double ElemSize = this->ElementSize(Area);
596  double Viscosity = this->EffectiveViscosity(Density,N,DN_DX,ElemSize, rCurrentProcessInfo);
597 
598  // Get Advective velocity
599  array_1d<double, 3 > AdvVel;
600  this->GetAdvectiveVel(AdvVel, N);
601 
602  // Calculate stabilization parameters
603  double TauOne, TauTwo;
604  this->CalculateTau(TauOne, TauTwo, AdvVel, ElemSize, Density, Viscosity, rCurrentProcessInfo);
605 
606  this->AddIntegrationPointVelocityContribution(rDampingMatrix, rRightHandSideVector, Density, Viscosity, AdvVel, TauOne, TauTwo, N, DN_DX, wGauss,Nenriched(igauss, 0),gauss_gradients[igauss]);
607 // if (ndivisions > 1)
608 // {
609 // //compute enrichment terms contribution
610 // for (unsigned int inode = 0; inode < TNumNodes; inode++)
611 // {
612 // int base_index = (TDim + 1) * inode;
613 // array_1d<double,TNumNodes> AGradN = ZeroVector(TNumNodes);
614 // this->GetConvectionOperator(AGradN,AdvVel,DN_DX);
615 // //momentum term
616 // for (unsigned int k = 0; k < TDim; k++)
617 // {
618 // double ConvTerm = wGauss * TauOne * gauss_gradients[igauss](0,k)* Density * AGradN[inode];
619 // enrichment_terms_vertical[base_index + k] += ConvTerm - wGauss * DN_DX(inode, k) * Nenriched(igauss, 0);
620 // enrichment_terms_horizontal[base_index + k] += ConvTerm + wGauss * DN_DX(inode, k) * Nenriched(igauss, 0);
621 // // enrichment_terms_vertical[base_index + k] +=wGauss*N[inode]*gauss_gradients[igauss](0, k); //-= wGauss * DN_DX(inode, k) * Nenriched(igauss, 0);
622 // // enrichment_terms_horizontal[base_index + k] -=Density*wGauss*N[inode]*gauss_gradients[igauss](0, k); // += Density*wGauss * DN_DX(inode, k) * Nenriched(igauss, 0);
623 // }
624 // //pressure term
625 // for (unsigned int k = 0; k < TDim; k++)
626 // {
627 // double temp = wGauss * TauOne* DN_DX(inode, k) * gauss_gradients[igauss](0, k);
628 // enrichment_terms_vertical[base_index + TDim] += temp;
629 // enrichment_terms_horizontal[base_index + TDim] += temp;
630 // }
631 // //add acceleration enrichment term
632 // //const array_1d<double,3>& vnode = this->GetGeometry()[inode].FastGetSolutionStepValue(VELOCITY);
633 // const array_1d<double,3>& old_vnode = this->GetGeometry()[inode].FastGetSolutionStepValue(VELOCITY,1);
634 // for (unsigned int k = 0; k < TDim; k++)
635 // {
636 // double coeff = wGauss * TauOne *Density * gauss_gradients[igauss](0,k)*N[inode] * 2.0/ Dt;
637 // enrichment_terms_horizontal[base_index + k] += coeff;
638 // enriched_rhs += coeff * (old_vnode[k]);
639 // // enrichment_terms_vertical[base_index + k] +=wGauss*N[inode]*gauss_gradients[igauss](0, k); //-= wGauss * DN_DX(inode, k) * Nenriched(igauss, 0);
640 // // enrichment_terms_horizontal[base_index + k] -=Density*wGauss*N[inode]*gauss_gradients[igauss](0, k); // += Density*wGauss * DN_DX(inode, k) * Nenriched(igauss, 0);
641 // }
642 // }
643 // //compute diagonal enrichment term
644 // array_1d<double,3> OldAcceleration = N[0]*this->GetGeometry()[0].FastGetSolutionStepValue(ACCELERATION,1);
645 // for(unsigned int jjj=0; jjj<(this->GetGeometry()).size(); jjj++)
646 // OldAcceleration += N[jjj]*(this->GetGeometry())[jjj].FastGetSolutionStepValue(ACCELERATION,1);
647 //
648 // for (unsigned int k = 0; k < TDim; k++)
649 // {
650 // const Matrix& enriched_grad = gauss_gradients[igauss];
651 // enrichment_diagonal += wGauss * TauOne * pow(enriched_grad(0, k), 2);
652 // enriched_rhs += wGauss * TauOne *Density * enriched_grad(0,k)*(bf[k]+OldAcceleration[k]);
653 // }
654 // }
655  }
656 
657 // if (ndivisions > 1)
658 // {
659 // //add to LHS enrichment contributions
660 // double inverse_diag_term = 1.0 / ( enrichment_diagonal);
661 //
662 //
663 //
664 // for (unsigned int i = 0; i < LocalSize; i++)
665 // for (unsigned int j = 0; j < LocalSize; j++)
666 // rDampingMatrix(i, j) -= inverse_diag_term * enrichment_terms_vertical[i] * enrichment_terms_horizontal[j];
667 // rRightHandSideVector -= (inverse_diag_term*enriched_rhs )*enrichment_terms_vertical;
668 //
669 // }
670 
671  // Now calculate an additional contribution to the residual: r -= rDampingMatrix * (u,p)
672  VectorType U = ZeroVector(LocalSize);
673  int LocalIndex = 0;
674  for (unsigned int iNode = 0; iNode < TNumNodes; ++iNode)
675  {
676  array_1d< double, 3 > & rVel = this->GetGeometry()[iNode].FastGetSolutionStepValue(VELOCITY);
677  for (unsigned int d = 0; d < TDim; ++d) // Velocity Dofs
678  {
679  U[LocalIndex] = rVel[d];
680  ++LocalIndex;
681  }
682  U[LocalIndex] = this->GetGeometry()[iNode].FastGetSolutionStepValue(PRESSURE); // Pressure Dof
683  ++LocalIndex;
684  }
685  const double enriched_pr = this->GetValue(PRESSUREAUX);
686  U[LocalIndex] = enriched_pr;
687  noalias(rRightHandSideVector) -= prod(rDampingMatrix, U);
688 // KRATOS_WATCH(enriched_pr);
689  }
690  }
691 
693  void FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override
694  {
695 // this->IsCutted();
696  if( this->is_cutted == 0)
697  ElementBaseType::FinalizeNonLinearIteration(rCurrentProcessInfo);
698  else
699  {
700  //fill vector of solution
701  const unsigned int LocalSize = (TDim + 1) * TNumNodes;
702  VectorType DU = ZeroVector(LocalSize);
703  int LocalIndex = 0;
704  for (unsigned int iNode = 0; iNode < TNumNodes; ++iNode)
705  {
706  const array_1d< double, 3 > rVel = this->GetGeometry()[iNode].FastGetSolutionStepValue(VELOCITY);
707  const array_1d< double, 3 > old_rVel = this->GetGeometry()[iNode].FastGetSolutionStepValue(VELOCITY,1);
708  for (unsigned int d = 0; d < TDim; ++d) // Velocity Dofs
709  {
710  DU[LocalIndex] = rVel[d]-old_rVel[d];
711  ++LocalIndex;
712  }
713  DU[LocalIndex] = this->GetGeometry()[iNode].FastGetSolutionStepValue(PRESSURE) - this->GetGeometry()[iNode].FastGetSolutionStepValue(PRESSURE,1); // Pressure Dof
714  ++LocalIndex;
715  }
716 
717  /*call Residual vector for condensation, it is filled in the
718  schme and consists of last row of LHS plus last member of RHS*/
719  VectorType residual_enr_vector = ZeroVector(LocalSize + 2);
720  residual_enr_vector = this->GetValue(GAPS);
721 
722  //compute dp_enr = D^-1 * ( f - C U)
723  double C_Dup(0.0);
724  for (unsigned int ii = 0; ii < LocalSize; ++ii)
725  C_Dup += residual_enr_vector[ii]*DU[ii];
726 
727  //take the value of enriched pressure from the last step and add teh increment
728  double enr_p = this->GetValue(AUX_INDEX);
729  if( residual_enr_vector[LocalSize] == 0.0 )
730  KRATOS_THROW_ERROR(std::invalid_argument,"Diagonla member of enriched RES is zero !!!!!","")
731  else
732  enr_p += (residual_enr_vector[LocalSize + 1] - C_Dup)/residual_enr_vector[LocalSize] ;
733 
734  //current iteration value of the enriched pressure
735 // enr_p = 0.0;
736  this->SetValue(PRESSUREAUX,enr_p);
737  }
738  }
739 
741 
746  void GetFirstDerivativesVector(Vector& values, int Step) const override
747  {
748 // this->IsCutted();
749  if( this->is_cutted == 0)
751  else
752  {
753  unsigned int MatSize = (TDim + 1) * TNumNodes + 1;
754  if (values.size() != MatSize) values.resize(MatSize, false);
755  for (unsigned int i = 0; i < TNumNodes; i++)
756  {
757  unsigned int index = i * (TDim + 1);
758  values[index] = this->GetGeometry()[i].GetSolutionStepValue(VELOCITY_X, Step);
759  values[index + 1] = this->GetGeometry()[i].GetSolutionStepValue(VELOCITY_Y, Step);
760  values[index + 2] = this->GetGeometry()[i].GetSolutionStepValue(VELOCITY_Z, Step);
761  values[index + 3] = this->GetGeometry()[i].GetSolutionStepValue(PRESSURE, Step);
762 
763  }
764  //add teh enriched component
765  int last_index = (TDim + 1) * TNumNodes;
766  values[last_index] = this->GetValue(PRESSUREAUX);
767  }
768  }
770 
775  void GetSecondDerivativesVector(Vector& values, int Step) const override
776  {
777 // this->IsCutted();
778  if( this->is_cutted == 0)
780  else
781  {
782  unsigned int MatSize = (TDim + 1) * TNumNodes + 1;
783  if (values.size() != MatSize) values.resize(MatSize, false);
784  for (unsigned int i = 0; i < TNumNodes; i++)
785  {
786  unsigned int index = i * (TDim + 1);
787  values[index] = this->GetGeometry()[i].GetSolutionStepValue(ACCELERATION_X, Step);
788  values[index + 1] = this->GetGeometry()[i].GetSolutionStepValue(ACCELERATION_Y, Step);
789  values[index + 2] = this->GetGeometry()[i].GetSolutionStepValue(ACCELERATION_Z, Step);
790  values[index + 3] = 0.0;
791  }
792  //add teh enriched component
793  int last_index = (TDim + 1) * TNumNodes;
794  values[last_index] = 0.0;
795  }
796  }
797 
798 
800 
811  void Calculate(const Variable<array_1d<double, 3 > >& rVariable,
812  array_1d<double, 3 > & rOutput,
813  const ProcessInfo& rCurrentProcessInfo) override
814  {
815  if (rVariable == ADVPROJ) // Compute residual projections for OSS
816  {
817  // Get the element's geometric parameters
818  double Area;
821  GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Area);
822  array_1d< double, 3 > ElementalMomRes = ZeroVector(3);
823  double ElementalMassRes(0);
824  //get position of the cut surface
825  Vector distances(TNumNodes);
826  Matrix Nenriched(6, 1);
827  Vector volumes(6);
828  Matrix coords(TNumNodes, TDim);
829  Matrix Ngauss(6, TNumNodes);
830  Vector signs(6);
831  std::vector< Matrix > gauss_gradients(6);
832  //fill coordinates
833  for (unsigned int i = 0; i < TNumNodes; i++)
834  {
835  const array_1d<double, 3 > & xyz = this->GetGeometry()[i].Coordinates();
836  volumes[i] = 0.0;
837  distances[i] = this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE);
838  for (unsigned int j = 0; j < TDim; j++)
839  coords(i, j) = xyz[j];
840  }
841  for (unsigned int i = 0; i < 6; i++)
842  gauss_gradients[i].resize(1, TDim, false);
843 
844  array_1d<double,6> edge_areas;
845  unsigned int ndivisions = EnrichmentUtilities::CalculateTetrahedraEnrichedShapeFuncions(coords, DN_DX, distances, volumes, Ngauss, signs, gauss_gradients, Nenriched,edge_areas);
846  //do integration
847  for (unsigned int igauss = 0; igauss < ndivisions; igauss++)
848  {
849  //assigning the gauss data
850  for (unsigned int k = 0; k < TNumNodes; k++)
851  N[k] = Ngauss(igauss, k);
852  double wGauss = volumes[igauss];
853  // Calculate this element's fluid properties
854  double Density;;
855  this->EvaluateInPoint(Density, DENSITY, N);
856 
857  // Get Advective velocity
858  array_1d<double, 3 > AdvVel;
859  this->GetAdvectiveVel(AdvVel, N);
860  // Output containers
861  ElementalMomRes = ZeroVector(3);
862  ElementalMassRes = 0.0;
863  this->AddProjectionResidualContribution(AdvVel, Density, ElementalMomRes, ElementalMassRes, N, DN_DX, wGauss);
864  if (rCurrentProcessInfo[OSS_SWITCH] == 1)
865  {
866  // Carefully write results to nodal variables, to avoid parallelism problems
867  for (unsigned int i = 0; i < TNumNodes; ++i)
868  {
869  this->GetGeometry()[i].SetLock(); // So it is safe to write in the node in OpenMP
870  array_1d< double, 3 > & rAdvProj = this->GetGeometry()[i].FastGetSolutionStepValue(ADVPROJ);
871  for (unsigned int d = 0; d < TDim; ++d)
872  rAdvProj[d] += N[i] * ElementalMomRes[d];
873  this->GetGeometry()[i].FastGetSolutionStepValue(DIVPROJ) += N[i] * ElementalMassRes;
874  this->GetGeometry()[i].FastGetSolutionStepValue(NODAL_AREA) += wGauss * N[i];
875  this->GetGeometry()[i].UnSetLock(); // Free the node for other threads
876  }
877  }
878  }
880  rOutput = ElementalMomRes;
881  }
882  else if (rVariable == SUBSCALE_VELOCITY)
883  {
884  // Get the element's geometric parameters
885  double Area;
888  GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Area);
889  array_1d< double, 3 > ElementalMomRes = ZeroVector(3);
890  double ElementalMassRes(0);
891  //get position of the cut surface
892  Vector distances(TNumNodes);
893  Matrix Nenriched(6, 1);
894  Vector volumes(6);
895  Matrix coords(TNumNodes, TDim);
896  Matrix Ngauss(6, TNumNodes);
897  Vector signs(6);
898  std::vector< Matrix > gauss_gradients(6);
899  //fill coordinates
900  for (unsigned int i = 0; i < TNumNodes; i++)
901  {
902  const array_1d<double, 3 > & xyz = this->GetGeometry()[i].Coordinates();
903  volumes[i] = 0.0;
904  distances[i] = this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE);
905  for (unsigned int j = 0; j < TDim; j++)
906  coords(i, j) = xyz[j];
907  }
908  for (unsigned int i = 0; i < 6; i++)
909  gauss_gradients[i].resize(1, TDim, false);
910 
911  array_1d<double,6> edge_areas;
912  unsigned int ndivisions = EnrichmentUtilities::CalculateTetrahedraEnrichedShapeFuncions(coords, DN_DX, distances, volumes, Ngauss, signs, gauss_gradients, Nenriched,edge_areas);
913  //do integration
914  for (unsigned int igauss = 0; igauss < ndivisions; igauss++)
915  {
916  //assigning the gauss data
917  for (unsigned int k = 0; k < TNumNodes; k++)
918  N[k] = Ngauss(igauss, k);
919  double wGauss = volumes[igauss];
920  // Calculate this element's fluid properties
921  double Density;
922  this->EvaluateInPoint(Density, DENSITY, N);
923 
924  // Get Advective velocity
925  array_1d<double, 3 > AdvVel;
926  this->GetAdvectiveVel(AdvVel, N);
927 
928  // Output containers
929  ElementalMomRes = ZeroVector(3);
930  ElementalMassRes = 0.0;
931  this->AddProjectionResidualContribution(AdvVel, Density, ElementalMomRes, ElementalMassRes, N, DN_DX, wGauss);
932  if (rCurrentProcessInfo[OSS_SWITCH] == 1)
933  {
934  /* Projections of the elemental residual are computed with
935  * Newton-Raphson iterations of type M(lumped) dx = ElemRes - M(consistent) * x
936  */
937  const double Weight = ElementBaseType::ConsistentMassCoef(wGauss); // Consistent mass matrix is Weigth * ( Ones(TNumNodes,TNumNodes) + Identity(TNumNodes,TNumNodes) )
938  // Carefully write results to nodal variables, to avoid parallelism problems
939  for (unsigned int i = 0; i < TNumNodes; ++i)
940  {
941  this->GetGeometry()[i].SetLock(); // So it is safe to write in the node in OpenMP
942  // Add elemental residual to RHS
943  array_1d< double, 3 > & rMomRHS = this->GetGeometry()[i].GetValue(ADVPROJ);
944  double& rMassRHS = this->GetGeometry()[i].GetValue(DIVPROJ);
945  for (unsigned int d = 0; d < TDim; ++d)
946  rMomRHS[d] += N[i] * ElementalMomRes[d];
947  rMassRHS += N[i] * ElementalMassRes;
948  // Write nodal area
949  this->GetGeometry()[i].FastGetSolutionStepValue(NODAL_AREA) += wGauss * N[i];
950  // Substract M(consistent)*x(i-1) from RHS
951  for (unsigned int j = 0; j < TNumNodes; ++j) // RHS -= Weigth * Ones(TNumNodes,TNumNodes) * x(i-1)
952  {
953  for (unsigned int d = 0; d < TDim; ++d)
954  rMomRHS[d] -= Weight * this->GetGeometry()[j].FastGetSolutionStepValue(ADVPROJ)[d];
955  rMassRHS -= Weight * this->GetGeometry()[j].FastGetSolutionStepValue(DIVPROJ);
956  }
957  for (unsigned int d = 0; d < TDim; ++d) // RHS -= Weigth * Identity(TNumNodes,TNumNodes) * x(i-1)
958  rMomRHS[d] -= Weight * this->GetGeometry()[i].FastGetSolutionStepValue(ADVPROJ)[d];
959  rMassRHS -= Weight * this->GetGeometry()[i].FastGetSolutionStepValue(DIVPROJ);
960  this->GetGeometry()[i].UnSetLock(); // Free the node for other threads
961  }
962  }
963  }
965  rOutput = ElementalMomRes;
966  }
967  }
968 
974  const Variable<double>& rVariable,
975  std::vector<double>& rValues,
976  const ProcessInfo& rCurrentProcessInfo) override
977  {
978 
979  if (rVariable == PRESSUREAUX)
980  {
981  for (unsigned int PointNumber = 0;
982  PointNumber < 1; PointNumber++)
983  {
984  // KRATOS_WATCH(this->GetValue(IS_WATER));
985  // KRATOS_WATCH(this->Info());
986  rValues[PointNumber] = this->GetValue(PRESSUREAUX);;
987  }
988  }
989  else if(rVariable == AUX_INDEX)
990  {
991  double Area;
994  GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Area);
995 
996  array_1d<double, 3 > AdvVel;
997  this->GetAdvectiveVel(AdvVel, N);
998 
999  double Density;
1000  this->EvaluateInPoint(Density, DENSITY, N);
1001  double ElemSize = this->ElementSize(Area);
1002 
1003  rValues.resize(1, false);
1004 
1005  rValues[0] = this->EffectiveViscosity(Density,N,DN_DX,ElemSize,rCurrentProcessInfo);
1006  }
1007 
1008  }
1010 
1018  int Check(const ProcessInfo& rCurrentProcessInfo) const override
1019  {
1020  KRATOS_TRY
1021  // Perform basic element checks
1022  int ErrorCode = Kratos::Element::Check(rCurrentProcessInfo);
1023  if (ErrorCode != 0) return ErrorCode;
1024 
1025  // Checks on nodes
1026  // Check that the element's nodes contain all required SolutionStepData and Degrees of freedom
1027  for (unsigned int i = 0; i<this->GetGeometry().size(); ++i)
1028  {
1029  if (this->GetGeometry()[i].SolutionStepsDataHas(DISTANCE) == false)
1030  KRATOS_THROW_ERROR(std::invalid_argument, "missing DISTANCE variable on solution step data for node ", this->GetGeometry()[i].Id());
1031  if (this->GetGeometry()[i].SolutionStepsDataHas(VELOCITY) == false)
1032  KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY variable on solution step data for node ", this->GetGeometry()[i].Id());
1033  if (this->GetGeometry()[i].SolutionStepsDataHas(PRESSURE) == false)
1034  KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE variable on solution step data for node ", this->GetGeometry()[i].Id());
1035  if (this->GetGeometry()[i].SolutionStepsDataHas(MESH_VELOCITY) == false)
1036  KRATOS_THROW_ERROR(std::invalid_argument, "missing MESH_VELOCITY variable on solution step data for node ", this->GetGeometry()[i].Id());
1037  if (this->GetGeometry()[i].SolutionStepsDataHas(ACCELERATION) == false)
1038  KRATOS_THROW_ERROR(std::invalid_argument, "missing ACCELERATION variable on solution step data for node ", this->GetGeometry()[i].Id());
1039  if (this->GetGeometry()[i].HasDofFor(VELOCITY_X) == false ||
1040  this->GetGeometry()[i].HasDofFor(VELOCITY_Y) == false ||
1041  this->GetGeometry()[i].HasDofFor(VELOCITY_Z) == false)
1042  KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY component degree of freedom on node ", this->GetGeometry()[i].Id());
1043  if (this->GetGeometry()[i].HasDofFor(PRESSURE) == false)
1044  KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE component degree of freedom on node ", this->GetGeometry()[i].Id());
1045  }
1046  // Not checking OSS related variables NODAL_AREA, ADVPROJ, DIVPROJ, which are only required as SolutionStepData if OSS_SWITCH == 1
1047  // If this is a 2D problem, check that nodes are in XY plane
1048  if (this->GetGeometry().WorkingSpaceDimension() == 2)
1049  {
1050  for (unsigned int i = 0; i<this->GetGeometry().size(); ++i)
1051  {
1052  if (this->GetGeometry()[i].Z() != 0.0)
1053  KRATOS_THROW_ERROR(std::invalid_argument, "Node with non-zero Z coordinate found. Id: ", this->GetGeometry()[i].Id());
1054  }
1055  }
1056  return 0;
1057  KRATOS_CATCH("");
1058  }
1072  std::string Info() const override
1073  {
1074  std::stringstream buffer;
1075  buffer << "DPGVMS #" << this->Id();
1076  return buffer.str();
1077  }
1079  void PrintInfo(std::ostream& rOStream) const override
1080  {
1081  rOStream << "DPGVMS" << TDim << "D";
1082  }
1083  // /// Print object's data.
1084  // virtual void PrintData(std::ostream& rOStream) const;
1089 protected:
1102  void LumpMassMatrix(MatrixType& rMassMatrix)
1103  {
1104  for (unsigned int i = 0; i < rMassMatrix.size1(); ++i)
1105  {
1106  double diag_factor = 0.0;
1107  for (unsigned int j = 0; j < rMassMatrix.size2(); ++j)
1108  {
1109  diag_factor += rMassMatrix(i, j);
1110  rMassMatrix(i, j) = 0.0;
1111  }
1112  rMassMatrix(i, i) = diag_factor;
1113  }
1114  }
1116 
1127  virtual void AddPointContribution(double& rResult,
1128  const Variable< double >& rVariable,
1129  const array_1d< double, TNumNodes >& rShapeFunc,
1130  const double Weight = 1.0)
1131  {
1132  double temp = 0.0;
1133  this->EvaluateInPoint(temp, rVariable, rShapeFunc);
1134  rResult += Weight*temp;
1135  }
1137 
1146  void EvaluateInPoint(double& rResult,
1147  const Variable< double >& rVariable,
1148  const array_1d< double, TNumNodes >& rShapeFunc) override
1149  {
1150  //compute sign of distance on gauss point
1151  double dist = 0.0;
1152  for (unsigned int i = 0; i < TNumNodes; i++)
1153  dist += rShapeFunc[i] * this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE);
1154 
1155  double navg = 0.0;
1156  double value = 0.0;
1157  for (unsigned int i = 0; i < TNumNodes; i++)
1158  {
1159  if ( (dist * this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE)) > 0.0)
1160  {
1161  navg += 1.0;
1162  value += this->GetGeometry()[i].FastGetSolutionStepValue(rVariable);
1163  }
1164  }
1165  if(navg != 0)
1166  value /= navg;
1167  else
1168  KRATOS_THROW_ERROR(std::invalid_argument,"IT IS A CUTTED ELEMENT navg MUST BE NON ZERO !!!!","");
1169  rResult = value;
1170 // if(rVariable==DENSITY)
1171 // KRATOS_WATCH(rResult)
1172  }
1174 
1185  const Variable< array_1d< double, 3 > >& rVariable,
1186  const array_1d< double, TNumNodes>& rShapeFunc,
1187  const double Weight = 1.0)
1188  {
1190  this->EvaluateInPoint(temp, rVariable, rShapeFunc);
1191  rResult += Weight*temp;
1192  }
1194 
1203  const Variable< array_1d< double, 3 > >& rVariable,
1204  const array_1d< double, TNumNodes >& rShapeFunc) override
1205  {
1206  //compute sign of distance on gauss point
1207  double dist = 0.0;
1208  for (unsigned int i = 0; i < TNumNodes; i++)
1209  dist += rShapeFunc[i] * this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE);
1210  double navg = 0.0;
1211  array_1d< double, 3 > value = ZeroVector(3);
1212  for (unsigned int i = 0; i < TNumNodes; i++)
1213  {
1214  if (dist * this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE) > 0.0)
1215  {
1216  navg += 1.0;
1217  value += this->GetGeometry()[i].FastGetSolutionStepValue(rVariable);
1218  }
1219  }
1220  if(navg != 0)
1221  value /= navg;
1222  else
1223  ElementBaseType::EvaluateInPoint(value,rVariable,rShapeFunc);
1224  rResult = value;
1225  }
1226 
1227 // virtual void IsCutted(){
1228 // int negative = 0;
1229 // this->is_cutted = 0;
1230 // for( int ii = 0; ii<TNumNodes; ++ii)
1231 // if( this->GetGeometry()[ii].FastGetSolutionStepValue(DISTANCE) < 0.0)
1232 // negative++;
1233 //
1234 // if( negative != TNumNodes && negative != 0)
1235 // this->is_cutted = 1;
1236 //
1237 // }
1239 
1251  void AddMassStabTerms(MatrixType& rLHSMatrix,
1252  const double Density,
1253  const array_1d<double, 3 > & rAdvVel,
1254  const double TauOne,
1255  const array_1d<double, TNumNodes>& rShapeFunc,
1256  const BoundedMatrix<double, TNumNodes, TDim>& rShapeDeriv,
1257  const double Weight,
1258  const Matrix& gauss_enriched_gradients)
1259  {
1260  const unsigned int BlockSize = TDim + 1;
1261 
1262  double Coef = Weight * TauOne;
1263  unsigned int FirstRow(0), FirstCol(0);
1264  double K; // Temporary results
1265 
1266  // If we want to use more than one Gauss point to integrate the convective term, this has to be evaluated once per integration point
1268  this->GetConvectionOperator(AGradN, rAdvVel, rShapeDeriv); // Get a * grad(Ni)
1269 
1270  // Note: Dof order is (vx,vy,[vz,]p) for each node
1271  for (unsigned int i = 0; i < TNumNodes; ++i)
1272  {
1273  // Loop over columns
1274  for (unsigned int j = 0; j < TNumNodes; ++j)
1275  {
1276  // Delta(u) * TauOne * [ AdvVel * Grad(v) ] in velocity block
1277  K = Coef * Density * AGradN[i] * rShapeFunc[j];
1278 
1279  for (unsigned int d = 0; d < TDim; ++d) // iterate over dimensions for velocity Dofs in this node combination
1280  {
1281  rLHSMatrix(FirstRow + d, FirstCol + d) += K;
1282  // Delta(u) * TauOne * Grad(q) in q * Div(u) block
1283  rLHSMatrix(FirstRow + TDim, FirstCol + d) += Coef * Density * rShapeDeriv(i, d) * rShapeFunc[j];
1284  }
1285  // Update column index
1286  FirstCol += BlockSize;
1287  }
1288  // Update matrix indices
1289  FirstRow += BlockSize;
1290  FirstCol = 0;
1291  }
1292 
1293  //add Delta(u) * TauOne * Grad(q_ENR)
1294  // Loop over columns
1295  for (unsigned int j = 0; j < TNumNodes; ++j)
1296  {
1297  for (unsigned int d = 0; d < TDim; ++d)
1298  {
1299  rLHSMatrix(FirstRow , FirstCol + d) += Coef * Density * gauss_enriched_gradients(0,d) * rShapeFunc[j];
1300  }
1301  FirstCol += BlockSize;
1302  }
1303  }
1306  VectorType& rDampRHS,
1307  const double Density,
1308  const double Viscosity,
1309  const array_1d< double, 3 > & rAdvVel,
1310  const double TauOne,
1311  const double TauTwo,
1312  const array_1d< double, TNumNodes >& rShapeFunc,
1313  const BoundedMatrix<double, TNumNodes, TDim >& rShapeDeriv,
1314  const double Weight,
1315  const double gauss_N_en,
1316  Matrix& gauss_enriched_gradients)
1317  {
1318  const unsigned int BlockSize = TDim + 1;
1319 
1320  // If we want to use more than one Gauss point to integrate the convective term, this has to be evaluated once per integration point
1322  this->GetConvectionOperator(AGradN, rAdvVel, rShapeDeriv); // Get a * grad(Ni)
1323 
1324  // Build the local matrix and RHS
1325  unsigned int FirstRow(0), FirstCol(0); // position of the first term of the local matrix that corresponds to each node combination
1326  double K, G, PDivV, L, qF; // Temporary results
1327 
1328  // Note that we iterate first over columns, then over rows to read the Body Force only once per node
1329  for (unsigned int j = 0; j < TNumNodes; ++j) // iterate over colums
1330  {
1331  // Get Body Force
1332  const array_1d<double, 3 > & rBodyForce = this->GetGeometry()[j].FastGetSolutionStepValue(BODY_FORCE);
1333 
1334  for (unsigned int i = 0; i < TNumNodes; ++i) // iterate over rows
1335  {
1336  // Calculate the part of the contributions that is constant for each node combination
1337 
1338  // Velocity block
1339  K = Density * rShapeFunc[i] * AGradN[j]; // Convective term: v * ( a * Grad(u) )
1340  K += TauOne * Density * AGradN[i] * Density * AGradN[j]; // Stabilization: (a * Grad(v)) * TauOne * (a * Grad(u))
1341  K *= Weight;
1342 
1343  // q-p stabilization block (reset result)
1344  L = 0;
1345 
1346  for (unsigned int m = 0; m < TDim; ++m) // iterate over v components (vx,vy[,vz])
1347  {
1348  // Velocity block
1349 // K += Weight * Viscosity * rShapeDeriv(i, m) * rShapeDeriv(j, m); // Diffusive term: Viscosity * Grad(v) * Grad(u)
1350 
1351  // v * Grad(p) block
1352  G = TauOne * Density * AGradN[i] * rShapeDeriv(j, m); // Stabilization: (a * Grad(v)) * TauOne * Grad(p)
1353  PDivV = rShapeDeriv(i, m) * rShapeFunc[j]; // Div(v) * p
1354 
1355  // Write v * Grad(p) component
1356  rDampingMatrix(FirstRow + m, FirstCol + TDim) += Weight * (G - PDivV);
1357  // Use symmetry to write the q * Div(u) component
1358  rDampingMatrix(FirstCol + TDim, FirstRow + m) += Weight * (G + PDivV);
1359 // rDampingMatrix(FirstCol + TDim, FirstRow + m) += Weight * (G - rShapeDeriv(j, m) * rShapeFunc[i]);
1360 
1361  // q-p stabilization block
1362  L += rShapeDeriv(i, m) * rShapeDeriv(j, m); // Stabilization: Grad(q) * TauOne * Grad(p)
1363 
1364  for (unsigned int n = 0; n < TDim; ++n) // iterate over u components (ux,uy[,uz])
1365  {
1366  // Velocity block
1367  rDampingMatrix(FirstRow + m, FirstCol + n) += Weight * TauTwo * rShapeDeriv(i, m) * rShapeDeriv(j, n); // Stabilization: Div(v) * TauTwo * Div(u)
1368  }
1369 
1370  }
1371 
1372  // Write remaining terms to velocity block
1373  for (unsigned int d = 0; d < TDim; ++d)
1374  rDampingMatrix(FirstRow + d, FirstCol + d) += K;
1375 
1376  // Write q-p stabilization block
1377  rDampingMatrix(FirstRow + TDim, FirstCol + TDim) += Weight * TauOne * L;
1378 
1379  // Operate on RHS
1380  qF = 0.0;
1381  for (unsigned int d = 0; d < TDim; ++d)
1382  {
1383  rDampRHS[FirstRow + d] += Weight * TauOne * Density * AGradN[i] * rShapeFunc[j] * Density * rBodyForce[d]; // ( a * Grad(v) ) * TauOne * (Density * BodyForce)
1384  qF += rShapeDeriv(i, d) * rShapeFunc[j] * rBodyForce[d];
1385  }
1386  rDampRHS[FirstRow + TDim] += Weight * Density * TauOne * qF; // Grad(q) * TauOne * (Density * BodyForce)
1387 
1388  // Update reference row index for next iteration
1389  FirstRow += BlockSize;
1390  }
1391 
1392  // Update reference indices
1393  FirstRow = 0;
1394  FirstCol += BlockSize;
1395  }
1396 
1397 // this->AddBTransCB(rDampingMatrix,rShapeDeriv,Viscosity*Weight);
1398  this->AddViscousTerm(rDampingMatrix,rShapeDeriv,Viscosity*Weight);
1399 
1400 
1401  //add enrichment terms
1402  for (unsigned int j = 0; j < TNumNodes; ++j) // iterate over colums
1403  {
1404  // Get Body Force
1405  const array_1d<double, 3 > & rBodyForce = this->GetGeometry()[j].FastGetSolutionStepValue(BODY_FORCE);
1406  L = 0.0;
1407  qF = 0.0;
1408  for (unsigned int m = 0; m < TDim; ++m) // iterate over v components (vx,vy[,vz])
1409  {
1410  // v * Grad(p) block
1411  G = TauOne * Density * AGradN[j] * gauss_enriched_gradients(0,m); // Stabilization: (a * Grad(v)) * TauOne * Grad(p)
1412  PDivV = rShapeDeriv(j, m) * gauss_N_en; // Div(v) * p
1413  double VGradP = -gauss_enriched_gradients(0,m)*rShapeFunc[j]; // Grad(p_star) * v
1414 
1415  // Write v * Grad(p) component
1416  rDampingMatrix(FirstRow + m, FirstCol) += Weight * (G - VGradP);
1417  // Use symmetry to write the q * Div(u) component
1418  rDampingMatrix(FirstCol , FirstRow + m) += Weight * (G + PDivV);//Weight * (G + PDivV);
1419 
1420  // q-p stabilization block
1421  L += rShapeDeriv(j, m) * gauss_enriched_gradients(0,m); // Stabilization: Grad(q) * TauOne * Grad(p)
1422 
1423  // grad_q*body_force
1424  qF += gauss_enriched_gradients(0,m) * rShapeFunc[j] * rBodyForce[m];
1425  }
1426 
1427  // Write q-p stabilization block
1428  rDampingMatrix(FirstRow + TDim, FirstCol ) += Weight * TauOne * L;
1429  rDampingMatrix(FirstCol, FirstRow + TDim ) += Weight * TauOne * L;
1430 
1431  // Operate on RHS
1432  rDampRHS[FirstCol] += Weight * Density * TauOne * qF; // Grad(q) * TauOne * (Density * BodyForce)
1433 
1434  // Update reference indices
1435  FirstRow += BlockSize;
1436  }
1437  //Write q_enr-p_enr stabilization
1438  for (unsigned int m = 0; m < TDim; ++m) // iterate over v components (vx,vy[,vz])
1439  rDampingMatrix(FirstCol, FirstCol ) += Weight * TauOne * gauss_enriched_gradients(0,m) * gauss_enriched_gradients(0,m);
1440 
1441  }
1442 
1453 private:
1456  unsigned int is_cutted;
1463  friend class Serializer;
1464  void save(Serializer& rSerializer) const override
1465  {
1467  }
1468  void load(Serializer& rSerializer) override
1469  {
1471  }
1478 void AddBoundaryTerm(BoundedMatrix<double, 16, 16 >& rDampingMatrix,
1479  const BoundedMatrix<double,4,3>& rShapeDeriv,
1480  const array_1d<double, 4>& N_shape,
1481  const array_1d<double,3>& nn,
1482  const double& Weight,
1483  const double ElementVolume,
1484  ProcessInfo& rCurrentProcessInfo)
1485 {
1486 
1487  const double OneThird = 1.0 / 3.0;
1488 
1489  double Density,Viscosity;
1490  ElementBaseType::EvaluateInPoint(Density, DENSITY, N_shape);
1491  // NODAL viscosity (no Smagorinsky/non-newtonian behaviour)
1492  ElementBaseType::EvaluateInPoint(Viscosity,VISCOSITY,N_shape);
1493 
1494  double viscos_weight = Weight * OneThird * Viscosity * Density;
1495 
1496  unsigned int FirstRow(0),FirstCol(0);
1497  for (unsigned int j = 0; j < TNumNodes; ++j)
1498  {
1499  double jj_nd_flag = this->GetGeometry()[j].FastGetSolutionStepValue(FLAG_VARIABLE);
1500  if(jj_nd_flag == 5.0){
1501  //pressrue terms (three gauss points)
1502  array_1d<double,3> node_normal = this->GetGeometry()[j].FastGetSolutionStepValue(NORMAL);
1503  node_normal /= norm_2(node_normal);
1504 // double dot_prod = MathUtils<double>::Dot(node_normal,nn);
1505 
1506 // rDampingMatrix(FirstRow,FirstRow+3) = Weight * OneThird * (nn[0]);// - dot_prod * node_normal[0]);//nn[0];
1507 // rDampingMatrix(FirstRow+1,FirstRow+3) = Weight * OneThird * (nn[1]);// - dot_prod * node_normal[1]);//nn[1];
1508 // rDampingMatrix(FirstRow+2,FirstRow+3) = Weight * OneThird * (nn[2]);// - dot_prod * node_normal[2]);//nn[2];
1509 
1510  for (unsigned int i = 0; i < TNumNodes; ++i)
1511  {
1512  double ii_nd_flag = this->GetGeometry()[i].FastGetSolutionStepValue(FLAG_VARIABLE);
1513  if(ii_nd_flag == 5.0){
1514  // nxdn/dx + nydn/dy + nz dn/dz
1515  const double Diag = nn[0]*rShapeDeriv(i,0) + nn[1]*rShapeDeriv(i,1) + nn[2]*rShapeDeriv(i,2);
1516 
1517  // First Row
1518  rDampingMatrix(FirstRow,FirstCol) = -(viscos_weight * ( nn[0]*rShapeDeriv(i,0) + Diag ) );// * nn[0]*nn[0];
1519  rDampingMatrix(FirstRow,FirstCol+1) = -(viscos_weight * nn[1]*rShapeDeriv(i,0) );//* nn[0]*nn[1] ;
1520  rDampingMatrix(FirstRow,FirstCol+2) = -(viscos_weight * nn[2]*rShapeDeriv(i,0) );//* nn[0]*nn[2];;
1521 
1522 
1523  // Second Row
1524  rDampingMatrix(FirstRow+1,FirstCol) = -(viscos_weight * nn[0]*rShapeDeriv(i,1) );//* nn[1]*nn[0] ;
1525  rDampingMatrix(FirstRow+1,FirstCol+1) = -(viscos_weight * ( nn[1]*rShapeDeriv(i,1) + Diag ) );//*nn[1]*nn[1] ;
1526  rDampingMatrix(FirstRow+1,FirstCol+2) = -(viscos_weight * nn[2]*rShapeDeriv(i,1) );// * nn[1]*nn[2];
1527 
1528 
1529  // Third Row
1530  rDampingMatrix(FirstRow+2,FirstCol) = -(viscos_weight * nn[0]*rShapeDeriv(i,2) );// * nn[2]*nn[0];
1531  rDampingMatrix(FirstRow+2,FirstCol+1) = -(viscos_weight * nn[1]*rShapeDeriv(i,2) );// * nn[2]*nn[1];
1532  rDampingMatrix(FirstRow+2,FirstCol+2) = -(viscos_weight * ( nn[2]*rShapeDeriv(i,2) + Diag ) );//* nn[2]*nn[2] ;
1533  }
1534 
1535  // Update Counter
1536  FirstCol += 4;
1537  }
1538  }
1539  FirstCol = 0;
1540  FirstRow += 4;
1541  }
1542 }
1543 
1544 
1545 
1556  DPGVMS & operator=(DPGVMS const& rOther);
1558  DPGVMS(DPGVMS const& rOther);
1560 }; // Class DPGVMS
1568 template< unsigned int TDim,
1569  unsigned int TNumNodes >
1570 inline std::istream & operator >>(std::istream& rIStream,
1571  DPGVMS<TDim, TNumNodes>& rThis)
1572 {
1573  return rIStream;
1574 }
1576 template< unsigned int TDim,
1577  unsigned int TNumNodes >
1578 inline std::ostream & operator <<(std::ostream& rOStream,
1579  const DPGVMS<TDim, TNumNodes>& rThis)
1580 {
1581  rThis.PrintInfo(rOStream);
1582  rOStream << std::endl;
1583  rThis.PrintData(rOStream);
1584  return rOStream;
1585 }
1588 } // namespace Kratos.
1589 #endif // KRATOS_TWO_FLUID_DPGVMSS_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Definition: dpg_vms.h:51
Node NodeType
definition of node type (default is: Node)
Definition: dpg_vms.h:62
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Checks the input and that all required Kratos variables have been registered.
Definition: dpg_vms.h:1018
std::vector< std::size_t > EquationIdVectorType
Definition: dpg_vms.h:76
std::size_t IndexType
Definition: dpg_vms.h:74
VMS< TDim, TNumNodes > ElementBaseType
Element from which it is derived.
Definition: dpg_vms.h:60
DPGVMS(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constuctor using geometry and properties.
Definition: dpg_vms.h:115
void CalculateOnIntegrationPoints(const Variable< double > &rVariable, std::vector< double > &rValues, const ProcessInfo &rCurrentProcessInfo) override
Definition: dpg_vms.h:973
void AddIntegrationPointVelocityContribution(MatrixType &rDampingMatrix, VectorType &rDampRHS, const double Density, const double Viscosity, const array_1d< double, 3 > &rAdvVel, const double TauOne, const double TauTwo, const array_1d< double, TNumNodes > &rShapeFunc, const BoundedMatrix< double, TNumNodes, TDim > &rShapeDeriv, const double Weight, const double gauss_N_en, Matrix &gauss_enriched_gradients)
Add a the contribution from a single integration point to the velocity contribution.
Definition: dpg_vms.h:1305
std::vector< Dof< double >::Pointer > DofsVectorType
Definition: dpg_vms.h:77
Geometry< NodeType >::PointsArrayType NodesArrayType
definition of nodes container type, redefined from GeometryType
Definition: dpg_vms.h:71
~DPGVMS() override
Destructor.
Definition: dpg_vms.h:120
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Provides local contributions from body forces and OSS projection terms.
Definition: dpg_vms.h:221
void AddMassStabTerms(MatrixType &rLHSMatrix, const double Density, const array_1d< double, 3 > &rAdvVel, const double TauOne, const array_1d< double, TNumNodes > &rShapeFunc, const BoundedMatrix< double, TNumNodes, TDim > &rShapeDeriv, const double Weight, const Matrix &gauss_enriched_gradients)
Add mass-like stabilization terms to LHS.
Definition: dpg_vms.h:1251
std::size_t SizeType
Definition: dpg_vms.h:75
void FinalizeNonLinearIteration(const ProcessInfo &rCurrentProcessInfo) override
Implementation of FinalizeNonLinearIteration to compute enriched pressure.
Definition: dpg_vms.h:693
PointerVectorSet< Dof< double >, IndexedObject > DofsArrayType
Definition: dpg_vms.h:78
void LumpMassMatrix(MatrixType &rMassMatrix)
Definition: dpg_vms.h:1102
ElementBaseType::MatrixType MatrixType
Definition: dpg_vms.h:73
void CalculateLocalVelocityContribution(MatrixType &rDampingMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Computes the local contribution associated to 'new' velocity and pressure values.
Definition: dpg_vms.h:444
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: dpg_vms.h:1079
DPGVMS(IndexType NewId=0)
Default constuctor.
Definition: dpg_vms.h:87
Geometry< NodeType > GeometryType
definition of the geometry type with given NodeType
Definition: dpg_vms.h:69
void Calculate(const Variable< array_1d< double, 3 > > &rVariable, array_1d< double, 3 > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Implementation of Calculate to compute the local OSS projections.
Definition: dpg_vms.h:811
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Definition: dpg_vms.h:137
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Provides local contributions from body forces and projections to the RHS.
Definition: dpg_vms.h:262
virtual void AddPointContribution(array_1d< double, 3 > &rResult, const Variable< array_1d< double, 3 > > &rVariable, const array_1d< double, TNumNodes > &rShapeFunc, const double Weight=1.0)
Add the weighted value of a variable at a point inside the element to a vector.
Definition: dpg_vms.h:1184
DPGVMS(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor using a geometry object.
Definition: dpg_vms.h:105
virtual void AddPointContribution(double &rResult, const Variable< double > &rVariable, const array_1d< double, TNumNodes > &rShapeFunc, const double Weight=1.0)
Add the weighted value of a variable at a point inside the element to a double.
Definition: dpg_vms.h:1127
void InitializeSolutionStep(const ProcessInfo &rCurrentProcessInfo) override
Call at teh begining of each step, ita decides if element is cutted or no!
Definition: dpg_vms.h:160
DPGVMS(IndexType NewId, const NodesArrayType &ThisNodes)
Constructor using an array of nodes.
Definition: dpg_vms.h:96
void InitializeNonLinearIteration(const ProcessInfo &rCurrentProcessInfo) override
Call at teh begining of each iteration, ita decides if element is cutted or no!
Definition: dpg_vms.h:171
void GetFirstDerivativesVector(Vector &values, int Step) const override
Returns VELOCITY_X, VELOCITY_Y, (VELOCITY_Z,) PRESSURE for each node.
Definition: dpg_vms.h:746
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
Create a new element of this type.
Definition: dpg_vms.h:149
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(DPGVMS)
void EvaluateInPoint(double &rResult, const Variable< double > &rVariable, const array_1d< double, TNumNodes > &rShapeFunc) override
Write the value of a variable at a point inside the element to a double.
Definition: dpg_vms.h:1146
void GetSecondDerivativesVector(Vector &values, int Step) const override
Returns ACCELERATION_X, ACCELERATION_Y, (ACCELERATION_Z,) 0 for each node.
Definition: dpg_vms.h:775
Properties PropertiesType
Definition: dpg_vms.h:67
IndexedObject BaseType
base type: an IndexedObject that automatically has a unique number
Definition: dpg_vms.h:58
Vector VectorType
Definition: dpg_vms.h:72
void EvaluateInPoint(array_1d< double, 3 > &rResult, const Variable< array_1d< double, 3 > > &rVariable, const array_1d< double, TNumNodes > &rShapeFunc) override
Write the value of a variable at a point inside the element to a double.
Definition: dpg_vms.h:1202
void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo) override
Computes local contributions to the mass matrix.
Definition: dpg_vms.h:348
std::string Info() const override
Turn back information as a string.
Definition: dpg_vms.h:1072
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: element.h:1135
virtual int Check(const ProcessInfo &rCurrentProcessInfo) const
Definition: element.h:904
static int CalculateTetrahedraEnrichedShapeFuncions(TMatrixType const &rPoints, TGradientType const &DN_DX, TVectorType rDistances, TVectorType &rVolumes, TMatrixType &rShapeFunctionValues, TVectorType &rPartitionsSign, std::vector< TMatrixType > &rGradientsValue, TMatrixType &NEnriched, array_1d< double, 6 > &edge_areas)
Definition: enrichment_utilities.h:69
std::size_t IndexType
Definition: flags.h:74
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometrical_object.h:248
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
void SetValue(const TVariableType &rThisVariable, typename TVariableType::Type const &rValue)
Definition: geometrical_object.h:238
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
static void CalculateGeometryData(const GeometryType &rGeometry, BoundedMatrix< double, 4, 3 > &rDN_DX, array_1d< double, 4 > &rN, double &rVolume)
This function is designed to compute the shape function derivatives, shape functions and volume in 3D...
Definition: geometry_utilities.h:176
This object defines an indexed object.
Definition: indexed_object.h:54
IndexType Id() const
Definition: indexed_object.h:107
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
This class defines the node.
Definition: node.h:65
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
A stabilized element for the incompressible Navier-Stokes equations.
Definition: vms.h:104
void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo) override
Computes local contributions to the mass matrix.
Definition: vms.h:326
virtual void GetAdvectiveVel(array_1d< double, 3 > &rAdvVel, const array_1d< double, TNumNodes > &rShapeFunc)
Write the advective velocity evaluated at this point to an array.
Definition: vms.h:1434
double ElementSize(const double)
Return an estimate for the element size h, used to calculate the stabilization parameters.
void GetFirstDerivativesVector(Vector &Values, int Step=0) const override
Returns VELOCITY_X, VELOCITY_Y, (VELOCITY_Z,) PRESSURE for each node.
void FinalizeNonLinearIteration(const ProcessInfo &rCurrentProcessInfo) override
Definition: vms.h:437
void CalculateLocalVelocityContribution(MatrixType &rDampingMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Computes the local contribution associated to 'new' velocity and pressure values.
Definition: vms.h:382
virtual void EvaluateInPoint(double &rResult, const Variable< double > &rVariable, const array_1d< double, TNumNodes > &rShapeFunc)
Write the value of a variable at a point inside the element to a double.
Definition: vms.h:1495
virtual void AddMomentumRHS(VectorType &F, const double Density, const array_1d< double, TNumNodes > &rShapeFunc, const double Weight)
Add the momentum equation contribution to the RHS (body forces)
Definition: vms.h:994
virtual void CalculateTau(double &TauOne, double &TauTwo, const array_1d< double, 3 > &rAdvVel, const double ElemSize, const double Density, const double Viscosity, const ProcessInfo &rCurrentProcessInfo)
Calculate Stabilization parameters.
Definition: vms.h:945
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Provides local contributions from body forces and projections to the RHS.
Definition: vms.h:276
void AddConsistentMassMatrixContribution(MatrixType &rLHSMatrix, const array_1d< double, TNumNodes > &rShapeFunc, const double Density, const double Weight)
Definition: vms.h:1076
double ConsistentMassCoef(const double Area)
void AddProjectionResidualContribution(const array_1d< double, 3 > &rAdvVel, const double Density, array_1d< double, 3 > &rElementalMomRes, double &rElementalMassRes, const array_1d< double, TNumNodes > &rShapeFunc, const BoundedMatrix< double, TNumNodes, TDim > &rShapeDeriv, const double Weight)
Assemble the contribution from an integration point to the element's residual.
Definition: vms.h:1267
virtual double EffectiveViscosity(double Density, const array_1d< double, TNumNodes > &rN, const BoundedMatrix< double, TNumNodes, TDim > &rDN_DX, double ElemSize, const ProcessInfo &rProcessInfo)
EffectiveViscosity Calculate the viscosity at given integration point, using Smagorinsky if enabled.
Definition: vms.h:1392
virtual void AddViscousTerm(MatrixType &rDampingMatrix, const BoundedMatrix< double, TNumNodes, TDim > &rShapeDeriv, const double Weight)
Adds the contribution of the viscous term to the momentum equation.
void GetConvectionOperator(array_1d< double, TNumNodes > &rResult, const array_1d< double, 3 > &rVelocity, const BoundedMatrix< double, TNumNodes, TDim > &rShapeDeriv)
Write the convective operator evaluated at this point (for each nodal funciton) to an array.
Definition: vms.h:1471
void GetSecondDerivativesVector(Vector &Values, int Step=0) const override
Returns ACCELERATION_X, ACCELERATION_Y, (ACCELERATION_Z,) 0 for each node.
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#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
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
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
list values
Definition: bombardelli_test.py:42
ProcessInfo
Definition: edgebased_PureConvection.py:116
float dist
Definition: edgebased_PureConvection.py:89
def load(f)
Definition: ode_solve.py:307
int L
Definition: ode_solve.py:390
int d
Definition: ode_solve.py:397
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
float temp
Definition: rotating_cone.py:85
int m
Definition: run_marine_rain_substepping.py:8
N
Definition: sensitivityMatrix.py:29
K
Definition: sensitivityMatrix.py:73
integer i
Definition: TensorModule.f:17