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.h
Go to the documentation of this file.
1 #ifndef KRATOS_TRILINOS_FRACTIONAL_STEP_SETTINGS_H
2 #define KRATOS_TRILINOS_FRACTIONAL_STEP_SETTINGS_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 TrilinosFractionalStepSettings: public SolverSettings<TSparseSpace,TDenseSpace,TLinearSolver>
50 {
51 public:
54 
57 
59 
63 
66 
70 
72  TrilinosFractionalStepSettings(Epetra_MpiComm& rComm,
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  SolverSettings<TSparseSpace,TDenseSpace,TLinearSolver>(rModelPart,ThisDomainSize,ThisTimeOrder,UseSlip,MoveMeshFlag,ReformDofSet),
80  mrComm(rComm)
81  {}
82 
85 
89 
90 
94 
98 
99  void SetStrategy(StrategyLabel const& rStrategyLabel,
100  typename TLinearSolver::Pointer pLinearSolver,
101  const double Tolerance,
102  const unsigned int MaxIter) override
103  {
104  KRATOS_TRY;
105 
106  // pointer types for solution strategy construcion
107  typedef typename Scheme< TSparseSpace, TDenseSpace >::Pointer SchemePointerType;
108  //~ typedef typename ConvergenceCriteria< TSparseSpace, TDenseSpace >::Pointer ConvergenceCriteriaPointerType;
109  typedef typename BuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver>::Pointer BuilderSolverTypePointer;
110 
111  // Default, fixed flags
112  bool CalculateReactions = false;
113  bool CalculateNormDxFlag = true;
114 
115  // Trilinos defaults
116  int RowSizeGuess;
117  if(this->GetDomainSize() == 2)
118  RowSizeGuess = 15;
119  else
120  RowSizeGuess = 40;
121 
122  ModelPart& rModelPart = this->GetModelPart();
123  bool ReformDofSet = this->GetReformDofSet();
124  bool UseSlip = this->UseSlipConditions();
125  unsigned int EchoLevel = this->GetEchoLevel();
126 
127  if ( rStrategyLabel == BaseType::Velocity )
128  {
129  // Velocity Builder and Solver
130  BuilderSolverTypePointer pBuildAndSolver = BuilderSolverTypePointer(new TrilinosBlockBuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver > (mrComm,RowSizeGuess,pLinearSolver));
131 
132  SchemePointerType pScheme;
133  //initializing fractional velocity solution step
134  if (UseSlip)
135  {
136  double DomainSize = this->GetDomainSize();
137  SchemePointerType Temp = SchemePointerType(new ResidualBasedIncrementalUpdateStaticSchemeSlip< TSparseSpace, TDenseSpace > (DomainSize,DomainSize));
138  pScheme.swap(Temp);
139  }
140  else
141  {
142  SchemePointerType Temp = SchemePointerType(new ResidualBasedIncrementalUpdateStaticScheme< TSparseSpace, TDenseSpace > ());
143  pScheme.swap(Temp);
144  }
145 
146  // Strategy
148  rModelPart,
149  pScheme,
150  pBuildAndSolver,
151  CalculateReactions,
152  ReformDofSet,
153  CalculateNormDxFlag));
154 
155  }
156  else if ( rStrategyLabel == BaseType::Pressure )
157  {
158  // Pressure Builder and Solver
159  BuilderSolverTypePointer pBuildAndSolver = BuilderSolverTypePointer(new TrilinosBlockBuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver >(mrComm,RowSizeGuess,pLinearSolver));
160  SchemePointerType pScheme = SchemePointerType(new ResidualBasedIncrementalUpdateStaticScheme< TSparseSpace, TDenseSpace > ());
161 
162  // Strategy
164  rModelPart,
165  pScheme,
166  pBuildAndSolver,
167  CalculateReactions,
168  ReformDofSet,
169  CalculateNormDxFlag));
170  }
171  else
172  {
173  KRATOS_THROW_ERROR(std::runtime_error,"Error in TrilinosFractionalStepSettings: Unknown strategy label.","");
174  }
175 
176  this->mTolerances[rStrategyLabel] = Tolerance;
177 
178  this->mMaxIter[rStrategyLabel] = MaxIter;
179 
180  this->mStrategies[rStrategyLabel]->SetEchoLevel(EchoLevel);
181 
182  KRATOS_CATCH("");
183  }
184 
185  void SetTurbulenceModel(TurbulenceModelLabel const& rTurbulenceModel,
186  typename TLinearSolver::Pointer pLinearSolver,
187  const double Tolerance,
188  const unsigned int MaxIter) override
189  {
190  KRATOS_TRY;
191 
192  this->mHaveTurbulenceModel = true;
193 
194  ModelPart& rModelPart = this->GetModelPart();
195  double DomainSize = this->GetDomainSize();
196  bool ReformDofSet = this->GetReformDofSet();
197  unsigned int TimeOrder = this->GetTimeOrder();
198 
199  if (rTurbulenceModel == BaseType::SpalartAllmaras)
200  {
201  this->mpTurbulenceModel = ProcessPointerType( new TrilinosSpalartAllmarasTurbulenceModel<TSparseSpace,TDenseSpace,TLinearSolver>(mrComm,rModelPart,pLinearSolver,DomainSize,Tolerance,MaxIter,ReformDofSet,TimeOrder));
202  }
203  else
204  {
205  KRATOS_THROW_ERROR(std::runtime_error,"Error in TrilinosFractionalStepSettings: Unknown turbulence model label.","");
206  }
207 
208  KRATOS_CATCH("");
209  }
210 
211  void SetTurbulenceModel(ProcessPointerType pTurbulenceModel) override
212  {
213  BaseType::SetTurbulenceModel(pTurbulenceModel);
214  }
215 
219 
223 
225  std::string Info() const override
226  {
227  std::stringstream buffer;
228  buffer << "TrilinosFractionalStepSettings" ;
229  return buffer.str();
230  }
231 
233  void PrintInfo(std::ostream& rOStream) const override {rOStream << "TrilinosFractionalStepSettings";}
234 
236  void PrintData(std::ostream& rOStream) const override {}
237 
238 
242 
243 
245 
246 protected:
249 
250 
254 
255 
259 
260 
264 
265 
269 
270 
274 
275 
279 
280 
282 
283 private:
286 
287 
291 
292  Epetra_MpiComm& mrComm;
293 
297 
298 
302 
303 
307 
308 
312 
313 
317 
320 
322  TrilinosFractionalStepSettings& operator=(TrilinosFractionalStepSettings const& rOther){}
323 
325  TrilinosFractionalStepSettings(TrilinosFractionalStepSettings const& rOther){}
326 
327 
329 
330 }; // Class TrilinosFractionalStepSettings
331 
333 
336 
337 
341 
342 
344 template< class TDenseSpace, class TSparseSpace, class TLinearSolver >
345 inline std::istream& operator >> (std::istream& rIStream,
347 {
348  return rIStream;
349 }
350 
352 template< class TDenseSpace, class TSparseSpace, class TLinearSolver >
353 inline std::ostream& operator << (std::ostream& rOStream,
355 {
356  rThis.PrintInfo(rOStream);
357  rOStream << std::endl;
358  rThis.PrintData(rOStream);
359 
360  return rOStream;
361 }
363 
365 
366 } // namespace Kratos.
367 
368 #endif // KRATOS_TRILINOS_FRACTIONAL_STEP_SETTINGS_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 a static scheme.
Definition: residualbased_incrementalupdate_static_scheme.h:57
Scheme for the solution of problems involving a slip condition.
Definition: residualbased_incrementalupdate_static_scheme_slip.h:70
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
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
Current class provides an implementation for trilinos builder and solving operations.
Definition: trilinos_block_builder_and_solver.h:85
Helper class to define solution strategies for FS_Strategy.
Definition: trilinos_fractional_step_settings.h:50
void SetTurbulenceModel(ProcessPointerType pTurbulenceModel) override
Definition: trilinos_fractional_step_settings.h:211
BaseType::StrategyPointerType StrategyPointerType
Definition: trilinos_fractional_step_settings.h:61
void SetTurbulenceModel(TurbulenceModelLabel const &rTurbulenceModel, typename TLinearSolver::Pointer pLinearSolver, const double Tolerance, const unsigned int MaxIter) override
Definition: trilinos_fractional_step_settings.h:185
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: trilinos_fractional_step_settings.h:236
BaseType::TurbulenceModelLabel TurbulenceModelLabel
Definition: trilinos_fractional_step_settings.h:65
BaseType::ProcessPointerType ProcessPointerType
Definition: trilinos_fractional_step_settings.h:62
TrilinosFractionalStepSettings(Epetra_MpiComm &rComm, ModelPart &rModelPart, const unsigned int ThisDomainSize, const unsigned int ThisTimeOrder, const bool UseSlip, const bool MoveMeshFlag, const bool ReformDofSet)
Constructor.
Definition: trilinos_fractional_step_settings.h:72
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: trilinos_fractional_step_settings.h:233
BaseType::StrategyLabel StrategyLabel
Definition: trilinos_fractional_step_settings.h:64
SolverSettings< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: trilinos_fractional_step_settings.h:58
virtual ~TrilinosFractionalStepSettings()
Destructor.
Definition: trilinos_fractional_step_settings.h:84
KRATOS_CLASS_POINTER_DEFINITION(TrilinosFractionalStepSettings)
Pointer definition of TrilinosFractionalStepSettings.
std::string Info() const override
Turn back information as a string.
Definition: trilinos_fractional_step_settings.h:225
void SetStrategy(StrategyLabel const &rStrategyLabel, typename TLinearSolver::Pointer pLinearSolver, const double Tolerance, const unsigned int MaxIter) override
Definition: trilinos_fractional_step_settings.h:99
BaseType::StrategyType StrategyType
Definition: trilinos_fractional_step_settings.h:60
Trilinos implementation of the Spalart-Allmaras turbulence model.
Definition: trilinos_spalart_allmaras_turbulence_model.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