00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "Teuchos_ParameterList.hpp"
00043
00044 #include "LOCA_GlobalData.H"
00045 #include "LOCA_Factory.H"
00046 #include "LOCA_Abstract_Factory.H"
00047
00048 LOCA::Factory::Factory(
00049 const Teuchos::RCP<LOCA::GlobalData>& global_data) :
00050 globalData(global_data),
00051 factory(),
00052 haveFactory(false),
00053 predictorFactory(global_data),
00054 continuationFactory(global_data),
00055 bifurcationFactory(global_data),
00056 stepsizeFactory(global_data),
00057 borderedFactory(global_data),
00058 eigensolverFactory(global_data),
00059 eigenvalueSortFactory(global_data),
00060 saveEigenFactory(global_data),
00061 anasaziOperatorFactory(global_data),
00062 mooreSpenceTurningPointSolverFactory(global_data),
00063 mooreSpencePitchforkSolverFactory(global_data),
00064 mooreSpenceHopfSolverFactory(global_data)
00065 {
00066
00067 globalData->locaFactory = Teuchos::rcp(this, false);
00068 }
00069
00070 LOCA::Factory::Factory(
00071 const Teuchos::RCP<LOCA::GlobalData>& global_data,
00072 const Teuchos::RCP<LOCA::Abstract::Factory>& userFactory) :
00073 globalData(global_data),
00074 factory(userFactory),
00075 haveFactory(true),
00076 predictorFactory(global_data),
00077 continuationFactory(global_data),
00078 bifurcationFactory(global_data),
00079 stepsizeFactory(global_data),
00080 borderedFactory(global_data),
00081 eigensolverFactory(global_data),
00082 eigenvalueSortFactory(global_data),
00083 saveEigenFactory(global_data),
00084 anasaziOperatorFactory(global_data),
00085 mooreSpenceTurningPointSolverFactory(global_data),
00086 mooreSpencePitchforkSolverFactory(global_data),
00087 mooreSpenceHopfSolverFactory(global_data)
00088 {
00089
00090 factory->init(globalData);
00091
00092
00093 globalData->locaFactory = Teuchos::rcp(this, false);
00094 }
00095
00096 LOCA::Factory::~Factory()
00097 {
00098 }
00099
00100 Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy>
00101 LOCA::Factory::createPredictorStrategy(
00102 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00103 const Teuchos::RCP<Teuchos::ParameterList>& predictorParams)
00104 {
00105 string methodName = "LOCA::Factory::createPredictorStrategy()";
00106 Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy> strategy;
00107
00108
00109
00110 if (haveFactory) {
00111 const string& strategyName =
00112 predictorFactory.strategyName(*predictorParams);
00113 bool created = factory->createPredictorStrategy(strategyName,
00114 topParams,
00115 predictorParams,
00116 strategy);
00117 if (created)
00118 return strategy;
00119 }
00120
00121 strategy = predictorFactory.create(topParams, predictorParams);
00122
00123 return strategy;
00124 }
00125
00126 Teuchos::RCP<LOCA::MultiContinuation::AbstractStrategy>
00127 LOCA::Factory::createContinuationStrategy(
00128 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00129 const Teuchos::RCP<Teuchos::ParameterList>& stepperParams,
00130 const Teuchos::RCP<LOCA::MultiContinuation::AbstractGroup>& grp,
00131 const Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy>& pred,
00132 const vector<int>& paramIDs)
00133 {
00134 string methodName = "LOCA::Factory::createContinuationStrategy()";
00135 Teuchos::RCP<LOCA::MultiContinuation::AbstractStrategy> strategy;
00136
00137
00138
00139 if (haveFactory) {
00140 const string& strategyName =
00141 continuationFactory.strategyName(*stepperParams);
00142 bool created = factory->createContinuationStrategy(strategyName,
00143 topParams,
00144 stepperParams,
00145 grp, pred, paramIDs,
00146 strategy);
00147 if (created)
00148 return strategy;
00149 }
00150
00151 strategy = continuationFactory.create(topParams, stepperParams, grp, pred,
00152 paramIDs);
00153
00154 return strategy;
00155 }
00156
00157 Teuchos::RCP<LOCA::MultiContinuation::AbstractGroup>
00158 LOCA::Factory::createBifurcationStrategy(
00159 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00160 const Teuchos::RCP<Teuchos::ParameterList>& bifurcationParams,
00161 const Teuchos::RCP<LOCA::MultiContinuation::AbstractGroup>& grp)
00162 {
00163 string methodName = "LOCA::Factory::createBifurcationStrategy()";
00164 Teuchos::RCP<LOCA::MultiContinuation::AbstractGroup> strategy;
00165
00166
00167
00168 if (haveFactory) {
00169 const string& strategyName =
00170 bifurcationFactory.strategyName(*bifurcationParams);
00171 bool created = factory->createBifurcationStrategy(strategyName,
00172 topParams,
00173 bifurcationParams,
00174 grp, strategy);
00175 if (created)
00176 return strategy;
00177 }
00178
00179 strategy = bifurcationFactory.create(topParams, bifurcationParams, grp);
00180
00181 return strategy;
00182 }
00183
00184 Teuchos::RCP<LOCA::StepSize::AbstractStrategy>
00185 LOCA::Factory::createStepSizeStrategy(
00186 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00187 const Teuchos::RCP<Teuchos::ParameterList>& stepsizeParams)
00188 {
00189 string methodName = "LOCA::Factory::createStepSizeStrategy()";
00190 Teuchos::RCP<LOCA::StepSize::AbstractStrategy> strategy;
00191
00192
00193
00194 if (haveFactory) {
00195 const string& strategyName =
00196 stepsizeFactory.strategyName(*stepsizeParams);
00197 bool created = factory->createStepSizeStrategy(strategyName,
00198 topParams,
00199 stepsizeParams,
00200 strategy);
00201 if (created)
00202 return strategy;
00203 }
00204
00205 strategy = stepsizeFactory.create(topParams, stepsizeParams);
00206
00207 return strategy;
00208 }
00209
00210 Teuchos::RCP<LOCA::BorderedSolver::AbstractStrategy>
00211 LOCA::Factory::createBorderedSolverStrategy(
00212 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00213 const Teuchos::RCP<Teuchos::ParameterList>& solverParams)
00214 {
00215 string methodName = "LOCA::Factory::createBorderedSolverStrategy()";
00216 Teuchos::RCP<LOCA::BorderedSolver::AbstractStrategy> strategy;
00217
00218
00219
00220 if (haveFactory) {
00221 const string& strategyName =
00222 borderedFactory.strategyName(*solverParams);
00223 bool created = factory->createBorderedSolverStrategy(strategyName,
00224 topParams,
00225 solverParams,
00226 strategy);
00227 if (created)
00228 return strategy;
00229 }
00230
00231 strategy = borderedFactory.create(topParams, solverParams);
00232
00233 return strategy;
00234 }
00235
00236 Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy>
00237 LOCA::Factory::createEigensolverStrategy(
00238 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00239 const Teuchos::RCP<Teuchos::ParameterList>& eigenParams)
00240 {
00241 string methodName = "LOCA::Factory::createEigensolverStrategy()";
00242 Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy> strategy;
00243
00244
00245
00246 if (haveFactory) {
00247 const string& strategyName =
00248 eigensolverFactory.strategyName(*eigenParams);
00249 bool created = factory->createEigensolverStrategy(strategyName,
00250 topParams,
00251 eigenParams,
00252 strategy);
00253 if (created)
00254 return strategy;
00255 }
00256
00257 strategy = eigensolverFactory.create(topParams, eigenParams);
00258
00259 return strategy;
00260 }
00261
00262 Teuchos::RCP<LOCA::EigenvalueSort::AbstractStrategy>
00263 LOCA::Factory::createEigenvalueSortStrategy(
00264 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00265 const Teuchos::RCP<Teuchos::ParameterList>& eigenParams)
00266 {
00267 string methodName = "LOCA::Factory::createEigenvalueSortStrategy()";
00268 Teuchos::RCP<LOCA::EigenvalueSort::AbstractStrategy> strategy;
00269
00270
00271
00272 if (haveFactory) {
00273 const string& strategyName =
00274 eigenvalueSortFactory.strategyName(*eigenParams);
00275 bool created = factory->createEigenvalueSortStrategy(strategyName,
00276 topParams,
00277 eigenParams,
00278 strategy);
00279 if (created)
00280 return strategy;
00281 }
00282
00283 strategy = eigenvalueSortFactory.create(topParams, eigenParams);
00284
00285 return strategy;
00286 }
00287
00288 Teuchos::RCP<LOCA::SaveEigenData::AbstractStrategy>
00289 LOCA::Factory::createSaveEigenDataStrategy(
00290 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00291 const Teuchos::RCP<Teuchos::ParameterList>& eigenParams)
00292 {
00293 string methodName = "LOCA::Factory::createSaveEigenDataStrategy()";
00294 Teuchos::RCP<LOCA::SaveEigenData::AbstractStrategy> strategy;
00295
00296
00297
00298 if (haveFactory) {
00299 const string& strategyName =
00300 saveEigenFactory.strategyName(*eigenParams);
00301 bool created = factory->createSaveEigenDataStrategy(strategyName,
00302 topParams,
00303 eigenParams,
00304 strategy);
00305 if (created)
00306 return strategy;
00307 }
00308
00309 strategy = saveEigenFactory.create(topParams, eigenParams);
00310
00311 return strategy;
00312 }
00313
00314 Teuchos::RCP<LOCA::AnasaziOperator::AbstractStrategy>
00315 LOCA::Factory::createAnasaziOperatorStrategy(
00316 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00317 const Teuchos::RCP<Teuchos::ParameterList>& eigenParams,
00318 const Teuchos::RCP<Teuchos::ParameterList>& solverParams,
00319 const Teuchos::RCP<NOX::Abstract::Group>& grp)
00320 {
00321 string methodName = "LOCA::Factory::createAnasaziOperatorStrategy()";
00322 Teuchos::RCP<LOCA::AnasaziOperator::AbstractStrategy> strategy;
00323
00324
00325
00326 if (haveFactory) {
00327 const string& strategyName =
00328 anasaziOperatorFactory.strategyName(*eigenParams);
00329 bool created = factory->createAnasaziOperatorStrategy(strategyName,
00330 topParams,
00331 eigenParams,
00332 solverParams,
00333 grp,
00334 strategy);
00335 if (created)
00336 return strategy;
00337 }
00338
00339 strategy = anasaziOperatorFactory.create(topParams, eigenParams,
00340 solverParams, grp);
00341
00342 return strategy;
00343 }
00344
00345 Teuchos::RCP<LOCA::TurningPoint::MooreSpence::SolverStrategy>
00346 LOCA::Factory::createMooreSpenceTurningPointSolverStrategy(
00347 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00348 const Teuchos::RCP<Teuchos::ParameterList>& solverParams)
00349 {
00350 string methodName =
00351 "LOCA::Factory::createMooreSpenceTurningPointSolverStrategy()";
00352 Teuchos::RCP<LOCA::TurningPoint::MooreSpence::SolverStrategy> strategy;
00353
00354
00355
00356 if (haveFactory) {
00357 const string& strategyName =
00358 mooreSpenceTurningPointSolverFactory.strategyName(*solverParams);
00359 bool created =
00360 factory->createMooreSpenceTurningPointSolverStrategy(strategyName,
00361 topParams,
00362 solverParams,
00363 strategy);
00364 if (created)
00365 return strategy;
00366 }
00367
00368 strategy = mooreSpenceTurningPointSolverFactory.create(topParams,
00369 solverParams);
00370
00371 return strategy;
00372 }
00373
00374 Teuchos::RCP<LOCA::Pitchfork::MooreSpence::SolverStrategy>
00375 LOCA::Factory::createMooreSpencePitchforkSolverStrategy(
00376 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00377 const Teuchos::RCP<Teuchos::ParameterList>& solverParams)
00378 {
00379 string methodName =
00380 "LOCA::Factory::createMooreSpencePitchforkSolverStrategy()";
00381 Teuchos::RCP<LOCA::Pitchfork::MooreSpence::SolverStrategy> strategy;
00382
00383
00384
00385 if (haveFactory) {
00386 const string& strategyName =
00387 mooreSpencePitchforkSolverFactory.strategyName(*solverParams);
00388 bool created =
00389 factory->createMooreSpencePitchforkSolverStrategy(strategyName,
00390 topParams,
00391 solverParams,
00392 strategy);
00393 if (created)
00394 return strategy;
00395 }
00396
00397 strategy = mooreSpencePitchforkSolverFactory.create(topParams,
00398 solverParams);
00399
00400 return strategy;
00401 }
00402
00403 Teuchos::RCP<LOCA::Hopf::MooreSpence::SolverStrategy>
00404 LOCA::Factory::createMooreSpenceHopfSolverStrategy(
00405 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00406 const Teuchos::RCP<Teuchos::ParameterList>& solverParams)
00407 {
00408 string methodName =
00409 "LOCA::Factory::createMooreSpenceHopfSolverStrategy()";
00410 Teuchos::RCP<LOCA::Hopf::MooreSpence::SolverStrategy> strategy;
00411
00412
00413
00414 if (haveFactory) {
00415 const string& strategyName =
00416 mooreSpenceHopfSolverFactory.strategyName(*solverParams);
00417 bool created =
00418 factory->createMooreSpenceHopfSolverStrategy(strategyName,
00419 topParams,
00420 solverParams,
00421 strategy);
00422 if (created)
00423 return strategy;
00424 }
00425
00426 strategy = mooreSpenceHopfSolverFactory.create(topParams,
00427 solverParams);
00428
00429 return strategy;
00430 }