17 #include "Teuchos_XMLParameterListHelpers.hpp"
20 #include "create_inline_mesh.h"
31 int main(
int narg,
char *arg[]) {
33 Tpetra::ScopeGuard tscope(&narg, &arg);
34 Teuchos::RCP<const Teuchos::Comm<int> > CommT = Tpetra::getDefaultComm();
36 int me = CommT->getRank();
37 int numProcs = CommT->getSize();
44 std::string xmlMeshInFileName(
"Poisson.xml");
47 Teuchos::CommandLineProcessor cmdp (
false,
false);
48 cmdp.setOption(
"xmlfile", &xmlMeshInFileName,
49 "XML file with PamGen specifications");
50 cmdp.parse(narg, arg);
53 Teuchos::ParameterList inputMeshList;
55 if(xmlMeshInFileName.length()) {
57 std::cout <<
"\nReading parameter list from the XML file \""
58 <<xmlMeshInFileName<<
"\" ...\n\n";
60 Teuchos::updateParametersFromXmlFile(xmlMeshInFileName,
61 Teuchos::inoutArg(inputMeshList));
63 inputMeshList.print(std::cout,2,
true,
true);
68 std::cout <<
"Cannot read input file: " << xmlMeshInFileName <<
"\n";
73 std::string meshInput = Teuchos::getParameter<std::string>(inputMeshList,
87 if (me == 0) std::cout <<
"Generating mesh ... \n\n";
90 long long maxInt = 9223372036854775807LL;
91 Create_Pamgen_Mesh(meshInput.c_str(), dim, me, numProcs, maxInt);
94 if (me == 0) std::cout <<
"Creating mesh adapter ... \n\n";
98 inputAdapter_t ia(*CommT,
"region");
99 inputAdapter_t ia2(*CommT,
"vertex");
101 inputAdapter_t::offset_t
const *offsets=NULL;
107 std::cout << me <<
" Region-based: Number of components on processor = "
109 std::cout << me <<
" Region-based: Max component size on processor = "
111 std::cout << me <<
" Region-based: Min component size on processor = "
113 std::cout << me <<
" Region-based: Avg component size on processor = "
120 int dimension, num_nodes, num_elem;
124 int num_elem_blk, num_node_sets, num_side_sets;
125 error += im_ex_get_init(exoid, title, &dimension, &num_nodes, &num_elem,
126 &num_elem_blk, &num_node_sets, &num_side_sets);
128 int *element_num_map =
new int [num_elem];
129 error += im_ex_get_elem_num_map(exoid, element_num_map);
131 int *node_num_map =
new int [num_nodes];
132 error += im_ex_get_node_num_map(exoid, node_num_map);
134 int *elem_blk_ids =
new int [num_elem_blk];
135 error += im_ex_get_elem_blk_ids(exoid, elem_blk_ids);
137 int *num_nodes_per_elem =
new int [num_elem_blk];
138 int *num_attr =
new int [num_elem_blk];
139 int *num_elem_this_blk =
new int [num_elem_blk];
140 char **elem_type =
new char * [num_elem_blk];
141 int **connect =
new int * [num_elem_blk];
143 for(
int i = 0; i < num_elem_blk; i++){
144 elem_type[i] =
new char [MAX_STR_LENGTH + 1];
145 error += im_ex_get_elem_block(exoid, elem_blk_ids[i], elem_type[i],
146 (
int*)&(num_elem_this_blk[i]),
147 (
int*)&(num_nodes_per_elem[i]),
148 (
int*)&(num_attr[i]));
149 delete[] elem_type[i];
157 for(
int b = 0; b < num_elem_blk; b++) {
158 connect[b] =
new int [num_nodes_per_elem[b]*num_elem_this_blk[b]];
159 error += im_ex_get_elem_conn(exoid, elem_blk_ids[b], connect[b]);
162 delete[] elem_blk_ids;
167 if (ia.availAdjs(primaryEType, adjEType)) {
168 ia.getAdjsView(primaryEType, adjEType, offsets, adjacencyIds);
170 if ((
int)ia.getLocalNumOf(primaryEType) != num_elem) {
171 std::cout <<
"Number of elements do not match\n";
175 for (
int b = 0; b < num_elem_blk; b++) {
176 for (
int i = 0; i < num_elem_this_blk[b]; i++) {
177 if (offsets[telct + 1] - offsets[telct] != num_nodes_per_elem[b]) {
178 std::cout <<
"Number of adjacencies do not match" << std::endl;
182 for (
int j = 0; j < num_nodes_per_elem[b]; j++) {
183 ssize_t in_list = -1;
185 for(inputAdapter_t::offset_t k=offsets[telct];k<offsets[telct+1];k++){
186 if(adjacencyIds[k] ==
187 node_num_map[connect[b][i*num_nodes_per_elem[b]+j]-1]) {
194 std::cout <<
"Adjacency missing" << std::endl;
203 if (telct != num_elem) {
204 std::cout <<
"Number of elements do not match\n";
209 std::cout <<
"Adjacencies not available" << std::endl;
216 std::cout << me <<
" Vertex-based: Number of components on processor = "
218 std::cout << me <<
" Vertex-based: Max component size on processor = "
220 std::cout << me <<
" Vertex-based: Min component size on processor = "
222 std::cout << me <<
" Vertex-based: Avg component size on processor = "
226 primaryEType = ia2.getPrimaryEntityType();
227 adjEType = ia2.getAdjacencyEntityType();
229 if (ia2.availAdjs(primaryEType, adjEType)) {
230 ia2.getAdjsView(primaryEType, adjEType, offsets, adjacencyIds);
232 if ((
int)ia2.getLocalNumOf(primaryEType) != num_nodes) {
233 std::cout <<
"Number of nodes do not match\n";
238 int *num_adj =
new int[num_nodes];
240 for (
int i = 0; i < num_nodes; i++) {
244 for (
int b = 0; b < num_elem_blk; b++) {
245 for (
int i = 0; i < num_elem_this_blk[b]; i++) {
246 for (
int j = 0; j < num_nodes_per_elem[b]; j++) {
247 ssize_t in_list = -1;
248 ++num_adj[connect[b][i * num_nodes_per_elem[b] + j] - 1];
251 offsets[connect[b][i * num_nodes_per_elem[b] + j] - 1];
252 k < offsets[connect[b][i * num_nodes_per_elem[b] + j]]; k++) {
253 if(adjacencyIds[k] == element_num_map[telct]) {
260 std::cout <<
"Adjacency missing" << std::endl;
269 for (
int i = 0; i < num_nodes; i++) {
270 if (offsets[i + 1] - offsets[i] != num_adj[i]) {
271 std::cout <<
"Number of adjacencies do not match" << std::endl;
280 std::cout <<
"Adjacencies not available" << std::endl;
285 if (me == 0) std::cout <<
"Deleting the mesh ... \n\n";
287 Delete_Pamgen_Mesh();
291 std::cout << std::flush;
294 std::cout <<
"PASS" << std::endl;
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.
double getAvgComponentSize()
int main(int narg, char **arg)
Defines the PamgenMeshAdapter class.
size_t getMaxComponentSize()
map_t::local_ordinal_type lno_t
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.