MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_ScalarDroppingDistanceLaplacian_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_SCALARDROPPINGDISTANCELAPLACIAN_DEF_HPP
11 #define MUELU_SCALARDROPPINGDISTANCELAPLACIAN_DEF_HPP
12 
14 
15 namespace MueLu {
16 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, Misc::StrengthMeasure SoC>
18  results_view& results,
19  rowptr_type& filtered_rowptr,
20  LocalOrdinal& nnz_filtered,
21  boundary_nodes_type& boundaryNodes,
22  const std::string& droppingMethod,
23  const magnitudeType threshold,
24  const bool aggregationMayCreateDirichlet,
25  const bool symmetrizeDroppedGraph,
26  const bool useBlocking,
27  const std::string& distanceLaplacianMetric,
28  Level& level,
29  const Factory& factory) {
31  auto coords = level.template Get<Teuchos::RCP<doubleMultiVector>>("Coordinates", factory.GetFactory("Coordinates").get());
32  if (distanceLaplacianMetric == "unweighted") {
33  auto dist2 = DistanceLaplacian::UnweightedDistanceFunctor(A, coords);
34  runDroppingFunctors_on_dlap_inner(A, results, filtered_rowptr, nnz_filtered, boundaryNodes, droppingMethod, threshold, aggregationMayCreateDirichlet, symmetrizeDroppedGraph, useBlocking, dist2, level, factory);
35  } else if (distanceLaplacianMetric == "material") {
36  auto material = level.template Get<Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>>("Material", factory.GetFactory("Material").get());
37 
38  if (factory.IsPrint(Runtime0)) {
39  auto spatialDim = coords->getNumVectors();
40  if (material->getNumVectors() == 1) {
41  factory.GetOStream(Runtime0) << "material scalar mean = " << material->getVector(0)->meanValue() << std::endl;
42  } else {
43  TEUCHOS_TEST_FOR_EXCEPTION(spatialDim * spatialDim != material->getNumVectors(), Exceptions::RuntimeError, "Need \"Material\" to have spatialDim^2 vectors.");
44  {
45  Teuchos::Array<Scalar> means(material->getNumVectors());
46  material->meanValue(means());
47  std::stringstream ss;
48  ss << "material tensor mean =" << std::endl;
49  size_t k = 0;
50  for (size_t i = 0; i < spatialDim; ++i) {
51  ss << " ";
52  for (size_t j = 0; j < spatialDim; ++j) {
53  ss << means[k] << " ";
54  ++k;
55  }
56  ss << std::endl;
57  }
58  factory.GetOStream(Runtime0) << ss.str();
59  }
60  }
61  }
62 
63  if (material->getNumVectors() == 1) {
64  auto dist2 = DistanceLaplacian::ScalarMaterialDistanceFunctor(A, coords, material);
65  runDroppingFunctors_on_dlap_inner(A, results, filtered_rowptr, nnz_filtered, boundaryNodes, droppingMethod, threshold, aggregationMayCreateDirichlet, symmetrizeDroppedGraph, useBlocking, dist2, level, factory);
66  } else {
67  auto dist2 = DistanceLaplacian::TensorMaterialDistanceFunctor(A, coords, material);
68  runDroppingFunctors_on_dlap_inner(A, results, filtered_rowptr, nnz_filtered, boundaryNodes, droppingMethod, threshold, aggregationMayCreateDirichlet, symmetrizeDroppedGraph, useBlocking, dist2, level, factory);
69  }
70  }
71 }
72 } // namespace MueLu
73 
74 #define MUELU_ETI_GROUP(SC, LO, GO, NO) \
75  MUELU_ETI_SLGN_SoC(MueLu::ScalarDroppingDistanceLaplacian, SC, LO, GO, NO)
76 
77 #endif
MueLu::DefaultLocalOrdinal LocalOrdinal
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
typename Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
Kokkos::View< DecisionType *, memory_space > results_view
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
One-liner description of what is happening.
typename MueLu::LWGraph_kokkos< LocalOrdinal, GlobalOrdinal, Node >::boundary_nodes_type boundary_nodes_type
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
static void runDroppingFunctors_on_dlap(matrix_type &A, results_view &results, rowptr_type &filtered_rowptr, LocalOrdinal &nnz_filtered, boundary_nodes_type &boundaryNodes, const std::string &droppingMethod, const magnitudeType threshold, const bool aggregationMayCreateDirichlet, const bool symmetrizeDroppedGraph, const bool useBlocking, const std::string &distanceLaplacianMetric, Level &level, const Factory &factory)
typename local_graph_type::row_map_type::non_const_type rowptr_type
Exception throws to report errors in the internal logical of the program.
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Default implementation of FactoryAcceptor::GetFactory()