27 RCP<ParameterList> validParamList = rcp(
new ParameterList());
29#define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
32 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).");
34 validParamList->set<RCP<const FactoryBase>>(
"A", Teuchos::null,
"Generating factory of the fine level matrix (only needed if default null space is generated)");
35 validParamList->set<RCP<const FactoryBase>>(
"Nullspace", Teuchos::null,
"Generating factory of the fine level null space");
36 validParamList->set<RCP<const FactoryBase>>(
"Coordinates", Teuchos::null,
"Generating factory of the coordinates");
41 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.");
42 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.");
43 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.");
44 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.");
45 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.");
46 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.");
47 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.");
48 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.");
49 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.");
51 return validParamList;
138 RCP<MultiVector> nullspace;
141 const ParameterList& pL = GetParameterList();
142 std::string nspName = pL.get<std::string>(
"Fine level nullspace");
146 RCP<RealValuedMultiVector> Coords;
153 GetOStream(
Runtime1) <<
"Use user-given nullspace " << nspName <<
":"
154 <<
" nullspace dimension=" << nullspace->getNumVectors()
155 <<
" nullspace length=" << nullspace->getGlobalLength() << std::endl;
159 auto A = Get<RCP<Matrix>>(currentLevel,
"A");
163 if (A->IsView(
"stridedMaps") ==
true) {
164 Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps");
165 TEUCHOS_TEST_FOR_EXCEPTION(rcp_dynamic_cast<const StridedMap>(A->getRowMap()).is_null(),
Exceptions::BadCast,
166 "MueLu::CoalesceFactory::Build: cast to strided row map failed.");
167 numPDEs = rcp_dynamic_cast<const StridedMap>(A->getRowMap())->getFixedBlockSize();
168 oldView = A->SwitchToView(oldView);
171 LO nullspaceDim = numPDEs;
175 if (calculateRotations_) {
176 Coords = Get<RCP<RealValuedMultiVector>>(currentLevel,
"Coordinates");
177 if (Coords->getNumVectors() > 1) nullspaceDim++;
178 if (Coords->getNumVectors() > 2) nullspaceDim += 2;
180 meanView =
MeanCoordsType(
"mean coords", Coords->getNumVectors());
181 Teuchos::Array<coordinate_type> hostMeans(Coords->getNumVectors());
182 Coords->meanValue(hostMeans);
183 Kokkos::View<typename RealValuedMultiVector::impl_scalar_type*, Kokkos::HostSpace> hostMeanView(hostMeans.getRawPtr(), hostMeans.size());
184 Kokkos::deep_copy(meanView, hostMeanView);
185 coordsView = Coords->getLocalViewDevice(Tpetra::Access::ReadOnly);
186 GetOStream(
Runtime1) <<
"Generating nullspace with rotations: dimension = " << nullspaceDim << std::endl;
188 GetOStream(
Runtime1) <<
"Generating canonical nullspace: dimension = " << numPDEs << std::endl;
190 nullspace = MultiVectorFactory::Build(A->getDomainMap(), nullspaceDim);
192 fillNullspaceVector(nullspace, numPDEs, nullspaceDim, coordsView, meanView);
198 nullspace = currentLevel.
Get<RCP<MultiVector>>(
"Nullspace", GetFactory(nspName).get());
202 Set(currentLevel,
"Nullspace", nullspace);
208 RCP<BlockedMultiVector> bnsp = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(nullspace);
209 if (bnsp.is_null() ==
true) {
210 auto nullspaceView = nullspace->getLocalViewDevice(Tpetra::Access::OverwriteAll);
212 int numBlocks = nullspace->getLocalLength() / numPDEs;
213 if (nullspaceDim > numPDEs)
214 TEUCHOS_TEST_FOR_EXCEPTION(numBlocks != coordsView.extent_int(0),
Exceptions::RuntimeError,
"MueLu::NullspaceFactory::fillNullspaceVector(): number of coordinates does not match ndofs/numPDEs.");
216 NullspaceFunctor<
decltype(nullspaceView),
decltype(coordsView),
decltype(meanView), LO> nullspaceFunctor(nullspaceView, coordsView, meanView, numPDEs, nullspaceDim);
217 Kokkos::parallel_for(
"MueLu:NullspaceF:Build:for",
range_type(0, numBlocks), nullspaceFunctor);
234 RCP<const BlockedMap> bmap = bnsp->getBlockedMap();
235 for (
size_t r = 0; r < bmap->getNumMaps(); r++) {
236 Teuchos::RCP<MultiVector> part = bnsp->getMultiVector(r);
237 fillNullspaceVector(part, numPDEs, nullspaceDim, coordsView, meanView);
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....