panzer::ScatterDirichletResidual_Tpetra<panzer::Traits::Residual, TRAITS,LO,GO,NodeT>:: ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const UniqueGlobalIndexer<LO,GO> > & indexer, const Teuchos::ParameterList& p) : globalIndexer_(indexer) , globalDataKey_("Residual Scatter Container") { std::string scatterName = p.get<std::string>("Scatter Name"); scatterHolder_ = Teuchos::rcp(new PHX::Tag<ScalarT>(scatterName,Teuchos::rcp(new PHX::MDALayout<Dummy>(0)))); // get names to be evaluated const std::vector<std::string>& names = *(p.get< Teuchos::RCP< std::vector<std::string> > >("Dependent Names")); // grab map from evaluated names to field names fieldMap_ = p.get< Teuchos::RCP< std::map<std::string,std::string> > >("Dependent Map"); // determine if we are scattering an initial condition scatterIC_ = p.isParameter("Scatter Initial Condition") ? p.get<bool>("Scatter Initial Condition") : false; Teuchos::RCP<PHX::DataLayout> dl = (!scatterIC_) ? p.get< Teuchos::RCP<panzer::PureBasis> >("Basis")->functional : p.get< Teuchos::RCP<const panzer::PureBasis> >("Basis")->functional ; if (!scatterIC_) { side_subcell_dim_ = p.get<int>("Side Subcell Dimension"); local_side_id_ = p.get<int>("Local Side ID"); } // build the vector of fields that this is dependent on scatterFields_.resize(names.size()); for (std::size_t eq = 0; eq < names.size(); ++eq) { scatterFields_[eq] = PHX::MDField<const ScalarT,Cell,NODE>(names[eq],dl); // tell the field manager that we depend on this field this->addDependentField(scatterFields_[eq]); } checkApplyBC_ = p.isParameter("Check Apply BC") ? p.get<bool>("Check Apply BC") : false; if (checkApplyBC_) { applyBC_.resize(names.size()); for (std::size_t eq = 0; eq < names.size(); ++eq) { applyBC_[eq] = PHX::MDField<const bool,Cell,NODE>(std::string("APPLY_BC_")+fieldMap_->find(names[eq])->second,dl); this->addDependentField(applyBC_[eq]); } } // this is what this evaluator provides this->addEvaluatedField(*scatterHolder_); if (p.isType<std::string>("Global Data Key")) globalDataKey_ = p.get<std::string>("Global Data Key"); this->setName(scatterName+" Scatter Residual"); }
//---------------------------------------------------------------------------// // Set parameters for mapping. void MoabEntityLocalMap::setParameters( const Teuchos::ParameterList& parameters ) { if ( parameters.isParameter("Point Inclusion Tolerance") ) { d_inclusion_tol = parameters.get<double>("Point Inclusion Tolerance"); } if ( parameters.isParameter("Newton Tolerance") ) { d_newton_tol = parameters.get<double>("Newton Tolerance"); } }
PeridigmNS::ElasticPlasticMaterial::ElasticPlasticMaterial(const Teuchos::ParameterList & params) : Material(params), m_disablePlasticity(false), m_applyAutomaticDifferentiationJacobian(true), m_isPlanarProblem(false), m_volumeFieldId(-1), m_damageFieldId(-1), m_weightedVolumeFieldId(-1), m_dilatationFieldId(-1), m_modelCoordinatesFieldId(-1), m_coordinatesFieldId(-1), m_forceDensityFieldId(-1), m_bondDamageFieldId(-1), m_deviatoricPlasticExtensionFieldId(-1), m_lambdaFieldId(-1) { //! \todo Add meaningful asserts on material properties. m_bulkModulus = calculateBulkModulus(params); m_shearModulus = calculateShearModulus(params); m_horizon = params.get<double>("Horizon"); m_density = params.get<double>("Density"); m_yieldStress = params.get<double>("Yield Stress"); if(params.isParameter("Disable Plasticity")) m_disablePlasticity = params.get<bool>("Disable Plasticity"); if(params.isParameter("Apply Automatic Differentiation Jacobian")) m_applyAutomaticDifferentiationJacobian = params.get<bool>("Apply Automatic Differentiation Jacobian"); if(params.isParameter("Planar Problem")){ m_isPlanarProblem= params.get<bool>("Planar Problem"); m_thickness= params.get<double>("Thickness"); } TEUCHOS_TEST_FOR_EXCEPT_MSG(params.isParameter("Thermal Expansion Coefficient"), "**** Error: Thermal expansion is not currently supported for the Elastic Plastic material model.\n"); if(m_disablePlasticity) m_yieldStress = std::numeric_limits<double>::max(); if(!m_isPlanarProblem) m_thickness = std::numeric_limits<double>::max(); PeridigmNS::FieldManager& fieldManager = PeridigmNS::FieldManager::self(); m_volumeFieldId = fieldManager.getFieldId(PeridigmField::ELEMENT, PeridigmField::SCALAR, PeridigmField::CONSTANT, "Volume"); m_damageFieldId = fieldManager.getFieldId(PeridigmField::ELEMENT, PeridigmField::SCALAR, PeridigmField::TWO_STEP, "Damage"); m_weightedVolumeFieldId = fieldManager.getFieldId(PeridigmField::ELEMENT, PeridigmField::SCALAR, PeridigmField::CONSTANT, "Weighted_Volume"); m_dilatationFieldId = fieldManager.getFieldId(PeridigmField::ELEMENT, PeridigmField::SCALAR, PeridigmField::TWO_STEP, "Dilatation"); m_modelCoordinatesFieldId = fieldManager.getFieldId(PeridigmField::NODE, PeridigmField::VECTOR, PeridigmField::CONSTANT, "Model_Coordinates"); m_coordinatesFieldId = fieldManager.getFieldId(PeridigmField::NODE, PeridigmField::VECTOR, PeridigmField::TWO_STEP, "Coordinates"); m_forceDensityFieldId = fieldManager.getFieldId(PeridigmField::NODE, PeridigmField::VECTOR, PeridigmField::TWO_STEP, "Force_Density"); m_bondDamageFieldId = fieldManager.getFieldId(PeridigmField::BOND, PeridigmField::SCALAR, PeridigmField::TWO_STEP, "Bond_Damage"); m_deviatoricPlasticExtensionFieldId = fieldManager.getFieldId(PeridigmField::BOND, PeridigmField::SCALAR, PeridigmField::TWO_STEP, "Deviatoric_Plastic_Extension"); m_lambdaFieldId = fieldManager.getFieldId(PeridigmField::ELEMENT, PeridigmField::SCALAR, PeridigmField::TWO_STEP, "Lambda"); m_fieldIds.push_back(m_volumeFieldId); m_fieldIds.push_back(m_damageFieldId); m_fieldIds.push_back(m_weightedVolumeFieldId); m_fieldIds.push_back(m_dilatationFieldId); m_fieldIds.push_back(m_modelCoordinatesFieldId); m_fieldIds.push_back(m_coordinatesFieldId); m_fieldIds.push_back(m_forceDensityFieldId); m_fieldIds.push_back(m_bondDamageFieldId); m_fieldIds.push_back(m_deviatoricPlasticExtensionFieldId); m_fieldIds.push_back(m_lambdaFieldId); }
Teuchos::ParameterList TrilinosSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Ifpack2ToIfpack1Param(const Teuchos::ParameterList& ifpack2List) { Teuchos::ParameterList ifpack1List = ifpack2List; if (ifpack2List.isParameter("relaxation: type") && ifpack2List.get<std::string>("relaxation: type") == "Symmetric Gauss-Seidel") ifpack1List.set("relaxation: type", "symmetric Gauss-Seidel"); if (ifpack2List.isParameter("fact: iluk level-of-fill")) { ifpack1List.remove("fact: iluk level-of-fill"); ifpack1List.set("fact: level-of-fill", ifpack2List.get<int>("fact: iluk level-of-fill")); } return ifpack1List; }
bool ComparisonHelper::metricComparisonTest(const RCP<const Comm<int> > &comm, const Zoltan2::MetricValues<zscalar_t> & metric, const Zoltan2::MetricValues<zscalar_t> & ref_metric, const Teuchos::ParameterList & metricPlist, ostringstream &msg) { // run a comparison of min and max agains a given metric // return an error message on failure bool pass = true; string test_name = metricPlist.name() + " test"; double ref_value = ref_metric.getMaxImbalance(); double value = metric.getMaxImbalance(); // want to reduce value to max value for all procs if (metricPlist.isParameter("lower")) { double min = metricPlist.get<double>("lower")*ref_value; if(value < min) { msg << test_name << " FAILED: imbalance per part, " << value << ", less than specified allowable minimum, " << min << ".\n"; pass = false; }else{ msg << test_name << " PASSED: imbalance per part, " << value << ", greater than specified allowable minimum, " << min << ".\n"; } } if(metricPlist.isParameter("upper" ) && pass != false) { double max = metricPlist.get<double>("upper") * ref_value; if (value > max) { msg << test_name << " FAILED: imbalance per part, " << value << ", greater than specified allowable maximum, " << max << ".\n"; pass = false; }else{ msg << test_name << " PASSED: imbalance per part, " << value << ", less than specified allowable maximum, " << max << ".\n"; } } return pass; }
PeridigmNS::InterfaceAwareDamageModel::InterfaceAwareDamageModel(const Teuchos::ParameterList& params) : DamageModel(params), m_applyThermalStrains(false), m_modelCoordinatesFieldId(-1), m_coordinatesFieldId(-1), m_damageFieldId(-1), m_bondDamageFieldId(-1), m_criticalStretchFieldId(-1), m_deltaTemperatureFieldId(-1) { m_criticalStretch = params.get<double>("Critical Stretch"); if(params.isParameter("Thermal Expansion Coefficient")){ m_alpha = params.get<double>("Thermal Expansion Coefficient"); m_applyThermalStrains = true; } PeridigmNS::FieldManager& fieldManager = PeridigmNS::FieldManager::self(); m_modelCoordinatesFieldId = fieldManager.getFieldId("Model_Coordinates"); m_coordinatesFieldId = fieldManager.getFieldId("Coordinates"); m_damageFieldId = fieldManager.getFieldId(PeridigmNS::PeridigmField::ELEMENT, PeridigmNS::PeridigmField::SCALAR, PeridigmNS::PeridigmField::TWO_STEP, "Damage"); m_bondDamageFieldId = fieldManager.getFieldId(PeridigmNS::PeridigmField::BOND, PeridigmNS::PeridigmField::SCALAR, PeridigmNS::PeridigmField::TWO_STEP, "Bond_Damage"); if(m_applyThermalStrains) m_deltaTemperatureFieldId = fieldManager.getFieldId(PeridigmField::NODE, PeridigmField::SCALAR, PeridigmField::TWO_STEP, "Temperature_Change"); m_criticalStretchFieldId = fieldManager.getFieldId(PeridigmNS::PeridigmField::ELEMENT, PeridigmNS::PeridigmField::SCALAR, PeridigmNS::PeridigmField::CONSTANT, "Critical_Stretch"); m_fieldIds.push_back(m_modelCoordinatesFieldId); m_fieldIds.push_back(m_coordinatesFieldId); m_fieldIds.push_back(m_damageFieldId); m_fieldIds.push_back(m_bondDamageFieldId); if(m_applyThermalStrains) m_fieldIds.push_back(m_deltaTemperatureFieldId); m_fieldIds.push_back(m_criticalStretchFieldId); }
//============================================================================= int Amesos_Klu::SetParameters( Teuchos::ParameterList &ParameterList ) { // ========================================= // // retrive KLU's parameters from list. // // default values defined in the constructor // // ========================================= // // retrive general parameters SetStatusParameters( ParameterList ); SetControlParameters( ParameterList ); if (ParameterList.isParameter("TrustMe") ) TrustMe_ = ParameterList.get<bool>( "TrustMe" ); #if 0 unused for now if (ParameterList.isSublist("Klu") ) { Teuchos::ParameterList KluParams = ParameterList.sublist("Klu") ; } #endif return 0; }
XZHydrostatic_GeoPotential<EvalT, Traits>:: XZHydrostatic_GeoPotential(const Teuchos::ParameterList& p, const Teuchos::RCP<Aeras::Layouts>& dl) : density (p.get<std::string> ("Density") , dl->node_scalar_level), Pi (p.get<std::string> ("Pi") , dl->node_scalar_level), Phi (p.get<std::string> ("GeoPotential"), dl->node_scalar_level), PhiSurf (p.get<std::string> ("SurfaceGeopotential") , dl->node_scalar), numNodes ( dl->node_scalar ->dimension(1)), numLevels( dl->node_scalar_level ->dimension(2)), Phi0(0.0) { Teuchos::ParameterList* xzhydrostatic_params = p.isParameter("XZHydrostatic Problem") ? p.get<Teuchos::ParameterList*>("XZHydrostatic Problem"): p.get<Teuchos::ParameterList*>("Hydrostatic Problem"); Phi0 = xzhydrostatic_params->get<double>("Phi0", 0.0); //Default: Phi0=0.0 //std::cout << "XZHydrostatic_GeoPotential: Phi0 = " << Phi0 << std::endl; this->addDependentField(density); this->addDependentField(Pi); this->addDependentField(PhiSurf); this->addEvaluatedField(Phi); this->setName("Aeras::XZHydrostatic_GeoPotential" ); }
/*! * \brief Find the set of entities a point neighbors. */ void CoarseLocalSearch::search( const Teuchos::ArrayView<const double>& point, const Teuchos::ParameterList& parameters, Teuchos::Array<Entity>& neighbors ) const { // Find the leaf of nearest neighbors. int num_neighbors = 100; if ( parameters.isParameter("Coarse Local Search kNN") ) { num_neighbors = parameters.get<int>("Coarse Local Search kNN"); } num_neighbors = std::min( num_neighbors, Teuchos::as<int>(d_entity_map.size()) ); Teuchos::Array<unsigned> local_neighbors = d_tree->nnSearch( point, num_neighbors ); // Extract the neighbors. neighbors.resize( local_neighbors.size() ); Teuchos::Array<unsigned>::const_iterator local_it; Teuchos::Array<Entity>::iterator entity_it; for ( local_it = local_neighbors.begin(), entity_it = neighbors.begin(); local_it != local_neighbors.end(); ++local_it, ++entity_it ) { DTK_CHECK( d_entity_map.count(*local_it) ); *entity_it = d_entity_map.find(*local_it)->second; } }
XZHydrostatic_GeoPotential<EvalT, Traits>:: XZHydrostatic_GeoPotential(const Teuchos::ParameterList& p, const Teuchos::RCP<Aeras::Layouts>& dl) : density (p.get<std::string> ("Density") , dl->node_scalar_level), Pi (p.get<std::string> ("Pi") , dl->node_scalar_level), Phi (p.get<std::string> ("GeoPotential"), dl->node_scalar_level), PhiSurf (p.get<std::string> ("SurfaceGeopotential") , dl->node_scalar), numNodes ( dl->node_scalar ->dimension(1)), numLevels( dl->node_scalar_level ->dimension(2)), Phi0(0.0), E (Eta<EvalT>::self()) { Teuchos::ParameterList* xzhydrostatic_params = p.isParameter("XZHydrostatic Problem") ? p.get<Teuchos::ParameterList*>("XZHydrostatic Problem"): p.get<Teuchos::ParameterList*>("Hydrostatic Problem"); Phi0 = xzhydrostatic_params->get<double>("Phi0", 0.0); //Default: Phi0=0.0 //std::cout << "XZHydrostatic_GeoPotential: Phi0 = " << Phi0 << std::endl; this->addDependentField(density); this->addDependentField(Pi); this->addDependentField(PhiSurf); this->addEvaluatedField(Phi); this->setName("Aeras::XZHydrostatic_GeoPotential" + PHX::typeAsString<EvalT>()); #ifdef ALBANY_KOKKOS_UNDER_DEVELOPMENT delta = E.delta_kokkos; #endif }
XZHydrostatic_Omega<EvalT, Traits>:: XZHydrostatic_Omega(const Teuchos::ParameterList& p, const Teuchos::RCP<Aeras::Layouts>& dl) : Velocity (p.get<std::string> ("Velocity"), dl->node_vector_level), density (p.get<std::string> ("Density"), dl->node_scalar_level), Cpstar (p.get<std::string> ("QP Cpstar"), dl->node_scalar_level), gradp (p.get<std::string> ("Gradient QP Pressure"), dl->qp_gradient_level), divpivelx (p.get<std::string> ("Divergence QP PiVelx"), dl->qp_scalar_level), omega (p.get<std::string> ("Omega") , dl->node_scalar_level), numQPs (dl->node_qp_scalar ->dimension(2)), numDims (dl->node_qp_gradient ->dimension(3)), numLevels (dl->node_scalar_level ->dimension(2)), Cp (p.isParameter("XZHydrostatic Problem") ? p.get<Teuchos::ParameterList*>("XZHydrostatic Problem")->get<double>("Cp", 1005.7): p.get<Teuchos::ParameterList*>("Hydrostatic Problem")->get<double>("Cp", 1005.7)), E (Eta<EvalT>::self()) { this->addDependentField(Velocity); this->addDependentField(gradp); this->addDependentField(density); this->addDependentField(Cpstar); this->addDependentField(divpivelx); this->addEvaluatedField(omega); this->setName("Aeras::XZHydrostatic_Omega" + PHX::typeAsString<EvalT>()); #ifdef ALBANY_KOKKOS_UNDER_DEVELOPMENT delta = E.delta_kokkos; #endif }
//---------------------------------------------------------------------------// // Constructor. CoarseGlobalSearch::CoarseGlobalSearch( const Teuchos::RCP<const Teuchos::Comm<int> >& comm, const int physical_dimension, const EntityIterator& domain_iterator, const Teuchos::ParameterList& parameters ) : d_comm( comm ) , d_space_dim( physical_dimension ) , d_track_missed_range_entities( false ) , d_missed_range_entity_ids( 0 ) , d_inclusion_tol( 1.0e-6 ) { // Determine if we are tracking missed range entities. if ( parameters.isParameter("Track Missed Range Entities") ) { d_track_missed_range_entities = parameters.get<bool>("Track Missed Range Entities"); } // Get the point inclusion tolerance. if ( parameters.isParameter("Point Inclusion Tolerance") ) { d_inclusion_tol = parameters.get<double>("Point Inclusion Tolerance"); } // Assemble the local domain bounding box. Teuchos::Tuple<double,6> domain_box; assembleBoundingBox( domain_iterator, domain_box ); // Gather the bounding boxes from all domains. int comm_size = d_comm->getSize(); Teuchos::Array<double> all_bounds( 6*comm_size ); Teuchos::gatherAll<int,double>( *d_comm, 6, domain_box.getRawPtr(), all_bounds.size(), all_bounds.getRawPtr() ); // Extract the bounding boxes. d_domain_boxes.resize( comm_size ); int id = 0; for ( int n = 0; n < comm_size; ++n ) { id = 6*n; d_domain_boxes[n] = Teuchos::tuple( all_bounds[id], all_bounds[id+1], all_bounds[id+2], all_bounds[id+3], all_bounds[id+4], all_bounds[id+5] ); } }
/// \brief Preforms the analysis /// /// @param comm RCP for a communicator /// @param metric the metrics for the problem /// @param metricsPlist parameter list defining tolerances /// @param[out] msg_stream a std::ostringstream stream to return information from the analysis /// /// @return returns a boolean value indicated pass/failure. static bool MetricBoundsTest( zscalar_t value, const std::string &test_name, const Teuchos::ParameterList & metricPlist, const RCP<const Comm<int>> &comm, ostringstream &msg) { // run a comparison of min and max agains a given metric // return an error message on failure bool pass = true; // Perfom tests if (metricPlist.isParameter("lower")) { double min = metricPlist.get<double>("lower"); if(value < min) { if (comm->getRank() == 0) msg << test_name << " FAILED: " + test_name + ": " << value << ", less than specified allowable minimum, " << min << ".\n"; pass = false; } else { if (comm->getRank() == 0) msg << test_name << " PASSED: " + test_name + ": " << value << ", greater than specified allowable minimum, " << min << ".\n"; } } if(metricPlist.isParameter("upper" ) && pass != false) { double max = metricPlist.get<double>("upper"); if (value > max) { if (comm->getRank() == 0) msg << test_name << " FAILED: " + test_name + ": " << value << ", greater than specified allowable maximum, " << max << ".\n"; pass = false; } else { if (comm->getRank() == 0) msg << test_name << " PASSED: " + test_name + ": " << value << ", less than specified allowable maximum, " << max << ".\n"; } } return pass; }
QCAD::ResponseSaveField<EvalT, Traits>:: ResponseSaveField(Teuchos::ParameterList& p, const Teuchos::RCP<Albany::Layouts>& dl) : weights("Weights", dl->qp_scalar) { //! get and validate Response parameter list Teuchos::ParameterList* plist = p.get<Teuchos::ParameterList*>("Parameter List"); Teuchos::RCP<const Teuchos::ParameterList> reflist = this->getValidResponseParameters(); plist->validateParameters(*reflist,0); //! User-specified parameters if(plist->isParameter("Vector Field Name")) { fieldName = plist->get<std::string>("Vector Field Name"); isVectorField = true; } else { fieldName = plist->get<std::string>("Field Name"); isVectorField = false; } stateName = plist->get<std::string>("State Name", fieldName); outputToExodus = plist->get<bool>("Output to Exodus", true); outputCellAverage = plist->get<bool>("Output Cell Average", true); memoryHolderOnly = plist->get<bool>("Memory Placeholder Only", false); vectorOp = plist->get<std::string>("Vector Operation", "magnitude"); //! number of quad points per cell and dimension Teuchos::RCP<PHX::DataLayout> scalar_dl = dl->qp_scalar; Teuchos::RCP<PHX::DataLayout> vector_dl = dl->qp_vector; Teuchos::RCP<PHX::DataLayout> cell_dl = dl->cell_scalar; numQPs = vector_dl->dimension(1); numDims = vector_dl->dimension(2); //! add dependent fields Teuchos::RCP<PHX::DataLayout>& field_dl = isVectorField ? vector_dl : scalar_dl; PHX::MDField<ScalarT> f(fieldName, field_dl); field = f; this->addDependentField(field); this->addDependentField(weights); //! Register with state manager Albany::StateManager* pStateMgr = p.get< Albany::StateManager* >("State Manager Ptr"); if( outputCellAverage ) { pStateMgr->registerStateVariable(stateName, cell_dl, "ALL", "scalar", 0.0, false, outputToExodus); } else { pStateMgr->registerStateVariable(stateName, scalar_dl, "ALL", "scalar", 0.0, false, outputToExodus); } // Create field tag response_field_tag = Teuchos::rcp(new PHX::Tag<ScalarT>(fieldName + " Save Field Response", dl->dummy)); this->addEvaluatedField(*response_field_tag); }
/** \brief This function builds the internals of the state from a parameter list. * * This function builds the internals of the LU 2x2 state * from a parameter list. Furthermore, it allows a * developer to easily add a factory to the build system. * * \param[in] settings Parameter list to use as the internal settings * \param[in] invLib Inverse library to use for building inverse factory objects * * \note The default implementation does nothing. */ void LU2x2DiagonalStrategy::initializeFromParameterList(const Teuchos::ParameterList & pl, const InverseLibrary & invLib) { Teko_DEBUG_SCOPE("LU2x2DiagonalStrategy::initializeFromParameterList",10); std::string invStr="Amesos", invA00Str="", invSStr=""; // "parse" the parameter list if(pl.isParameter("Inverse Type")) invStr = pl.get<std::string>("Inverse Type"); if(pl.isParameter("Inverse A00 Type")) invA00Str = pl.get<std::string>("Inverse A00 Type"); if(pl.isParameter("Inverse Schur Type")) invSStr = pl.get<std::string>("Inverse Schur Type"); if(pl.isParameter("Diagonal Type")) { std::string massInverseStr = pl.get<std::string>("Diagonal Type"); // build inverse types a00InverseType_ = getDiagonalType(massInverseStr); } // set defaults as needed if(invA00Str=="") invA00Str = invStr; if(invSStr=="") invSStr = invStr; Teko_DEBUG_MSG_BEGIN(5) DEBUG_STREAM << "LU2x2 Diagonal Strategy Parameters: " << std::endl; DEBUG_STREAM << " inv type = \"" << invStr << "\"" << std::endl; DEBUG_STREAM << " inv A00 type = \"" << invA00Str << "\"" << std::endl; DEBUG_STREAM << " inv S type = \"" << invSStr << "\"" << std::endl; DEBUG_STREAM << "LU2x2 Diagonal Strategy Parameter list: " << std::endl; pl.print(DEBUG_STREAM); Teko_DEBUG_MSG_END() // build velocity inverse factory invFactoryA00_ = invLib.getInverseFactory(invA00Str); if(invA00Str==invSStr) invFactoryS_ = invFactoryA00_; else invFactoryS_ = invLib.getInverseFactory(invSStr); }
//*********************************************************************** void NOX::Epetra::LinearSystemStratimikos:: reset(Teuchos::ParameterList& noxStratParams) { // First remove any preconditioner that may still be active destroyPreconditioner(); zeroInitialGuess = noxStratParams.get("Zero Initial Guess", false); manualScaling = noxStratParams.get("Compute Scaling Manually", true); // Place linear solver details in the "Output" sublist of the // "Linear Solver" parameter list outputSolveDetails = noxStratParams.get("Output Solver Details", true); throwErrorOnPrecFailure = noxStratParams.get("Throw Error on Prec Failure", true); // Setup the preconditioner reuse policy std::string preReusePolicyName = noxStratParams.get("Preconditioner Reuse Policy", "Rebuild"); if (preReusePolicyName == "Rebuild") precReusePolicy = PRPT_REBUILD; else if (preReusePolicyName == "Recompute") precReusePolicy = PRPT_RECOMPUTE; else if (preReusePolicyName == "Reuse") precReusePolicy = PRPT_REUSE; else { std::string errorMessage = "Option for \"Preconditioner Reuse Policy\" is invalid! \nPossible options are \"Reuse\", \"Rebuild\", and \"Recompute\"."; throwError("reset()", errorMessage); } maxAgeOfPrec = noxStratParams.get("Max Age Of Prec", 1); precQueryCounter = 0; // This needs to be in sync with Inexact Newton option from // a different sublist getLinearSolveToleranceFromNox = noxStratParams.get("Use Linear Solve Tolerance From NOX", false); linearSolveCount = 0; linearSolveIters_last = 0; linearSolveIters_total = 0; linearSolveAchievedTol = 0.0; if (noxStratParams.isParameter("Output Stream")) outputStream = noxStratParams.get< Teuchos::RCP<Teuchos::FancyOStream> >("Output Stream"); else outputStream = Teuchos::VerboseObjectBase::getDefaultOStream(); }
/** \brief This function builds the internals of the preconditioner factory * from a parameter list. */ void IterativePreconditionerFactory::initializeFromParameterList(const Teuchos::ParameterList & settings) { correctionNum_ = 1; if(settings.isParameter("Iteration Count")) correctionNum_ = settings.get<int>("Iteration Count"); TEUCHOS_TEST_FOR_EXCEPTION(not settings.isParameter("Preconditioner Type"),std::runtime_error, "Parameter \"Preconditioner Type\" is required by a Teko::IterativePreconditionerFactory"); // grab library and preconditioner name Teuchos::RCP<const InverseLibrary> il = getInverseLibrary(); std::string precName = settings.get<std::string>("Preconditioner Type"); // build preconditioner factory precFactory_ = il->getInverseFactory(precName); TEUCHOS_TEST_FOR_EXCEPTION(precFactory_==Teuchos::null,std::runtime_error, "ERROR: \"Preconditioner Type\" = " << precName << " could not be found"); }
void panzer::EquationSet_DefaultImpl<EvalT>:: buildAndRegisterScatterEvaluators(PHX::FieldManager<panzer::Traits>& fm, const panzer::FieldLibrary& fl, const LinearObjFactory<panzer::Traits> & lof, const Teuchos::ParameterList& user_data) const { using Teuchos::ParameterList; using Teuchos::RCP; using Teuchos::rcp; // this turns off the scatter contribution, and does // only the gather bool ignoreScatter = false; if(user_data.isParameter("Ignore Scatter")) ignoreScatter = user_data.get<bool>("Ignore Scatter"); if(!ignoreScatter) { for(typename std::map<std::string,DOFDescriptor>::const_iterator itr=m_provided_dofs_desc.begin(); itr!=m_provided_dofs_desc.end();++itr) { RCP<std::map<std::string,std::string> > names_map = rcp(new std::map<std::string,std::string>); RCP< std::vector<std::string> > residual_names = rcp(new std::vector<std::string>); // sanity check to make sure a residual name was registered for each provided variable TEUCHOS_ASSERT(itr->second.residualName.first); names_map->insert(std::make_pair(itr->second.residualName.second,itr->first)); residual_names->push_back(itr->second.residualName.second); { ParameterList p("Scatter"); p.set("Scatter Name", itr->second.scatterName); p.set("Basis", itr->second.basis.getConst()); p.set("Dependent Names", residual_names); p.set("Dependent Map", names_map); RCP< PHX::Evaluator<panzer::Traits> > op = lof.buildScatter<EvalT>(p); this->template registerEvaluator<EvalT>(fm, op); } // Require variables { PHX::Tag<typename EvalT::ScalarT> tag(itr->second.scatterName, Teuchos::rcp(new PHX::MDALayout<Dummy>(0))); fm.template requireField<EvalT>(tag); } } } }
//============================================================================== int Ifpack_Polynomial::SetParameters(Teuchos::ParameterList& List) { RealEigRatio_ = List.get("polynomial: real eigenvalue ratio", RealEigRatio_); ImagEigRatio_ = List.get("polynomial: imag eigenvalue ratio", ImagEigRatio_); LambdaRealMin_ = List.get("polynomial: min real part", LambdaRealMin_); LambdaRealMax_ = List.get("polynomial: max real part", LambdaRealMax_); LambdaImagMin_ = List.get("polynomial: min imag part", LambdaImagMin_); LambdaImagMax_ = List.get("polynomial: max imag part", LambdaImagMax_); PolyDegree_ = List.get("polynomial: degree",PolyDegree_); LSPointsReal_ = List.get("polynomial: real interp points",LSPointsReal_); LSPointsImag_ = List.get("polynomial: imag interp points",LSPointsImag_); IsIndefinite_ = List.get("polynomial: indefinite",IsIndefinite_); IsComplex_ = List.get("polynomial: complex",IsComplex_); MinDiagonalValue_ = List.get("polynomial: min diagonal value", MinDiagonalValue_); ZeroStartingSolution_ = List.get("polynomial: zero starting solution", ZeroStartingSolution_); Epetra_Vector* ID = List.get("polynomial: operator inv diagonal", (Epetra_Vector*)0); EigMaxIters_ = List.get("polynomial: eigenvalue max iterations",EigMaxIters_); #ifdef HAVE_IFPACK_EPETRAEXT // This is *always* false if EpetraExt isn't enabled UseBlockMode_ = List.get("polynomial: use block mode",UseBlockMode_); if(!List.isParameter("polynomial: block list")) UseBlockMode_=false; else{ BlockList_ = List.get("polynomial: block list",BlockList_); // Since we know we're doing a matrix inverse, clobber the block list // w/"invert" if it's set to multiply Teuchos::ParameterList Blist; Blist=BlockList_.get("blockdiagmatrix: list",Blist); std::string dummy("invert"); std::string ApplyMode=Blist.get("apply mode",dummy); if(ApplyMode==std::string("multiply")){ Blist.set("apply mode","invert"); BlockList_.set("blockdiagmatrix: list",Blist); } } #endif SolveNormalEquations_ = List.get("polynomial: solve normal equations",SolveNormalEquations_); if (ID != 0) { InvDiagonal_ = Teuchos::rcp( new Epetra_Vector(*ID) ); } SetLabel(); return(0); }
bool actionInterpretParameter(Teuchos::ParameterList& mlParams, const std::string& paramName, std::string& str) { //MUELU_READ_PARAM(mlParams, paramName, int, 0, data); Type varName; // = defaultValue; // extract from master list if (mlParams.isParameter(paramName)) varName = mlParams.get<Type>(paramName); std::stringstream placeholder; placeholder << "$" << paramName << "$"; return MueLu::replacePlaceholder<Type>(str, placeholder.str(), varName); }
int Piro::PerformDakotaAnalysis( Thyra::ModelEvaluatorDefaultBase<double>& piroModel, Teuchos::ParameterList& dakotaParams, RCP< Thyra::VectorBase<double> >& p) { #ifdef HAVE_PIRO_TRIKOTA dakotaParams.validateParameters(*Piro::getValidPiroAnalysisDakotaParameters(),0); using std::string; string dakotaIn = dakotaParams.get("Input File","dakota.in"); string dakotaOut = dakotaParams.get("Output File","dakota.out"); string dakotaErr = dakotaParams.get("Error File","dakota.err"); string dakotaRes = dakotaParams.get("Restart File","dakota_restart.out"); string dakotaRestartIn; if (dakotaParams.isParameter("Restart File To Read")) dakotaRestartIn = dakotaParams.get<string>("Restart File To Read"); int dakotaRestartEvals= dakotaParams.get("Restart Evals To Read", 0); int p_index = dakotaParams.get("Parameter Vector Index", 0); int g_index = dakotaParams.get("Response Vector Index", 0); TriKota::Driver dakota(dakotaIn, dakotaOut, dakotaErr, dakotaRes, dakotaRestartIn, dakotaRestartEvals); RCP<TriKota::ThyraDirectApplicInterface> trikota_interface = rcp(new TriKota::ThyraDirectApplicInterface (dakota.getProblemDescDB(), rcp(&piroModel,false), p_index, g_index), false); dakota.run(trikota_interface.get()); Dakota::RealVector finalValues; if (dakota.rankZero()) finalValues = dakota.getFinalSolution().all_continuous_variables(); // Copy Dakota parameters into Thyra p = Thyra::createMember(piroModel.get_p_space(p_index)); { Thyra::DetachedVectorView<double> global_p(p); for (int i = 0; i < finalValues.length(); ++i) global_p[i] = finalValues[i]; } return 0; #else RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream(); *out << "ERROR: Trilinos/Piro was not configured to include Dakota analysis." << "\nYou must enable TriKota." << endl; return 0; // should not fail tests #endif }
Teuchos::ParameterList TrilinosSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::Ifpack2ToIfpack1Param(Teuchos::ParameterList const & ifpack2List) { Teuchos::ParameterList ifpack1List = ifpack2List; if (ifpack2List.isParameter("relaxation: type")) { std::string relaxationType = ifpack2List.get<std::string>("relaxation: type"); if (relaxationType == "Symmetric Gauss-Seidel") { ifpack1List.remove("relaxation: type"); ifpack1List.set("relaxation: type", "symmetric Gauss-Seidel"); } } return ifpack1List; }
EffectivePressure<EvalT, Traits>::EffectivePressure (const Teuchos::ParameterList& p, const Teuchos::RCP<Albany::Layouts>& dl) : phi (p.get<std::string> ("Hydraulic Potential Variable Name"), dl->node_scalar), H (p.get<std::string> ("Ice Thickness Variable Name"), dl->node_scalar), z_s (p.get<std::string> ("Surface Height Variable Name"), dl->node_scalar), N (p.get<std::string> ("Effective Pressure Variable Name"),dl->node_scalar) { has_phi = p.isParameter("Has Hydraulic Potential") ? p.get<bool>("Has Hydraulic Potential") : false; if (has_phi) { this->addDependentField(phi); } else { TEUCHOS_TEST_FOR_EXCEPTION (!p.isParameter("Hydraulic-Over-Hydrostatic Potential Ratio"), std::logic_error, "Error! The parameter 'Hydraulic-Over-Hydrostatic Potential Ratio' must be specified if the Hydraulic Potential is not available.\n"); alpha = p.get<double>("Hydraulic-Over-Hydrostatic Potential Ratio"); } this->addDependentField(H); this->addDependentField(z_s); this->addEvaluatedField(N); // Setting parameters Teuchos::ParameterList& physical_params = *p.get<Teuchos::ParameterList*>("Physical Parameters"); rho_i = physical_params.get<double>("Ice Density", 910.0); rho_w = physical_params.get<double>("Water Density", 1028.0); g = physical_params.get<double>("Gravity Acceleration", 9.8); std::vector<PHX::DataLayout::size_type> dims; dl->node_scalar->dimensions(dims); numNodes = dims[1]; this->setName("EffectivePressure"+PHX::typeAsString<EvalT>()); }
XZHydrostatic_EtaDotPi<EvalT, Traits>:: XZHydrostatic_EtaDotPi(const Teuchos::ParameterList& p, const Teuchos::RCP<Aeras::Layouts>& dl) : divpivelx (p.get<std::string> ("Divergence QP PiVelx"), dl->qp_scalar_level), pdotP0 (p.get<std::string> ("Pressure Dot Level 0"), dl->node_scalar), Pi (p.get<std::string> ("Pi"), dl->qp_scalar_level), Temperature (p.get<std::string> ("QP Temperature"), dl->node_scalar_level), Velx (p.get<std::string> ("QP Velx"), dl->node_vector_level), tracerNames (p.get< Teuchos::ArrayRCP<std::string> >("Tracer Names")), //etadotdtracerNames (p.get< Teuchos::ArrayRCP<std::string> >("Tracer EtaDotd Names")), dedotpitracerdeNames (p.get< Teuchos::ArrayRCP<std::string> >("Tracer EtaDotd Names")), etadotdT (p.get<std::string> ("EtaDotdT"), dl->qp_scalar_level), etadotdVelx (p.get<std::string> ("EtaDotdVelx"), dl->node_vector_level), Pidot (p.get<std::string> ("PiDot"), dl->qp_scalar_level), numQPs (dl->node_qp_scalar ->dimension(2)), numDims (dl->node_qp_gradient ->dimension(3)), numLevels (dl->node_scalar_level ->dimension(2)) { Teuchos::ParameterList* xzhydrostatic_params = p.isParameter("XZHydrostatic Problem") ? p.get<Teuchos::ParameterList*>("XZHydrostatic Problem"): p.get<Teuchos::ParameterList*>("Hydrostatic Problem"); this->addDependentField(divpivelx); this->addDependentField(pdotP0); this->addDependentField(Pi); this->addDependentField(Temperature); this->addDependentField(Velx); this->addEvaluatedField(etadotdT); this->addEvaluatedField(etadotdVelx); this->addEvaluatedField(Pidot); for (int i = 0; i < tracerNames.size(); ++i) { PHX::MDField<ScalarT,Cell,QuadPoint,Level> in (tracerNames[i], dl->qp_scalar_level); //PHX::MDField<ScalarT,Cell,QuadPoint,Level> out (etadotdtracerNames[i], dl->qp_scalar_level); PHX::MDField<ScalarT,Cell,QuadPoint,Level> out (dedotpitracerdeNames[i], dl->qp_scalar_level); Tracer[tracerNames[i]] = in; //etadotdTracer[tracerNames[i]] = out; dedotpiTracerde[tracerNames[i]] = out; this->addDependentField(Tracer[tracerNames[i]]); //this->addEvaluatedField(etadotdTracer[tracerNames[i]]); this->addEvaluatedField(dedotpiTracerde[tracerNames[i]]); } this->setName("Aeras::XZHydrostatic_EtaDotPi"+PHX::typeAsString<EvalT>()); pureAdvection = xzhydrostatic_params->get<bool>("Pure Advection", false); }
MovingLeastSquareReconstructionOperator<Basis,DIM>:: MovingLeastSquareReconstructionOperator( const Teuchos::RCP<const TpetraMap>& domain_map, const Teuchos::RCP<const TpetraMap>& range_map, const Teuchos::ParameterList& parameters ) : Base( domain_map, range_map ) , d_domain_entity_dim( 0 ) , d_range_entity_dim( 0 ) { // Get the basis radius. DTK_REQUIRE( parameters.isParameter("RBF Radius") ); d_radius = parameters.get<double>("RBF Radius"); // Get the topological dimension of the domain and range entities. This // map will use their centroids for the point cloud. if ( parameters.isParameter("Domain Entity Dimension") ) { d_domain_entity_dim = parameters.get<int>("Domain Entity Dimension"); } if ( parameters.isParameter("Range Entity Dimension") ) { d_range_entity_dim = parameters.get<int>("Range Entity Dimension"); } }
int Amesos_Scalapack::SetParameters( Teuchos::ParameterList &ParameterList ) { if( debug_ == 1 ) std::cout << "Entering `SetParameters()'" << std::endl; // retrive general parameters SetStatusParameters( ParameterList ); SetControlParameters( ParameterList ); // // We have to set these to their defaults here because user codes // are not guaranteed to have a "Scalapack" parameter list. // TwoD_distribution_ = true; grid_nb_ = 32; // Some compilers reject the following cast: // if( &ParameterList == 0 ) return 0; // ========================================= // // retrive ScaLAPACK's parameters from list. // // ========================================= // // retrive general parameters // check to see if they exist before trying to retrieve them if (ParameterList.isSublist("Scalapack") ) { const Teuchos::ParameterList ScalapackParams = ParameterList.sublist("Scalapack") ; // Fix Bug #3251 if ( ScalapackParams.isParameter("2D distribution") ) TwoD_distribution_ = ScalapackParams.get<bool>("2D distribution"); if ( ScalapackParams.isParameter("grid_nb") ) grid_nb_ = ScalapackParams.get<int>("grid_nb"); } return 0; }
void DiagonalPreconditionerFactory::initializeFromParameterList(const Teuchos::ParameterList & pl) { List_=pl; diagonalType_ = BlkDiag; if(pl.isParameter("Diagonal Type")) { diagonalType_ = getDiagonalType(pl.get<std::string>("Diagonal Type")); TEUCHOS_TEST_FOR_EXCEPT(diagonalType_==NotDiag); } if(diagonalType_==BlkDiag) { // Reset default to invert mode if the user hasn't specified something else Teuchos::ParameterList & SubList=List_.sublist("blockdiagmatrix: list"); SubList.set("apply mode",SubList.get("apply mode","invert")); } }
IceSoftness<EvalT, Traits, ThermoCoupled>::IceSoftness (const Teuchos::ParameterList& p, const Teuchos::RCP<Albany::Layouts>& dl) : ice_softness (p.get<std::string> ("Ice Softness Variable Name"), dl->cell_scalar2) { std::string ice_softnessType; if(p.isParameter("Ice Softness Type")) { ice_softnessType = p.get<std::string>("Ice Softness Type"); } else { ice_softnessType = "Uniform"; } if (ice_softnessType == "Uniform") { ice_softness_type = UNIFORM; A = p.get<Teuchos::ParameterList*>("LandIce Physical Parameters")->get<double>("Ice Softness"); #ifdef OUTPUT_TO_SCREEN *out << "Uniform Ice Softness" << std::endl; #endif } else if (ice_softnessType == "Given Field") { ice_softness_type = GIVEN_FIELD; given_ice_softness = decltype(given_ice_softness)(p.get<std::string> ("Given Ice Softness Field Name"), dl->cell_scalar2); this->addDependentField(given_ice_softness); #ifdef OUTPUT_TO_SCREEN *out << "Ice softness read in from file (exodus or ascii) or passed in from CISM." << std::endl; #endif } else if (ice_softnessType == "Temperature Based") { ice_softness_type = TEMPERATURE_BASED; temperature = decltype(temperature)(p.get<std::string> ("Temperature Variable Name"), dl->cell_scalar2); this->addDependentField(temperature); #ifdef OUTPUT_TO_SCREEN *out << "Ice softness computed using temperature field." << std::endl; #endif } else { TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter, std::endl << "Error in LandIce::IceSoftness: \"" << ice_softnessType << "\" is not a valid parameter for Ice Softness Type" << std::endl); } this->addEvaluatedField(ice_softness); this->setName("IceSoftness"+PHX::typeAsString<EvalT>()); }
//============================================================================== int Ifpack_Chebyshev::SetParameters(Teuchos::ParameterList& List) { EigRatio_ = List.get("chebyshev: ratio eigenvalue", EigRatio_); LambdaMin_ = List.get("chebyshev: min eigenvalue", LambdaMin_); LambdaMax_ = List.get("chebyshev: max eigenvalue", LambdaMax_); PolyDegree_ = List.get("chebyshev: degree",PolyDegree_); MinDiagonalValue_ = List.get("chebyshev: min diagonal value", MinDiagonalValue_); ZeroStartingSolution_ = List.get("chebyshev: zero starting solution", ZeroStartingSolution_); Epetra_Vector* ID = List.get("chebyshev: operator inv diagonal", (Epetra_Vector*)0); EigMaxIters_ = List.get("chebyshev: eigenvalue max iterations",EigMaxIters_); #ifdef HAVE_IFPACK_EPETRAEXT // This is *always* false if EpetraExt isn't enabled UseBlockMode_ = List.get("chebyshev: use block mode",UseBlockMode_); if(!List.isParameter("chebyshev: block list")) UseBlockMode_=false; else{ BlockList_ = List.get("chebyshev: block list",BlockList_); // Since we know we're doing a matrix inverse, clobber the block list // w/"invert" if it's set to multiply Teuchos::ParameterList Blist; Blist=BlockList_.get("blockdiagmatrix: list",Blist); string dummy("invert"); string ApplyMode=Blist.get("apply mode",dummy); if(ApplyMode==string("multiply")){ Blist.set("apply mode","invert"); BlockList_.set("blockdiagmatrix: list",Blist); } } #endif SolveNormalEquations_ = List.get("chebyshev: solve normal equations",SolveNormalEquations_); if (ID != 0) { InvDiagonal_ = Teuchos::rcp( new Epetra_Vector(*ID) ); } SetLabel(); return(0); }
//! Initialize from a parameter list void PresLaplaceLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & pl,const InverseLibrary & invLib) { // get string specifying inverse std::string invStr="Amesos", invVStr="", invPStr=""; bool useLDU = false; scaleType_ = AbsRowSum; // "parse" the parameter list if(pl.isParameter("Inverse Type")) invStr = pl.get<std::string>("Inverse Type"); if(pl.isParameter("Inverse Velocity Type")) invVStr = pl.get<std::string>("Inverse Velocity Type"); if(pl.isParameter("Inverse Pressure Type")) invPStr = pl.get<std::string>("Inverse Pressure Type"); if(pl.isParameter("Use LDU")) useLDU = pl.get<bool>("Use LDU"); if(pl.isParameter("Use Mass Scaling")) useMass_ = pl.get<bool>("Use Mass Scaling"); if(pl.isParameter("Eigen Solver Iterations")) eigSolveParam_ = pl.get<int>("Eigen Solver Iterations"); if(pl.isParameter("Scaling Type")) { scaleType_ = getDiagonalType(pl.get<std::string>("Scaling Type")); TEUCHOS_TEST_FOR_EXCEPT(scaleType_==NotDiag); } // set defaults as needed if(invVStr=="") invVStr = invStr; if(invPStr=="") invPStr = invStr; Teko_DEBUG_MSG_BEGIN(5) DEBUG_STREAM << "LSC Inverse Strategy Parameters: " << std::endl; DEBUG_STREAM << " inv v type = \"" << invVStr << "\"" << std::endl; DEBUG_STREAM << " inv p type = \"" << invPStr << "\"" << std::endl; DEBUG_STREAM << " use ldu = " << useLDU << std::endl; DEBUG_STREAM << " use mass = " << useMass_ << std::endl; DEBUG_STREAM << " scale type = " << getDiagonalName(scaleType_) << std::endl; DEBUG_STREAM << "LSC Pressure Laplace Strategy Parameter list: " << std::endl; pl.print(DEBUG_STREAM); Teko_DEBUG_MSG_END() // build velocity inverse factory invFactoryV_ = invLib.getInverseFactory(invVStr); invFactoryP_ = invFactoryV_; // by default these are the same if(invVStr!=invPStr) // if different, build pressure inverse factory invFactoryP_ = invLib.getInverseFactory(invPStr); // set other parameters setUseFullLDU(useLDU); }