18 #include "Teuchos_XMLParameterListHelpers.hpp"
21 #include "create_inline_mesh.h"
36 int main(
int narg,
char *arg[]) {
38 Tpetra::ScopeGuard tscope(&narg, &arg);
39 Teuchos::RCP<const Teuchos::Comm<int> > CommT = Tpetra::getDefaultComm();
41 int me = CommT->getRank();
42 int numProcs = CommT->getSize();
49 std::string xmlMeshInFileName(
"Poisson.xml");
52 Teuchos::CommandLineProcessor cmdp (
false,
false);
53 cmdp.setOption(
"xmlfile", &xmlMeshInFileName,
54 "XML file with PamGen specifications");
55 cmdp.parse(narg, arg);
58 Teuchos::ParameterList inputMeshList;
60 if(xmlMeshInFileName.length()) {
62 std::cout <<
"\nReading parameter list from the XML file \""
63 <<xmlMeshInFileName<<
"\" ...\n\n";
65 Teuchos::updateParametersFromXmlFile(xmlMeshInFileName,
66 Teuchos::inoutArg(inputMeshList));
68 inputMeshList.print(std::cout,2,
true,
true);
73 std::cout <<
"Cannot read input file: " << xmlMeshInFileName <<
"\n";
78 std::string meshInput = Teuchos::getParameter<std::string>(inputMeshList,
92 if (me == 0) std::cout <<
"Generating mesh ... \n\n";
95 long long maxInt = std::numeric_limits<long long>::max();
96 Create_Pamgen_Mesh(meshInput.c_str(), dim, me, numProcs, maxInt);
99 if (me == 0) std::cout <<
"Creating mesh adapter ... \n\n";
104 inputAdapter_t ia(*CommT,
"region");
105 inputAdapter_t ia2(*CommT,
"vertex");
107 inputAdapter_t::offset_t
const *offsets=NULL;
108 Teuchos::ArrayRCP<inputAdapter_t::offset_t> moffsets;
109 Teuchos::ArrayRCP<inputAdapter_t::gno_t> madjacencyIds;
112 if (me == 0) std::cout <<
"REGION-BASED TEST" << std::endl;
116 RCP<const base_adapter_t> baseInputAdapter;
118 std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags;
120 if (ia.availAdjs(primaryEType, adjEType)) {
123 if (me == 0) std::cout <<
" Creating GraphModel" << std::endl;
125 baseInputAdapter = (rcp(dynamic_cast<const base_adapter_t *>(&ia),
false));
131 std::cout <<
" Calling get2ndAdjsViewFromAdjs" << std::endl;
134 secondAdjEType, moffsets, madjacencyIds);
136 if (me == 0) std::cout <<
" Checking results" << std::endl;
137 if (ia.avail2ndAdjs(primaryEType, secondAdjEType)) {
138 ia.get2ndAdjsView(primaryEType, secondAdjEType, offsets, adjacencyIds);
141 std::cout <<
"2nd adjacencies not available; cannot check results"
146 for (
size_t telct = 0; telct < ia.getLocalNumOf(primaryEType); telct++) {
147 if (offsets[telct+1]-offsets[telct]!=moffsets[telct+1]-moffsets[telct]) {
148 std::cout <<
"Number of adjacencies do not match" << std::endl;
152 for (inputAdapter_t::offset_t j=moffsets[telct]; j<moffsets[telct+1]; j++) {
153 ssize_t in_list = -1;
155 for (inputAdapter_t::offset_t k=offsets[telct]; k<offsets[telct+1]; k++) {
156 if (adjacencyIds[k] == madjacencyIds[j]) {
163 std::cout <<
"Adjacency missing" << std::endl;
170 std::cout <<
"Adjacencies not available" << std::endl;
174 if (me == 0) std::cout <<
"VERTEX-BASED TEST" << std::endl;
175 primaryEType = ia2.getPrimaryEntityType();
176 adjEType = ia2.getAdjacencyEntityType();
177 secondAdjEType = ia2.getSecondAdjacencyEntityType();
179 if (ia2.availAdjs(primaryEType, adjEType)) {
180 if (ia2.avail2ndAdjs(primaryEType, secondAdjEType)) {
181 ia2.get2ndAdjsView(primaryEType, secondAdjEType, offsets, adjacencyIds);
184 std::cout <<
"2nd adjacencies not available" << std::endl;
190 if (me == 0) std::cout <<
" Creating GraphModel" << std::endl;
192 baseInputAdapter = (rcp(dynamic_cast<const base_adapter_t *>(&ia2),
false));
198 std::cout <<
" Calling get2ndAdjsViewFromAdjs" << std::endl;
201 secondAdjEType, moffsets, madjacencyIds);
203 if (me == 0) std::cout <<
" Checking results" << std::endl;
205 for (
size_t tnoct = 0; tnoct < ia2.getLocalNumOf(primaryEType); tnoct++) {
206 if (offsets[tnoct+1]-offsets[tnoct]!=moffsets[tnoct+1]-moffsets[tnoct]) {
207 std::cout <<
"Number of adjacencies do not match" << std::endl;
211 for (inputAdapter_t::offset_t j=moffsets[tnoct]; j<moffsets[tnoct+1]; j++) {
212 ssize_t in_list = -1;
214 for (inputAdapter_t::offset_t k=offsets[tnoct]; k<offsets[tnoct+1]; k++) {
215 if (adjacencyIds[k] == madjacencyIds[j]) {
222 std::cout <<
"Adjacency missing" << std::endl;
229 std::cout <<
"Adjacencies not available" << std::endl;
234 if (me == 0) std::cout <<
"Deleting the mesh ... \n\n";
236 Delete_Pamgen_Mesh();
239 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 >::offset_t > &offsets, Teuchos::ArrayRCP< typename MeshAdapter< User >::gno_t > &adjacencyIds)
Zoltan2::BasicUserTypes basic_user_t
map_t::global_ordinal_type gno_t
A simple class that can be the User template argument for an InputAdapter.
int main(int narg, char **arg)
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...
GraphModel defines the interface required for graph models.
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.