46 #ifndef MUELU_Q2Q1Q2COARSEGRIDFACTORY_DEF_HPP
47 #define MUELU_Q2Q1Q2COARSEGRIDFACTORY_DEF_HPP
54 #include <Xpetra_Map.hpp>
55 #include <Xpetra_MapFactory.hpp>
56 #include <Xpetra_Matrix.hpp>
57 #include <Xpetra_MultiVector.hpp>
58 #include <Xpetra_MultiVectorFactory.hpp>
59 #include <Xpetra_VectorFactory.hpp>
60 #include <Xpetra_CrsMatrixWrap.hpp>
61 #include <Xpetra_MultiVector.hpp>
62 #include <Xpetra_MultiVectorFactory.hpp>
67 #include <MueLu_Utilities.hpp>
73 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 GetOStream(
Runtime1) <<
"I constructed a Q2Q1Q2CoarseGridFactory object... Nothing else to do here." << std::endl;
78 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
83 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 Input(fineLevel,
"VElementList");
87 Input(fineLevel,
"PElementList");
88 Input(fineLevel,
"MElementList");
90 Input(coarseLevel,
"VElementList");
91 Input(coarseLevel,
"PElementList");
92 Input(coarseLevel,
"MElementList");
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
101 GetOStream(
Runtime1) <<
"Starting 'build' routine...\n";
109 return BuildCoarseGrid(fineLevel,coarseLevel);
114 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
118 GetOStream(
Runtime1) <<
"starting 'BuildCoarseGrid' routine...\n";
122 GO totalFineElements = fineElementPDOFs->numRows();
125 GO totalCoarseElements = totalFineElements/4;
126 LO nCoarseElements = (int) sqrt(totalCoarseElements);
129 size_t EdgeCount = (nCoarseElements + 1) * (nCoarseElements + 1);
130 size_t CenterCount = EdgeCount + 2 * nCoarseElements * (nCoarseElements + 1);
139 for ( GO coarseElement=0; coarseElement < totalCoarseElements; coarseElement++ )
150 if (coarseElement < nCoarseElements)
153 (*coarseElementMDOFs)(coarseElement,0) = coarseElement;
154 (*coarseElementMDOFs)(coarseElement,1) = coarseElement+1;
157 (*coarseElementMDOFs)(coarseElement,4) = EdgeCount++;
163 (*coarseElementMDOFs)(coarseElement,0) = (*coarseElementMDOFs)(coarseElement-nCoarseElements,3);
164 (*coarseElementMDOFs)(coarseElement,1) = (*coarseElementMDOFs)(coarseElement-nCoarseElements,2);
167 (*coarseElementMDOFs)(coarseElement,4) = (*coarseElementMDOFs)(coarseElement-nCoarseElements,6);
173 (*coarseElementMDOFs)(coarseElement,5) = EdgeCount++;
174 (*coarseElementMDOFs)(coarseElement,6) = EdgeCount++;
178 if (coarseElement % nCoarseElements == 0)
181 (*coarseElementMDOFs)(coarseElement,3) = (*coarseElementMDOFs)(coarseElement,0)+nCoarseElements+1;
184 (*coarseElementMDOFs)(coarseElement,7) = EdgeCount++;
190 (*coarseElementMDOFs)(coarseElement,3) = (*coarseElementMDOFs)(coarseElement-1,2);
193 (*coarseElementMDOFs)(coarseElement,7) = (*coarseElementMDOFs)(coarseElement-1,5);
197 (*coarseElementMDOFs)(coarseElement,2) = (*coarseElementMDOFs)(coarseElement,3)+1;
200 (*coarseElementMDOFs)(coarseElement,8) = CenterCount++;
206 (*coarseElementVDOFs)(coarseElement,0) = 2*(*coarseElementMDOFs)(coarseElement,0);
207 (*coarseElementVDOFs)(coarseElement,1) = 2*(*coarseElementMDOFs)(coarseElement,0)+1;
208 (*coarseElementVDOFs)(coarseElement,2) = 2*(*coarseElementMDOFs)(coarseElement,1);
209 (*coarseElementVDOFs)(coarseElement,3) = 2*(*coarseElementMDOFs)(coarseElement,1)+1;
210 (*coarseElementVDOFs)(coarseElement,4) = 2*(*coarseElementMDOFs)(coarseElement,2);
211 (*coarseElementVDOFs)(coarseElement,5) = 2*(*coarseElementMDOFs)(coarseElement,2)+1;
212 (*coarseElementVDOFs)(coarseElement,6) = 2*(*coarseElementMDOFs)(coarseElement,3);
213 (*coarseElementVDOFs)(coarseElement,7) = 2*(*coarseElementMDOFs)(coarseElement,3)+1;
214 (*coarseElementVDOFs)(coarseElement,8) = 2*(*coarseElementMDOFs)(coarseElement,4);
215 (*coarseElementVDOFs)(coarseElement,9) = 2*(*coarseElementMDOFs)(coarseElement,4)+1;
216 (*coarseElementVDOFs)(coarseElement,10) = 2*(*coarseElementMDOFs)(coarseElement,5);
217 (*coarseElementVDOFs)(coarseElement,11) = 2*(*coarseElementMDOFs)(coarseElement,5)+1;
218 (*coarseElementVDOFs)(coarseElement,12) = 2*(*coarseElementMDOFs)(coarseElement,6);
219 (*coarseElementVDOFs)(coarseElement,13) = 2*(*coarseElementMDOFs)(coarseElement,6)+1;
220 (*coarseElementVDOFs)(coarseElement,14) = 2*(*coarseElementMDOFs)(coarseElement,7);
221 (*coarseElementVDOFs)(coarseElement,15) = 2*(*coarseElementMDOFs)(coarseElement,7)+1;
222 (*coarseElementVDOFs)(coarseElement,16) = 2*(*coarseElementMDOFs)(coarseElement,8);
223 (*coarseElementVDOFs)(coarseElement,17) = 2*(*coarseElementMDOFs)(coarseElement,8)+1;
226 (*coarseElementPDOFs)(coarseElement,0) = (*coarseElementMDOFs)(coarseElement,0);
227 (*coarseElementPDOFs)(coarseElement,1) = (*coarseElementMDOFs)(coarseElement,1);
228 (*coarseElementPDOFs)(coarseElement,2) = (*coarseElementMDOFs)(coarseElement,2);
229 (*coarseElementPDOFs)(coarseElement,3) = (*coarseElementMDOFs)(coarseElement,3);
233 Set(coarseLevel,
"VElementList",coarseElementVDOFs);
234 Set(coarseLevel,
"PElementList",coarseElementPDOFs);
235 Set(coarseLevel,
"MElementList",coarseElementMDOFs);
246 #define MUELU_Q2Q1Q2COARSEGRIDFACTORY_SHORT
247 #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.