[cig-commits] r13975 - in cs/cigma/trunk: . src
luis at geodynamics.org
luis at geodynamics.org
Wed Jan 28 09:05:01 PST 2009
Author: luis
Date: 2009-01-28 09:05:01 -0800 (Wed, 28 Jan 2009)
New Revision: 13975
Added:
cs/cigma/trunk/src/cli_mesh_info_cmd.cpp
cs/cigma/trunk/src/cli_mesh_info_cmd.h
Modified:
cs/cigma/trunk/Makefile.am
cs/cigma/trunk/src/cli_application.cpp
Log:
Added mesh-info command for convenience
Modified: cs/cigma/trunk/Makefile.am
===================================================================
--- cs/cigma/trunk/Makefile.am 2009-01-28 17:04:58 UTC (rev 13974)
+++ cs/cigma/trunk/Makefile.am 2009-01-28 17:05:01 UTC (rev 13975)
@@ -305,6 +305,8 @@
src/cli_list_cmd.cpp \
src/cli_info_cmd.h \
src/cli_info_cmd.cpp \
+ src/cli_mesh_info_cmd.h \
+ src/cli_mesh_info_cmd.cpp \
src/cli_extract_cmd.h \
src/cli_extract_cmd.cpp \
src/cli_eval_cmd.h \
Modified: cs/cigma/trunk/src/cli_application.cpp
===================================================================
--- cs/cigma/trunk/src/cli_application.cpp 2009-01-28 17:04:58 UTC (rev 13974)
+++ cs/cigma/trunk/src/cli_application.cpp 2009-01-28 17:05:01 UTC (rev 13975)
@@ -19,6 +19,7 @@
#include "cli_extract_cmd.h"
#include "cli_list_cmd.h"
#include "cli_info_cmd.h"
+#include "cli_mesh_info_cmd.h"
using namespace std;
using namespace cigma;
@@ -33,6 +34,7 @@
this->addCommand(new ExtractCmd());
this->addCommand(new ListCmd());
this->addCommand(new InfoCmd());
+ this->addCommand(new MeshInfoCmd());
}
@@ -215,7 +217,7 @@
if (cmd != 0)
{
cout << prefix
- << std::setw(9) << std::left
+ << std::setw(12) << std::left
<< cmd->name
<< cmd->brief
<< endl;
Added: cs/cigma/trunk/src/cli_mesh_info_cmd.cpp
===================================================================
--- cs/cigma/trunk/src/cli_mesh_info_cmd.cpp (rev 0)
+++ cs/cigma/trunk/src/cli_mesh_info_cmd.cpp 2009-01-28 17:05:01 UTC (rev 13975)
@@ -0,0 +1,96 @@
+#include "cli_mesh_info_cmd.h"
+#include "core_args.h"
+#include "core_writers.h"
+#include <iostream>
+#include <sstream>
+
+using namespace cigma;
+using namespace std;
+
+namespace po = boost::program_options;
+
+// ----------------------------------------------------------------------------
+
+MeshInfoCmd::MeshInfoCmd()
+{
+ name = "mesh-info";
+ brief = "Calculate maximum cell diameter for mesh";
+ usage = "Usage: cigma mesh-info <MeshFile>";
+ appendix = "";
+}
+
+MeshInfoCmd::~MeshInfoCmd()
+{
+}
+
+void MeshInfoCmd::defineOptions()
+{
+ BaseCmd::defineOptions();
+ opts_section = "Options: ";
+ opts.add_options()
+ ("mesh,m", po::value<string>(&meshfile), "Input mesh")
+ ("mesh-cell", po::value<string>(&cellname), "...cell type for mesh")
+ ("mesh-coords", po::value<string>(&ncfile), "...node coordinates for mesh")
+ ("mesh-connect", po::value<string>(&ebfile), "...connectivity for mesh")
+ ;
+ args.add("mesh", -1);
+}
+
+void MeshInfoCmd::configure()
+{
+ BaseCmd::configure();
+
+ MeshInfo mesh_info;
+
+ if (vm.count("mesh"))
+ {
+ mesh_info.p_mesh = DataPath(meshfile);
+ mesh_info.cell_type_name = cellname;
+ }
+ else
+ {
+ mesh_info.p_nc = DataPath(ncfile);
+ mesh_info.p_eb = DataPath(ebfile);
+ mesh_info.cell_type_name = cellname;
+ }
+
+ TRI_LOG_STR(mesh_info);
+ mesh = MeshPart::New(mesh_info);
+}
+
+int MeshInfoCmd::run()
+{
+ BaseCmd::run();
+
+ if (meshfile == "")
+ {
+ printUsage();
+ }
+ else if (mesh)
+ {
+ mesh->computeCellVolumes();
+
+ double h = mesh->getMaxCellDiameter();
+ double volume = mesh->getVolume();
+ const string indent = " ";
+ cout << "Mesh Info:" << endl;
+ cout << indent << "Location = " << meshfile << endl;
+ cout << indent << "Cell type = " << Cell::type2string(mesh->getCellType()) << endl;
+ cout << indent << "Total mesh volume = " << volume << endl;
+ cout << indent << "Max cell diameter = " << h << endl;
+
+ if (false)
+ {
+ DataPath output_path("debug-mesh.h5");
+ WriteMeshPart(output_path, mesh, true);
+ }
+
+ }
+ else
+ {
+ string msg("Input mesh not specified!");
+ throw cigma::Exception("MeshInfoCmd::run", msg, 1);
+ }
+
+ return 0;
+}
Added: cs/cigma/trunk/src/cli_mesh_info_cmd.h
===================================================================
--- cs/cigma/trunk/src/cli_mesh_info_cmd.h (rev 0)
+++ cs/cigma/trunk/src/cli_mesh_info_cmd.h 2009-01-28 17:05:01 UTC (rev 13975)
@@ -0,0 +1,32 @@
+#ifndef CIGMA_MESH_INFO_CMD_H
+#define CIGMA_MESH_INFO_CMD_H
+
+#include "cli_base_cmd.h"
+#include "MeshPart.h"
+
+namespace cigma
+{
+ class MeshInfoCmd;
+}
+
+class cigma::MeshInfoCmd : public BaseCmd
+{
+public:
+
+ MeshInfoCmd();
+ ~MeshInfoCmd();
+
+ void defineOptions();
+ void configure();
+ int run();
+
+public:
+ std::string meshfile;
+ std::string ncfile;
+ std::string ebfile;
+ std::string cellname;
+ boost::shared_ptr<MeshPart> mesh;
+
+};
+
+#endif
More information about the CIG-COMMITS
mailing list