// ------------------------------------------------------------- // NonlinearSolverImplementation::p_configure // ------------------------------------------------------------- void NonlinearSolverImplementation::p_configure(utility::Configuration::CursorPtr props) { if (props) { p_solutionTolerance = props->get("SolutionTolerance", p_solutionTolerance); p_functionTolerance = props->get("FunctionTolerance", p_functionTolerance); p_maxIterations = props->get("MaxIterations", p_maxIterations); } }
/// Specialized way to configure from property tree void p_configure(utility::Configuration::CursorPtr props) { if (props) { p_solutionTolerance = props->get("SolutionTolerance", p_solutionTolerance); p_relativeTolerance = props->get("RelativeTolerance", p_relativeTolerance); p_maxIterations = props->get("MaxIterations", p_maxIterations); p_doSerial = props->get("ForceSerial", p_doSerial); p_constSerialMatrix = props->get("SerialMatrixConstant", p_constSerialMatrix); // SerialOnly has no effect unless parallel p_doSerial = (p_doSerial && (this->processor_size() > 1)); p_guessZero = props->get("InitialGuessZero", p_guessZero); } }
/// Initialize this instance using the specified configuration property tree void configure(utility::Configuration::CursorPtr theprops) { if (theprops) { p_configCursor = theprops->getCursor(this->p_key); } this->p_configure(p_configCursor); p_isConfigured = true; }
/** * * * @param comm * @param props * * @return PETSc options prefix to use */ void PETScConfigurable::p_processOptions(utility::Configuration::CursorPtr props) { if (!props) return; p_prefix = props->get(p_prefixKey, p_generatePrefix(p_comm)); if (*p_prefix.rbegin() != '_') { p_prefix.append("_"); } std::string optsorig, optsmod, optsfmt; optsorig = props->get(p_optionsKey, ""); boost::char_separator<char> sep(" \t\f\n\r\v", ""); boost::tokenizer<boost::char_separator<char> > opttok(optsorig, sep); boost::tokenizer<boost::char_separator<char> >::iterator o; for (o = opttok.begin(); o != opttok.end(); ++o) { optsfmt.append(*o); optsfmt.append(" "); optsmod.append(prefixOptionMaybe(p_prefix, *o)); optsmod.append(" "); } if (verbose) { std::cout << "p_processOptions: in: " << optsorig << std::endl; std::cout << "p_processOptions: fmt: " << optsfmt << std::endl; std::cout << "p_processOptions: out: " << optsmod << std::endl; } p_loadedOptions = optsmod; PetscErrorCode ierr(0); try { ierr = PetscOptionsInsertString( #if PETSC_VERSION_GE(3,7,0) NULL, #endif p_loadedOptions.c_str()); CHKERRXX(ierr); } catch (const PETSC_EXCEPTION_TYPE& e) { throw PETScException(ierr, e); } return; }
// ------------------------------------------------------------- // Optimizer::p_preconfigure // ------------------------------------------------------------- void Optimizer::p_preconfigure(utility::Configuration::CursorPtr theprops) { parallel::Communicator comm(p_impl->communicator()); std::string key(p_impl->configurationKey()); utility::Configuration::CursorPtr p = theprops->getCursor(key); std::string solver; solver = p->get("Solver", solver); if (!solver.empty()) { p_setImpl(NULL); if (solver == "GLPK") { #if defined(HAVE_GLPK) p_setImpl(new GLPKOptimizerImplementation(comm)); #else throw gridpack::Exception("GLPK Optimizer not supported"); #endif } if (solver == "CPLEX") { #if defined(HAVE_CPLEX) p_setImpl(new CPlexOptimizerImplementation(comm)); #else throw gridpack::Exception("CPLEX Optimizer not supported"); #endif } if (solver == "Julia") { p_setImpl(new JuliaOptimizerImplementation(comm)); } if (solver == "LPFile") { p_setImpl(new LPFileOptimizerImplementation(comm)); } if (!p_impl) { std::string s("Unknown ptimizer solver type \""); s += solver; s += "\""; throw gridpack::Exception(s); } } }