// @HEADER // ***************************************************************************** // Stokhos Package // // Copyright 2009 NTESS and the Stokhos contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #include "Stokhos_BasisFactory.hpp" #include "Stokhos_ProductBasis.hpp" #include "Stokhos_TensorProductPseudoSpectralOperator.hpp" #include "Stokhos_SmolyakPseudoSpectralOperator.hpp" #include "Stokhos_QuadraturePseudoSpectralOperator.hpp" #include "Stokhos_QuadratureFactory.hpp" template Teuchos::RCP::psop_type> Stokhos::PseudoSpectralOperatorFactory:: create(Teuchos::ParameterList& sgParams) { // Check if operator is already there Teuchos::ParameterList& psopParams = sgParams.sublist("Pseudospectral Operator"); Teuchos::RCP psop = psopParams.template get< Teuchos::RCP >("Stochastic Galerkin Pseudospectral Operator", Teuchos::null); if (psop != Teuchos::null) return psop; // Get basis Teuchos::ParameterList& basisParams = sgParams.sublist("Basis"); Teuchos::RCP< const OrthogPolyBasis > basis; if (basisParams.template isType< Teuchos::RCP< const OrthogPolyBasis > >("Stochastic Galerkin Basis")) basis = basisParams.template get< Teuchos::RCP > >("Stochastic Galerkin Basis"); else basis = BasisFactory::create(sgParams); // Create operator std::string type = psopParams.get("Type", "Tensor Product"); if (type == "Tensor Product") { bool use_pst = psopParams.get("Use PST", false); Teuchos::RCP > product_basis = Teuchos::rcp_dynamic_cast >(basis, true); psop = Teuchos::rcp(new TensorProductPseudoSpectralOperator(*product_basis, use_pst)); } else if (type == "Smolyak") { bool use_pst = psopParams.get("Use PST", true); bool use_smolyak = psopParams.get("Use Smolyak Apply", true); Teuchos::RCP > smolyak_basis = Teuchos::rcp_dynamic_cast >(basis, true); psop = Teuchos::rcp(new SmolyakPseudoSpectralOperator( *smolyak_basis, use_smolyak, use_pst)); } else if (type == "Quadrature") { Teuchos::ParameterList& quadParams = sgParams.sublist("Quadrature"); Teuchos::RCP > quad; if (quadParams.template isType > >("Stochastic Galerkin Quadrature")) quad = quadParams.template get > >("Stochastic Galerkin Quadrature"); else { quad = Stokhos::QuadratureFactory::create(sgParams); quadParams.set("Stochastic Galerkin Quadrature", quad); } psop = Teuchos::rcp(new QuadraturePseudoSpectralOperator(*basis, *quad)); } else TEUCHOS_TEST_FOR_EXCEPTION( true, Teuchos::Exceptions::InvalidParameter, std::endl << "Invalid pseudospectral operator type " << type << std::endl); psopParams.set("Stochastic Galerkin Pseudospectral Operator", psop); return psop; }