10 #ifndef MUELU_Q2Q1Q2COARSEGRIDFACTORY_DEF_HPP
11 #define MUELU_Q2Q1Q2COARSEGRIDFACTORY_DEF_HPP
18 #include <Xpetra_Map.hpp>
19 #include <Xpetra_MapFactory.hpp>
22 #include <Xpetra_MultiVectorFactory.hpp>
24 #include <Xpetra_CrsMatrixWrap.hpp>
31 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
33 GetOStream(
Runtime1) <<
"I constructed a Q2Q1Q2CoarseGridFactory object... Nothing else to do here." << std::endl;
36 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
41 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
43 Input(fineLevel,
"VElementList");
44 Input(fineLevel,
"PElementList");
45 Input(fineLevel,
"MElementList");
47 Input(coarseLevel,
"VElementList");
48 Input(coarseLevel,
"PElementList");
49 Input(coarseLevel,
"MElementList");
54 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
56 GetOStream(
Runtime1) <<
"Starting 'build' routine...\n";
64 return BuildCoarseGrid(fineLevel, coarseLevel);
67 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 GetOStream(
Runtime1) <<
"starting 'BuildCoarseGrid' routine...\n";
73 GO totalFineElements = fineElementPDOFs->numRows();
76 GO totalCoarseElements = totalFineElements / 4;
77 LO nCoarseElements = (int)sqrt(totalCoarseElements);
80 size_t EdgeCount = (nCoarseElements + 1) * (nCoarseElements + 1);
81 size_t CenterCount = EdgeCount + 2 * nCoarseElements * (nCoarseElements + 1);
88 for (
GO coarseElement = 0; coarseElement < totalCoarseElements; coarseElement++) {
97 if (coarseElement < nCoarseElements) {
99 (*coarseElementMDOFs)(coarseElement, 0) = coarseElement;
100 (*coarseElementMDOFs)(coarseElement, 1) = coarseElement + 1;
103 (*coarseElementMDOFs)(coarseElement, 4) = EdgeCount++;
107 (*coarseElementMDOFs)(coarseElement, 0) = (*coarseElementMDOFs)(coarseElement - nCoarseElements, 3);
108 (*coarseElementMDOFs)(coarseElement, 1) = (*coarseElementMDOFs)(coarseElement - nCoarseElements, 2);
111 (*coarseElementMDOFs)(coarseElement, 4) = (*coarseElementMDOFs)(coarseElement - nCoarseElements, 6);
115 (*coarseElementMDOFs)(coarseElement, 5) = EdgeCount++;
116 (*coarseElementMDOFs)(coarseElement, 6) = EdgeCount++;
119 if (coarseElement % nCoarseElements == 0) {
121 (*coarseElementMDOFs)(coarseElement, 3) = (*coarseElementMDOFs)(coarseElement, 0) + nCoarseElements + 1;
124 (*coarseElementMDOFs)(coarseElement, 7) = EdgeCount++;
128 (*coarseElementMDOFs)(coarseElement, 3) = (*coarseElementMDOFs)(coarseElement - 1, 2);
131 (*coarseElementMDOFs)(coarseElement, 7) = (*coarseElementMDOFs)(coarseElement - 1, 5);
135 (*coarseElementMDOFs)(coarseElement, 2) = (*coarseElementMDOFs)(coarseElement, 3) + 1;
138 (*coarseElementMDOFs)(coarseElement, 8) = CenterCount++;
142 (*coarseElementVDOFs)(coarseElement, 0) = 2 * (*coarseElementMDOFs)(coarseElement, 0);
143 (*coarseElementVDOFs)(coarseElement, 1) = 2 * (*coarseElementMDOFs)(coarseElement, 0) + 1;
144 (*coarseElementVDOFs)(coarseElement, 2) = 2 * (*coarseElementMDOFs)(coarseElement, 1);
145 (*coarseElementVDOFs)(coarseElement, 3) = 2 * (*coarseElementMDOFs)(coarseElement, 1) + 1;
146 (*coarseElementVDOFs)(coarseElement, 4) = 2 * (*coarseElementMDOFs)(coarseElement, 2);
147 (*coarseElementVDOFs)(coarseElement, 5) = 2 * (*coarseElementMDOFs)(coarseElement, 2) + 1;
148 (*coarseElementVDOFs)(coarseElement, 6) = 2 * (*coarseElementMDOFs)(coarseElement, 3);
149 (*coarseElementVDOFs)(coarseElement, 7) = 2 * (*coarseElementMDOFs)(coarseElement, 3) + 1;
150 (*coarseElementVDOFs)(coarseElement, 8) = 2 * (*coarseElementMDOFs)(coarseElement, 4);
151 (*coarseElementVDOFs)(coarseElement, 9) = 2 * (*coarseElementMDOFs)(coarseElement, 4) + 1;
152 (*coarseElementVDOFs)(coarseElement, 10) = 2 * (*coarseElementMDOFs)(coarseElement, 5);
153 (*coarseElementVDOFs)(coarseElement, 11) = 2 * (*coarseElementMDOFs)(coarseElement, 5) + 1;
154 (*coarseElementVDOFs)(coarseElement, 12) = 2 * (*coarseElementMDOFs)(coarseElement, 6);
155 (*coarseElementVDOFs)(coarseElement, 13) = 2 * (*coarseElementMDOFs)(coarseElement, 6) + 1;
156 (*coarseElementVDOFs)(coarseElement, 14) = 2 * (*coarseElementMDOFs)(coarseElement, 7);
157 (*coarseElementVDOFs)(coarseElement, 15) = 2 * (*coarseElementMDOFs)(coarseElement, 7) + 1;
158 (*coarseElementVDOFs)(coarseElement, 16) = 2 * (*coarseElementMDOFs)(coarseElement, 8);
159 (*coarseElementVDOFs)(coarseElement, 17) = 2 * (*coarseElementMDOFs)(coarseElement, 8) + 1;
162 (*coarseElementPDOFs)(coarseElement, 0) = (*coarseElementMDOFs)(coarseElement, 0);
163 (*coarseElementPDOFs)(coarseElement, 1) = (*coarseElementMDOFs)(coarseElement, 1);
164 (*coarseElementPDOFs)(coarseElement, 2) = (*coarseElementMDOFs)(coarseElement, 2);
165 (*coarseElementPDOFs)(coarseElement, 3) = (*coarseElementMDOFs)(coarseElement, 3);
169 Set(coarseLevel,
"VElementList", coarseElementVDOFs);
170 Set(coarseLevel,
"PElementList", coarseElementPDOFs);
171 Set(coarseLevel,
"MElementList", coarseElementMDOFs);
181 #define MUELU_Q2Q1Q2COARSEGRIDFACTORY_SHORT
182 #endif // MUELU_Q2Q1Q2COARSEGRIDFACTORY_DEF_HPP
Q2Q1Q2CoarseGridFactory()
Constructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
virtual ~Q2Q1Q2CoarseGridFactory()
Destructor.
Description of what is happening (more verbose)
void BuildCoarseGrid(Level &fineLevel, Level &coarseLevel) const
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Specifies the data that this class needs, and the factories that generate that data.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.