コード例 #1
0
ファイル: NodeReordering.cpp プロジェクト: envinf/ogs
int main (int argc, char* argv[])
{
	LOGOG_INITIALIZE();
	logog::Cout* logogCout = new logog::Cout;
	BaseLib::LogogSimpleFormatter* formatter = new BaseLib::LogogSimpleFormatter;
	logogCout->SetFormatter(*formatter);

	TCLAP::CmdLine cmd("Reordering of mesh nodes to make OGS Data Explorer 5 meshes compatible with OGS6.\n" \
	                   "Method 1 is the re-ordering between DataExplorer 5 and DataExplorer 6 meshes,\n" \
	                   "Method 2 is the re-ordering with and without InSitu-Lib in OGS6.",
	                   ' ', "0.1");
	TCLAP::UnlabeledValueArg<std::string> input_mesh_arg("input_mesh",
	                                                     "the name of the input mesh file",
	                                                     true, "", "oldmesh.msh");
	cmd.add(input_mesh_arg);
	TCLAP::UnlabeledValueArg<std::string> output_mesh_arg("output_mesh",
	                                                      "the name of the output mesh file",
	                                                      true, "", "newmesh.vtu");
	cmd.add(output_mesh_arg);
	TCLAP::ValueArg<int> method_arg("m", "method", "reordering method selection", false,  1, "value");

	cmd.add(method_arg);
	cmd.parse(argc, argv);

	MeshLib::Mesh* mesh (FileIO::readMeshFromFile(input_mesh_arg.getValue().c_str()));

	INFO("Reordering nodes... ");
	if (!method_arg.isSet() || method_arg.getValue() == 1)
		reorderNodes(const_cast<std::vector<MeshLib::Element*>&>(mesh->getElements()));
	else if (method_arg.getValue() == 2)
		reorderNodes2(const_cast<std::vector<MeshLib::Element*>&>(mesh->getElements()));
	else
	{
		ERR ("Unknown re-ordering method. Exit program...");
		return 1;
	}

	FileIO::VtuInterface writer(mesh);
	writer.writeToFile(output_mesh_arg.getValue().c_str());

	INFO("VTU file written.");

	delete formatter;
	delete logogCout;
	LOGOG_SHUTDOWN();

	return 0;
}
コード例 #2
0
ファイル: extrema.cpp プロジェクト: nrmassey/tri_tracker
int main(int argc, char** argv)
{
	std::cout << "#### extrema" << std::endl;

	std::string input_fname;		// input file name from regrid
	std::string output_fname;		// output file name
	std::string mesh_fname;			// file name of grid definition file
	std::string method_string;		// method string format: = method_name(arg1, arg2,arg3)
	std::string steering_string;	// steering vector calculation method.  format as above
	int grid_level;					// level to detect extrema at
	ADJACENCY adjacency_type;		// adjacency type, 0 = POINT | 1 = EDGE
	bool text_out = false;

	try
	{
		TCLAP::CmdLine cmd("Locate extrema from data regridded onto a regional triangular mesh using regrid");
		TCLAP::ValueArg<int> g_level_arg("l", "g_level", "Level of grid to detect extremas at", false, -1, "integer", cmd);
		TCLAP::ValueArg<int> ex_adj_arg("a", "adjacency", "Adjacency type: 0 = point | 1 = edge", false, 0, "integer", cmd);
		TCLAP::ValueArg<std::string> method_arg("e", "method", "Extrema detection method", true, "", "string", cmd);
		TCLAP::ValueArg<std::string> steering_arg("s", "steering", "Steering vector calculation method", false, "", "string", cmd);
		TCLAP::SwitchArg text_out_arg("T", "text", "Output grid in text format, as well as the binary format", cmd, false);		
		TCLAP::ValueArg<std::string> out_fname_arg("o", "output", "Output file name", true, "", "string", cmd);
		TCLAP::ValueArg<std::string> mesh_fname_arg("m", "mesh_file", "Name of file containing mesh generated by gen_grid", true, "", "string", cmd);
		TCLAP::ValueArg<std::string> in_fname_arg("i", "input", "Input file of regridded data as generated by regrid", true, "", "string", cmd);
		cmd.parse(argc, argv);

		grid_level = g_level_arg.getValue();
		output_fname = out_fname_arg.getValue();
		input_fname = in_fname_arg.getValue();
		mesh_fname = mesh_fname_arg.getValue();
		adjacency_type = (ADJACENCY)(ex_adj_arg.getValue());
		method_string = method_arg.getValue();
		steering_string = steering_arg.getValue();
		text_out = text_out_arg.getValue();

	}
	catch (TCLAP::ArgException &e)  // catch exceptions
	{
		std::cerr << "Error: " << e.error() << " for arg " << e.argId() << std::endl;
		return 1;
	}
	catch (char const* m)           // general error message exception
	{
		std::cerr << "Error: " << m << std::endl;
		return 1;
	}
	catch (std::string &s)          // string error message
	{
		std::cerr << "Error: " << s << std::endl;
		return 1;
	}
	// create the extrema locator
	try
	{
		// create an extrema locator
		extrema_locator* el = create_extrema_locator(method_string);
		el->parse_arg_string(method_string);
		el->set_inputs(input_fname, mesh_fname, grid_level, adjacency_type);		
		// create a steering vector if necessary
		steering_vector* sv = create_steering_vector(steering_string);
		if (sv != NULL)
		{
			sv->parse_arg_string(steering_string);
			el->set_steering_vector(sv);
		}
		// do the location - pass in the arguments
		el->locate();
		// save to the output file
		el->save(output_fname, text_out);
		std::cout << "# Saved to file: " << output_fname << std::endl;
		delete el;
	}
	catch(std::string &s)
	{
		std::cerr << s << std::endl;
	}
}