Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ogs/tools/vis-tools
1 result
Show changes
Commits on Source (2)
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(VisOgsTools) project(VisOgsTools)
set (CMAKE_CXX_STANDARD 20)
include(${PROJECT_SOURCE_DIR}/cmake/CPM.cmake) include(${PROJECT_SOURCE_DIR}/cmake/CPM.cmake)
...@@ -20,8 +21,8 @@ endif() ...@@ -20,8 +21,8 @@ endif()
CPMAddPackage( CPMAddPackage(
NAME ogs NAME ogs
GIT_REPOSITORY https://gitlab.opengeosys.org/ogs/ogs.git GIT_REPOSITORY https://gitlab.opengeosys.org/ogs/ogs.git
GIT_TAG 204dd9474551a68174966ca15bb91de9948ca937 GIT_TAG 2a2bcbe6673a42a840674eea113a2d19fa18f3b5
VERSION 6.4.0-dev #VERSION 6.4.0-dev
EXCLUDE_FROM_ALL YES EXCLUDE_FROM_ALL YES
OPTIONS "OGS_BUILD_GUI ON" OPTIONS "OGS_BUILD_GUI ON"
) )
......
/** /**
* @file RappbodeTracer.cpp * @file addScalarArrayTimeSeries.cpp
* @author Karsten Rink * @author Karsten Rink
* @date 2015/04/22 * @date 2015/04/22
* @brief Converts an ERT-CSV-file into a mesh * @brief Converts an ERT-CSV-file into a mesh
...@@ -37,33 +37,30 @@ ...@@ -37,33 +37,30 @@
#include "MeshLib/Elements/Element.h" #include "MeshLib/Elements/Element.h"
#include "MeshLib/Elements/Quad.h" #include "MeshLib/Elements/Quad.h"
MeshLib::Mesh *createMesh() MeshLib::Mesh* createMesh()
{ {
std::string const x_file("utm_x.csv"); std::string const x_file("utm_x.csv");
std::string const y_file("utm_y.csv"); std::string const y_file("utm_y.csv");
std::string const z_file("Z.csv"); std::string const z_file("Z.csv");
std::vector<double> x; std::pair<int, std::vector<double>> x = FileIO::CsvInterface::readColumn<double>(x_file, '\t', 0);
int const e1 = FileIO::CsvInterface::readColumn<double>(x_file, '\t', x, 0); std::pair<int, std::vector<double>> y = FileIO::CsvInterface::readColumn<double>(y_file, '\t', 0);
std::vector<double> y; std::pair<int, std::vector<double>> z = FileIO::CsvInterface::readColumn<double>(z_file, '\t', 0);
int const e2 = FileIO::CsvInterface::readColumn<double>(y_file, '\t', y, 0);
std::vector<double> z; if (x.first != 0 || y.first != 0 || z.first != 0)
int const e3 = FileIO::CsvInterface::readColumn<double>(z_file, '\t', z, 0);
if (e1 != 0 || e2 != 0 || e3 != 0)
return nullptr; return nullptr;
if (x.size() != y.size()) if (x.second.size() != y.second.size())
return nullptr; return nullptr;
std::size_t const n_cols(x.size()); std::size_t const n_cols(x.second.size());
std::size_t const n_rows(z.size()); std::size_t const n_rows(z.second.size());
std::vector<MeshLib::Node *> nodes; std::vector<MeshLib::Node*> nodes;
nodes.reserve(n_rows * n_cols); nodes.reserve(n_rows * n_cols);
for (std::size_t r = 0; r < n_rows; ++r) for (std::size_t r = 0; r < n_rows; ++r)
for (std::size_t c = 0; c < n_cols; ++c) for (std::size_t c = 0; c < n_cols; ++c)
nodes.push_back(new MeshLib::Node(x[c], y[c], z[r], nodes.size())); nodes.push_back(new MeshLib::Node(x.second[c], y.second[c], z.second[r], nodes.size()));
std::vector<MeshLib::Element *> elems; std::vector<MeshLib::Element*> elems;
elems.reserve((n_rows - 1) * (n_cols - 1)); elems.reserve((n_rows - 1) * (n_cols - 1));
std::vector<std::size_t> mats; std::vector<std::size_t> mats;
mats.reserve((n_rows - 1) * (n_cols - 1)); mats.reserve((n_rows - 1) * (n_cols - 1));
...@@ -72,7 +69,7 @@ MeshLib::Mesh *createMesh() ...@@ -72,7 +69,7 @@ MeshLib::Mesh *createMesh()
std::size_t base_idx = r * n_cols; std::size_t base_idx = r * n_cols;
for (std::size_t c = 0; c < n_cols - 1; ++c) for (std::size_t c = 0; c < n_cols - 1; ++c)
{ {
std::array<MeshLib::Node *, 4> quad_nodes; std::array<MeshLib::Node*, 4> quad_nodes;
quad_nodes[0] = nodes[base_idx + c]; quad_nodes[0] = nodes[base_idx + c];
quad_nodes[1] = nodes[base_idx + c + n_cols]; quad_nodes[1] = nodes[base_idx + c + n_cols];
quad_nodes[2] = nodes[base_idx + c + n_cols + 1]; quad_nodes[2] = nodes[base_idx + c + n_cols + 1];
...@@ -82,7 +79,7 @@ MeshLib::Mesh *createMesh() ...@@ -82,7 +79,7 @@ MeshLib::Mesh *createMesh()
} }
} }
MeshLib::Mesh *mesh = new MeshLib::Mesh("Mesh", nodes, elems); MeshLib::Mesh* mesh = new MeshLib::Mesh("Mesh", nodes, elems);
auto mat_prop(mesh->getProperties().createNewPropertyVector<int>("MaterialIDs", MeshLib::MeshItemType::Cell)); auto mat_prop(mesh->getProperties().createNewPropertyVector<int>("MaterialIDs", MeshLib::MeshItemType::Cell));
mat_prop->insert(mat_prop->end(), mats.begin(), mats.end()); mat_prop->insert(mat_prop->end(), mats.begin(), mats.end());
...@@ -96,7 +93,7 @@ std::string number2str(std::size_t n) ...@@ -96,7 +93,7 @@ std::string number2str(std::size_t n)
return convert.str(); return convert.str();
} }
std::string output_question(std::string const &output_name) std::string output_question(std::string const& output_name)
{ {
WARN("Output file {:s} already exists. Overwrite? (y/n)", output_name); WARN("Output file {:s} already exists. Overwrite? (y/n)", output_name);
std::string input; std::string input;
...@@ -104,7 +101,7 @@ std::string output_question(std::string const &output_name) ...@@ -104,7 +101,7 @@ std::string output_question(std::string const &output_name)
return input; return input;
} }
bool overwriteFiles(std::string const &output_name) bool overwriteFiles(std::string const& output_name)
{ {
if (!BaseLib::IsFileExisting(output_name)) if (!BaseLib::IsFileExisting(output_name))
return true; return true;
...@@ -118,22 +115,22 @@ bool overwriteFiles(std::string const &output_name) ...@@ -118,22 +115,22 @@ bool overwriteFiles(std::string const &output_name)
return false; return false;
} }
int main(int argc, char *argv[]) int main(int argc, char* argv[])
{ {
TCLAP::CmdLine cmd("Adds a scalar array time series from a csv-file to an existing mesh or a time series of meshes.", ' ', "0.1"); TCLAP::CmdLine cmd("Adds a scalar array time series from a csv-file to an existing mesh or a time series of meshes.", ' ', "0.1");
// I/O params // I/O params
TCLAP::ValueArg<std::string> mesh_new("b", "base", TCLAP::ValueArg<std::string> mesh_new("b", "base",
"Use this if a time series of vtu-files should be created based on a single vtu-file. If a time series *is* already existing, this parameter need not be set.", "Use this if a time series of vtu-files should be created based on a single vtu-file. If a time series *is* already existing, this parameter need not be set.",
false, "", "base mesh input"); false, "", "base mesh input");
cmd.add(mesh_new); cmd.add(mesh_new);
TCLAP::ValueArg<std::string> mesh_add("t", "output", TCLAP::ValueArg<std::string> mesh_add("t", "output",
"This is the base name of the output files, e.g. \'output\' will result in files called \'output0.vtu\', \'output1.vtu\', etc. If a time series is already existing, a new array will simply be added to each time step.", "This is the base name of the output files, e.g. \'output\' will result in files called \'output0.vtu\', \'output1.vtu\', etc. If a time series is already existing, a new array will simply be added to each time step.",
true, "", "name of mesh output"); true, "", "name of mesh output");
cmd.add(mesh_add); cmd.add(mesh_add);
TCLAP::ValueArg<std::string> csv_in("i", "csv", TCLAP::ValueArg<std::string> csv_in("i", "csv",
"CSV-file containing the input information for the scalar arrays. It is assumed that all timesteps are in one file with an empty line between timesteps and with one value per grid cell per time step.", "CSV-file containing the input information for the scalar arrays. It is assumed that all timesteps are in one file with an empty line between timesteps and with one value per grid cell per time step.",
true, "", "csv input file"); true, "", "csv input file");
cmd.add(csv_in); cmd.add(csv_in);
cmd.parse(argc, argv); cmd.parse(argc, argv);
...@@ -152,7 +149,7 @@ int main(int argc, char *argv[]) ...@@ -152,7 +149,7 @@ int main(int argc, char *argv[])
} }
int n_rows = -1; int n_rows = -1;
MeshLib::Mesh *mesh = nullptr; MeshLib::Mesh* mesh = nullptr;
if (mesh_new.isSet()) if (mesh_new.isSet())
{ {
mesh = MeshLib::IO::VtuInterface::readVTUFile(mesh_new.getValue()); mesh = MeshLib::IO::VtuInterface::readVTUFile(mesh_new.getValue());
......