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.
solver_settings.h
Go to the documentation of this file.
1 #ifndef KRATOS_SOLVER_SETTINGS_H
2 #define KRATOS_SOLVER_SETTINGS_H
3 
4 // System includes
5 #include <string>
6 #include <iostream>
7 
8 
9 // External includes
10 
11 
12 // Project includes
13 #include "includes/define.h"
18 #include "processes/process.h"
19 
20 // Application includes
21 
22 
23 namespace Kratos
24 {
27 
30 
34 
38 
42 
46 
48 template< class TSparseSpace,
49  class TDenseSpace,
50  class TLinearSolver
51  >
53 {
54 public:
57 
60 
62  typedef typename StrategyType::Pointer StrategyPointerType;
63  typedef typename Process::Pointer ProcessPointerType;
65 
66  enum StrategyLabel { Velocity, Pressure, /*EddyViscosity,*/ NumLabels };
67 
69 
73 
76  const unsigned int ThisDomainSize,
77  const unsigned int ThisTimeOrder,
78  const bool UseSlip,
79  const bool MoveMeshFlag,
80  const bool ReformDofSet):
81  mStrategies(),
82  mHaveTurbulenceModel(false),
83  mrModelPart(rModelPart),
84  mDomainSize(ThisDomainSize),
85  mTimeOrder(ThisTimeOrder),
86  mEchoLevel(1),
87  mUseSlip(UseSlip),
88  mReformDofSet(ReformDofSet),
89  mMoveMeshFlag(MoveMeshFlag)
90  {}
91 
93  virtual ~SolverSettings(){}
94 
98 
99 
103 
107 
108  virtual StrategyPointerType pGetStrategy(StrategyLabel const& rStrategyLabel)
109  {
110  return mStrategies[rStrategyLabel];
111  }
112 
113  virtual void SetStrategy(StrategyLabel const& rStrategyLabel,
114  StrategyPointerType pStrategy)
115  {
116  mStrategies[rStrategyLabel] = pStrategy;
117  }
118 
119  virtual void SetStrategy(StrategyLabel const& rStrategyLabel,
120  typename TLinearSolver::Pointer pLinearSolver,
121  const double Tolerance,
122  const unsigned int MaxIter) = 0;
123 
124  virtual void SetTurbulenceModel(TurbulenceModelLabel const& rTurbulenceModel,
125  typename TLinearSolver::Pointer pLinearSolver,
126  const double Tolerance,
127  const unsigned int MaxIter) {}
128 
129  virtual void SetTurbulenceModel(ProcessPointerType pTurbulenceModel)
130  {
131  mpTurbulenceModel = ProcessPointerType(pTurbulenceModel);
132  mHaveTurbulenceModel = true;
133  }
134 
135  virtual bool GetTurbulenceModel(ProcessPointerType& pTurbulenceModel)
136  {
138  {
139  pTurbulenceModel.reset();
140  pTurbulenceModel = ProcessPointerType(mpTurbulenceModel);
141  }
142 
143  return mHaveTurbulenceModel;
144  }
145 
146  virtual unsigned int GetDomainSize() const
147  {
148  return mDomainSize;
149  }
150 
151  virtual unsigned int GetTimeOrder() const
152  {
153  return mTimeOrder;
154  }
155 
156  virtual bool UseSlipConditions() const
157  {
158  return mUseSlip;
159  }
160 
161  virtual bool MoveMesh() const
162  {
163  return mMoveMeshFlag;
164  }
165 
166  virtual bool FindStrategy(StrategyLabel const& rStrategyLabel,
167  StrategyPointerType& pThisStrategy)
168  {
169  typename std::map<StrategyLabel,StrategyPointerType>::iterator itStrategy = mStrategies.find(rStrategyLabel);
170 
171  if ( itStrategy != mStrategies.end() )
172  {
173  if(itStrategy->second != nullptr)
174  {
175  pThisStrategy.swap(itStrategy->second);
176  return true;
177  } else {
178  KRATOS_INFO("SolverSettingsFractionalStepStrategy")<<"Strategy for :: "<<rStrategyLabel<<" not found."<<std::endl;
179  return false;
180  }
181  }
182  else {
183  KRATOS_INFO("SolverSettingsFractionalStepStrategy")<<"Strategy for :: "<<rStrategyLabel<<" not found."<<std::endl;
184  return false;
185  }
186  }
187 
188  virtual bool FindTolerance(StrategyLabel const& rStrategyLabel,
189  double& rTolerance)
190  {
191  typename std::map< StrategyLabel,double >::iterator itTol = mTolerances.find(rStrategyLabel);
192  if ( itTol != mTolerances.end() )
193  {
194  rTolerance = itTol->second;
195  return true;
196  }
197  else
198  return false;
199  }
200 
201  virtual bool FindMaxIter(StrategyLabel const& rStrategyLabel,
202  unsigned int& rMaxIter)
203  {
204  typename std::map< StrategyLabel,unsigned int >::iterator itMaxIter = mMaxIter.find(rStrategyLabel);
205  if ( itMaxIter != mMaxIter.end() )
206  {
207  rMaxIter = itMaxIter->second;
208  return true;
209  }
210  else
211  return false;
212  }
213 
214  virtual void SetEchoLevel(unsigned int EchoLevel)
215  {
216  mEchoLevel = EchoLevel;
217  for (typename std::map< StrategyLabel, StrategyPointerType>::iterator itStrategy = mStrategies.begin(); itStrategy != mStrategies.end(); ++itStrategy)
218  (itStrategy->second)->SetEchoLevel(mEchoLevel);
219  }
220 
221  virtual unsigned int GetEchoLevel()
222  {
223  return mEchoLevel;
224  }
225 
227  {
228  return mReformDofSet;
229  }
230 
234 
238 
240  virtual std::string Info() const
241  {
242  std::stringstream buffer;
243  buffer << "SolverSettings" ;
244  return buffer.str();
245  }
246 
248  virtual void PrintInfo(std::ostream& rOStream) const {rOStream << "SolverSettings";}
249 
251  virtual void PrintData(std::ostream& rOStream) const {}
252 
253 
257 
258 
260 
261 protected:
264 
265 
269 
270 
274 
275 
279 
280 
284 
286  {
287  return mrModelPart;
288  }
289 
290  std::map< StrategyLabel, StrategyPointerType > mStrategies;
291 
292  std::map< StrategyLabel, double > mTolerances;
293 
294  std::map< StrategyLabel, unsigned int > mMaxIter;
295 
297 
299 
303 
304 
308 
309 
311 
312 private:
315 
316 
320 
321  ModelPart& mrModelPart;
322 
323  unsigned int mDomainSize;
324 
325  unsigned int mTimeOrder;
326 
327  unsigned int mEchoLevel;
328 
329  bool mUseSlip;
330 
331  bool mReformDofSet;
332 
333  bool mMoveMeshFlag;
334 
335 
339 
340 
344 
345 
349 
350 
354 
355 
359 
361  SolverSettings(){}
362 
364  SolverSettings& operator=(SolverSettings const& rOther){}
365 
367  SolverSettings(SolverSettings const& rOther){}
368 
369 
371 
372 }; // Class SolverSettings
373 
375 
378 
379 
383 
384 
386 template< class TDenseSpace, class TSparseSpace, class TLinearSolver >
387 inline std::istream& operator >> (std::istream& rIStream,
389 {
390  return rIStream;
391 }
392 
394 template< class TDenseSpace, class TSparseSpace, class TLinearSolver >
395 inline std::ostream& operator << (std::ostream& rOStream,
397 {
398  rThis.PrintInfo(rOStream);
399  rOStream << std::endl;
400  rThis.PrintData(rOStream);
401 
402  return rOStream;
403 }
405 
407 
408 } // namespace Kratos.
409 
410 #endif // KRATOS_SOLVER_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
Helper class to define solution strategies for FS_Strategy.
Definition: solver_settings.h:53
virtual std::string Info() const
Turn back information as a string.
Definition: solver_settings.h:240
KRATOS_CLASS_POINTER_DEFINITION(SolverSettings)
Pointer definition of SolverSettings.
StrategyLabel
Definition: solver_settings.h:66
@ Velocity
Definition: solver_settings.h:66
@ Pressure
Definition: solver_settings.h:66
@ NumLabels
Definition: solver_settings.h:66
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > StrategyType
Definition: solver_settings.h:61
virtual bool FindMaxIter(StrategyLabel const &rStrategyLabel, unsigned int &rMaxIter)
Definition: solver_settings.h:201
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: solver_settings.h:248
virtual void SetStrategy(StrategyLabel const &rStrategyLabel, typename TLinearSolver::Pointer pLinearSolver, const double Tolerance, const unsigned int MaxIter)=0
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
virtual bool MoveMesh() const
Definition: solver_settings.h:161
bool GetReformDofSet()
Definition: solver_settings.h:226
virtual void SetTurbulenceModel(ProcessPointerType pTurbulenceModel)
Definition: solver_settings.h:129
StrategyType::Pointer StrategyPointerType
Definition: solver_settings.h:62
virtual bool UseSlipConditions() const
Definition: solver_settings.h:156
SolverSettings(ModelPart &rModelPart, const unsigned int ThisDomainSize, const unsigned int ThisTimeOrder, const bool UseSlip, const bool MoveMeshFlag, const bool ReformDofSet)
Constructor.
Definition: solver_settings.h:75
virtual StrategyPointerType pGetStrategy(StrategyLabel const &rStrategyLabel)
Definition: solver_settings.h:108
std::map< StrategyLabel, double > mTolerances
Definition: solver_settings.h:292
virtual bool GetTurbulenceModel(ProcessPointerType &pTurbulenceModel)
Definition: solver_settings.h:135
virtual bool FindStrategy(StrategyLabel const &rStrategyLabel, StrategyPointerType &pThisStrategy)
Definition: solver_settings.h:166
std::map< StrategyLabel, StrategyPointerType > mStrategies
Definition: solver_settings.h:290
std::map< StrategyLabel, unsigned int > mMaxIter
Definition: solver_settings.h:294
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: solver_settings.h:251
BuilderAndSolver< TSparseSpace, TDenseSpace, TLinearSolver > TBuilderAndSolverType
Definition: solver_settings.h:64
Process::Pointer ProcessPointerType
Definition: solver_settings.h:63
virtual unsigned int GetEchoLevel()
Definition: solver_settings.h:221
TurbulenceModelLabel
Definition: solver_settings.h:68
@ NumTurbModels
Definition: solver_settings.h:68
@ SpalartAllmaras
Definition: solver_settings.h:68
virtual bool FindTolerance(StrategyLabel const &rStrategyLabel, double &rTolerance)
Definition: solver_settings.h:188
virtual ~SolverSettings()
Destructor.
Definition: solver_settings.h:93
bool mHaveTurbulenceModel
Definition: solver_settings.h:298
virtual void SetStrategy(StrategyLabel const &rStrategyLabel, StrategyPointerType pStrategy)
Definition: solver_settings.h:113
virtual void SetEchoLevel(unsigned int EchoLevel)
Definition: solver_settings.h:214
ProcessPointerType mpTurbulenceModel
Definition: solver_settings.h:296
virtual unsigned int GetTimeOrder() const
Definition: solver_settings.h:151
#define KRATOS_INFO(label)
Definition: logger.h:250
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