46 #ifndef MUELU_NULLSPACEFACTORY_KOKKOS_DEF_HPP 
   47 #define MUELU_NULLSPACEFACTORY_KOKKOS_DEF_HPP 
   49 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 
   54 #include <Xpetra_MultiVectorFactory.hpp> 
   61   template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class DeviceType>
 
   62   RCP<const ParameterList> NullspaceFactory_kokkos<Scalar,LocalOrdinal,GlobalOrdinal,Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType>>::GetValidParameterList()
 const {
 
   63     RCP<ParameterList> validParamList = 
rcp(
new ParameterList());
 
   65     validParamList->set< RCP<const FactoryBase> >(
"A",          Teuchos::null, 
"Generating factory of the fine level matrix (only needed if default null space is generated)");
 
   66     validParamList->set< RCP<const FactoryBase> >(
"Nullspace",  Teuchos::null, 
"Generating factory of the fine level null space");
 
   69     validParamList->set< std::string >(
"Fine level nullspace", 
"Nullspace", 
"Variable name which is used to store null space multi vector on the finest level (default=\"Nullspace\"). For block matrices also \"Nullspace1\" to \"Nullspace9\" are accepted to describe the null space vectors for the (i,i) block (i=1..9).");
 
   72     validParamList->set< RCP<const FactoryBase> >(
"Nullspace1", Teuchos::null, 
"Generating factory of the fine level null space associated with the (1,1) block in your n x n block matrix.");
 
   73     validParamList->set< RCP<const FactoryBase> >(
"Nullspace2", Teuchos::null, 
"Generating factory of the fine level null space associated with the (2,2) block in your n x n block matrix.");
 
   74     validParamList->set< RCP<const FactoryBase> >(
"Nullspace3", Teuchos::null, 
"Generating factory of the fine level null space associated with the (3,3) block in your n x n block matrix.");
 
   75     validParamList->set< RCP<const FactoryBase> >(
"Nullspace4", Teuchos::null, 
"Generating factory of the fine level null space associated with the (4,4) block in your n x n block matrix.");
 
   76     validParamList->set< RCP<const FactoryBase> >(
"Nullspace5", Teuchos::null, 
"Generating factory of the fine level null space associated with the (5,5) block in your n x n block matrix.");
 
   77     validParamList->set< RCP<const FactoryBase> >(
"Nullspace6", Teuchos::null, 
"Generating factory of the fine level null space associated with the (6,6) block in your n x n block matrix.");
 
   78     validParamList->set< RCP<const FactoryBase> >(
"Nullspace7", Teuchos::null, 
"Generating factory of the fine level null space associated with the (7,7) block in your n x n block matrix.");
 
   79     validParamList->set< RCP<const FactoryBase> >(
"Nullspace8", Teuchos::null, 
"Generating factory of the fine level null space associated with the (8,8) block in your n x n block matrix.");
 
   80     validParamList->set< RCP<const FactoryBase> >(
"Nullspace9", Teuchos::null, 
"Generating factory of the fine level null space associated with the (9,9) block in your n x n block matrix.");
 
   82     return validParamList;
 
   85   template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class DeviceType>
 
   86   void NullspaceFactory_kokkos<Scalar,LocalOrdinal,GlobalOrdinal,Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType>>::DeclareInput(Level& currentLevel)
 const {
 
   87     const ParameterList& pL = GetParameterList();
 
   88     std::string nspName = pL.get<std::string>(
"Fine level nullspace");
 
   93     if (currentLevel.IsAvailable(nspName, 
NoFactory::get()) == 
false && currentLevel.GetLevelID() == 0)
 
   94       Input(currentLevel, 
"A");
 
   96     if (currentLevel.GetLevelID() != 0) {
 
  103         "MueLu::NullspaceFactory::DeclareInput(): You must declare an existing factory which " 
  104         "produces the variable \"Nullspace\" in the NullspaceFactory (e.g. a TentativePFactory).");
 
  105       currentLevel.DeclareInput(
"Nullspace", GetFactory(nspName).
get(), 
this); 
 
  109   template<
class NullspaceType, 
class LO>
 
  110   class NullspaceFunctor {
 
  112     NullspaceType                               nullspace;
 
  114     typedef typename NullspaceType::value_type  
SC;
 
  115     typedef Kokkos::ArithTraits<SC>             ATS;
 
  118     NullspaceFunctor(NullspaceType nullspace_, 
LO numPDEs_) :
 
  119       nullspace(nullspace_),
 
  123     KOKKOS_INLINE_FUNCTION
 
  124     void operator()(
const LO j)
 const {
 
  126       for  (
LO i = 0; i < numPDEs; i++)
 
  127         nullspace(j*numPDEs + i, i) = one;
 
  130   template <
class Scalar, 
class LocalOrdinal, 
class GlobalOrdinal, 
class DeviceType>
 
  131   void NullspaceFactory_kokkos<Scalar,LocalOrdinal,GlobalOrdinal,Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType>>::Build(Level& currentLevel)
 const {
 
  132     FactoryMonitor m(*
this, 
"Nullspace factory", currentLevel);
 
  134     RCP<MultiVector> nullspace;
 
  137     const ParameterList& pL = GetParameterList();
 
  138     std::string nspName = pL.get<std::string>(
"Fine level nullspace");
 
  140     if (currentLevel.GetLevelID() == 0) {
 
  144         nullspace = currentLevel.Get< RCP<MultiVector> >(nspName, 
NoFactory::get());
 
  145         GetOStream(
Runtime1) << 
"Use user-given nullspace " << nspName << 
":" 
  146             << 
" nullspace dimension=" << nullspace->getNumVectors()
 
  147             << 
" nullspace length="    << nullspace->getGlobalLength() << std::endl;
 
  151         auto A = Get< RCP<Matrix> >(currentLevel, 
"A");
 
  155         if (A->IsView(
"stridedMaps") == 
true) {
 
  158                                      "MueLu::CoalesceFactory::Build: cast to strided row map failed.");
 
  159           numPDEs = rcp_dynamic_cast<
const StridedMap>(A->getRowMap())->getFixedBlockSize();
 
  160           oldView = A->SwitchToView(oldView);
 
  163         GetOStream(
Runtime1) << 
"Generating canonical nullspace: dimension = " << numPDEs << std::endl;
 
  165         nullspace = MultiVectorFactory::Build(A->getDomainMap(), numPDEs);
 
  166         auto nullspaceView = nullspace->template getLocalView<DeviceType>();
 
  168         int numBlocks = nullspace->getLocalLength() / numPDEs;
 
  170         NullspaceFunctor<decltype(nullspaceView), LO> nullspaceFunctor(nullspaceView, numPDEs);
 
  178       nullspace = currentLevel.Get< RCP<MultiVector> >(
"Nullspace", GetFactory(nspName).get()); 
 
  182     Set(currentLevel, 
"Nullspace", nullspace);
 
  188 #endif // HAVE_MUELU_KOKKOS_REFACTOR 
  189 #endif // MUELU_NULLSPACEFACTORY_KOKKOS_DEF_HPP 
void parallel_for(const ExecPolicy &policy, const FunctorType &functor, const std::string &str="", typename Impl::enable_if< Kokkos::Impl::is_execution_policy< ExecPolicy >::value >::type *=0)
 
bool is_null(const boost::shared_ptr< T > &p)
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
static const NoFactory * get()
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
Description of what is happening (more verbose)