| 1 |
//@HEADER |
| 2 |
// ************************************************************************ |
| 3 |
// |
| 4 |
// Kokkos v. 4.0 |
| 5 |
// Copyright (2022) National Technology & Engineering |
| 6 |
// Solutions of Sandia, LLC (NTESS). |
| 7 |
// |
| 8 |
// Under the terms of Contract DE-NA0003525 with NTESS, |
| 9 |
// the U.S. Government retains certain rights in this software. |
| 10 |
// |
| 11 |
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. |
| 12 |
// See https://kokkos.org/LICENSE for license information. |
| 13 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 14 |
// |
| 15 |
//@HEADER |
| 16 |
|
| 17 |
// Use "scalar" version of mean-based preconditioner (i.e., a preconditioner |
| 18 |
// with double as the scalar type). This is currently necessary to get the |
| 19 |
// MueLu tests to pass on OpenMP and Cuda due to various kernels that don't |
| 20 |
// work with the PCE scalar type. |
| 21 |
#define USE_SCALAR_MEAN_BASED_PREC 1 |
| 22 |
|
| 23 |
#include "Stokhos_Tpetra_UQ_PCE.hpp" |
| 24 |
#include "Stokhos_Sacado_Kokkos_MP_Vector.hpp" |
| 25 |
|
| 26 |
#if defined( HAVE_STOKHOS_BELOS ) |
| 27 |
#include "Belos_TpetraAdapter_UQ_PCE.hpp" |
| 28 |
#endif |
| 29 |
|
| 30 |
#if defined( HAVE_STOKHOS_MUELU ) |
| 31 |
#include "Stokhos_MueLu_UQ_PCE.hpp" |
| 32 |
#endif |
| 33 |
|
| 34 |
#include <Kokkos_Core.hpp> |
| 35 |
#include <HexElement.hpp> |
| 36 |
#include <fenl.hpp> |
| 37 |
#include <fenl_functors_pce.hpp> |
| 38 |
|
| 39 |
#if defined(HAVE_TRILINOSCOUPLINGS_BELOS) && defined(HAVE_TRILINOSCOUPLINGS_MUELU) |
| 40 |
#include <MeanBasedPreconditioner.hpp> |
| 41 |
#include "Stokhos_Tpetra_Utilities.hpp" |
| 42 |
|
| 43 |
namespace Kokkos { |
| 44 |
namespace Example { |
| 45 |
|
| 46 |
// Overload of build_mean_based_muelu_preconditioner() for UQ::PCE scalar type |
| 47 |
template<class S, class LO, class GO, class N> |
| 48 |
Teuchos::RCP<Tpetra::Operator<Sacado::UQ::PCE<S>,LO,GO,N> > |
| 49 |
build_mean_based_muelu_preconditioner( |
| 50 |
const Teuchos::RCP<Tpetra::CrsMatrix<Sacado::UQ::PCE<S>,LO,GO,N> >& A, |
| 51 |
const Teuchos::RCP<Teuchos::ParameterList>& precParams, |
| 52 |
const Teuchos::RCP<Tpetra::MultiVector<double,LO,GO,N> >& coords) |
| 53 |
{ |
| 54 |
typedef Sacado::UQ::PCE<S> Scalar; |
| 55 |
typedef typename Scalar::value_type BaseScalar; |
| 56 |
|
| 57 |
using Teuchos::RCP; |
| 58 |
using Teuchos::rcp; |
| 59 |
|
| 60 |
#if USE_SCALAR_MEAN_BASED_PREC |
| 61 |
RCP<Tpetra::CrsMatrix<BaseScalar,LO,GO,N> > mean_scalar = |
| 62 |
build_mean_scalar_matrix(*A); |
| 63 |
RCP<Tpetra::Operator<BaseScalar,LO,GO,N> > prec_scalar = |
| 64 |
build_muelu_preconditioner(mean_scalar, precParams, coords); |
| 65 |
RCP<Tpetra::Operator<Scalar,LO,GO,N> > prec = |
| 66 |
rcp(new Stokhos::MeanBasedTpetraOperator<Scalar,LO,GO,N>(prec_scalar)); |
| 67 |
#else |
| 68 |
RCP<Tpetra::CrsMatrix<Scalar,LO,GO,N> > mean = |
| 69 |
Stokhos::build_mean_matrix(*A); |
| 70 |
RCP<Tpetra::Operator<Scalar,LO,GO,N> > prec = |
| 71 |
build_muelu_preconditioner(mean, precParams, coords); |
| 72 |
#endif |
| 73 |
|
| 74 |
return prec; |
| 75 |
} |
| 76 |
|
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
#endif |
| 81 |
|
| 82 |
#include <fenl_impl.hpp> |