10 #ifndef AMESOS2_SOLVER_UQ_PCE_HPP
11 #define AMESOS2_SOLVER_UQ_PCE_HPP
13 #include "Amesos2_Solver.hpp"
14 #include "Amesos2_Factory.hpp"
20 template <
class S,
class LO,
class GO,
class NO>
28 return Kokkos::cijk(
A->getLocalValuesDevice(Tpetra::Access::ReadOnly));
31 return Kokkos::cijk(X->getLocalViewDevice(Tpetra::Access::ReadOnly));
34 return Kokkos::cijk(
B->getLocalViewDevice(Tpetra::Access::ReadOnly));
46 class Node,
template<
class,
class>
class ConcreteSolver>
48 public Solver< Tpetra::CrsMatrix<Sacado::UQ::PCE<Storage>,
52 Tpetra::MultiVector<Sacado::UQ::PCE<Storage>,
61 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>
Matrix;
62 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
Vector;
65 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node>
Map;
66 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node>
FlatGraph;
67 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node>
FlatMatrix;
68 typedef Tpetra::MultiVector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node>
FlatVector;
73 typedef typename solver_type::type
type;
83 const size_t pce_size =
99 create_solver_with_supported_type<ConcreteSolver,FlatMatrix,FlatVector>::apply(
flat_A,
flat_X,
flat_B);
268 EPhase keep_phase = CLEAN ) {
273 if (keep_phase <= CLEAN) {
285 if (keep_phase <= SYMBFACT)
310 virtual void setA(
const Matrix* a, EPhase keep_phase = CLEAN ) {
408 virtual std::string
name(
void )
const {
478 template <
template <
class,
class>
class ConcreteSolver,
479 class ST,
class LO,
class GO,
class NO >
480 struct create_solver_with_supported_type<
482 Tpetra::CrsMatrix<Sacado::UQ::PCE<ST>,LO,GO,NO >,
483 Tpetra::MultiVector<Sacado::UQ::PCE<ST>,LO,GO,NO > > {
485 typedef Tpetra::CrsMatrix<SC,LO,GO,NO>
Matrix;
486 typedef Tpetra::MultiVector<SC,LO,GO,NO>
Vector;
494 typename MatrixTraits<Matrix>::scalar_t,
495 typename MultiVecAdapter<Vector>::scalar_t
497 > same_scalar_assertion;
498 (void)same_scalar_assertion;
508 template <
template <
class,
class>
class ConcreteSolver,
510 struct solver_supports_scalar<ConcreteSolver, Sacado::UQ::PCE<Storage> > {
514 static const bool value =
515 std::conditional_t<std::is_same_v<supported_scalars, Meta::nil_t>,
524 #endif // AMESOS2_SOLVER_UQ_PCE_HPP
virtual void setX(const Teuchos::RCP< Vector > x)
Sets the LHS vector X.
Teuchos::RCP< Tpetra::CrsMatrix< typename Storage::value_type, LocalOrdinal, GlobalOrdinal, Node > > create_flat_matrix(const Tpetra::CrsMatrix< Sacado::UQ::PCE< Storage >, LocalOrdinal, GlobalOrdinal, Node > &mat, const Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &flat_graph, const Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &cijk_graph, const CijkType &cijk_dev)
virtual Vector * getXRaw(void)
Returns a raw pointer to the LHS of the linear system.
Scalar::value_type BaseScalar
virtual Status & getStatus() const
Returns a reference to this solver's internal status object.
Stokhos::StandardStorage< int, double > Storage
virtual type & numericFactorization(void)
Performs numeric factorization on the matrix.
virtual const Vector * getBRaw(void)
Returns a raw pointer to the RHS of the linear system.
virtual std::string description(void) const
Returns a short description of this Solver.
Sacado::UQ::PCE< Storage > Scalar
Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
Teuchos::RCP< const Matrix > A
Solver< FlatMatrix, FlatVector > FlatSolver
Scalar::value_type BaseScalar
virtual const Teuchos::RCP< Vector > getX(void)
Returns the vector that is the LHS of the linear system.
Teuchos::RCP< const Tpetra::MultiVector< typename Storage::value_type, LocalOrdinal, GlobalOrdinal, Node > > create_flat_vector_view(const Tpetra::MultiVector< Sacado::UQ::PCE< Storage >, LocalOrdinal, GlobalOrdinal, Node > &vec, const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_map)
virtual void setA(const Teuchos::RCP< const Matrix > a, EPhase keep_phase=CLEAN)
Sets the matrix A of this solver.
Teuchos::RCP< const Vector > B
virtual Teuchos::RCP< const Teuchos::ParameterList > getValidParameters(void) const
Return a const parameter list of all of the valid parameters that this->setParameterList(...) will accept.
virtual void printTiming(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Prints timing information about the current solver.
virtual void setA(const Matrix *a, EPhase keep_phase=CLEAN)
Sets the matrix A of this solver.
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
virtual void solve(const Teuchos::Ptr< Vector > XX, const Teuchos::Ptr< const Vector > BB) const
Solve using the given X and B vectors.
Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > Matrix
Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > Vector
Scalar::cijk_type cijk_type
Tpetra::CrsMatrix< SC, LO, GO, NO > Matrix
Sacado::UQ::PCE< Storage > Scalar
Amesos2 solver adapter for UQ::PCE scalar type.
virtual std::string name(void) const
Return the name of this solver.
virtual void setB(const Teuchos::RCP< const Vector > b)
Sets the RHS vector B.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
static Teuchos::RCP< Solver< Matrix, Vector > > apply(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
virtual void setX(Vector *x)
Sets the LHS vector X using a raw pointer.
Tpetra::MultiVector< SC, LO, GO, NO > Vector
virtual void solve(Vector *XX, const Vector *BB) const
Solve using the given X and B vectors.
Teuchos::RCP< const FlatGraph > flat_graph
ConcreteSolver< FlatMatrix, FlatVector > FlatConcreteSolver
Teuchos::RCP< FlatVector > flat_X
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm(void) const
Returns a pointer to the Teuchos::Comm communicator with this matrix.
Teuchos::RCP< const Map > flat_B_map
virtual bool matrixShapeOK(void)
Returns true if the solver can handle the matrix shape.
Tpetra::MultiVector< BaseScalar, LocalOrdinal, GlobalOrdinal, Node > FlatVector
static const EVerbosityLevel verbLevel_default
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, typename CijkType< view_type >::type >::type cijk(const view_type &view)
Teuchos::RCP< const FlatMatrix > flat_A
Solver< Matrix, Vector > solver_type
virtual type & preOrdering(void)
Pre-orders the matrix.
virtual type & symbolicFactorization(void)
Performs symbolic factorization on the matrix.
Teuchos::RCP< const Map > flat_X_map
virtual void getTiming(Teuchos::ParameterList &timingParameterList) const
Extracts timing information from the current solver.
virtual const Teuchos::RCP< const Vector > getB(void)
Returns the vector that is the RHS of the linear system.
Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > FlatGraph
Teuchos::RCP< FlatSolver > flat_solver
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType Node
Teuchos::RCP< const FlatGraph > cijk_graph
Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > create_flat_pce_graph(const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > &graph, const CijkType &cijk, Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_domain_map, Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_range_map, Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &cijk_graph, const size_t matrix_pce_size)
Teuchos::RCP< const FlatVector > flat_B
PCESolverAdapter(const Teuchos::RCP< const Matrix > &A_, const Teuchos::RCP< Vector > &X_, const Teuchos::RCP< const Vector > &B_)
Constructor.
solver_traits< ConcreteSolver >::supported_scalars supported_scalars
Tpetra::CrsMatrix< BaseScalar, LocalOrdinal, GlobalOrdinal, Node > FlatMatrix
virtual void setB(const Vector *b)
Sets the RHS vector B using a raw pointer.
virtual type & setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Set/update internal variables and solver options.
Sacado::UQ::PCE< S >::cijk_type get_pce_cijk(const Teuchos::RCP< const Tpetra::CrsMatrix< Sacado::UQ::PCE< S >, LO, GO, NO > > &A=Teuchos::null, const Teuchos::RCP< Tpetra::MultiVector< Sacado::UQ::PCE< S >, LO, GO, NO > > &X=Teuchos::null, const Teuchos::RCP< const Tpetra::MultiVector< Sacado::UQ::PCE< S >, LO, GO, NO > > &B=Teuchos::null)
virtual void solve(void)
Solves (or )