52 #include "Teuchos_XMLParameterListHelpers.hpp" 55 #include "create_inline_mesh.h" 64 typedef Tpetra::DefaultPlatform::DefaultPlatformType
Platform;
65 typedef Tpetra::MultiVector<double, int, int>
tMVector_t;
73 int main(
int narg,
char *arg[]) {
75 Teuchos::GlobalMPISession mpiSession(&narg, &arg,0);
76 Platform &platform = Tpetra::DefaultPlatform::getDefaultPlatform();
77 RCP<const Teuchos::Comm<int> > CommT = platform.getComm();
79 int me = CommT->getRank();
80 int numProcs = CommT->getSize();
87 std::string xmlMeshInFileName(
"Poisson.xml");
90 Teuchos::CommandLineProcessor cmdp (
false,
false);
91 cmdp.setOption(
"xmlfile", &xmlMeshInFileName,
92 "XML file with PamGen specifications");
93 cmdp.parse(narg, arg);
96 Teuchos::ParameterList inputMeshList;
98 if(xmlMeshInFileName.length()) {
100 cout <<
"\nReading parameter list from the XML file \"" 101 <<xmlMeshInFileName<<
"\" ...\n\n";
103 Teuchos::updateParametersFromXmlFile(xmlMeshInFileName,
104 Teuchos::inoutArg(inputMeshList));
106 inputMeshList.print(cout,2,
true,
true);
111 cout <<
"Cannot read input file: " << xmlMeshInFileName <<
"\n";
116 std::string meshInput = Teuchos::getParameter<std::string>(inputMeshList,
130 if (me == 0) cout <<
"Generating mesh ... \n\n";
133 long long maxInt = 9223372036854775807LL;
134 Create_Pamgen_Mesh(meshInput.c_str(), dim, me, numProcs, maxInt);
137 if (me == 0) cout <<
"Creating mesh adapter ... \n\n";
141 inputAdapter_t ia(*CommT,
"region");
142 inputAdapter_t ia2(*CommT,
"vertex");
143 inputAdapter_t::gno_t
const *adjacencyIds=NULL;
144 inputAdapter_t::lno_t
const *offsets=NULL;
150 std::cout << me <<
" Region-based: Number of components on processor = " 152 std::cout << me <<
" Region-based: Max component size on processor = " 154 std::cout << me <<
" Region-based: Min component size on processor = " 156 std::cout << me <<
" Region-based: Avg component size on processor = " 163 int dimension, num_nodes, num_elem;
167 int num_elem_blk, num_node_sets, num_side_sets;
168 error += im_ex_get_init(exoid, title, &dimension, &num_nodes, &num_elem,
169 &num_elem_blk, &num_node_sets, &num_side_sets);
171 int *element_num_map =
new int [num_elem];
172 error += im_ex_get_elem_num_map(exoid, element_num_map);
174 inputAdapter_t::gno_t *node_num_map =
new int [num_nodes];
175 error += im_ex_get_node_num_map(exoid, node_num_map);
177 int *elem_blk_ids =
new int [num_elem_blk];
178 error += im_ex_get_elem_blk_ids(exoid, elem_blk_ids);
180 int *num_nodes_per_elem =
new int [num_elem_blk];
181 int *num_attr =
new int [num_elem_blk];
182 int *num_elem_this_blk =
new int [num_elem_blk];
183 char **elem_type =
new char * [num_elem_blk];
184 int **connect =
new int * [num_elem_blk];
186 for(
int i = 0; i < num_elem_blk; i++){
187 elem_type[i] =
new char [MAX_STR_LENGTH + 1];
188 error += im_ex_get_elem_block(exoid, elem_blk_ids[i], elem_type[i],
189 (
int*)&(num_elem_this_blk[i]),
190 (
int*)&(num_nodes_per_elem[i]),
191 (
int*)&(num_attr[i]));
192 delete[] elem_type[i];
200 for(
int b = 0; b < num_elem_blk; b++) {
201 connect[b] =
new int [num_nodes_per_elem[b]*num_elem_this_blk[b]];
202 error += im_ex_get_elem_conn(exoid, elem_blk_ids[b], connect[b]);
205 delete[] elem_blk_ids;
210 if (ia.availAdjs(primaryEType, adjEType)) {
211 ia.getAdjsView(primaryEType, adjEType, offsets, adjacencyIds);
213 if ((
int)ia.getLocalNumOf(primaryEType) != num_elem) {
214 cout <<
"Number of elements do not match\n";
218 for (
int b = 0; b < num_elem_blk; b++) {
219 for (
int i = 0; i < num_elem_this_blk[b]; i++) {
220 if (offsets[telct + 1] - offsets[telct] != num_nodes_per_elem[b]) {
221 std::cout <<
"Number of adjacencies do not match" << std::endl;
225 for (
int j = 0; j < num_nodes_per_elem[b]; j++) {
226 ssize_t in_list = -1;
228 for(inputAdapter_t::lno_t k=offsets[telct];k<offsets[telct+1];k++) {
229 if(adjacencyIds[k] ==
230 node_num_map[connect[b][i*num_nodes_per_elem[b]+j]-1]) {
237 std::cout <<
"Adjacency missing" << std::endl;
246 if (telct != num_elem) {
247 cout <<
"Number of elements do not match\n";
252 std::cout <<
"Adjacencies not available" << std::endl;
259 std::cout << me <<
" Vertex-based: Number of components on processor = " 261 std::cout << me <<
" Vertex-based: Max component size on processor = " 263 std::cout << me <<
" Vertex-based: Min component size on processor = " 265 std::cout << me <<
" Vertex-based: Avg component size on processor = " 269 primaryEType = ia2.getPrimaryEntityType();
270 adjEType = ia2.getAdjacencyEntityType();
272 if (ia2.availAdjs(primaryEType, adjEType)) {
273 ia2.getAdjsView(primaryEType, adjEType, offsets, adjacencyIds);
275 if ((
int)ia2.getLocalNumOf(primaryEType) != num_nodes) {
276 cout <<
"Number of nodes do not match\n";
281 int *num_adj =
new int[num_nodes];
283 for (
int i = 0; i < num_nodes; i++) {
287 for (
int b = 0; b < num_elem_blk; b++) {
288 for (
int i = 0; i < num_elem_this_blk[b]; i++) {
289 for (
int j = 0; j < num_nodes_per_elem[b]; j++) {
290 ssize_t in_list = -1;
291 ++num_adj[connect[b][i * num_nodes_per_elem[b] + j] - 1];
293 for(inputAdapter_t::lno_t k =
294 offsets[connect[b][i * num_nodes_per_elem[b] + j] - 1];
295 k < offsets[connect[b][i * num_nodes_per_elem[b] + j]]; k++) {
296 if(adjacencyIds[k] == element_num_map[telct]) {
303 std::cout <<
"Adjacency missing" << std::endl;
312 for (
int i = 0; i < num_nodes; i++) {
313 if (offsets[i + 1] - offsets[i] != num_adj[i]) {
314 std::cout <<
"Number of adjacencies do not match" << std::endl;
323 std::cout <<
"Adjacencies not available" << std::endl;
328 if (me == 0) cout <<
"Deleting the mesh ... \n\n";
330 Delete_Pamgen_Mesh();
334 std::cout << std::flush;
337 std::cout <<
"PASS" << std::endl;
double getAvgComponentSize()
Defines the PamgenMeshAdapter class.
size_t getMaxComponentSize()
size_t getNumComponents()
MeshEntityType
Enumerate entity types for meshes: Regions, Faces, Edges, or Vertices.
size_t getMinComponentSize()
Identify and compute the number of connected components in a processor's input Note that this routine...
This class represents a mesh.