27 #ifndef _GRID_CREATOR_HH_
28 #define _GRID_CREATOR_HH_
32 template<
typename CellT,
typename InitialDistributionT >
35 void (*
usage)(
const char *,
const std :: string &) );
39 return "Options usually are parameters given to the simulation, \n"
40 "and have to be specified with this syntax: \n"
41 "\t--ParameterName=VALUE, for example --xMin=\"0\"\n"
42 "Parameters specified on the command line have priority over those in the parameter file.\n"
43 "If no parameter file name is given, './<programname>.input' is chosen as default.\n"
45 "Important options include:\n"
46 "\t-h, --help Print this usage message and exit\n"
47 "\t-PrintParameters [true|false] Print the run-time modifiable parameters _after_ \n"
48 "\t the simulation [default: true]\n"
49 "\t-PrintProperties [true|false] Print the compile-time parameters _before_ \n"
50 "\t the simulation [default: false]\n"
51 "\t-ParameterFile FILENAME File with parameter definitions\n"
56 template<
typename CellT,
typename InitialDistributionT >
59 void (*
usage)(
const char *,
const std :: string &) )
81 std :: cout <<
"No parameter file given. Defaulting to '"
83 <<
".input' for input file.\n";
84 std :: ifstream parameterFile;
86 std :: string defaultName = argv [ 0 ];
87 defaultName +=
".input";
88 parameterFile.open( defaultName.c_str() );
89 if ( !parameterFile.is_open() ) {
90 std :: cout <<
" -> Could not open file '"
97 parameterFile.close();
101 for (
int i = 1; i < argc; ++i ) {
102 if ( std :: string(
"--help") == argv [ i ] || std :: string(
"-h") == argv [ i ] ) {
109 for (
int i = 1; i < argc; ++i ) {
110 if ( std :: string(
"--version") == argv [ i ] || std :: string(
"-v") == argv [ i ] ) {
118 #if VERBOSE_LEVEL >= 2
119 std :: cout <<
"command line options are:\n";
126 usage(argv [ 0 ], usageMessage);
131 std :: string defaultName = argv [ 0 ];
132 defaultName +=
".input";
136 std :: ifstream parameterFile( parameterFileName.c_str() );
137 if ( !parameterFile.is_open() ) {
140 if ( ParameterTree :: tree().hasKey(
"ParameterFile") ) {
141 std :: cout <<
"\n\t -> Could not open file '"
154 parameterFile.close();
161 std :: vector< Scalar > blockNumberCoeff;
162 blockNumberCoeff.clear();
170 const int blockCenterRandSeqIdDefault = 0 ;
171 const int blockAngleRandSeqIdDefault = 0 ;
178 #if VERBOSE_LEVEL >= 2
179 std :: cout <<
"\n//*** primary input data ***//\n";
180 std :: cout <<
"outputPath = " << outputPath <<
"\n";
181 std :: cout <<
"xMin = " << xMin << ( xMin == 0 ?
" (default value)" :
"" ) <<
"\n";
182 std :: cout <<
"xMax = " << xMax << ( xMax == 1 ?
" (default value)" :
"" ) <<
"\n";
183 std :: cout <<
"blockNumberCoeffx = " << blockNumberCoeff [ 0 ] << ( blockNumberCoeff [ 0 ] == 1 ?
" (default value)" :
"" ) <<
"\n";
184 std :: cout <<
"blockNumberCoeffy = " << blockNumberCoeff [ 1 ] << ( blockNumberCoeff [ 1 ] == 1 ?
" (default value)" :
"" ) <<
"\n";
185 std :: cout <<
"dr = " << dr << ( dr == 0.1 ?
" (default value)" :
"" ) <<
"\n";
186 std :: cout <<
"rafCoeff = " << rafCoeff << ( rafCoeff == 1 ?
" (default value)" :
"" ) <<
"\n";
188 std :: cout <<
"\n//*** secondary input data ***//\n";
189 std :: cout <<
"blockCenterDistribution = " << blockCenterDistribution << ( blockCenterDistribution ==
"periodic" ?
" (default value)" :
"" ) <<
"\n";
190 std :: cout <<
"blockAngleDistribution = " << blockAngleDistribution << ( blockAngleDistribution ==
"random" ?
" (default value)" :
"" ) <<
"\n";
191 std :: cout <<
"blockCenterRandSeqId = " << blockCenterRandSeqId << ( blockCenterRandSeqId == blockCenterRandSeqIdDefault ?
" ( = (unsigned)time(0))" :
"" ) <<
"\n";
192 std :: cout <<
"blockAngleRandSeqId = " << blockAngleRandSeqId << ( blockAngleRandSeqId == blockAngleRandSeqIdDefault ?
" ( = (unsigned)time(0))" :
"" ) <<
"\n";
193 std :: cout <<
"blockCenterPertCoeff = " << blockCenterPertCoeff << ( blockCenterPertCoeff == 0 ?
" (default value)" :
"" ) <<
"\n";
194 std :: cout <<
"dist2BoundCoeff = " << dist2BoundCoeff << ( dist2BoundCoeff == 1 ?
" (default value)" :
"" ) <<
"\n";
195 std :: cout <<
"interBlockDistCoeff = " << interBlockDistCoeff << ( interBlockDistCoeff == 1 ?
" (default value)" :
"" ) <<
"\n";
198 InputData inputDataTmp(xMin, xMax, blockNumberCoeff, dr, rafCoeff, dist2BoundCoeff, interBlockDistCoeff, outputPath, outputDirName);
199 inputDataTmp.setSecondaryInputData(blockCenterDistribution, blockAngleDistribution, blockCenterRandSeqId, blockAngleRandSeqId, blockCenterPertCoeff);
201 InitialDistribution initialDist( &inputDataTmp);
203 if ( blockCenterDistribution ==
"periodic" ) {
207 if ( blockCenterDistribution ==
"random" ) {
211 if ( blockCenterDistribution ==
"predefined" ) {
215 if ( blockAngleDistribution ==
"random" ) {
219 if ( blockAngleDistribution ==
"predefined" ) {
224 InputData inputData( xMin, xMax, blockNumberCoeff, dr, rafCoeff, dist2BoundCoeff, interBlockDistCoeff
227 if ( blockCenterDistribution ==
"predefined" ) {
228 inputData.xMin() = initialDist.
inData().
xMin();
229 inputData.xMax() = initialDist.
inData().
xMax();
232 inputData.setSecondaryInputData(blockCenterDistribution
233 , blockAngleDistribution
234 , blockCenterRandSeqId
235 , blockAngleRandSeqId
236 , blockCenterPertCoeff);
239 GridFactory gridFactory1( &inputData);