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 //
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_VP_SOLVER_SETTINGS_H
10 #define KRATOS_TWO_STEP_VP_SOLVER_SETTINGS_H
11 
12 // System includes
13 #include <string>
14 #include <iostream>
15 
16 // External includes
17 
18 // Project includes
19 #include "includes/define.h"
24 #include "processes/process.h"
25 
26 // Application includes
27 
28 namespace Kratos
29 {
32 
35 
39 
43 
47 
51 
53  template <class TSparseSpace,
54  class TDenseSpace,
55  class TLinearSolver>
57  {
58  public:
61 
64 
66  typedef typename StrategyType::Pointer StrategyPointerType;
67  typedef typename Process::Pointer ProcessPointerType;
68 
70  {
73  /*EddyViscosity,*/ NumLabels
74  };
75 
79 
82  const unsigned int ThisDomainSize,
83  const unsigned int ThisTimeOrder,
84  const bool ReformDofSet) : mStrategies(),
85  mrModelPart(rModelPart),
86  mDomainSize(ThisDomainSize),
87  mTimeOrder(ThisTimeOrder),
88  mEchoLevel(1),
89  mReformDofSet(ReformDofSet)
90  {
91  }
92 
95 
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 unsigned int GetDomainSize() const
125  {
126  return mDomainSize;
127  }
128 
129  virtual bool FindStrategy(StrategyLabel const &rStrategyLabel,
130  StrategyPointerType &pThisStrategy)
131  {
132  typename std::map<StrategyLabel, StrategyPointerType>::iterator itStrategy = mStrategies.find(rStrategyLabel);
133 
134  if (itStrategy != mStrategies.end())
135  {
136  pThisStrategy.swap(itStrategy->second);
137  return true;
138  }
139  else
140  return false;
141  }
142 
143  virtual bool FindTolerance(StrategyLabel const &rStrategyLabel,
144  double &rTolerance)
145  {
146  typename std::map<StrategyLabel, double>::iterator itTol = mTolerances.find(rStrategyLabel);
147  if (itTol != mTolerances.end())
148  {
149  rTolerance = itTol->second;
150  return true;
151  }
152  else
153  return false;
154  }
155 
156  virtual bool FindMaxIter(StrategyLabel const &rStrategyLabel,
157  unsigned int &rMaxIter)
158  {
159  typename std::map<StrategyLabel, unsigned int>::iterator itMaxIter = mMaxIter.find(rStrategyLabel);
160  if (itMaxIter != mMaxIter.end())
161  {
162  rMaxIter = itMaxIter->second;
163  return true;
164  }
165  else
166  return false;
167  }
168 
169  virtual void SetEchoLevel(unsigned int EchoLevel)
170  {
171  mEchoLevel = EchoLevel;
172  for (typename std::map<StrategyLabel, StrategyPointerType>::iterator itStrategy = mStrategies.begin(); itStrategy != mStrategies.end(); ++itStrategy)
173  (itStrategy->second)->SetEchoLevel(mEchoLevel);
174  }
175 
176  virtual unsigned int GetEchoLevel()
177  {
178  return mEchoLevel;
179  }
180 
182  {
183  return mReformDofSet;
184  }
185 
189 
193 
195  virtual std::string Info() const
196  {
197  std::stringstream buffer;
198  buffer << "TwoStepVPSolverSettings";
199  return buffer.str();
200  }
201 
203  virtual void PrintInfo(std::ostream &rOStream) const { rOStream << "TwoStepVPSolverSettings"; }
204 
206  virtual void PrintData(std::ostream &rOStream) const {}
207 
211 
213 
214  protected:
217 
221 
225 
229 
233 
235  {
236  return mrModelPart;
237  }
238 
239  std::map<StrategyLabel, StrategyPointerType> mStrategies;
240 
241  std::map<StrategyLabel, double> mTolerances;
242 
243  std::map<StrategyLabel, unsigned int> mMaxIter;
244 
248 
252 
254 
255  private:
258 
262 
263  ModelPart &mrModelPart;
264 
265  unsigned int mDomainSize;
266 
267  unsigned int mEchoLevel;
268 
269  unsigned int mTimeOrder;
270 
271  bool mReformDofSet;
272 
276 
280 
284 
288 
292 
295 
297  TwoStepVPSolverSettings &operator=(TwoStepVPSolverSettings const &rOther) {}
298 
300  TwoStepVPSolverSettings(TwoStepVPSolverSettings const &rOther) {}
301 
303 
304  }; // Class TwoStepVPSolverSettings
305 
307 
310 
314 
316  template <class TDenseSpace, class TSparseSpace, class TLinearSolver>
317  inline std::istream &operator>>(std::istream &rIStream,
319  {
320  return rIStream;
321  }
322 
324  template <class TDenseSpace, class TSparseSpace, class TLinearSolver>
325  inline std::ostream &operator<<(std::ostream &rOStream,
327  {
328  rThis.PrintInfo(rOStream);
329  rOStream << std::endl;
330  rThis.PrintData(rOStream);
331 
332  return rOStream;
333  }
335 
337 
338 } // namespace Kratos.
339 
340 #endif // KRATOS_TWO_STEP_VP_SOLVER_SETTINGS_H
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Solving strategy base class This is the base class from which we will derive all the strategies (impl...
Definition: solving_strategy.h:64
Helper class to define solution strategies for TwoStepVPStrategy.
Definition: solver_settings.h:57
SolvingStrategy< TSparseSpace, TDenseSpace > StrategyType
Definition: solver_settings.h:65
ModelPart & GetModelPart()
Definition: solver_settings.h:234
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: solver_settings.h:203
virtual bool FindTolerance(StrategyLabel const &rStrategyLabel, double &rTolerance)
Definition: solver_settings.h:143
StrategyLabel
Definition: solver_settings.h:70
@ Velocity
Definition: solver_settings.h:71
@ NumLabels
Definition: solver_settings.h:73
@ Pressure
Definition: solver_settings.h:72
KRATOS_CLASS_POINTER_DEFINITION(TwoStepVPSolverSettings)
Pointer definition of TwoStepVPSolverSettings.
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: solver_settings.h:206
virtual bool FindMaxIter(StrategyLabel const &rStrategyLabel, unsigned int &rMaxIter)
Definition: solver_settings.h:156
virtual unsigned int GetDomainSize() const
Definition: solver_settings.h:124
std::map< StrategyLabel, double > mTolerances
Definition: solver_settings.h:241
virtual unsigned int GetEchoLevel()
Definition: solver_settings.h:176
std::map< StrategyLabel, unsigned int > mMaxIter
Definition: solver_settings.h:243
virtual bool FindStrategy(StrategyLabel const &rStrategyLabel, StrategyPointerType &pThisStrategy)
Definition: solver_settings.h:129
Process::Pointer ProcessPointerType
Definition: solver_settings.h:67
StrategyType::Pointer StrategyPointerType
Definition: solver_settings.h:66
virtual StrategyPointerType pGetStrategy(StrategyLabel const &rStrategyLabel)
Definition: solver_settings.h:108
TwoStepVPSolverSettings(ModelPart &rModelPart, const unsigned int ThisDomainSize, const unsigned int ThisTimeOrder, const bool ReformDofSet)
Constructor.
Definition: solver_settings.h:81
bool GetReformDofSet()
Definition: solver_settings.h:181
virtual std::string Info() const
Turn back information as a string.
Definition: solver_settings.h:195
std::map< StrategyLabel, StrategyPointerType > mStrategies
Definition: solver_settings.h:239
virtual void SetEchoLevel(unsigned int EchoLevel)
Definition: solver_settings.h:169
virtual ~TwoStepVPSolverSettings()
Destructor.
Definition: solver_settings.h:94
virtual void SetStrategy(StrategyLabel const &rStrategyLabel, typename TLinearSolver::Pointer pLinearSolver, const double Tolerance, const unsigned int MaxIter)=0
virtual void SetStrategy(StrategyLabel const &rStrategyLabel, StrategyPointerType pStrategy)
Definition: solver_settings.h:113
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