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.
fracstep_GLS_strategy.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: Author Julio Marti.
11 //
12 
13 #if !defined(KRATOS_GLS_STRATEGY)
14 #define KRATOS_GLS_STRATEGY
15 
16 /* System includes */
17 
18 /* External includes */
19 #include "boost/smart_ptr.hpp"
20 
21 /* Project includes */
22 
23 
24 #include "utilities/geometry_utilities.h"
25 
26 
28 #include "includes/define.h"
29 #include "includes/model_part.h"
31 #include "includes/cfd_variables.h"
32 #include "utilities/openmp_utils.h"
33 #include "processes/process.h"
36 
42 
43 //#include "custom_utilities/solver_settings.h"
44 
45 #ifdef _OPENMP
46 #include "omp.h"
47 #endif
48 
49 #define QCOMP
50 
51 namespace Kratos
52 {
53 
80 
103  template<class TSparseSpace,
104  class TDenseSpace,
105  class TLinearSolver
106  >
108  : public ImplicitSolvingStrategy<TSparseSpace, TDenseSpace, TLinearSolver>
109  {
110  public:
116 
118 
119  typedef typename BaseType::TDataType TDataType;
120 
121  //typedef typename BaseType::DofSetType DofSetType;
122 
124 
126 
128 
130 
132 
134 
135 
160  FracStepStrategy( ModelPart& model_part, typename TLinearSolver::Pointer pNewVelocityLinearSolver,typename TLinearSolver::Pointer pNewPressureLinearSolver,
161  bool ReformDofAtEachIteration = true,
162  double velocity_toll = 0.01,
163  double pressure_toll = 0.01,
164  int MaxVelocityIterations = 3,
165  int MaxPressureIterations = 1,
166  unsigned int time_order = 2,
167  unsigned int domain_size = 2,
168  bool predictor_corrector = false
169  )
170  : ImplicitSolvingStrategy<TSparseSpace, TDenseSpace, TLinearSolver>(model_part, false)//, msolver_config(solver_config)
171  {
172  KRATOS_TRY
173 
174  this->mvelocity_toll = velocity_toll;
175  this->mpressure_toll = pressure_toll;
176  this->mMaxVelIterations = MaxVelocityIterations;
177  this->mMaxPressIterations = MaxPressureIterations;
178  this->mtime_order = time_order;
180  this->mdomain_size = domain_size;
183  this->proj_is_initialized = false;
184  this->mecho_level = 1;
185 
186 
187  bool CalculateReactions = false;
188  bool CalculateNormDxFlag = true;
189  bool ReformDofAtEachIteration = false;
190 
191  //computation of the fractional vel velocity (first step)
192  //3 dimensional case
193  //typedef typename Kratos::VariableComponent<Kratos::VectorComponentAdaptor<Kratos::array_1d<double, 3 > > > VarComponent;
194  typedef typename BuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver>::Pointer BuilderSolverTypePointer;
196 
197  //initializing fractional velocity solution step
198  typedef Scheme< TSparseSpace, TDenseSpace > SchemeType;
199  typename SchemeType::Pointer pscheme = typename SchemeType::Pointer(new ResidualBasedIncrementalUpdateStaticScheme< TSparseSpace, TDenseSpace > ());
200 
201  // BuilderSolverTypePointer pVelocityBuildAndSolver = BuilderSolverTypePointer(new ResidualBasedEliminationBuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver > (pNewVelocityLinearSolver));
202  BuilderSolverTypePointer pVelocityBuildAndSolver = BuilderSolverTypePointer(new ResidualBasedBlockBuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver > (pNewVelocityLinearSolver));
203 
204  this->mpfracvel_strategy = typename BaseType::Pointer(new ResidualBasedLinearStrategy<TSparseSpace, TDenseSpace, TLinearSolver > (model_part, pscheme, pVelocityBuildAndSolver, CalculateReactions, ReformDofAtEachIteration, CalculateNormDxFlag));
205 
206  this->mpfracvel_strategy->SetEchoLevel(1);
207 
208 
209  // BuilderSolverTypePointer pPressureBuildAndSolver = BuilderSolverTypePointer(new ResidualBasedEliminationBuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver > (pNewVelocityLinearSolver));
210  BuilderSolverTypePointer pPressureBuildAndSolver = BuilderSolverTypePointer(new ResidualBasedBlockBuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver > (pNewPressureLinearSolver));
211 
212  // this->mppressurestep = typename BaseType::Pointer(new ResidualBasedLinearStrategy<TSparseSpace, TDenseSpace, TLinearSolver > (model_part, pscheme,pNewPressureLinearSolver, pressure_build, CalculateReactions, ReformDofAtEachIteration, CalculateNormDxFlag));
213  this->mppressurestep = typename BaseType::Pointer(new ResidualBasedLinearStrategy<TSparseSpace, TDenseSpace, TLinearSolver > (model_part, pscheme,pPressureBuildAndSolver, CalculateReactions, ReformDofAtEachIteration, CalculateNormDxFlag));
214  this->mppressurestep->SetEchoLevel(2);
215 
216  this->m_step = 1;
217 
218  mHasSlipProcess = false;
219 
220  KRATOS_CATCH("")
221  }
222 
226  {
227  }
228 
232  double Solve() override
233  {
234  KRATOS_TRY
235  Timer time;
236  Timer::Start("Solve_strategy");
237 
238 #if defined(QCOMP)
239  double Dp_norm;
240  Dp_norm = IterativeSolve();
241 #else
242  //multifluids
244 
245  double Dp_norm = 1.00;
246  //int iteration = 0;
247  //int MaxPressureIterations = this->mMaxPressIterations;
248  Dp_norm = IterativeSolve();
249 #endif
250  //this->Clear();
251  this->m_step += 1;
252  return Dp_norm;
253  KRATOS_CATCH("")
254  }
255 
256  double SolvePressure()
257  {
258  KRATOS_TRY
259 
260  //ProcessInfo& rCurrentProcessInfo = BaseType::GetModelPart().GetProcessInfo();
261  this->SolveStep7(); //pold=pn+1
262  double Dp_norm = this->SolveStep2();
263  return Dp_norm;
264 
265  KRATOS_CATCH("")
266  }
267 
268  double IterativeSolve()
269  {
270  KRATOS_TRY
271  Timer time;
272  Timer::Start("Solve_ambos");
273 
274  double Dp_norm = 1.00;
275  ProcessInfo& rCurrentProcessInfo = BaseType::GetModelPart().GetProcessInfo();
276  //KRATOS_THROW_ERROR(std::logic_error, "method not implemented" , "");
277  rCurrentProcessInfo[VISCOSITY] = 1.0;
278 
280  {
281  i->FastGetSolutionStepValue(VELOCITY_X,1) = i->FastGetSolutionStepValue(VELOCITY_X);
282  i->FastGetSolutionStepValue(VELOCITY_Y,1) = i->FastGetSolutionStepValue(VELOCITY_Y);
283  i->FastGetSolutionStepValue(VELOCITY_Z,1) = i->FastGetSolutionStepValue(VELOCITY_Z);
284  }
285 
286 #if defined(QCOMP)
287  this->SolveStep1(this->mvelocity_toll, this->mMaxVelIterations);
288 #else
289  this->SolveStep3();
290 #endif
291  //double p_norm=0.0;
292 #if defined(QCOMP)
293 
294  //polimero
295  this->SolveStepaux();
296  //int MaxPressureIterations = this->mMaxPressIterations;
297  //int rank = BaseType::GetModelPart().GetCommunicator().MyPID();
298  //double p_norm = SavePressureIteration();
299  Dp_norm = 1.0;
300  //Timer::Stop("Solve_ambos");
301  //KRATOS_WATCH(time)
302 #else
303  int iteration = 0;
304  while ( iteration++ < 3)
305  {
306  Dp_norm = SolvePressure();
307  double p_norm = SavePressureIteration();
308  if (fabs(p_norm) > 1e-10){
309  Dp_norm /= p_norm;
310  }
311  else
312  Dp_norm = 1.0;
313  this->SolveStep4();
314  }
315 #endif
316  this->Clear();
317  return Dp_norm;
318  KRATOS_CATCH("")
319  }
320 
326  {
327  KRATOS_TRY
328 
329  double local_p_norm = 0.0;
330  for (ModelPart::NodeIterator i = BaseType::GetModelPart().NodesBegin();
332  {
333  //setting the old value of the pressure to the current one
334  const double& p = (i)->FastGetSolutionStepValue(PRESSURE);
335  local_p_norm += p*p;
336  }
337 
338  double p_norm = local_p_norm;
339 
340  //TODO: prepare for parallelization
341  p_norm = sqrt(p_norm);
342 
343  return p_norm;
344  KRATOS_CATCH("")
345  }
346 
347 
348 
350  {
351  KRATOS_TRY
352 
354 
355  const double dt = model_part.GetProcessInfo()[DELTA_TIME];
356 
358  {
359  (i)->FastGetSolutionStepValue(PRESSURE_OLD_IT) = 0.0;
360  (i)->FastGetSolutionStepValue(PRESSURE) = 0.0;
361  (i)->FastGetSolutionStepValue(PRESSURE,1) = 0.0;
362  }
363  KRATOS_CATCH("");
364  }
365 
366 
373  void SolveStep1(double velocity_toll, int MaxIterations)
374  {
375  KRATOS_TRY;
376 
377  Timer time;
378  Timer::Start("SolveStep1");
379 
381 
382  double normDx = 0.0;
383 
384  bool is_converged = false;
385  int iteration = 0;
386  //double iteration = 1;
387  //ModelPart& model_part=BaseType::GetModelPart();
388 
389  while (is_converged == false && iteration++<3)
390  {
391  //perform one iteration over the fractional step velocity
392  normDx = FractionalVelocityIteration();
393  is_converged = ConvergenceCheck(normDx, velocity_toll);
394  }
395  if (is_converged == false)
396  if (rank == 0) std::cout << "ATTENTION: convergence NOT achieved" << std::endl;
397 
398  KRATOS_CATCH("");
399 
400  }
401 
403  {
404  KRATOS_TRY
405  ProcessInfo& rCurrentProcessInfo = BaseType::GetModelPart().GetProcessInfo();
406  rCurrentProcessInfo[FRACTIONAL_STEP] = 1;
407  double normDx = mpfracvel_strategy->Solve();
408  return normDx;
409  KRATOS_CATCH("");
410  }
411 
412  void SolveStep4()
413  {
414  KRATOS_TRY;
415  Timer time;
416  Timer::Start("paso_4");
417 
419 
420 //#ifdef _OPENMP
421 // int number_of_threads = omp_get_max_threads();
422 //#else
423 // int number_of_threads = 1;
424 //#endif
425 
426  //ModelPart& model_part=BaseType::GetModelPart();
427 
428  //double dt = model_part.GetProcessInfo()[DELTA_TIME];
429  //dt=0.005;
431  {
433  i->FastGetSolutionStepValue(FORCE)=ZeroVector(3);
434  double & nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS);
435  nodal_mass = 0.0;
436  }
437 
438  ProcessInfo& rCurrentProcessInfo = BaseType::GetModelPart().GetProcessInfo();
439  rCurrentProcessInfo[FRACTIONAL_STEP] = 6;
441  {
443  }
444 
446  {
447  array_1d<double,3>& force_temp = i->FastGetSolutionStepValue(FORCE);
448  double A = (i)->FastGetSolutionStepValue(NODAL_MASS);
449  if(A<0.0000000000000001){
450  A=1.0;
451  }
452 
453  double dt_Minv = 0.005 / A ;
454  //dt_Minv=1.0;
455  force_temp *= dt_Minv;
456 
457  //KRATOS_WATCH(force_temp);
458  if(!i->IsFixed(VELOCITY_X)) //FRACT_VEL_X
459  {
460  i->FastGetSolutionStepValue(VELOCITY_X) += force_temp[0] ;
461  }
462  if(!i->IsFixed(VELOCITY_Y))
463  {
464  i->FastGetSolutionStepValue(VELOCITY_Y) +=force_temp[1];
465  }
466  if(!i->IsFixed(VELOCITY_Z))
467  {
468  i->FastGetSolutionStepValue(VELOCITY_Z) +=force_temp[2] ;
469  }
470  if(i->IsFixed(VELOCITY_X))
471  {
472  i->FastGetSolutionStepValue(VELOCITY_X)=0.0; //i->FastGetSolutionStepValue(VELOCITY_X,1);
473  }
474  if(i->IsFixed(VELOCITY_Y))
475  {
476  i->FastGetSolutionStepValue(VELOCITY_Y)= 0.0; //i->FastGetSolutionStepValue(VELOCITY_Y,1) ;
477  }
478  if(i->IsFixed(VELOCITY_Z))
479  {
480  i->FastGetSolutionStepValue(VELOCITY_Z)=0.0; //i->FastGetSolutionStepValue(VELOCITY_Z,1) ;
481  }
482  }
483  KRATOS_CATCH("");
484  }
485 
486  void SolveStep7()
487  {
488  KRATOS_TRY;
489  // ProcessInfo& rCurrentProcessInfo = BaseType::GetModelPart().GetProcessInfo();
491  //Vector& BDFcoeffs = rCurrentProcessInfo[BDF_COEFFICIENTS];
492 
493 #ifdef _OPENMP
494  int number_of_threads = omp_get_max_threads();
495 #else
496  int number_of_threads = 1;
497 #endif
498 
499  //ModelPart& model_part=BaseType::GetModelPart();
500  //const double dt = model_part.GetProcessInfo()[DELTA_TIME];
501  vector<unsigned int> partition;
502  CreatePartition(number_of_threads, BaseType::GetModelPart().Nodes().size(), partition);
503 
504 #pragma omp parallel for schedule(static,1)
505  for (int k = 0; k < number_of_threads; k++)
506  {
507  ModelPart::NodeIterator it_begin = BaseType::GetModelPart().NodesBegin() + partition[k];
508  ModelPart::NodeIterator it_end = BaseType::GetModelPart().NodesBegin() + partition[k + 1];
509 
511  for (typename ModelPart::NodesContainerType::iterator it=it_begin; it!=it_end; ++it)
512  {
513  it->FastGetSolutionStepValue(PRESSURE_OLD_IT)=it->FastGetSolutionStepValue(PRESSURE);
514  }
515  }
516  KRATOS_CATCH("");
517  }
518 
519  double SolveStep2()
520  {
521  KRATOS_TRY;
522  Timer::Start("Presion");
523  BaseType::GetModelPart().GetProcessInfo()[FRACTIONAL_STEP] = 4;
524  return mppressurestep->Solve();
525  Timer::Stop("Presion");
526  //KRATOS_WATCH(*time)
527  //mppressurestep->Clear();
528  KRATOS_CATCH("");
529 
530  }
531 
532  void SolveStep3()
533  {
534  KRATOS_TRY
535 
537  const double dt = model_part.GetProcessInfo()[DELTA_TIME];
538  Timer time;
539  Timer::Start("paso_3");
540 
541 #ifdef _OPENMP
542  int number_of_threads = omp_get_max_threads();
543 #else
544  int number_of_threads = 1;
545 #endif
546 
547  vector<unsigned int> partition;
548  CreatePartition(number_of_threads, BaseType::GetModelPart().Nodes().size(), partition);
549 
550 
551 
552 #pragma omp parallel for schedule(static,1)
553  for (int k = 0; k < number_of_threads; k++)
554  {
555  ModelPart::NodeIterator it_begin = BaseType::GetModelPart().NodesBegin() + partition[k];
556  ModelPart::NodeIterator it_end = BaseType::GetModelPart().NodesBegin() + partition[k + 1];
557 
558 
560 
561 
562  for (ModelPart::NodeIterator i = it_begin; i != it_end; ++i)
563  {
564  double & nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS);
565  nodal_mass = 0.0;
566  noalias(i->FastGetSolutionStepValue(FORCE)) = zero;
567  //double & nodal_area = (i)->FastGetSolutionStepValue(NODAL_AREA);
568  //nodal_area = 0.0;
569  }
570  }
572 
573  ProcessInfo& rCurrentProcessInfo = BaseType::GetModelPart().GetProcessInfo();
574  rCurrentProcessInfo[FRACTIONAL_STEP] = 5;
575 
576  vector<unsigned int> elem_partition;
577  CreatePartition(number_of_threads, BaseType::GetModelPart().Elements().size(), elem_partition);
578 
579 #pragma omp parallel for schedule(static,1)
580  for (int k = 0; k < number_of_threads; k++)
581  {
582  ModelPart::ElementIterator it_begin = BaseType::GetModelPart().ElementsBegin() + elem_partition[k];
583  ModelPart::ElementIterator it_end = BaseType::GetModelPart().ElementsBegin() + elem_partition[k + 1];
584  for (ModelPart::ElementIterator i = it_begin; i != it_end; ++i)
585  {
587  }
588  }
589 #pragma omp parallel for schedule(static,1)
590  for (int k = 0; k < number_of_threads; k++)
591  {
592  ModelPart::NodeIterator it_begin = BaseType::GetModelPart().NodesBegin() + partition[k];
593  ModelPart::NodeIterator it_end = BaseType::GetModelPart().NodesBegin() + partition[k + 1];
594 
595  for (ModelPart::NodeIterator i = it_begin; i != it_end; ++i)
596  {
597  array_1d<double,3>& force_temp = i->FastGetSolutionStepValue(FORCE);
598 
599  force_temp *=(1.0/ i->FastGetSolutionStepValue(NODAL_MASS));
600 
601  //array_1d<double,3>& vel = i->FastGetSolutionStepValue(VELOCITY);
602  i->FastGetSolutionStepValue(VELOCITY) = i->FastGetSolutionStepValue(VELOCITY,1) + dt * force_temp;
603  }
604  }
605 
606  KRATOS_CATCH("");
607  }
608 
610  {
611  KRATOS_TRY
612 
613  Timer time;
614  Timer::Start("SolveStepaux");
615 
616  //ModelPart& model_part=BaseType::GetModelPart();
617  //const double dt = model_part.GetProcessInfo()[DELTA_TIME];
618 
619 #ifdef _OPENMP
620  int number_of_threads = omp_get_max_threads();
621 #else
622  int number_of_threads = 1;
623 #endif
624 
625  //number_of_threads = 1;
626  vector<unsigned int> partition;
627  CreatePartition(number_of_threads, BaseType::GetModelPart().Nodes().size(), partition);
628 
629 #pragma omp parallel for schedule(static,1)
630  for (int k = 0; k < number_of_threads; k++)
631  {
632  ModelPart::NodeIterator it_begin = BaseType::GetModelPart().NodesBegin() + partition[k];
633  ModelPart::NodeIterator it_end = BaseType::GetModelPart().NodesBegin() + partition[k + 1];
634 
636 
637  for (ModelPart::NodeIterator i = it_begin; i != it_end; ++i)
638  {
639  double & nodal_mass = (i)->FastGetSolutionStepValue(NODAL_MASS);
640  nodal_mass = 0.0;
641  i->FastGetSolutionStepValue(PRESSUREAUX)=0.0;
642  i->FastGetSolutionStepValue(PRESSURE)=0.0;
643  }
644  }
645 
646 
647  ProcessInfo& rCurrentProcessInfo = BaseType::GetModelPart().GetProcessInfo();
648  rCurrentProcessInfo[FRACTIONAL_STEP] = 7;
649 
650  vector<unsigned int> elem_partition;
651  CreatePartition(number_of_threads, BaseType::GetModelPart().Elements().size(), elem_partition);
652 #pragma omp parallel for schedule(static,1)
653  for (int k = 0; k < number_of_threads; k++)
654  {
655  ModelPart::ElementIterator it_begin = BaseType::GetModelPart().ElementsBegin() + elem_partition[k];
656  ModelPart::ElementIterator it_end = BaseType::GetModelPart().ElementsBegin() + elem_partition[k + 1];
657  for (ModelPart::ElementIterator i = it_begin; i != it_end; ++i)
658  {
660  }
661  }
662 
663 
664 #pragma omp parallel for schedule(static,1)
665  for (int k = 0; k < number_of_threads; k++)
666  {
667  ModelPart::NodeIterator it_begin = BaseType::GetModelPart().NodesBegin() + partition[k];
668  ModelPart::NodeIterator it_end = BaseType::GetModelPart().NodesBegin() + partition[k + 1];
669 
670  for (ModelPart::NodeIterator i = it_begin; i != it_end; ++i)
671  {
672  if(i->FastGetSolutionStepValue(NODAL_MASS)==0.0)
673  {
674  i->FastGetSolutionStepValue(PRESSURE)=0.0;
675  }
676  else
677  {
678  //if()
679  i->FastGetSolutionStepValue(PRESSURE)=i->FastGetSolutionStepValue(PRESSUREAUX) * (1.0/ i->FastGetSolutionStepValue(NODAL_MASS));
680  }
681 
682  }
683  }
684 
685 
686  KRATOS_CATCH("");
687 
688 
689  }
690 
691 
699  bool ConvergenceCheck(const double& normDx, double tol)
700  {
701  KRATOS_TRY;
702  double norm_v = 0.00;
703 
704 
705  for (ModelPart::NodeIterator i = BaseType::GetModelPart().NodesBegin();
707  {
708  const array_1d<double, 3 > & v = (i)->FastGetSolutionStepValue(VELOCITY);
709 
710  norm_v += v[0] * v[0];
711  norm_v += v[1] * v[1];
712  norm_v += v[2] * v[2];
713  }
714 
715  //BaseType::GetModelPart().GetCommunicator().SumAll(norm_v);
716 
717  double norm_v1 = sqrt(norm_v);
718 
719  if (norm_v1 == 0.0) norm_v1 = 1.00;
720 
721  double ratio = normDx / norm_v1;
722 
724  if (rank == 0) std::cout << "velocity ratio = " << ratio << std::endl;
725 
726 
727  if (ratio < tol)
728  {
729  if (rank == 0) std::cout << "convergence achieved" << std::endl;
730  return true;
731  }
732 
733  return false;
734 
735 
736  KRATOS_CATCH("");
737  }
738 
739 
740  void Compute()
741  {
742  KRATOS_TRY
743 
744 #ifdef _OPENMP
745  int number_of_threads = omp_get_max_threads();
746 #else
747  int number_of_threads = 1;
748 #endif
749 
750  array_1d<double,3> aux;
752 
754  const double dt = model_part.GetProcessInfo()[DELTA_TIME];
755 
756 
757  vector<unsigned int> partition;
758  CreatePartition(number_of_threads, BaseType::GetModelPart().Nodes().size(), partition);
759 
760 
761 
762 #pragma omp parallel for schedule(static,1)
763  for (int k = 0; k < number_of_threads; k++)
764  {
765  ModelPart::NodeIterator it_begin = BaseType::GetModelPart().NodesBegin() + partition[k];
766  ModelPart::NodeIterator it_end = BaseType::GetModelPart().NodesBegin() + partition[k + 1];
767 
768 
770 
771  //first of all set to zero the nodal variables to be updated nodally
772  for (ModelPart::NodeIterator i = it_begin; i != it_end; ++i)
773  {
774  noalias(i->FastGetSolutionStepValue(FORCE)) = zero;
775  (i)->FastGetSolutionStepValue(NODAL_MASS)=0.0;
776  }
777  }
778 
779  ProcessInfo& rCurrentProcessInfo = BaseType::GetModelPart().GetProcessInfo();
780  rCurrentProcessInfo[FRACTIONAL_STEP] = 6;
781 
782 
783  vector<unsigned int> elem_partition;
784  CreatePartition(number_of_threads, BaseType::GetModelPart().Elements().size(), elem_partition);
785 
786 #pragma omp parallel for schedule(static,1)
787  for (int k = 0; k < number_of_threads; k++)
788  {
789 
790  ModelPart::ElementIterator it_begin = BaseType::GetModelPart().ElementsBegin() + elem_partition[k];
791  ModelPart::ElementIterator it_end = BaseType::GetModelPart().ElementsBegin() + elem_partition[k + 1];
792 
793 
794  for (ModelPart::ElementIterator i = it_begin; i != it_end; ++i)
795  {
796 
798  }
799 
800  }
801 
802 
803 #pragma omp parallel for schedule(static,1)
804  for (int k = 0; k < number_of_threads; k++)
805  {
806  ModelPart::NodeIterator it_begin = BaseType::GetModelPart().NodesBegin() + partition[k];
807  ModelPart::NodeIterator it_end = BaseType::GetModelPart().NodesBegin() + partition[k + 1];
808 
809 
811 
812  //first of all set to zero the nodal variables to be updated nodally
813  for (ModelPart::NodeIterator i = it_begin; i != it_end; ++i)
814  {
815  array_1d<double,3>& force_temp = i->FastGetSolutionStepValue(FORCE);
816  force_temp -=i->FastGetSolutionStepValue(NODAL_MASS) * ((i)->FastGetSolutionStepValue(VELOCITY)-(i)->FastGetSolutionStepValue(VELOCITY,1))/dt;
817  }
818  }
819  KRATOS_CATCH("");
820  }
821 
822 
827  virtual void SetEchoLevel(int Level) override
828  {
829  mecho_level = Level;
830  mpfracvel_strategy->SetEchoLevel(Level);
831  mppressurestep->SetEchoLevel(Level);
832  }
833 
834 
835  virtual void Clear() override
836  {
838  if (rank == 0) KRATOS_WATCH("FracStepStrategy Clear Function called");
839  mpfracvel_strategy->Clear();
840  mppressurestep->Clear();
841  }
842 
843  virtual double GetStageResidualNorm(unsigned int step)
844  {
845  if (step <= 3)
846  return mpfracvel_strategy->GetResidualNorm();
847  if (step == 4)
848  return mppressurestep->GetResidualNorm();
849  else
850  return 0.0;
851  }
852 
853 
854 
882  protected:
890  typename BaseType::Pointer mpfracvel_strategy;
891  typename BaseType::Pointer mppressurestep;
892 
897  unsigned int mtime_order;
898  unsigned int mprediction_order;
902 
904 
905 
934  private:
942  unsigned int m_step;
943  unsigned int mdomain_size;
944  bool proj_is_initialized;
945 
946  //GenerateSlipConditionProcess::Pointer mpSlipProcess;
947  bool mHasSlipProcess;
948 
949  std::vector< Process::Pointer > mInitializeIterationProcesses;
950 
951  inline void CreatePartition(unsigned int number_of_threads, const int number_of_rows, vector<unsigned int>& partitions)
952  {
953  partitions.resize(number_of_threads + 1);
954  int partition_size = number_of_rows / number_of_threads;
955  partitions[0] = 0;
956  partitions[number_of_threads] = number_of_rows;
957  for (unsigned int i = 1; i < number_of_threads; i++)
958  partitions[i] = partitions[i - 1] + partition_size;
959  }
960 
961 
962 
963 
967  //this funcion is needed to ensure that all the memory is allocated correctly
968 
969 
991  FracStepStrategy(const FracStepStrategy& Other);
992 
993 
996  }; /* Class FracStepStrategy */
997 
1006 } /* namespace Kratos.*/
1007 
1008 #endif /* KRATOS_RESIDUALBASED_FRACTIONALSTEP_STRATEGY defined */
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
virtual int MyPID() const
Definition: communicator.cpp:91
Short class definition.
Definition: fracstep_GLS_strategy.h:109
unsigned int mtime_order
Definition: fracstep_GLS_strategy.h:897
unsigned int mprediction_order
Definition: fracstep_GLS_strategy.h:898
BaseType::DofsArrayType DofsArrayType
Definition: fracstep_GLS_strategy.h:123
bool mpredictor_corrector
Definition: fracstep_GLS_strategy.h:899
FracStepStrategy(ModelPart &model_part, typename TLinearSolver::Pointer pNewVelocityLinearSolver, typename TLinearSolver::Pointer pNewPressureLinearSolver, bool ReformDofAtEachIteration=true, double velocity_toll=0.01, double pressure_toll=0.01, int MaxVelocityIterations=3, int MaxPressureIterations=1, unsigned int time_order=2, unsigned int domain_size=2, bool predictor_corrector=false)
Definition: fracstep_GLS_strategy.h:160
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: fracstep_GLS_strategy.h:117
bool muse_dt_in_stabilization
Definition: fracstep_GLS_strategy.h:903
virtual double GetStageResidualNorm(unsigned int step)
Definition: fracstep_GLS_strategy.h:843
virtual void Clear() override
Clears the internal storage.
Definition: fracstep_GLS_strategy.h:835
double SavePressureIteration()
Definition: fracstep_GLS_strategy.h:325
void AssignInitialStepValues()
Definition: fracstep_GLS_strategy.h:349
BaseType::TDataType TDataType
Definition: fracstep_GLS_strategy.h:119
double Solve() override
Definition: fracstep_GLS_strategy.h:232
void SolveStepaux()
Definition: fracstep_GLS_strategy.h:609
bool ConvergenceCheck(const double &normDx, double tol)
Definition: fracstep_GLS_strategy.h:699
void SolveStep1(double velocity_toll, int MaxIterations)
Definition: fracstep_GLS_strategy.h:373
double IterativeSolve()
Definition: fracstep_GLS_strategy.h:268
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: fracstep_GLS_strategy.h:129
double mpressure_toll
Definition: fracstep_GLS_strategy.h:894
BaseType::TSystemMatrixType TSystemMatrixType
Definition: fracstep_GLS_strategy.h:125
void SolveStep3()
Definition: fracstep_GLS_strategy.h:532
double FractionalVelocityIteration()
Definition: fracstep_GLS_strategy.h:402
int mMaxPressIterations
Definition: fracstep_GLS_strategy.h:896
double SolveStep2()
Definition: fracstep_GLS_strategy.h:519
virtual ~FracStepStrategy()
Definition: fracstep_GLS_strategy.h:225
KRATOS_CLASS_POINTER_DEFINITION(FracStepStrategy)
double SolvePressure()
Definition: fracstep_GLS_strategy.h:256
BaseType::TSystemVectorType TSystemVectorType
Definition: fracstep_GLS_strategy.h:127
bool mReformDofAtEachIteration
Definition: fracstep_GLS_strategy.h:900
void Compute()
Definition: fracstep_GLS_strategy.h:740
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: fracstep_GLS_strategy.h:131
void SolveStep7()
Definition: fracstep_GLS_strategy.h:486
void SolveStep4()
Definition: fracstep_GLS_strategy.h:412
BaseType::Pointer mppressurestep
Definition: fracstep_GLS_strategy.h:891
OpenMPUtils::PartitionVector PartitionVector
Definition: fracstep_GLS_strategy.h:133
int mecho_level
Definition: fracstep_GLS_strategy.h:901
double mvelocity_toll
Definition: fracstep_GLS_strategy.h:893
virtual void SetEchoLevel(int Level) override
Definition: fracstep_GLS_strategy.h:827
int mMaxVelIterations
Definition: fracstep_GLS_strategy.h:895
BaseType::Pointer mpfracvel_strategy
Definition: fracstep_GLS_strategy.h:890
Implicit solving strategy base class This is the base class from which we will derive all the implici...
Definition: implicit_solving_strategy.h:61
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
Communicator & GetCommunicator()
Definition: model_part.h:1821
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
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
MeshType::ElementIterator ElementIterator
Definition: model_part.h:174
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
std::vector< int > PartitionVector
Vector type for the output of DivideInPartitions method.
Definition: openmp_utils.h:53
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
Current class provides an implementation for standard builder and solving operations.
Definition: residualbased_block_builder_and_solver.h:82
This class provides the implementation of a static scheme.
Definition: residualbased_incrementalupdate_static_scheme.h:57
This is a very simple strategy to solve linearly the problem.
Definition: residualbased_linear_strategy.h:64
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
TDenseSpace::MatrixType LocalSystemMatrixType
Definition: solving_strategy.h:79
virtual void InitializeSolutionStep()
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: solving_strategy.h:224
TSparseSpace::DataType TDataType
Definition: solving_strategy.h:69
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
TSparseSpace::MatrixType TSystemMatrixType
Definition: solving_strategy.h:71
TSparseSpace::VectorType TSystemVectorType
Definition: solving_strategy.h:73
TDenseSpace::VectorType LocalSystemVectorType
Definition: solving_strategy.h:81
This utility can be used to compute the time employed on computations.
Definition: timer.h:63
static void Start(std::string const &rIntervalName)
This method starts the timer meassures.
Definition: timer.cpp:109
static void Stop(std::string const &rIntervalName)
This method stops the timer meassures.
Definition: timer.cpp:125
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
dt
Definition: DEM_benchmarks.py:173
iteration
Definition: DEM_benchmarks.py:172
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int time_order
Definition: ProjectParameters.py:51
int domain_size
Definition: face_heat.py:4
time
Definition: face_heat.py:85
int step
Definition: face_heat.py:88
model_part
Definition: face_heat.py:14
bool predictor_corrector
Definition: fluid_only_var.py:8
v
Definition: generate_convection_diffusion_explicit_element.py:114
int tol
Definition: hinsberg_optimization.py:138
float aux1
Definition: isotropic_damage_automatic_differentiation.py:239
int k
Definition: quadrature.py:595
A
Definition: sensitivityMatrix.py:70
p
Definition: sensitivityMatrix.py:52
integer i
Definition: TensorModule.f:17
zero
Definition: test_pureconvectionsolver_benchmarking.py:94
ReformDofAtEachIteration
Definition: test_pureconvectionsolver_benchmarking.py:131
e
Definition: run_cpp_mpi_tests.py:31