10 #include <tclap/CmdLine.h>
25 int main(
int argc,
char* argv[])
28 "Query mesh information.\n\n"
29 "OpenGeoSys-6 software, version " +
32 "Copyright (c) 2012-2021, OpenGeoSys Community "
33 "(http://www.opengeosys.org)",
35 TCLAP::UnlabeledValueArg<std::string> mesh_arg(
36 "mesh-file",
"input mesh file",
true,
"",
"string");
38 TCLAP::MultiArg<std::size_t> eleId_arg(
"e",
"element-id",
"element ID",
41 TCLAP::MultiArg<std::size_t> nodeId_arg(
"n",
"node-id",
"node ID",
false,
44 TCLAP::SwitchArg showNodeWithMaxEle_arg(
45 "",
"show-node-with-max-elements",
46 "show a node having the max number of connected elements",
false);
47 cmd.add(showNodeWithMaxEle_arg);
49 cmd.parse(argc, argv);
51 const std::string filename(mesh_arg.getValue());
61 std::vector<std::size_t> selected_node_ids;
62 if (showNodeWithMaxEle_arg.getValue())
64 auto itr = std::max_element(
65 mesh->getNodes().begin(), mesh->getNodes().end(),
68 return mesh->getElementsConnectedToNode(*i).size() <
69 mesh->getElementsConnectedToNode(*j).size();
71 if (itr != mesh->getNodes().end())
74 selected_node_ids.push_back(node->
getID());
77 selected_node_ids.insert(selected_node_ids.end(),
78 nodeId_arg.getValue().begin(),
79 nodeId_arg.getValue().end());
82 for (
auto ele_id : eleId_arg.getValue())
84 std::stringstream out;
85 out << std::scientific
86 << std::setprecision(std::numeric_limits<double>::digits10);
87 out <<
"--------------------------------------------------------"
89 auto* ele = mesh->getElement(ele_id);
90 out <<
"# Element " << ele->getID() << std::endl;
94 out <<
"Mat ID : " << (*materialIds)[ele_id] << std::endl;
96 out <<
"Nodes: " << std::endl;
97 for (
unsigned i = 0; i < ele->getNumberOfNodes(); i++)
99 out << ele->getNode(i)->getID() <<
" " << *ele->getNode(i)
102 out <<
"Content: " << ele->getContent() << std::endl;
103 out <<
"Neighbors: ";
104 for (
unsigned i = 0; i < ele->getNumberOfNeighbors(); i++)
106 if (ele->getNeighbor(i))
108 out << ele->getNeighbor(i)->getID() <<
" ";
116 INFO(
"{:s}", out.str());
120 for (
auto node_id : selected_node_ids)
122 std::stringstream out;
123 out << std::scientific
124 << std::setprecision(std::numeric_limits<double>::digits10);
125 out <<
"--------------------------------------------------------"
128 out <<
"# Node " << node->
getID() << std::endl;
129 out <<
"Coordinates: " << *node << std::endl;
130 out <<
"Connected elements ("
131 << mesh->getElementsConnectedToNode(*node).size() <<
"): ";
132 for (
auto ele : mesh->getElementsConnectedToNode(*node))
134 out << ele->
getID() <<
" ";
137 out <<
"Connected nodes (" << connections[node->
getID()].size()
139 for (
auto nd : connections[node->
getID()])
141 out << nd->getID() <<
" ";
144 INFO(
"{:s}", out.str());
Definition of the Element class.
void INFO(char const *fmt, Args const &... args)
Definition of the Mesh class.
Definition of the Node class.
std::size_t getID() const
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)
std::vector< std::vector< Node * > > calculateNodesConnectedByElements(Mesh const &mesh)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
int main(int argc, char *argv[])
Definition of readMeshFromFile function.