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.
trilinos_fractional_step_settings_periodic.h
Go to the documentation of this file.
1 #ifndef KRATOS_TRILINOS_FRACTIONAL_STEP_SETTINGS_PERIODIC_H
2 #define KRATOS_TRILINOS_FRACTIONAL_STEP_SETTINGS_PERIODIC_H
3 
4 // System includes
5 
6 // External includes
7 #include "Epetra_MpiComm.h"
8 
9 // Project includes
12 
13 // Application includes
16 
17 // FluidDynamicsApplication dependences
18 #include "../FluidDynamicsApplication/custom_utilities/solver_settings.h"
19 
20 namespace Kratos
21 {
24 
27 
31 
35 
39 
43 
45 template< class TSparseSpace,
46  class TDenseSpace,
47  class TLinearSolver
48  >
49 class TrilinosFractionalStepSettingsPeriodic: public SolverSettings<TSparseSpace,TDenseSpace,TLinearSolver>
50 {
51 public:
54 
57 
59 
63 
66 
70 
73  ModelPart& rModelPart,
74  const unsigned int ThisDomainSize,
75  const unsigned int ThisTimeOrder,
76  const bool UseSlip,
77  const bool MoveMeshFlag,
78  const bool ReformDofSet,
79  const Kratos::Variable<int>& rPeriodicVar):
80  SolverSettings<TSparseSpace,TDenseSpace,TLinearSolver>(rModelPart,ThisDomainSize,ThisTimeOrder,UseSlip,MoveMeshFlag,ReformDofSet),
81  mrComm(rComm),
82  mrPeriodicVar(rPeriodicVar)
83  {}
84 
87 
91 
92 
96 
100 
101  void SetStrategy(StrategyLabel const& rStrategyLabel,
102  typename TLinearSolver::Pointer pLinearSolver,
103  const double Tolerance,
104  const unsigned int MaxIter) override
105  {
106  KRATOS_TRY;
107 
108  // pointer types for solution strategy construcion
109  typedef typename Scheme< TSparseSpace, TDenseSpace >::Pointer SchemePointerType;
110  //~ typedef typename ConvergenceCriteria< TSparseSpace, TDenseSpace >::Pointer ConvergenceCriteriaPointerType;
111  typedef typename BuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver>::Pointer BuilderSolverTypePointer;
112 
113  // Default, fixed flags
114  bool CalculateReactions = false;
115  bool CalculateNormDxFlag = true;
116 
117  // Trilinos defaults
118  int RowSizeGuess;
119  if(this->GetDomainSize() == 2)
120  RowSizeGuess = 15;
121  else
122  RowSizeGuess = 40;
123 
124  ModelPart& rModelPart = this->GetModelPart();
125  bool ReformDofSet = this->GetReformDofSet();
126  bool UseSlip = this->UseSlipConditions();
127  unsigned int EchoLevel = this->GetEchoLevel();
128 
129  if ( rStrategyLabel == BaseType::Velocity )
130  {
131  // Velocity Builder and Solver
132  BuilderSolverTypePointer pBuildAndSolver = Kratos::make_shared<TrilinosBlockBuilderAndSolverPeriodic<TSparseSpace, TDenseSpace, TLinearSolver > >(mrComm,RowSizeGuess,pLinearSolver,mrPeriodicVar);
133 
134  SchemePointerType pScheme;
135  //initializing fractional velocity solution step
136  if (UseSlip)
137  {
138  double DomainSize = this->GetDomainSize();
139  SchemePointerType Temp = Kratos::make_shared<ResidualBasedIncrementalUpdateStaticSchemeSlip< TSparseSpace, TDenseSpace > >(DomainSize,DomainSize);
140  pScheme.swap(Temp);
141  }
142  else
143  {
144  SchemePointerType Temp = Kratos::make_shared< ResidualBasedIncrementalUpdateStaticScheme< TSparseSpace, TDenseSpace > >();
145  pScheme.swap(Temp);
146  }
147 
148  // Strategy
149  this->mStrategies[BaseType::Velocity] = Kratos::make_shared< ResidualBasedLinearStrategy<TSparseSpace, TDenseSpace, TLinearSolver > >(rModelPart, pScheme, pBuildAndSolver, CalculateReactions, ReformDofSet, CalculateNormDxFlag);
150 
151  }
152  else if ( rStrategyLabel == BaseType::Pressure )
153  {
154  // Pressure Builder and Solver
155  BuilderSolverTypePointer pBuildAndSolver = Kratos::make_shared< TrilinosBlockBuilderAndSolverPeriodic<TSparseSpace, TDenseSpace, TLinearSolver> >(mrComm,RowSizeGuess,pLinearSolver,mrPeriodicVar);
156  SchemePointerType pScheme = Kratos::make_shared< ResidualBasedIncrementalUpdateStaticScheme< TSparseSpace, TDenseSpace > >();
157 
158  // Strategy
159  this->mStrategies[BaseType::Pressure] = Kratos::make_shared< ResidualBasedLinearStrategy<TSparseSpace, TDenseSpace, TLinearSolver > >(
160  rModelPart,
161  pScheme,
162  pBuildAndSolver,
163  CalculateReactions,
164  ReformDofSet,
165  CalculateNormDxFlag);
166  }
167  else
168  {
169  KRATOS_THROW_ERROR(std::runtime_error,"Error in TrilinosFractionalStepSettingsPeriodic: Unknown strategy label.","");
170  }
171 
172  this->mTolerances[rStrategyLabel] = Tolerance;
173 
174  this->mMaxIter[rStrategyLabel] = MaxIter;
175 
176  this->mStrategies[rStrategyLabel]->SetEchoLevel(EchoLevel);
177 
178  KRATOS_CATCH("");
179  }
180 
181  void SetTurbulenceModel(TurbulenceModelLabel const& rTurbulenceModel,
182  typename TLinearSolver::Pointer pLinearSolver,
183  const double Tolerance,
184  const unsigned int MaxIter) override
185  {
186  KRATOS_TRY;
187 
188  this->mHaveTurbulenceModel = true;
189 
190  ModelPart& rModelPart = this->GetModelPart();
191  double DomainSize = this->GetDomainSize();
192  bool ReformDofSet = this->GetReformDofSet();
193  unsigned int TimeOrder = this->GetTimeOrder();
194 
195  if (rTurbulenceModel == BaseType::SpalartAllmaras)
196  {
197  this->mpTurbulenceModel = Kratos::make_shared< TrilinosSpalartAllmarasTurbulenceModel<TSparseSpace,TDenseSpace,TLinearSolver> >(mrComm,rModelPart,pLinearSolver,DomainSize,Tolerance,MaxIter,ReformDofSet,TimeOrder);
198  }
199  else
200  {
201  KRATOS_THROW_ERROR(std::runtime_error,"Error in TrilinosFractionalStepSettingsPeriodic: Unknown turbulence model label.","");
202  }
203 
204  KRATOS_CATCH("");
205  }
206 
207  void SetTurbulenceModel(ProcessPointerType pTurbulenceModel) override
208  {
209  BaseType::SetTurbulenceModel(pTurbulenceModel);
210  }
211 
215 
219 
221  std::string Info() const override
222  {
223  std::stringstream buffer;
224  buffer << "TrilinosFractionalStepSettingsPeriodic" ;
225  return buffer.str();
226  }
227 
229  void PrintInfo(std::ostream& rOStream) const override {rOStream << "TrilinosFractionalStepSettingsPeriodic";}
230 
232  void PrintData(std::ostream& rOStream) const override {}
233 
234 
238 
239 
241 
242 protected:
245 
246 
250 
251 
255 
256 
260 
261 
265 
266 
270 
271 
275 
276 
278 
279 private:
282 
283 
287 
288  Epetra_MpiComm& mrComm;
289 
290  const Kratos::Variable<int>& mrPeriodicVar;
291 
295 
296 
300 
301 
305 
306 
310 
311 
315 
318 
320  TrilinosFractionalStepSettingsPeriodic& operator=(TrilinosFractionalStepSettingsPeriodic const& rOther){}
321 
323  TrilinosFractionalStepSettingsPeriodic(TrilinosFractionalStepSettingsPeriodic const& rOther){}
324 
325 
327 
328 }; // Class TrilinosFractionalStepSettingsPeriodic
329 
331 
334 
335 
339 
340 
342 template< class TDenseSpace, class TSparseSpace, class TLinearSolver >
343 inline std::istream& operator >> (std::istream& rIStream,
345 {
346  return rIStream;
347 }
348 
350 template< class TDenseSpace, class TSparseSpace, class TLinearSolver >
351 inline std::ostream& operator << (std::ostream& rOStream,
353 {
354  rThis.PrintInfo(rOStream);
355  rOStream << std::endl;
356  rThis.PrintData(rOStream);
357 
358  return rOStream;
359 }
361 
363 
364 } // namespace Kratos.
365 
366 #endif // KRATOS_TRILINOS_FRACTIONAL_STEP_SETTINGS_PERIODIC_H
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
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
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
Helper class to define solution strategies for FS_Strategy.
Definition: solver_settings.h:53
StrategyLabel
Definition: solver_settings.h:66
@ Velocity
Definition: solver_settings.h:66
@ Pressure
Definition: solver_settings.h:66
virtual unsigned int GetDomainSize() const
Definition: solver_settings.h:146
ModelPart & GetModelPart()
Definition: solver_settings.h:285
virtual void SetTurbulenceModel(TurbulenceModelLabel const &rTurbulenceModel, typename TLinearSolver::Pointer pLinearSolver, const double Tolerance, const unsigned int MaxIter)
Definition: solver_settings.h:124
bool GetReformDofSet()
Definition: solver_settings.h:226
StrategyType::Pointer StrategyPointerType
Definition: solver_settings.h:62
virtual bool UseSlipConditions() const
Definition: solver_settings.h:156
std::map< StrategyLabel, double > mTolerances
Definition: solver_settings.h:292
std::map< StrategyLabel, StrategyPointerType > mStrategies
Definition: solver_settings.h:290
std::map< StrategyLabel, unsigned int > mMaxIter
Definition: solver_settings.h:294
Process::Pointer ProcessPointerType
Definition: solver_settings.h:63
virtual unsigned int GetEchoLevel()
Definition: solver_settings.h:221
TurbulenceModelLabel
Definition: solver_settings.h:68
@ SpalartAllmaras
Definition: solver_settings.h:68
bool mHaveTurbulenceModel
Definition: solver_settings.h:298
ProcessPointerType mpTurbulenceModel
Definition: solver_settings.h:296
virtual unsigned int GetTimeOrder() const
Definition: solver_settings.h:151
Helper class to define solution strategies for FS_Strategy.
Definition: trilinos_fractional_step_settings_periodic.h:50
KRATOS_CLASS_POINTER_DEFINITION(TrilinosFractionalStepSettingsPeriodic)
Pointer definition of TrilinosFractionalStepSettingsPeriodic.
SolverSettings< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: trilinos_fractional_step_settings_periodic.h:58
BaseType::StrategyType StrategyType
Definition: trilinos_fractional_step_settings_periodic.h:60
BaseType::StrategyLabel StrategyLabel
Definition: trilinos_fractional_step_settings_periodic.h:64
void SetStrategy(StrategyLabel const &rStrategyLabel, typename TLinearSolver::Pointer pLinearSolver, const double Tolerance, const unsigned int MaxIter) override
Definition: trilinos_fractional_step_settings_periodic.h:101
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: trilinos_fractional_step_settings_periodic.h:232
void SetTurbulenceModel(ProcessPointerType pTurbulenceModel) override
Definition: trilinos_fractional_step_settings_periodic.h:207
std::string Info() const override
Turn back information as a string.
Definition: trilinos_fractional_step_settings_periodic.h:221
BaseType::ProcessPointerType ProcessPointerType
Definition: trilinos_fractional_step_settings_periodic.h:62
TrilinosFractionalStepSettingsPeriodic(Epetra_MpiComm &rComm, ModelPart &rModelPart, const unsigned int ThisDomainSize, const unsigned int ThisTimeOrder, const bool UseSlip, const bool MoveMeshFlag, const bool ReformDofSet, const Kratos::Variable< int > &rPeriodicVar)
Constructor.
Definition: trilinos_fractional_step_settings_periodic.h:72
void SetTurbulenceModel(TurbulenceModelLabel const &rTurbulenceModel, typename TLinearSolver::Pointer pLinearSolver, const double Tolerance, const unsigned int MaxIter) override
Definition: trilinos_fractional_step_settings_periodic.h:181
BaseType::TurbulenceModelLabel TurbulenceModelLabel
Definition: trilinos_fractional_step_settings_periodic.h:65
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: trilinos_fractional_step_settings_periodic.h:229
virtual ~TrilinosFractionalStepSettingsPeriodic()
Destructor.
Definition: trilinos_fractional_step_settings_periodic.h:86
BaseType::StrategyPointerType StrategyPointerType
Definition: trilinos_fractional_step_settings_periodic.h:61
#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
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
Temp
Definition: PecletTest.py:105