msbGrid  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
inputdata.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 _INPUT_DATA_HH_
24 #define _INPUT_DATA_HH_
25 
26 namespace msbGrid
27 {
28 class InputData;
29 }
30 
31 class msbGrid :: InputData
32 {
33 private:
35  std :: vector< Scalar > blockNumberController_;
36  std :: string outputPath_, outputDirName_;
37  std :: vector< std :: pair< Scalar, Scalar > > blockCenter_;
38  std :: vector< Scalar > blockAngle_;
39  std :: vector< Color > blockColor_;
40 
41  /* secondary input data : needed just to add output comments in *.geo files */
42 
43  std :: string blockCenterDistribution_;
44  std :: string blockAngleDistribution_;
48 
49 public:
50  InputData(const Scalar & xMin
51  , const Scalar & xMax
52  , const std :: vector< Scalar > & blockNumberController
53  , const Scalar & dr
54  , const Scalar & rafCoeff
55  , const Scalar & dist2BoundCoeff
56  , const Scalar & interBlockDistCoeff
57  , const std :: string & outputPath
58  , const std :: string & outputDirName)
59  {
60  xMin_ = xMin;
61  xMax_ = xMax;
62  blockNumberController_ = blockNumberController;
63  dr_ = dr;
64  rafCoeff_ = rafCoeff;
65  dist2BoundCoeff_ = dist2BoundCoeff;
66  interBlockDistCoeff_ = interBlockDistCoeff;
67  outputPath_ = outputPath;
68  outputDirName_ = outputDirName;
69 
70  blockCenterRandSeqId_ = ( unsigned ) time(0);
71  blockAngleRandSeqId_ = ( unsigned ) time(0);
72  blockCenterPertCoeff_ = 0;
73  }
74 
75  InputData(const Scalar & xMin
76  , const Scalar & xMax
77  , const std :: vector< Scalar > & blockNumberController
78  , const Scalar & dr
79  , const Scalar & rafCoeff
80  , const Scalar & dist2BoundCoeff
81  , const Scalar & interBlockDistCoeff
82  , const std :: string & outputPath
83  , const std :: string & outputDirName
84  , const std :: vector< std :: pair< Scalar, Scalar > > & blockCenter
85  , const std :: vector< Scalar > & blockAngle) : InputData(xMin, xMax, blockNumberController, dr, rafCoeff, dist2BoundCoeff, interBlockDistCoeff, outputPath, outputDirName)
86  {
87  if ( blockCenter.size() < blockAngle.size() ) {
88  std :: cerr << "warning : blockCenter.size() < blockAngle.size() , additional angles will be ignored!!\n";
89  }
90 
91  if ( blockCenter.size() > blockAngle.size() ) {
92  std :: cerr << "warning : blockCenter.size() > blockAngle.size() , additional angles will be randomly generated!!\n";
93  }
94 
95  blockCenter_.clear();
96  blockAngle_.clear();
97  blockColor_.clear();
98  for ( unsigned int ib = 0; ib < blockCenter.size(); ++ib ) {
99  blockCenter_.push_back(blockCenter [ ib ]);
100  blockColor_.push_back( randomColor() );
101  }
102 
103  for ( unsigned int ib = 0; ib < blockCenter.size(); ++ib ) {
104  blockAngle_.push_back(blockAngle [ ib ]);
105  }
106 
107  if ( blockCenter.size() > blockAngle.size() ) {
108  for ( unsigned int ib = 0; ib < ( blockCenter.size() - blockAngle.size() ); ++ib ) {
109  blockAngle_.push_back( randomAngle() );
110  }
111  }
112  }
113 
115 
116  void setSecondaryInputData(const std :: string &blockCenterDistribution,
117  const std :: string &blockAngleDistribution,
118  const int &blockCenterRandSeqId,
119  const int &blockAngleRandSeqId,
120  const int &blockCenterPertCoeff)
121  {
122  blockCenterDistribution_ = blockCenterDistribution;
123  blockAngleDistribution_ = blockAngleDistribution;
124  blockCenterRandSeqId_ = blockCenterRandSeqId;
125  blockAngleRandSeqId_ = blockAngleRandSeqId;
126  blockCenterPertCoeff_ = blockCenterPertCoeff;
127  }
128 
129  const Scalar &xMin() const
130  { return xMin_; }
131 
133  { return xMin_; }
134 
135  const Scalar &xMax() const
136  { return xMax_; }
137 
139  { return xMax_; }
140 
141  const Scalar &dr() const
142  { return dr_; }
143 
145  { return dr_; }
146 
147  const Scalar &rafCoeff() const
148  { return rafCoeff_; }
149 
151  { return rafCoeff_; }
152 
153  const Scalar &dist2BoundCoeff() const
154  { return dist2BoundCoeff_; }
155 
157  { return dist2BoundCoeff_; }
158 
160  { return interBlockDistCoeff_; }
161 
163  { return interBlockDistCoeff_; }
164 
165  const std :: vector< std :: pair< Scalar, Scalar > > &blockCenter() const
166  { return blockCenter_; }
167 
168  std :: vector< std :: pair< Scalar, Scalar > > &blockCenter()
169  { return blockCenter_; }
170 
171  const int blockNumber() const
172  { return blockCenter_.size(); }
173 
174  const int lastBlockIdx() const
175  { return ( blockNumber() - 1 ); }
176 
177  const std :: vector< Scalar > blockNumberController() const
178  { return blockNumberController_; }
179 
180  const std :: vector< Scalar > &blockAngle() const
181  { return blockAngle_; }
182 
183  std :: vector< Scalar > &blockAngle()
184  { return blockAngle_; }
185 
186  const std :: vector< Color > &blockColor() const
187  { return blockColor_; }
188 
189  std :: vector< Color > &blockColor()
190  { return blockColor_; }
191 
192  const std :: string &outputPath() const
193  { return outputPath_; }
194 
195  std :: string &outputPath()
196  { return outputPath_; }
197 
198  const std :: string &outputDirName() const
199  { return outputDirName_; }
200 
201  std :: string &outputDirName()
202  { return outputDirName_; }
203 
204  Scalar yMin(const Scalar &x) const
205  { return xMin_; }
206 
207  Scalar yMax(const Scalar &x) const
208  { return xMax_ /*/2.*/; }
209 
210  /* to output secondary input data */
211  const std :: string &blockCenterDistribution() const
212  { return blockCenterDistribution_; }
213 
214  const std :: string &blockAngleDistribution() const
215  { return blockAngleDistribution_; }
216 
217  const int &blockCenterRandSeqId() const
218  { return blockCenterRandSeqId_; }
219 
220  const int &blockAngleRandSeqId() const
221  { return blockAngleRandSeqId_; }
222 
223  const int &blockCenterPertCoeff() const
224  { return blockCenterPertCoeff_; }
225 }; /* class InputData */
226 
227 #endif /* #ifndef _INPUT_DATA_HH_ */