msbGrid  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
stepper.hh
Go to the documentation of this file.
1 /*****************************************************************************
2 * This program is part of the msbGrid software *
3 * *
4 * msbGrid stands for multi-structured block Grid generator *
5 * *
6 * msbGrid is a free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * msbGrid is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * See the file COPYING for full copying permissions. *
17 *****************************************************************************/
23 #ifndef _STEPPER_HH_
24 #define _STEPPER_HH_
25 
26 namespace msbGrid
27 {
28 template< typename GridFactoryT >
29 class Stepper;
30 }
31 
32 template< typename GridFactoryT >
33 class msbGrid :: Stepper
34 {
35 public:
36  typedef GridFactoryT GridFactory;
37 
38  typedef typename GridFactory :: Scalar Scalar;
39  enum { dim = GridFactory :: dim };
40 
42 
43  typedef typename GridFactory :: Point Point;
44  typedef typename GridFactory :: Edge Edge;
45  typedef typename GridFactory :: Cell Cell;
46 
47 private:
48  int Id_;
49  int iStepMax_;
51 
52  bool otherStep_;
53  bool firstStep_;
54 
55  std :: vector< bool > newStep_;
56  std :: vector< Scalar > velocity_;
57 
58 public:
59  Stepper(const int &iStepMax0 = 1e4)
60  {
61  iStepMax_ = iStepMax0;
62  init();
63  }
64 
65  ~Stepper() {}
66 
67  void init(const int &blockNumber0 = 0)
68  {
69  Id_ = 0;
70 
71  firstStep_ = true;
72  otherStep_ = true;
73 
74  stepperSize_ = blockNumber0;
75 
76  newStep_.resize(stepperSize_);
77  newStep_.assign(stepperSize_, true);
78 
79  velocity_.resize(stepperSize_);
80  velocity_.assign( stepperSize_, Scalar(1.0) );
81  }
82 
83  void reset()
84  {
85  assert(stepperSize_ != 0);
86 
87  init(stepperSize_);
88  }
89 
90  const int &Id() const
91  { return Id_; }
92 
93  int &Id()
94  { return Id_; }
95 
96  const int &iStepMax() const
97  { return iStepMax_; }
98 
99  int &iStepMax()
100  { return iStepMax_; }
101 
102  const int &stepperSize() const
103  { return stepperSize_; }
104 
105  int &stepperSize()
106  { return stepperSize_; }
107 
108  const bool &otherStep() const
109  { return otherStep_; }
110 
111  bool &otherStep()
112  { return otherStep_; }
113 
114  const bool &firstStep() const
115  { return firstStep_; }
116 
117  bool &firstStep()
118  { return firstStep_; }
119 
120  const std :: vector< bool > &newStep() const
121  { return newStep_; }
122 
123  std :: vector< bool > &newStep()
124  { return newStep_; }
125 
126  const std :: vector< Scalar > &velocity() const
127  { return velocity_; }
128 
129  std :: vector< Scalar > &velocity()
130  { return velocity_; }
131 };
132 
133 #endif /* #ifndef _STEPPER_HH_ */