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.
two_step_v_p_DEM_coupling_strategy.h
Go to the documentation of this file.
1 //
2 // Project Name: KratosPFEMFluidDynamicsApplication $
3 // Last modified by: $Author: AFranci $
4 // Date: $Date: January 2016 $
5 // Revision: $Revision: 0.0 $
6 //
7 //
8 
9 #ifndef KRATOS_TWO_STEP_V_P_DEM_COUPLING_STRATEGY_H
10 #define KRATOS_TWO_STEP_V_P_DEM_COUPLING_STRATEGY_H
11 
12 #include "includes/define.h"
13 #include "includes/model_part.h"
15 #include "includes/cfd_variables.h"
16 #include "utilities/openmp_utils.h"
17 #include "processes/process.h"
22 
24 /* #include "solving_strategies/schemes/residualbased_incrementalupdate_static_scheme_slip.h" */
28 
29 #include "custom_utilities/solver_settings.h"
30 
32 
35 
36 #include <stdio.h>
37 #include <cmath>
38 
39 namespace Kratos
40 {
41 
44 
47 
51 
53 
56 
60 
64 
65  template <class TSparseSpace,
66  class TDenseSpace,
67  class TLinearSolver>
68  class TwoStepVPDEMcouplingStrategy : public TwoStepVPStrategy<TSparseSpace, TDenseSpace, TLinearSolver>
69  {
70  public:
74 
76  //typedef boost::shared_ptr< TwoStepVPDEMcouplingStrategy<TSparseSpace, TDenseSpace, TLinearSolver> > Pointer;
77 
79 
80  typedef typename BaseType::TDataType TDataType;
81 
82  //typedef typename BaseType::DofSetType DofSetType;
83 
85 
87 
89 
91 
93 
95 
97 
106 
108  SolverSettingsType &rSolverConfig) : BaseType(rModelPart)
109  {
111  }
112 
114  /*SolverConfiguration<TSparseSpace, TDenseSpace, TLinearSolver>& rSolverConfig,*/
115  typename TLinearSolver::Pointer pVelocityLinearSolver,
116  typename TLinearSolver::Pointer pPressureLinearSolver,
117  bool ReformDofSet = true,
118  double VelTol = 0.0001,
119  double PresTol = 0.0001,
120  int MaxPressureIterations = 1, // Only for predictor-corrector
121  unsigned int TimeOrder = 2,
122  unsigned int DomainSize = 2) : BaseType(rModelPart,
123  pVelocityLinearSolver,
124  pPressureLinearSolver,
125  ReformDofSet,
126  VelTol,
127  PresTol,
128  MaxPressureIterations,
129  TimeOrder,
130  DomainSize)
131  {
132  }
133 
136 
138  {
139  ModelPart &rModelPart = BaseType::GetModelPart();
140  ProcessInfo &rCurrentProcessInfo = rModelPart.GetProcessInfo();
141 
142  for (ModelPart::NodeIterator i = rModelPart.NodesBegin();
143  i != rModelPart.NodesEnd(); ++i)
144  {
145 
146  array_1d<double, 3> &CurrentVelocity = (i)->FastGetSolutionStepValue(VELOCITY, 0);
147  array_1d<double, 3> &PreviousVelocity = (i)->FastGetSolutionStepValue(VELOCITY, 1);
148 
149  array_1d<double, 3> &CurrentAcceleration = (i)->FastGetSolutionStepValue(ACCELERATION, 0);
150  array_1d<double, 3> &PreviousAcceleration = (i)->FastGetSolutionStepValue(ACCELERATION, 1);
151 
152  /* if((i)->IsNot(ISOLATED) || (i)->Is(SOLID)){ */
153  if ((i)->IsNot(ISOLATED) && ((i)->IsNot(RIGID) || (i)->Is(SOLID)))
154  {
155  this->UpdateAccelerations(CurrentAcceleration, CurrentVelocity, PreviousAcceleration, PreviousVelocity);
156  }
157  else if ((i)->Is(RIGID))
158  {
159  array_1d<double, 3> Zeros(3, 0.0);
160  (i)->FastGetSolutionStepValue(ACCELERATION, 0) = Zeros;
161  (i)->FastGetSolutionStepValue(ACCELERATION, 1) = Zeros;
162  }
163  else
164  {
165  (i)->FastGetSolutionStepValue(PRESSURE, 0) = 0.0;
166  (i)->FastGetSolutionStepValue(PRESSURE, 1) = 0.0;
167  (i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0) = 0.0;
168  (i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 1) = 0.0;
169  (i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0) = 0.0;
170  (i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 1) = 0.0;
171  if ((i)->SolutionStepsDataHas(VOLUME_ACCELERATION))
172  {
173  array_1d<double, 3> &VolumeAcceleration = (i)->FastGetSolutionStepValue(VOLUME_ACCELERATION);
174  (i)->FastGetSolutionStepValue(ACCELERATION, 0) = VolumeAcceleration;
175  (i)->FastGetSolutionStepValue(VELOCITY, 0) += VolumeAcceleration * rCurrentProcessInfo[DELTA_TIME];
176  }
177  }
178 
179  const double timeInterval = rCurrentProcessInfo[DELTA_TIME];
180  unsigned int timeStep = rCurrentProcessInfo[STEP];
181  if (timeStep == 1)
182  {
183  (i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0) = 0;
184  (i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 1) = 0;
185  (i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0) = 0;
186  (i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 1) = 0;
187  }
188  else
189  {
190  double &CurrentPressure = (i)->FastGetSolutionStepValue(PRESSURE, 0);
191  double &PreviousPressure = (i)->FastGetSolutionStepValue(PRESSURE, 1);
192  double &CurrentPressureVelocity = (i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0);
193  double &CurrentPressureAcceleration = (i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0);
194 
195  CurrentPressureAcceleration = CurrentPressureVelocity / timeInterval;
196 
197  CurrentPressureVelocity = (CurrentPressure - PreviousPressure) / timeInterval;
198 
199  CurrentPressureAcceleration += -CurrentPressureVelocity / timeInterval;
200 
201  double &previousFluidFraction = (i)->FastGetSolutionStepValue(FLUID_FRACTION_OLD);
202  previousFluidFraction = (i)->FastGetSolutionStepValue(FLUID_FRACTION);
203  }
204  }
205  }
206 
208  {
209  ModelPart &rModelPart = BaseType::GetModelPart();
210  ProcessInfo &rCurrentProcessInfo = rModelPart.GetProcessInfo();
211  const double TimeStep = rCurrentProcessInfo[DELTA_TIME];
212 
213  for (ModelPart::NodeIterator i = rModelPart.NodesBegin();
214  i != rModelPart.NodesEnd(); ++i)
215  {
216  if ((i)->IsNot(PFEMFlags::EULERIAN_INLET))
217  {
218 
219  array_1d<double, 3> &CurrentVelocity = (i)->FastGetSolutionStepValue(VELOCITY, 0);
220  array_1d<double, 3> &PreviousVelocity = (i)->FastGetSolutionStepValue(VELOCITY, 1);
221 
222  array_1d<double, 3> &CurrentDisplacement = (i)->FastGetSolutionStepValue(DISPLACEMENT, 0);
223  array_1d<double, 3> &PreviousDisplacement = (i)->FastGetSolutionStepValue(DISPLACEMENT, 1);
224 
225  const double &currentFluidFraction = (i)->FastGetSolutionStepValue(FLUID_FRACTION);
226  const double &previousFluidFraction = (i)->FastGetSolutionStepValue(FLUID_FRACTION_OLD);
227  double &currentFluidFractionRate = (i)->FastGetSolutionStepValue(FLUID_FRACTION_RATE);
228 
229  /* if( i->IsFixed(DISPLACEMENT_X) == false ) */
230  CurrentDisplacement[0] = 0.5 * TimeStep * (CurrentVelocity[0] + PreviousVelocity[0]) + PreviousDisplacement[0];
231 
232  /* if( i->IsFixed(DISPLACEMENT_Y) == false ) */
233  CurrentDisplacement[1] = 0.5 * TimeStep * (CurrentVelocity[1] + PreviousVelocity[1]) + PreviousDisplacement[1];
234 
235  /* if( i->IsFixed(DISPLACEMENT_Z) == false ) */
236  CurrentDisplacement[2] = 0.5 * TimeStep * (CurrentVelocity[2] + PreviousVelocity[2]) + PreviousDisplacement[2];
237 
238  currentFluidFractionRate = (currentFluidFraction - previousFluidFraction) / TimeStep;
239  }
240  }
241  }
242 
245 
249  };
250 } // namespace Kratos
251 #endif
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
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
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
Definition: two_step_v_p_DEM_coupling_strategy.h:69
Helper class to define solution strategies for TwoStepVPStrategy.
Definition: solver_settings.h:57
Definition: two_step_v_p_strategy.h:71
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: two_step_v_p_strategy.h:89
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: two_step_v_p_strategy.h:87
BaseType::TSystemVectorType TSystemVectorType
Definition: two_step_v_p_strategy.h:85
BaseType::TSystemMatrixType TSystemMatrixType
Definition: two_step_v_p_strategy.h:83
BaseType::TDataType TDataType
Definition: two_step_v_p_strategy.h:79
void UpdateAccelerations(array_1d< double, 3 > &CurrentAcceleration, const array_1d< double, 3 > &CurrentVelocity, array_1d< double, 3 > &PreviousAcceleration, const array_1d< double, 3 > &PreviousVelocity)
Definition: v_p_strategy.h:385
virtual void InitializeStrategy(SolverSettingsType &rSolverConfig)
Definition: v_p_strategy.h:886
BaseType::TSystemMatrixType TSystemMatrixType
Definition: two_step_v_p_DEM_coupling_strategy.h:86
void CalculateDisplacementsAndPorosity() override
Definition: two_step_v_p_DEM_coupling_strategy.h:207
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: two_step_v_p_DEM_coupling_strategy.h:92
TwoStepVPSolverSettings< TSparseSpace, TDenseSpace, TLinearSolver > SolverSettingsType
Definition: two_step_v_p_DEM_coupling_strategy.h:96
TwoStepVPDEMcouplingStrategy< TSparseSpace, TDenseSpace, TLinearSolver >::Pointer StrategyPointerType
Definition: two_step_v_p_DEM_coupling_strategy.h:94
TwoStepVPStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Counted pointer of TwoStepVPDEMcouplingStrategy.
Definition: two_step_v_p_DEM_coupling_strategy.h:78
TwoStepVPDEMcouplingStrategy(ModelPart &rModelPart, typename TLinearSolver::Pointer pVelocityLinearSolver, typename TLinearSolver::Pointer pPressureLinearSolver, bool ReformDofSet=true, double VelTol=0.0001, double PresTol=0.0001, int MaxPressureIterations=1, unsigned int TimeOrder=2, unsigned int DomainSize=2)
Definition: two_step_v_p_DEM_coupling_strategy.h:113
KRATOS_CLASS_POINTER_DEFINITION(TwoStepVPDEMcouplingStrategy)
virtual ~TwoStepVPDEMcouplingStrategy()
Destructor.
Definition: two_step_v_p_DEM_coupling_strategy.h:135
BaseType::TDataType TDataType
Definition: two_step_v_p_DEM_coupling_strategy.h:80
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: two_step_v_p_DEM_coupling_strategy.h:90
BaseType::DofsArrayType DofsArrayType
Definition: two_step_v_p_DEM_coupling_strategy.h:84
TwoStepVPDEMcouplingStrategy(ModelPart &rModelPart, SolverSettingsType &rSolverConfig)
Definition: two_step_v_p_DEM_coupling_strategy.h:107
BaseType::TSystemVectorType TSystemVectorType
Definition: two_step_v_p_DEM_coupling_strategy.h:88
void CalculateTemporalVariables() override
Definition: two_step_v_p_DEM_coupling_strategy.h:137
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
integer i
Definition: TensorModule.f:17