53 #include "Teuchos_XMLParameterListHelpers.hpp" 56 #include "create_inline_mesh.h" 65 typedef Tpetra::DefaultPlatform::DefaultPlatformType
Platform;
74 int main(
int narg,
char *arg[]) {
76 Teuchos::GlobalMPISession mpiSession(&narg, &arg,0);
77 Platform &platform = Tpetra::DefaultPlatform::getDefaultPlatform();
78 RCP<const Teuchos::Comm<int> > CommT = platform.getComm();
80 int me = CommT->getRank();
81 int numProcs = CommT->getSize();
88 std::string xmlMeshInFileName(
"Poisson.xml");
91 Teuchos::CommandLineProcessor cmdp (
false,
false);
92 cmdp.setOption(
"xmlfile", &xmlMeshInFileName,
93 "XML file with PamGen specifications");
94 cmdp.parse(narg, arg);
97 ParameterList inputMeshList;
99 if(xmlMeshInFileName.length()) {
101 cout <<
"\nReading parameter list from the XML file \"" 102 <<xmlMeshInFileName<<
"\" ...\n\n";
104 Teuchos::updateParametersFromXmlFile(xmlMeshInFileName,
105 Teuchos::inoutArg(inputMeshList));
107 inputMeshList.print(cout,2,
true,
true);
112 cout <<
"Cannot read input file: " << xmlMeshInFileName <<
"\n";
117 std::string meshInput = Teuchos::getParameter<std::string>(inputMeshList,
131 if (me == 0) cout <<
"Generating mesh ... \n\n";
134 long long maxInt = std::numeric_limits<long long>::max();
135 Create_Pamgen_Mesh(meshInput.c_str(), dim, me, numProcs, maxInt);
138 if (me == 0) cout <<
"Creating mesh adapter ... \n\n";
143 inputAdapter_t ia(*CommT,
"region");
144 inputAdapter_t ia2(*CommT,
"vertex");
145 inputAdapter_t::gno_t
const *adjacencyIds=NULL;
146 inputAdapter_t::lno_t
const *offsets=NULL;
147 Teuchos::ArrayRCP<inputAdapter_t::lno_t> moffsets;
148 Teuchos::ArrayRCP<inputAdapter_t::gno_t> madjacencyIds;
151 if (me == 0) std::cout <<
"REGION-BASED TEST" << std::endl;
155 RCP<const base_adapter_t> baseInputAdapter;
157 std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags;
159 if (ia.availAdjs(primaryEType, adjEType)) {
162 if (me == 0) std::cout <<
" Creating GraphModel" << std::endl;
164 baseInputAdapter = (rcp(dynamic_cast<const base_adapter_t *>(&ia),
false));
170 std::cout <<
" Calling get2ndAdjsViewFromAdjs" << std::endl;
173 secondAdjEType, moffsets, madjacencyIds);
175 if (me == 0) std::cout <<
" Checking results" << std::endl;
176 if (ia.avail2ndAdjs(primaryEType, secondAdjEType)) {
177 ia.get2ndAdjsView(primaryEType, secondAdjEType, offsets, adjacencyIds);
180 std::cout <<
"2nd adjacencies not available; cannot check results" 185 for (
size_t telct = 0; telct < ia.getLocalNumOf(primaryEType); telct++) {
186 if (offsets[telct+1]-offsets[telct]!=moffsets[telct+1]-moffsets[telct]) {
187 std::cout <<
"Number of adjacencies do not match" << std::endl;
191 for (inputAdapter_t::lno_t j=moffsets[telct]; j<moffsets[telct+1]; j++) {
192 ssize_t in_list = -1;
194 for (inputAdapter_t::lno_t k=offsets[telct]; k<offsets[telct+1]; k++) {
195 if (adjacencyIds[k] == madjacencyIds[j]) {
202 std::cout <<
"Adjacency missing" << std::endl;
209 std::cout <<
"Adjacencies not available" << std::endl;
213 if (me == 0) std::cout <<
"VERTEX-BASED TEST" << std::endl;
214 primaryEType = ia2.getPrimaryEntityType();
215 adjEType = ia2.getAdjacencyEntityType();
216 secondAdjEType = ia2.getSecondAdjacencyEntityType();
218 if (ia2.availAdjs(primaryEType, adjEType)) {
219 if (ia2.avail2ndAdjs(primaryEType, secondAdjEType)) {
220 ia2.get2ndAdjsView(primaryEType, secondAdjEType, offsets, adjacencyIds);
223 std::cout <<
"2nd adjacencies not available" << std::endl;
229 if (me == 0) std::cout <<
" Creating GraphModel" << std::endl;
231 baseInputAdapter = (rcp(dynamic_cast<const base_adapter_t *>(&ia2),
false));
237 std::cout <<
" Calling get2ndAdjsViewFromAdjs" << std::endl;
240 secondAdjEType, moffsets, madjacencyIds);
242 if (me == 0) std::cout <<
" Checking results" << std::endl;
244 for (
size_t tnoct = 0; tnoct < ia2.getLocalNumOf(primaryEType); tnoct++) {
245 if (offsets[tnoct+1]-offsets[tnoct]!=moffsets[tnoct+1]-moffsets[tnoct]) {
246 std::cout <<
"Number of adjacencies do not match" << std::endl;
250 for (inputAdapter_t::lno_t j=moffsets[tnoct]; j<moffsets[tnoct+1]; j++) {
251 ssize_t in_list = -1;
253 for (inputAdapter_t::lno_t k=offsets[tnoct]; k<offsets[tnoct+1]; k++) {
254 if (adjacencyIds[k] == madjacencyIds[j]) {
261 std::cout <<
"Adjacency missing" << std::endl;
268 std::cout <<
"Adjacencies not available" << std::endl;
273 if (me == 0) cout <<
"Deleting the mesh ... \n\n";
275 Delete_Pamgen_Mesh();
278 std::cout <<
"PASS" << std::endl;
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
void get2ndAdjsViewFromAdjs(const Teuchos::RCP< const MeshAdapter< User > > &ia, const RCP< const Comm< int > > comm, Zoltan2::MeshEntityType sourcetarget, Zoltan2::MeshEntityType through, Teuchos::ArrayRCP< typename MeshAdapter< User >::lno_t > &offsets, Teuchos::ArrayRCP< typename MeshAdapter< User >::gno_t > &adjacencyIds)
Defines the PamgenMeshAdapter class.
Defines helper functions for use in the models.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
int main(int narg, char *arg[])
GraphModel defines the interface required for graph models.
Tpetra::DefaultPlatform::DefaultPlatformType Platform
MeshEntityType
Enumerate entity types for meshes: Regions, Faces, Edges, or Vertices.
Defines the GraphModel interface.
const RCP< const Comm< int > > getComm()
Return the communicator used by the model.
This class represents a mesh.
Tpetra::MultiVector< double > tMVector_t