MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_ConstraintFactory_def.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef MUELU_CONSTRAINTFACTORY_DEF_HPP
11#define MUELU_CONSTRAINTFACTORY_DEF_HPP
12
14
15#include "MueLu_Constraint.hpp"
16#include "MueLu_DenseConstraint.hpp"
17#include "MueLu_Monitor.hpp"
18#include "MueLu_MasterList.hpp"
19
20namespace MueLu {
21
22template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
24 RCP<ParameterList> validParamList = rcp(new ParameterList());
25
26#define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
27 SET_VALID_ENTRY("emin: constraint type");
28 validParamList->getEntry("emin: constraint type").setValidator(rcp(new Teuchos::StringValidator(Teuchos::tuple<std::string>("nullspace", "maxwell"))));
29
30 SET_VALID_ENTRY("emin: least squares solver type");
31 validParamList->getEntry("emin: least squares solver type").setValidator(rcp(new Teuchos::StringValidator(Teuchos::tuple<std::string>("Belos", "direct"))));
32#undef SET_VALID_ENTRY
33
34 validParamList->set<RCP<const FactoryBase>>("FineNullspace", Teuchos::null, "Generating factory for the nullspace");
35 validParamList->set<RCP<const FactoryBase>>("CoarseNullspace", Teuchos::null, "Generating factory for the nullspace");
36 validParamList->set<RCP<const FactoryBase>>("Ppattern", Teuchos::null, "Generating factory for the nonzero pattern");
37
38 return validParamList;
39}
40
41template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
43 Input(fineLevel, "Nullspace", "FineNullspace");
44 Input(coarseLevel, "Nullspace", "CoarseNullspace");
45 Input(coarseLevel, "Ppattern");
46}
47
48template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
50 FactoryMonitor m(*this, "Constraint", coarseLevel);
51
52 auto Ppattern = Get<RCP<const CrsGraph>>(coarseLevel, "Ppattern");
53 RCP<Constraint> constraint;
54 const ParameterList& pL = GetParameterList();
55
56 std::string solverType = pL.get<std::string>("emin: least squares solver type");
57
58 if (pL.get<std::string>("emin: constraint type") == "nullspace") {
59 RCP<MultiVector> fineNullspace = Get<RCP<MultiVector>>(fineLevel, "Nullspace", "FineNullspace");
60 RCP<MultiVector> coarseNullspace = Get<RCP<MultiVector>>(coarseLevel, "Nullspace", "CoarseNullspace");
61 {
62 SubFactoryMonitor m2(*this, "Dense Constraint", coarseLevel);
63 constraint = rcp(new DenseConstraint(fineNullspace, coarseNullspace, Ppattern, solverType));
64 }
65 } else {
66 TEUCHOS_ASSERT(false);
67 }
68
69 Set(coarseLevel, "Constraint", constraint);
70}
71
72} // namespace MueLu
73
74#endif // MUELU_CONSTRAINTFACTORY_DEF_HPP
#define SET_VALID_ENTRY(name)
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void Build(Level &fineLevel, Level &coarseLevel) const
Build method.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
Timer to be used in factories. Similar to Monitor but with additional timers.
Class that holds all level-specific information.
Timer to be used in factories. Similar to SubMonitor but adds a timer level by level.
Namespace for MueLu classes and methods.