53 #include "Teuchos_XMLParameterListHelpers.hpp" 56 #include "create_inline_mesh.h" 65 typedef Tpetra::DefaultPlatform::DefaultPlatformType
Platform;
66 typedef Tpetra::MultiVector<double, int, int>
tMVector_t;
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 = 9223372036854775807LL;
135 Create_Pamgen_Mesh(meshInput.c_str(), dim, me, numProcs, maxInt);
138 if (me == 0) cout <<
"Creating mesh adapter ... \n\n";
141 typedef inputAdapter_t::base_adapter_t base_adapter_t;
143 inputAdapter_t ia(*CommT,
"region");
144 inputAdapter_t ia2(*CommT,
"vertex");
145 inputAdapter_t::gno_t
const *adjacencyIds=NULL;
146 inputAdapter_t::gno_t
const *madjacencyIds=NULL;
147 inputAdapter_t::lno_t
const *offsets=NULL;
148 inputAdapter_t::lno_t
const *moffsets=NULL;
153 RCP<const base_adapter_t> baseInputAdapter;
155 std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags;
157 if (ia.availAdjs(primaryEType, adjEType)) {
158 if (ia.avail2ndAdjs(primaryEType, secondAdjEType)) {
159 ia.get2ndAdjsView(primaryEType, secondAdjEType, offsets, adjacencyIds);
162 std::cout <<
"2nd adjacencies not available" << std::endl;
168 if (me == 0) std::cout <<
" Creating GraphModel" << std::endl;
170 baseInputAdapter = (rcp(dynamic_cast<const base_adapter_t *>(&ia),
false));
177 secondAdjEType, moffsets, madjacencyIds);
179 for (
size_t telct = 0; telct < ia.getLocalNumOf(primaryEType); telct++) {
180 if (offsets[telct+1]-offsets[telct]!=moffsets[telct+1]-moffsets[telct]) {
181 std::cout <<
"Number of adjacencies do not match" << std::endl;
185 for (inputAdapter_t::lno_t j=moffsets[telct]; j<moffsets[telct+1]; j++) {
186 ssize_t in_list = -1;
188 for (inputAdapter_t::lno_t k=offsets[telct]; k<offsets[telct+1]; k++) {
189 if (adjacencyIds[k] == adjacencyIds[j]) {
196 std::cout <<
"Adjacency missing" << std::endl;
203 std::cout <<
"Adjacencies not available" << std::endl;
207 primaryEType = ia2.getPrimaryEntityType();
208 adjEType = ia2.getAdjacencyEntityType();
209 secondAdjEType = ia2.getSecondAdjacencyEntityType();
211 if (ia2.availAdjs(primaryEType, adjEType)) {
212 if (ia2.avail2ndAdjs(primaryEType, secondAdjEType)) {
213 ia2.get2ndAdjsView(primaryEType, secondAdjEType, offsets, adjacencyIds);
216 std::cout <<
"2nd adjacencies not available" << std::endl;
222 if (me == 0) std::cout <<
" Creating GraphModel" << std::endl;
224 baseInputAdapter = (rcp(dynamic_cast<const base_adapter_t *>(&ia2),
false));
231 secondAdjEType, moffsets, madjacencyIds);
233 for (
size_t tnoct = 0; tnoct < ia2.getLocalNumOf(primaryEType); tnoct++) {
234 if (offsets[tnoct+1]-offsets[tnoct]!=moffsets[tnoct+1]-moffsets[tnoct]) {
235 std::cout <<
"Number of adjacencies do not match" << std::endl;
239 for (inputAdapter_t::lno_t j=moffsets[tnoct]; j<moffsets[tnoct+1]; j++) {
240 ssize_t in_list = -1;
242 for (inputAdapter_t::lno_t k=offsets[tnoct]; k<offsets[tnoct+1]; k++) {
243 if (adjacencyIds[k] == adjacencyIds[j]) {
250 std::cout <<
"Adjacency missing" << std::endl;
257 std::cout <<
"Adjacencies not available" << std::endl;
262 if (me == 0) cout <<
"Deleting the mesh ... \n\n";
264 Delete_Pamgen_Mesh();
267 std::cout <<
"PASS" << std::endl;
Defines the PamgenMeshAdapter class.
Defines helper functions for use in the models.
void get2ndAdjsViewFromAdjs(const Teuchos::RCP< const MeshAdapter< User > > &ia, const RCP< const Comm< int > > comm, Zoltan2::MeshEntityType sourcetarget, Zoltan2::MeshEntityType through, const typename MeshAdapter< User >::lno_t *&offsets, const typename MeshAdapter< User >::gno_t *&adjacencyIds)
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.
Tpetra::MultiVector< double, int, int > tMVector_t
const RCP< const Comm< int > > getComm()
Return the communicator used by the model.
This class represents a mesh.