46 #ifndef MUELU_INDEXMANAGER_DEF_KOKKOS_HPP
47 #define MUELU_INDEXMANAGER_DEF_KOKKOS_HPP
49 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
55 #include <Xpetra_MapFactory.hpp>
69 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 IndexManager_kokkos<LocalOrdinal, GlobalOrdinal, Node>::
71 IndexManager_kokkos(
const int NumDimensions,
72 const int interpolationOrder,
74 const ArrayView<const LO> LFineNodesPerDir,
75 const ArrayView<const int> CoarseRate) :
76 myRank(MyRank), coarseRate(
"coarsening rate"), endRate(
"endRate"),
77 lFineNodesPerDir(
"lFineNodesPerDir"), coarseNodesPerDir(
"lFineNodesPerDir") {
79 RCP<Teuchos::FancyOStream> out;
80 if(
const char* dbg = std::getenv(
"MUELU_INDEXMANAGER_DEBUG")) {
81 out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
82 out->setShowAllFrontMatter(
false).setShowProcRank(
true);
87 setupIM(NumDimensions, interpolationOrder, CoarseRate, LFineNodesPerDir);
89 *out <<
"Done setting up the IndexManager" << std::endl;
91 computeMeshParameters();
93 *out <<
"Computed Mesh Parameters" << std::endl;
97 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
98 void IndexManager_kokkos<LocalOrdinal, GlobalOrdinal, Node>::
99 setupIM(
const int NumDimensions,
const int interpolationOrder,
100 const ArrayView<const int> CoarseRate,
const ArrayView<const LO> LFineNodesPerDir) {
102 numDimensions = NumDimensions;
103 interpolationOrder_ = interpolationOrder;
106 && (LFineNodesPerDir.size() != numDimensions),
107 Exceptions::RuntimeError,
108 "LFineNodesPerDir has to be of size 3 or of size numDimensions!");
117 for(
int dim = 0; dim < 3; ++dim) {
118 if(dim < getNumDimensions()) {
119 lFineNodesPerDir_h(dim) = LFineNodesPerDir[dim];
120 if(CoarseRate.size() == 1) {
121 coarseRate_h(dim) = CoarseRate[0];
122 }
else if(CoarseRate.size() == getNumDimensions()) {
123 coarseRate_h(dim) = CoarseRate[dim];
126 lFineNodesPerDir_h(dim) = 1;
127 coarseRate_h(dim) = 1;
136 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
137 void IndexManager_kokkos<LocalOrdinal, GlobalOrdinal, Node>::computeMeshParameters() {
139 RCP<Teuchos::FancyOStream> out;
140 if(
const char* dbg = std::getenv(
"MUELU_INDEXMANAGER_DEBUG")) {
141 out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
142 out->setShowAllFrontMatter(
false).setShowProcRank(
true);
155 lNumFineNodes10 = lFineNodesPerDir_h(1)*lFineNodesPerDir_h(0);
156 lNumFineNodes = lFineNodesPerDir_h(2)*lNumFineNodes10;
157 for(
int dim = 0; dim < 3; ++dim) {
158 if(dim < numDimensions) {
159 endRate_h(dim) = (lFineNodesPerDir_h(dim) - 1) % coarseRate_h(dim);
160 if(endRate_h(dim) == 0) {endRate_h(dim) = coarseRate_h(dim);}
167 *out <<
"lFineNodesPerDir: {" << lFineNodesPerDir_h(0) <<
", " << lFineNodesPerDir_h(1) <<
", "
168 << lFineNodesPerDir_h(2) <<
"}" << std::endl;
169 *out <<
"endRate: {" << endRate_h(0) <<
", " << endRate_h(1) <<
", "
170 << endRate_h(2) <<
"}" << std::endl;
185 for(
int dim = 0; dim < 3; ++dim) {
186 if(dim < numDimensions) {
190 coarseNodesPerDir_h(dim) = (lFineNodesPerDir_h(dim) - endRate_h(dim) - 1)
191 / coarseRate_h(dim) + 2;
195 coarseNodesPerDir_h(dim) = 1;
200 if(lFineNodesPerDir_h(dim) < 1) {coarseNodesPerDir_h(dim) = 0;}
204 numCoarseNodes10 = coarseNodesPerDir_h(0)*coarseNodesPerDir_h(1);
205 numCoarseNodes = numCoarseNodes10*coarseNodesPerDir_h(2);
207 *out <<
"coarseNodesPerDir: {" << coarseNodesPerDir_h(0) <<
", "
208 << coarseNodesPerDir_h(1) <<
", " << coarseNodesPerDir_h(2) <<
"}" << std::endl;
209 *out <<
"numCoarseNodes=" << numCoarseNodes << std::endl;
218 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
219 Array<LocalOrdinal> IndexManager_kokkos<LocalOrdinal, GlobalOrdinal, Node>::
220 getCoarseNodesPerDirArray()
const {
221 typename LOTupleView::HostMirror coarseNodesPerDir_h = Kokkos::create_mirror_view(coarseNodesPerDir);
222 Array<LO> coarseNodesPerDirArray(3);
224 for(
int dim = 0; dim < 3; ++dim) {
225 coarseNodesPerDirArray[dim] = coarseNodesPerDir_h(dim);
228 return coarseNodesPerDirArray;
233 #endif // HAVE_MUELU_KOKKOS_REFACTOR
234 #define MUELU_INDEXMANAGER_KOKKOS_SHORT
235 #endif // MUELU_INDEXMANAGER_DEF_KOKKOS_HPP
void deep_copy(const View< DT, DP...> &dst, typename ViewTraits< DT, DP...>::const_value_type &value, typename std::enable_if< std::is_same< typename ViewTraits< DT, DP...>::specialize, void >::value >::type *=nullptr)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)