26int main(
int argc,
char* argv[])
29 "Query mesh information.\n\n"
30 "OpenGeoSys-6 software, version " +
33 "Copyright (c) 2012-2024, OpenGeoSys Community "
34 "(http://www.opengeosys.org)",
36 TCLAP::UnlabeledValueArg<std::string> mesh_arg(
37 "mesh-file",
"input mesh file",
true,
"",
"string");
39 TCLAP::MultiArg<std::size_t> eleId_arg(
"e",
"element-id",
"element ID",
42 TCLAP::MultiArg<std::size_t> nodeId_arg(
"n",
"node-id",
"node ID",
false,
45 TCLAP::SwitchArg showNodeWithMaxEle_arg(
46 "",
"show-node-with-max-elements",
47 "show a node having the max number of connected elements",
false);
48 cmd.add(showNodeWithMaxEle_arg);
50 cmd.parse(argc, argv);
54 const std::string filename(mesh_arg.getValue());
65 std::vector<std::size_t> selected_node_ids;
66 if (showNodeWithMaxEle_arg.getValue())
68 auto itr = std::max_element(
69 mesh->getNodes().begin(), mesh->getNodes().end(),
72 return mesh->getElementsConnectedToNode(*i).size() <
73 mesh->getElementsConnectedToNode(*j).size();
75 if (itr != mesh->getNodes().end())
78 selected_node_ids.push_back(node->
getID());
81 selected_node_ids.insert(selected_node_ids.end(),
82 nodeId_arg.getValue().begin(),
83 nodeId_arg.getValue().end());
85 auto const materialIds = materialIDs(*mesh);
86 for (
auto ele_id : eleId_arg.getValue())
88 std::stringstream out;
89 out << std::scientific
90 << std::setprecision(std::numeric_limits<double>::max_digits10);
91 out <<
"--------------------------------------------------------"
93 auto* ele = mesh->getElement(ele_id);
94 out <<
"# Element " << ele->getID() << std::endl;
95 out <<
"Type : " << CellType2String(ele->getCellType()) << std::endl;
98 out <<
"Mat ID : " << (*materialIds)[ele_id] << std::endl;
100 out <<
"Nodes: " << std::endl;
101 for (
unsigned i = 0; i < ele->getNumberOfNodes(); i++)
103 out << ele->getNode(i)->getID() <<
" " << *ele->getNode(i)
106 out <<
"Content: " << ele->getContent() << std::endl;
107 out <<
"Neighbors: ";
108 for (
unsigned i = 0; i < ele->getNumberOfNeighbors(); i++)
110 if (ele->getNeighbor(i))
112 out << ele->getNeighbor(i)->getID() <<
" ";
120 INFO(
"{:s}", out.str());
124 for (
auto node_id : selected_node_ids)
126 std::stringstream out;
127 out << std::scientific
128 << std::setprecision(std::numeric_limits<double>::max_digits10);
129 out <<
"--------------------------------------------------------"
132 out <<
"# Node " << node->
getID() << std::endl;
133 out <<
"Coordinates: " << *node << std::endl;
134 out <<
"Connected elements ("
135 << mesh->getElementsConnectedToNode(*node).size() <<
"): ";
136 for (
auto ele : mesh->getElementsConnectedToNode(*node))
138 out << ele->
getID() <<
" ";
141 out <<
"Connected nodes (" << connections[node->
getID()].size()
143 for (
auto nd : connections[node->
getID()])
145 out << nd->getID() <<
" ";
148 INFO(
"{:s}", out.str());