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.
FSI_utils.h
Go to the documentation of this file.
1 
2 /* *********************************************************
3 *
4 * Last Modified by: $Author: rrossi $
5 * Date: $Date: 2009-01-13 15:39:55 $
6 * Revision: $Revision: 1.7 $
7 *
8 * ***********************************************************/
9 #include "includes/model_part.h"
10 
11 #if !defined(KRATOS_FSI_UTILS )
12 #define KRATOS_FSI_UTILS
13 
14 
15 /* System includes */
16 
17 
18 /* External includes */
19 
20 
21 /* Project includes */
22 #include "includes/cfd_variables.h"
23 #include "utilities/math_utils.h"
24 #include "fsi_application.h"
25 
26 
27 namespace Kratos
28 {
29 
78 class FSIUtils
79 {
80 public:
105  //***********************************************************************
106  //***********************************************************************
107  /* void GenerateCouplingElements(ModelPart& structural_model_part, int dim)
108  {
109  KRATOS_TRY
110 
111  if(dim == 2)
112  {
113  for(ModelPart::ConditionsContainerType::iterator it = structural_model_part.ConditionsBegin();
114  it != structural_model_part.ConditionsEnd();
115  it ++ )
116  {
117  Geometry< Node >::Pointer pgeom =it->pGetGeometry();
118  Properties::Pointer props = structural_model_part.GetMesh().pGetProperties(1);
119 
120  unsigned int id = (structural_model_part.Elements().end() - 1)->Id() + 1;
121  Element::Pointer newel = Element::Pointer( new CouplingFace2D(id, pgeom,props) );
122 
123  (structural_model_part.Elements()).push_back(newel);
124  }
125  }
126 
127  KRATOS_CATCH("")
128  }
129  */
130 
131 
132  //***********************************************************************
133  //***********************************************************************
134  bool CheckPressureConvergence(ModelPart::NodesContainerType& fluid_interface_nodes, double toll, double abs_toll)
135  {
136  KRATOS_TRY
137 
138  double dp_norm = 0.00;
139  double p_norm = 0.00;
140  double dp=0.0;
141  double p=0.0;
142 
143  //verifies that the pressure variation is sufficiently small
144  for(ModelPart::NodesContainerType::iterator it = fluid_interface_nodes.begin(); it != fluid_interface_nodes.end(); it++)
145  {
146  p = it->FastGetSolutionStepValue(PRESSURE);
147  dp = p - (it->FastGetSolutionStepValue(PRESSURE_OLD_IT));
148  dp_norm += dp*dp;
149  p_norm += p*p;
150  }
151 
152  if( p_norm < 1e-20)
153  p_norm = 1.00;
154 
155  double ratio = sqrt(dp_norm/p_norm);
156  std::cout << "dp_norm = " << dp_norm << std::endl;
157  std::cout << "FSI convergence ratio = " << ratio << std::endl;
158 
159  if( dp < abs_toll*abs_toll )
160  return true;
161  else
162  {
163  if(ratio < toll)
164  return true;
165  else
166  return false;
167  }
168  KRATOS_CATCH("")
169  }
170 
171  //***********************************************************************
172  //***********************************************************************
173  void StructuralPressurePrediction( Variable<double>& rVariable, ModelPart::NodesContainerType& structure_interface_nodes, const int structure_buffer_size, const int order )
174  {
175  KRATOS_TRY
176 
177  if( order > structure_buffer_size-1)
178  KRATOS_THROW_ERROR(std::logic_error,"using a force prediction order higher than the buffer size ... increase the buffer size or reduce the prediction order","");
179 
180  if(order == 1)
181  {
182  std::cout << "first order force prediction" << std::endl;
183  for(ModelPart::NodesContainerType::iterator it = structure_interface_nodes.begin(); it != structure_interface_nodes.end(); it++)
184  {
185  it->FastGetSolutionStepValue(rVariable) = it->FastGetSolutionStepValue(rVariable,1);
186  }
187  }
188  else if (order == 2)
189  {
190  std::cout << "second order force prediction" << std::endl;
191  for(ModelPart::NodesContainerType::iterator it = structure_interface_nodes.begin(); it != structure_interface_nodes.end(); it++)
192  {
193  it->FastGetSolutionStepValue(rVariable) = 2.0*it->FastGetSolutionStepValue(rVariable,1) - it->FastGetSolutionStepValue(rVariable,2);
194  }
195  }
196 
197  KRATOS_CATCH("")
198  }
199 
200 
218 private:
251  //FSIUtils(void);
252 
253  //FSIUtils(FSIUtils& rSource);
254 
255 
258 }; /* Class ClassName */
259 
268 } /* namespace Kratos.*/
269 
270 #endif /* KRATOS_FSI_UTILS defined */
271 
Definition: FSI_utils.h:79
void StructuralPressurePrediction(Variable< double > &rVariable, ModelPart::NodesContainerType &structure_interface_nodes, const int structure_buffer_size, const int order)
Definition: FSI_utils.h:173
bool CheckPressureConvergence(ModelPart::NodesContainerType &fluid_interface_nodes, double toll, double abs_toll)
Definition: FSI_utils.h:134
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#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
p
Definition: sensitivityMatrix.py:52
e
Definition: run_cpp_mpi_tests.py:31