310 using Teuchos::rcp_implicit_cast;
311 typedef Teuchos::ParameterEntryValidator PEV;
312 if (is_null(validParamList_)) {
313 RCP<Teuchos::ParameterList>
314 validParamList = Teuchos::rcp(
new Teuchos::ParameterList);
316 lowsfValidator_ = Teuchos::rcp(
317 new Teuchos::StringToIntegralParameterEntryValidator<int>(
318 validLowsfNames_,LinearSolverType_name
322 LinearSolverType_name, defaultLOWSF_,
323 (std::string(
"Determines the type of linear solver that will be used.\n")
324 +
"The parameters for each solver type are specified in the sublist \""
325 + LinearSolverTypes_name +
"\"").c_str(),
326 rcp_implicit_cast<const PEV>(lowsfValidator_)
328 Teuchos::ParameterList &linearSolverTypesSL = validParamList->sublist(
329 LinearSolverTypes_name,
false,
330 "Sublists for each of the linear solver types set using the parameter\n"
331 "\"" + LinearSolverType_name +
"\". Note that the options for each\n"
332 "linear solver type given below will only be used if linear solvers\n"
333 "of that type are created. It is fine to list parameter sublists for\n"
334 "linear solver types that are not used."
336 for(
int i = 0; i < static_cast<int>(lowsfArray_.size()); ++i ) {
338 &lsname = validLowsfNames_[i];
339 const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> >
340 lowsf = lowsfArray_[i]->create();
341 linearSolverTypesSL.sublist(lsname).setParameters(*lowsf->getValidParameters()
342 ).disableRecursiveValidation();
345 pfValidator_ = Teuchos::rcp(
346 new Teuchos::StringToIntegralParameterEntryValidator<int>(
347 validPfNames_, PreconditionerType_name ) );
349 PreconditionerType_name, defaultPF_,
350 (std::string(
"Determines the type of preconditioner that will be used.\n")
351 +
"This option is only meaningful for linear solvers that accept preconditioner"
352 +
" factory objects!\n"
353 +
"The parameters for each preconditioner are specified in the sublist \""
354 + PreconditionerTypes_name +
"\"").c_str(),
355 rcp_implicit_cast<const PEV>(pfValidator_)
357 Teuchos::ParameterList &precTypesSL = validParamList->sublist(
358 PreconditionerTypes_name,
false,
359 "Sublists for each of the preconditioner types set using the parameter\n"
360 "\"" + PreconditionerType_name +
"\". Note that the options for each\n"
361 "preconditioner type given below will only be used if preconditioners\n"
362 "of that type are created. It is fine to list parameter sublists for\n"
363 "preconditioner types that are not used."
365 for(
int i = 0; i < static_cast<int>(pfArray_.size()); ++i ) {
367 &pfname = validPfNames_[i+1];
368 const RCP<Thyra::PreconditionerFactoryBase<Scalar> >
369 pf = pfArray_[i]->create();
370 precTypesSL.sublist(pfname).setParameters(*pf->getValidParameters()
371 ).disableRecursiveValidation();
375 EnableDelayedSolverConstruction_name, EnableDelayedSolverConstruction_default,
376 "When this option is set to true, the linear solver factory will be wrapped\n"
377 "in a delayed evaluation Decorator factory object. This results in a delay\n"
378 "in the creation of a linear solver (and the associated preconditioner) until\n"
379 "the first solve is actually performed. This helps in cases where it is not\n"
380 "known a-priori if a linear solve will be needed on a given linear operator and\n"
381 "therefore can significantly improve performance for some types of algorithms\n"
382 "such as NOX and LOCA."
385 validParamList_ = validParamList;
387 return validParamList_;
397 const std::string &linearSolveStrategyName
400 justInTimeInitialize();
403#ifdef THYRA_DEFAULT_REAL_LINEAR_SOLVER_BUILDER_DUMP
404 std::cout <<
"\nEntering LinearSolverBuilder"
405 <<
"::createLinearSolveStrategy(...) ...\n";
406 std::cout <<
"\nlinearSolveStrategyName = \""
407 << linearSolveStrategyName <<
"\"\n";
408 std::cout <<
"\nlinearSolveStrategyName.length() = "
409 << linearSolveStrategyName.length() <<
"\n";
410 std::cout <<
"\ndefaultLOWSF_ = \"" << defaultLOWSF_ <<
"\"\n";
411 std::cout <<
"\nthis->getLinearSolveStrategyName() = \""
415 lsname = ( linearSolveStrategyName.length()
416 ? linearSolveStrategyName
418#ifdef THYRA_DEFAULT_REAL_LINEAR_SOLVER_BUILDER_DUMP
419 std::cout <<
"\nlsname = \"" << lsname <<
"\"\n";
424 ls_idx = lowsfValidator_->getIntegralValue(lsname, LinearSolverType_name);
427 RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> >
428 lowsf = lowsfArray_[ls_idx]->create();
431 if(lowsf->acceptsPreconditionerFactory()) {
433 RCP<Thyra::PreconditionerFactoryBase<Scalar> >
436 lowsf->setPreconditionerFactory(pf,pfName);
441 lowsf->setParameterList(
442 sublist(sublist(paramList_, LinearSolverTypes_name), lsname));
444 if (enableDelayedSolverConstruction_) {
446 new Thyra::DelayedLinearOpWithSolveFactory<Scalar>(lowsf)
458 const std::string &preconditioningStrategyName
461 justInTimeInitialize();
465 pfname = ( preconditioningStrategyName.length()
466 ? preconditioningStrategyName
468 RCP<Thyra::PreconditionerFactoryBase<Scalar> >
473 pf_idx = pfValidator_->getIntegralValue(pfname, PreconditionerType_name);
475 pf = pfArray_[pf_idx-1]->create();
476 pf->setParameterList(
477 sublist(sublist(paramList_, PreconditionerTypes_name), pfname));