29int main(
int argc,
char* argv[])
32 "Query mesh information.\n\n"
33 "OpenGeoSys-6 software, version " +
36 "Copyright (c) 2012-2024, OpenGeoSys Community "
37 "(http://www.opengeosys.org)",
39 TCLAP::UnlabeledValueArg<std::string> mesh_arg(
40 "mesh-file",
"input mesh file",
true,
"",
"string");
42 TCLAP::MultiArg<std::size_t> eleId_arg(
"e",
"element-id",
"element ID",
45 TCLAP::MultiArg<std::size_t> nodeId_arg(
"n",
"node-id",
"node ID",
false,
48 TCLAP::SwitchArg showNodeWithMaxEle_arg(
49 "",
"show-node-with-max-elements",
50 "show a node having the max number of connected elements",
false);
51 cmd.add(showNodeWithMaxEle_arg);
53 cmd.parse(argc, argv);
56 MPI_Init(&argc, &argv);
59 const std::string filename(mesh_arg.getValue());
73 std::vector<std::size_t> selected_node_ids;
74 if (showNodeWithMaxEle_arg.getValue())
76 auto itr = std::max_element(
77 mesh->getNodes().begin(), mesh->getNodes().end(),
80 return mesh->getElementsConnectedToNode(*i).size() <
81 mesh->getElementsConnectedToNode(*j).size();
83 if (itr != mesh->getNodes().end())
86 selected_node_ids.push_back(node->
getID());
89 selected_node_ids.insert(selected_node_ids.end(),
90 nodeId_arg.getValue().begin(),
91 nodeId_arg.getValue().end());
93 auto const materialIds = materialIDs(*mesh);
94 for (
auto ele_id : eleId_arg.getValue())
96 std::stringstream out;
97 out << std::scientific
98 << std::setprecision(std::numeric_limits<double>::max_digits10);
99 out <<
"--------------------------------------------------------"
101 auto* ele = mesh->getElement(ele_id);
102 out <<
"# Element " << ele->getID() << std::endl;
103 out <<
"Type : " << CellType2String(ele->getCellType()) << std::endl;
106 out <<
"Mat ID : " << (*materialIds)[ele_id] << std::endl;
108 out <<
"Nodes: " << std::endl;
109 for (
unsigned i = 0; i < ele->getNumberOfNodes(); i++)
111 out << ele->getNode(i)->getID() <<
" " << *ele->getNode(i)
114 out <<
"Content: " << ele->getContent() << std::endl;
115 out <<
"Neighbors: ";
116 for (
unsigned i = 0; i < ele->getNumberOfNeighbors(); i++)
118 if (ele->getNeighbor(i))
120 out << ele->getNeighbor(i)->getID() <<
" ";
128 INFO(
"{:s}", out.str());
132 for (
auto node_id : selected_node_ids)
134 std::stringstream out;
135 out << std::scientific
136 << std::setprecision(std::numeric_limits<double>::max_digits10);
137 out <<
"--------------------------------------------------------"
140 out <<
"# Node " << node->
getID() << std::endl;
141 out <<
"Coordinates: " << *node << std::endl;
142 out <<
"Connected elements ("
143 << mesh->getElementsConnectedToNode(*node).size() <<
"): ";
144 for (
auto ele : mesh->getElementsConnectedToNode(*node))
146 out << ele->getID() <<
" ";
149 out <<
"Connected nodes (" << connections[node->
getID()].size()
151 for (
auto nd : connections[node->
getID()])
153 out << nd->getID() <<
" ";
156 INFO(
"{:s}", out.str());