OGS
FileIO Namespace Reference

Namespaces

namespace  GMSH
 
namespace  Gocad
 
namespace  Legacy
 

Classes

class  AsciiRasterInterface
 
class  CsvInterface
 
class  FEFLOWGeoInterface
 
class  FEFLOWMeshInterface
 
class  GMSInterface
 Manages the import and export of Aquaveo GMS files into and out of GeoLib. More...
 
class  PetrelInterface
 
class  SHPInterface
 Manages the import of ESRI shape files into GeoLib. More...
 
class  SwmmInterface
 
class  TetGenInterface
 
class  XmlLutReader
 Reader for vtk-Lookup-Tables (in XML / ParaView Format) More...
 
class  XmlPrjInterface
 

Enumerations

enum class  SwmmObject { SUBCATCHMENT = 0 , NODE = 1 , LINK = 2 , SYSTEM = 3 }
 SWMM object types. More...
 

Functions

bool createSurface (GeoLib::Polyline const &ply, GeoLib::GEOObjects &geometries, std::string const &geometry_name, std::string const &gmsh_binary)
 
std::unique_ptr< GeoLib::SurfacecreateSurfaceWithEarClipping (GeoLib::Polyline const &line)
 
static std::string readLine (std::istream &in)
 
static std::list< std::string > split (std::string const &line)
 
static void printListInfo (const std::list< std::string > &str_list, std::string_view const prefix, std::string_view const message)
 
static double getLastNumberFromList (const std::list< std::string > &str_list)
 
void readGeometryFromFile (std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
 
auto constructPointsFromNodes (std::vector< MeshLib::Node * > nodes)
 
void writeGeometryToFile (std::string const &geo_name, GeoLib::GEOObjects &geo_objs, std::string const &fname)
 
void addTextNode (QDomDocument &doc, QDomElement &parent, QString const &node_name, QString const &content)
 
bool PVarExists (std::string const &name, std::vector< DataHolderLib::ProcessVariable > const &p_vars)
 
static double readDoubleFromStream (std::istream &in)
 Reads a double replacing comma by point.
 
static std::optional< GeoLib::RasterHeaderreadASCHeader (std::ifstream &in)
 
static std::optional< std::tuple< GeoLib::RasterHeader, double, double > > readSurferHeader (std::ifstream &in)
 
std::vector< std::string > readFile (std::istream &in)
 
std::optional< std::array< double, 3 > > readXyzCoordinates (std::string const &line)
 
GeoLib::RasterHeader getXyzHeader (std::vector< std::string > const &lines)
 
static bool allRastersExist (std::vector< std::string > const &raster_paths)
 Checks if all raster files actually exist.
 
std::optional< std::vector< GeoLib::Raster const * > > readRasters (std::vector< std::string > const &raster_paths)
 

Variables

const std::array< std::string, 9 > subcatchment_vars
 Variables that always exist for subcatchments. There might be more.
 
const std::array< std::string, 7 > node_vars
 Variables that always exist for nodes. There might be more.
 
const std::array< std::string, 6 > link_vars
 Variables that always exist for links. There might be more.
 
const std::array< std::string, 15 > system_vars
 All variables that exist for the system.
 
std::array< std::size_t, 4 > const n_obj_params = {8, 6, 5, 15}
 

Enumeration Type Documentation

◆ SwmmObject

enum class FileIO::SwmmObject
strong

SWMM object types.

Enumerator
SUBCATCHMENT 
NODE 
LINK 
SYSTEM 

Definition at line 35 of file SWMMInterface.h.

Function Documentation

◆ addTextNode()

void FileIO::addTextNode ( QDomDocument & doc,
QDomElement & parent,
QString const & node_name,
QString const & content )

Definition at line 426 of file XmlPrjInterface.cpp.

430{
431 QDomElement tag = doc.createElement(node_name);
432 parent.appendChild(tag);
433 QDomText order_text = doc.createTextNode(content);
434 tag.appendChild(order_text);
435}

Referenced by FileIO::XmlPrjInterface::writeCondition(), and FileIO::XmlPrjInterface::writeProcessVariables().

◆ allRastersExist()

static bool FileIO::allRastersExist ( std::vector< std::string > const & raster_paths)
static

Checks if all raster files actually exist.

Definition at line 381 of file AsciiRasterInterface.cpp.

382{
383 return std::all_of(raster_paths.begin(), raster_paths.end(),
384 [](std::string const& raster_path)
385 {
386 if (BaseLib::IsFileExisting(raster_path))
387 {
388 return true;
389 }
390 ERR("Opening raster file {} failed.", raster_path);
391 return false;
392 });
393}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45

References ERR().

Referenced by readRasters().

◆ constructPointsFromNodes()

auto FileIO::constructPointsFromNodes ( std::vector< MeshLib::Node * > nodes)

Definition at line 36 of file TetGenInterface.cpp.

37{
38 std::vector<GeoLib::Point*> points;
39 points.reserve(nodes.size());
40 std::transform(nodes.begin(), nodes.end(), std::back_inserter(points),
41 [](auto const* node)
42 { return new GeoLib::Point(*node, node->getID()); });
43 return points;
44}

Referenced by FileIO::TetGenInterface::readTetGenGeometry().

◆ createSurface()

bool FileIO::createSurface ( GeoLib::Polyline const & ply,
GeoLib::GEOObjects & geometries,
std::string const & geometry_name,
std::string const & gmsh_binary )

Creates a plane surface from the given polyline. The polyline has to be closed, i.e. the first and the last point have to be the identical. The triangulation of the polyline is done by the finite element meshing tool Gmsh. Finally, the resulting mesh is converted into a GeoLib::Surface which is inserted into the GeoLib::GEOObjects instance geometries using the name geometry_name.

Definition at line 33 of file createSurface.cpp.

37{
38 if (!ply.isClosed())
39 {
40 WARN("Error in createSurface() - Polyline is not closed.");
41 return false;
42 }
43
44 if (ply.getNumberOfPoints() <= 2)
45 {
46 WARN(
47 "Error in createSurface() - Polyline consists of less "
48 "than three points and therefore cannot be triangulated.");
49 return false;
50 }
51
52 // create new GEOObjects and insert a copy of the polyline
53 std::vector<GeoLib::Point*> polyline_points;
55 auto ply_points = ply.getPointsVec();
56 std::transform(ply_points.begin(), ply_points.end(),
57 std::back_inserter(polyline_points),
58 [](auto const* p) { return new GeoLib::Point(*p); });
59 std::string ply_name = "temporary_polyline_name";
60 geo.addPointVec(std::move(polyline_points), ply_name,
61 std::map<std::string, std::size_t>{});
62 auto polyline =
63 std::make_unique<GeoLib::Polyline>(*geo.getPointVec(ply_name));
64 for (std::size_t k(0); k < ply.getNumberOfPoints(); ++k)
65 {
66 polyline->addPoint(ply.getPointID(k));
67 }
68 std::vector<GeoLib::Polyline*> polylines;
69 polylines.push_back(polyline.release());
70 geo.addPolylineVec(std::move(polylines), ply_name,
72
73 // use GMSHInterface to create a mesh from the closed polyline
74 auto const geo_names = geo.getGeometryNames();
77 0.0, 0, geo_names, false, false);
78
79 // write to random file in temp directory
80 auto geo_file = std::filesystem::temp_directory_path() /=
82 auto msh_file = std::filesystem::temp_directory_path() /=
84
85 BaseLib::IO::writeStringToFile(gmsh_io.writeToString(), geo_file);
86 // Using GMSH's vtk output here so we don't have to deal with GMSH and it's
87 // various file format versions here
88 std::string gmsh_command = "\"" + gmsh_binary +
89 "\" -2 -algo meshadapt -format vtk -o " +
90 msh_file.string() + " " + geo_file.string();
91
92 int const gmsh_return_value = std::system(gmsh_command.c_str());
93 if (gmsh_return_value != 0)
94 {
95 WARN("Call to '{:s}' returned non-zero value {:d}.", gmsh_command,
96 gmsh_return_value);
97 }
98 auto const* surface_mesh = MeshLib::IO::readMeshFromFile(
99 msh_file.string(), true /* compute_element_neighbors */);
100 if (!surface_mesh)
101 {
102 WARN("The surface mesh could not be created.");
103 return false;
104 }
105 if (!(std::filesystem::remove(geo_file) &&
106 std::filesystem::remove(msh_file)))
107 {
108 WARN("Could not remove temporary files in createSurface.");
109 }
110
111 // convert the surface mesh into a geometric surface
112 if (!MeshToolsLib::convertMeshToGeo(*surface_mesh, geometries,
113 std::numeric_limits<double>::epsilon()))
114 {
115 WARN("The surface mesh could not be converted to a geometry.");
116 return false;
117 }
118 std::string merged_geometry_name("geometry_with_surfaces");
119 geometries.mergeGeometries({geometry_name, surface_mesh->getName()},
120 merged_geometry_name);
121 geometries.removeSurfaceVec(geometry_name);
122 geometries.removePolylineVec(geometry_name);
123 geometries.removePointVec(geometry_name);
124 geometries.removeSurfaceVec(surface_mesh->getName());
125 geometries.removePolylineVec(surface_mesh->getName());
126 geometries.removePointVec(surface_mesh->getName());
127 geometries.renameGeometry(merged_geometry_name, geometry_name);
128
129 return true;
130}
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
Reads and writes GMSH-files to and from OGS data structures.
Container class for geometric objects.
Definition GEOObjects.h:57
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
const std::vector< Point * > * getPointVec(const std::string &name) const
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
void renameGeometry(std::string const &old_name, std::string const &new_name)
bool removePointVec(const std::string &name)
bool removeSurfaceVec(const std::string &name)
int mergeGeometries(std::vector< std::string > const &geo_names, std::string &merged_geo_name)
bool removePolylineVec(const std::string &name)
std::map< std::string, std::size_t > NameIdMap
Definition TemplateVec.h:41
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
Definition Writer.cpp:45
std::string randomString(std::size_t const length)
Returns a random string of the given length containing just a-z,A-Z,0-9.
@ FixedMeshDensity
set the parameter with a fixed value
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double const eps)

References GeoLib::GEOObjects::addPointVec(), GeoLib::GEOObjects::addPolylineVec(), MeshToolsLib::convertMeshToGeo(), FileIO::GMSH::FixedMeshDensity, GeoLib::GEOObjects::getGeometryNames(), GeoLib::Polyline::getNumberOfPoints(), GeoLib::Polyline::getPointID(), GeoLib::Polyline::getPointsVec(), GeoLib::GEOObjects::getPointVec(), GeoLib::Polyline::isClosed(), GeoLib::GEOObjects::mergeGeometries(), BaseLib::randomString(), MeshLib::IO::readMeshFromFile(), GeoLib::GEOObjects::removePointVec(), GeoLib::GEOObjects::removePolylineVec(), GeoLib::GEOObjects::removeSurfaceVec(), GeoLib::GEOObjects::renameGeometry(), WARN(), BaseLib::IO::writeStringToFile(), and BaseLib::IO::Writer::writeToString().

Referenced by FileIO::SHPInterface::readPolygons(), and FileIO::Legacy::readSurfaces().

◆ createSurfaceWithEarClipping()

std::unique_ptr< GeoLib::Surface > FileIO::createSurfaceWithEarClipping ( GeoLib::Polyline const & line)

Creates a plane surface from the given polyline. The polyline has to be closed, i.e. the first and the last point have to be the identical. The triangulation of the polyline is done via a simple ear clipping algorithm.

Definition at line 132 of file createSurface.cpp.

134{
135 if (!line.isClosed())
136 {
137 WARN("Error in Surface::createSurface() - Polyline is not closed.");
138 return nullptr;
139 }
140
141 if (line.getNumberOfPoints() <= 2)
142 {
143 WARN(
144 "Error in Surface::createSurface() - Polyline consists of less "
145 "than three points and therefore cannot be triangulated.");
146 return nullptr;
147 }
148
149 // create empty surface
150 auto sfc = std::make_unique<GeoLib::Surface>(line.getPointsVec());
151 auto polygon = std::make_unique<GeoLib::Polygon>(GeoLib::Polygon(line));
152 std::list<GeoLib::Polygon*> const& list_of_simple_polygons =
153 polygon->computeListOfSimplePolygons();
154
155 for (auto const& simple_polygon : list_of_simple_polygons)
156 {
157 std::list<GeoLib::Triangle> triangles;
158 GeoLib::EarClippingTriangulation(*simple_polygon, triangles);
159
160 // add Triangles to Surface
161 for (auto const& t : triangles)
162 {
163 sfc->addTriangle(t[0], t[1], t[2]);
164 }
165 }
166 if (sfc->getNumberOfTriangles() == 0)
167 {
168 WARN(
169 "Surface::createSurface(): Triangulation does not contain any "
170 "triangles.");
171 return nullptr;
172 }
173 return sfc;
174}

References GeoLib::Polyline::getNumberOfPoints(), GeoLib::Polyline::getPointsVec(), GeoLib::Polyline::isClosed(), and WARN().

Referenced by GEOModels::connectPolylineSegments().

◆ getLastNumberFromList()

static double FileIO::getLastNumberFromList ( const std::list< std::string > & str_list)
static

Definition at line 137 of file PetrelInterface.cpp.

138{
139 return std::stod(*(--str_list.end()));
140}

Referenced by FileIO::PetrelInterface::readPetrelWellTrace().

◆ getXyzHeader()

GeoLib::RasterHeader FileIO::getXyzHeader ( std::vector< std::string > const & lines)

Definition at line 273 of file AsciiRasterInterface.cpp.

274{
275 double x_min = std::numeric_limits<double>::max();
276 double x_max = -std::numeric_limits<double>::max();
277 double y_min = std::numeric_limits<double>::max();
278 double y_max = -std::numeric_limits<double>::max();
279 double cellsize = std::numeric_limits<double>::max();
280 std::optional<std::array<double, 3>> coords;
281
282 std::size_t const n_lines(lines.size());
283 for (std::size_t i = 0; i < n_lines; ++i)
284 {
285 coords = readXyzCoordinates(lines[i]);
286 if (coords == std::nullopt)
287 {
288 MathLib::Point3d org(std::array<double, 3>{{0, 0, 0}});
289 GeoLib::RasterHeader fail = {0, 0, 0, org, 0, 0};
290 return fail;
291 }
292 double const diff = (*coords)[0] - x_min;
293 if (diff > 0)
294 {
295 cellsize = std::min(cellsize, diff);
296 }
297 x_min = std::min((*coords)[0], x_min);
298 x_max = std::max((*coords)[0], x_max);
299 y_min = std::min((*coords)[1], y_min);
300 y_max = std::max((*coords)[1], y_max);
301 }
302
304 header.cell_size = cellsize;
305 header.no_data = -9999;
306 header.n_cols = static_cast<std::size_t>(((x_max - x_min) / cellsize) + 1);
307 header.n_rows = static_cast<std::size_t>(((y_max - y_min) / cellsize) + 1);
308 header.n_depth = 1;
309 header.origin[0] = x_min;
310 header.origin[1] = y_min;
311 return header;
312}
std::optional< std::array< double, 3 > > readXyzCoordinates(std::string const &line)
Contains the relevant information when storing a geoscientific raster data.
Definition Raster.h:28
std::size_t n_depth
Definition Raster.h:31
MathLib::Point3d origin
Definition Raster.h:32
std::size_t n_cols
Definition Raster.h:29
std::size_t n_rows
Definition Raster.h:30

References GeoLib::RasterHeader::cell_size, GeoLib::RasterHeader::n_cols, GeoLib::RasterHeader::n_depth, GeoLib::RasterHeader::n_rows, GeoLib::RasterHeader::no_data, GeoLib::RasterHeader::origin, and readXyzCoordinates().

Referenced by FileIO::AsciiRasterInterface::getRasterFromXyzFile().

◆ printListInfo()

static void FileIO::printListInfo ( const std::list< std::string > & str_list,
std::string_view const prefix,
std::string_view const message )
static

Definition at line 127 of file PetrelInterface.cpp.

130{
131 for (auto const& str : str_list)
132 {
133 INFO("PetrelInterface::{:s}(): {:s}: {:s}.", prefix, message, str);
134 }
135}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35

References INFO().

Referenced by FileIO::PetrelInterface::readPetrelWellTrace(), and FileIO::PetrelInterface::readPetrelWellTraceData().

◆ PVarExists()

bool FileIO::PVarExists ( std::string const & name,
std::vector< DataHolderLib::ProcessVariable > const & p_vars )

Definition at line 437 of file XmlPrjInterface.cpp.

439{
440 return std::any_of(p_vars.begin(), p_vars.end(),
441 [&](auto const& p_var) { return p_var.name == name; });
442}

Referenced by FileIO::XmlPrjInterface::getPrimaryVariableVec().

◆ readASCHeader()

static std::optional< GeoLib::RasterHeader > FileIO::readASCHeader ( std::ifstream & in)
static

Reads the header of a Esri asc-file. If the return value is empty, reading was not successful.

Definition at line 56 of file AsciiRasterInterface.cpp.

57{
59
60 std::string tag;
61 std::string value;
62
63 in >> tag;
64 if (tag == "ncols")
65 {
66 in >> value;
67 header.n_cols = atoi(value.c_str());
68 }
69 else
70 {
71 return {};
72 }
73
74 in >> tag;
75 if (tag == "nrows")
76 {
77 in >> value;
78 header.n_rows = atoi(value.c_str());
79 }
80 else
81 {
82 return {};
83 }
84
85 header.n_depth = 1;
86
87 in >> tag;
88 if (tag == "xllcorner" || tag == "xllcenter")
89 {
90 header.origin[0] = readDoubleFromStream(in);
91 }
92 else
93 {
94 return {};
95 }
96
97 in >> tag;
98 if (tag == "yllcorner" || tag == "yllcenter")
99 {
100 header.origin[1] = readDoubleFromStream(in);
101 }
102 else
103 {
104 return {};
105 }
106 header.origin[2] = 0;
107
108 in >> tag;
109 if (tag == "cellsize")
110 {
111 header.cell_size = readDoubleFromStream(in);
112 }
113 else
114 {
115 return {};
116 }
117
118 in >> tag;
119 if (tag == "NODATA_value" || tag == "nodata_value")
120 {
121 header.no_data = readDoubleFromStream(in);
122 }
123 else
124 {
125 return {};
126 }
127
128 return header;
129}
static double readDoubleFromStream(std::istream &in)
Reads a double replacing comma by point.

References GeoLib::RasterHeader::cell_size, GeoLib::RasterHeader::n_cols, GeoLib::RasterHeader::n_depth, GeoLib::RasterHeader::n_rows, GeoLib::RasterHeader::no_data, GeoLib::RasterHeader::origin, and readDoubleFromStream().

Referenced by FileIO::AsciiRasterInterface::getRasterFromASCFile().

◆ readDoubleFromStream()

static double FileIO::readDoubleFromStream ( std::istream & in)
static

Reads a double replacing comma by point.

Definition at line 46 of file AsciiRasterInterface.cpp.

47{
48 std::string value;
49 in >> value;
50 return std::strtod(BaseLib::replaceString(",", ".", value).c_str(),
51 nullptr);
52}
std::string replaceString(const std::string &searchString, const std::string &replaceString, std::string stringToReplace)

References BaseLib::replaceString().

Referenced by FileIO::AsciiRasterInterface::getRasterFromASCFile(), FileIO::AsciiRasterInterface::getRasterFromSurferFile(), and readASCHeader().

◆ readFile()

std::vector< std::string > FileIO::readFile ( std::istream & in)

Definition at line 247 of file AsciiRasterInterface.cpp.

248{
249 std::vector<std::string> lines;
250 std::string line("");
251 while (std::getline(in, line))
252 {
253 lines.emplace_back(line);
254 }
255 return lines;
256}

Referenced by FileIO::AsciiRasterInterface::getRasterFromXyzFile().

◆ readGeometryFromFile()

void FileIO::readGeometryFromFile ( std::string const & fname,
GeoLib::GEOObjects & geo_objs,
std::string const & gmsh_path )

Definition at line 24 of file readGeometryFromFile.cpp.

27{
28 if (BaseLib::getFileExtension(fname) == ".gml")
29 {
31 xml.readFile(fname);
32 }
33 else
34 {
35 std::vector<std::string> errors;
36 std::string geo_name; // geo_name is output of the reading function
38 fname, geo_objs, geo_name, errors, gmsh_path);
39 }
40
41 if (geo_objs.getGeometryNames().empty())
42 {
44 "GEOObjects has no geometry name after reading the geometry file. "
45 "Something is wrong in the reading function.");
46 }
47}
#define OGS_FATAL(...)
Definition Error.h:26
std::string getFileExtension(const std::string &path)
bool readGLIFileV4(const std::string &fname, GeoLib::GEOObjects &geo, std::string &unique_name, std::vector< std::string > &errors, std::string const &gmsh_path)

References BaseLib::getFileExtension(), GeoLib::GEOObjects::getGeometryNames(), OGS_FATAL, GeoLib::IO::BoostXmlGmlInterface::readFile(), and FileIO::Legacy::readGLIFileV4().

Referenced by main().

◆ readLine()

static std::string FileIO::readLine ( std::istream & in)
static

Definition at line 77 of file PetrelInterface.cpp.

78{
79 std::string line;
80 std::getline(in, line);
81 return line;
82}

Referenced by FileIO::PetrelInterface::readPetrelSurfacePoints(), FileIO::PetrelInterface::readPetrelWellTrace(), and FileIO::PetrelInterface::readPetrelWellTraceData().

◆ readRasters()

std::optional< std::vector< GeoLib::Raster const * > > FileIO::readRasters ( std::vector< std::string > const & raster_paths)

Reads a vector of rasters given by file names. On error nothing is returned, otherwise the returned vector contains pointers to the read rasters.

Definition at line 395 of file AsciiRasterInterface.cpp.

397{
398 if (!allRastersExist(raster_paths))
399 {
400 return std::nullopt;
401 }
402
403 std::vector<GeoLib::Raster const*> rasters;
404 rasters.reserve(raster_paths.size());
405 std::transform(raster_paths.begin(), raster_paths.end(),
406 std::back_inserter(rasters),
407 [](auto const& path)
408 { return FileIO::AsciiRasterInterface::readRaster(path); });
409 return std::make_optional(rasters);
410}
static bool allRastersExist(std::vector< std::string > const &raster_paths)
Checks if all raster files actually exist.

References allRastersExist().

Referenced by MeshLayerEditDialog::createPrismMesh(), MeshLayerEditDialog::createTetMesh(), and main().

◆ readSurferHeader()

static std::optional< std::tuple< GeoLib::RasterHeader, double, double > > FileIO::readSurferHeader ( std::ifstream & in)
static

Reads the header of a Surfer grd-file with minimum and maximum values. If the return value is empty, reading was not successful.

Definition at line 170 of file AsciiRasterInterface.cpp.

171{
172 std::string tag;
173
174 in >> tag;
175
176 if (tag != "DSAA")
177 {
178 ERR("Error in readSurferHeader() - No Surfer file.");
179 return {};
180 }
181
183 in >> header.n_cols >> header.n_rows;
184 double min, max;
185 in >> min >> max;
186 header.origin[0] = min;
187 header.cell_size = (max - min) / static_cast<double>(header.n_cols);
188
189 in >> min >> max;
190 header.origin[1] = min;
191 header.origin[2] = 0;
192
193 if (ceil((max - min) / static_cast<double>(header.n_rows)) ==
194 ceil(header.cell_size))
195 {
196 header.cell_size = ceil(header.cell_size);
197 }
198 else
199 {
200 ERR("Error in readSurferHeader() - Anisotropic cellsize detected.");
201 return {};
202 }
203 header.n_depth = 1;
204 header.no_data = -9999;
205 in >> min >> max;
206
207 return {{header, min, max}};
208}

References GeoLib::RasterHeader::cell_size, ERR(), GeoLib::RasterHeader::n_cols, GeoLib::RasterHeader::n_depth, GeoLib::RasterHeader::n_rows, GeoLib::RasterHeader::no_data, and GeoLib::RasterHeader::origin.

Referenced by FileIO::AsciiRasterInterface::getRasterFromSurferFile().

◆ readXyzCoordinates()

std::optional< std::array< double, 3 > > FileIO::readXyzCoordinates ( std::string const & line)

Definition at line 258 of file AsciiRasterInterface.cpp.

259{
260 std::array<double, 3> coords = {0, 0, 0};
261 if (auto const n = std::sscanf(line.c_str(), "%lf %lf %lf", &coords[0],
262 &coords[1], &coords[2]);
263 n != 3)
264 {
265 ERR("Raster::readXyzCoordinates() - Read {:d} doubles out of 3 "
266 "expected from the following line:\n{:s}",
267 n, line);
268 return std::nullopt;
269 }
270 return coords;
271}
constexpr ranges::views::view_closure coords
Definition Mesh.h:232

References ERR().

Referenced by FileIO::AsciiRasterInterface::getRasterFromXyzFile(), and getXyzHeader().

◆ split()

static std::list< std::string > FileIO::split ( std::string const & line)
static

Definition at line 84 of file PetrelInterface.cpp.

85{
86 return BaseLib::splitString(line, ' ');
87}
std::vector< std::string > splitString(std::string const &str)

References BaseLib::splitString().

Referenced by FileIO::PetrelInterface::readPetrelWellTrace(), and FileIO::PetrelInterface::readPetrelWellTraceData().

◆ writeGeometryToFile()

void FileIO::writeGeometryToFile ( std::string const & geo_name,
GeoLib::GEOObjects & geo_objs,
std::string const & fname )

Write geometry given by the geo_objs object and specified by the name stored in param geo_name either to a gml or a gli file. If the extension given in the fname parameter is "gml" or "GML" a gml file is written. In case the extension is "gli" or "GLI" a gli file is written.

Definition at line 21 of file writeGeometryToFile.cpp.

23{
24 std::string const extension(BaseLib::getFileExtension(fname));
25 if (extension == ".gml" || extension == ".GML")
26 {
28 xml.export_name = geo_name;
29 BaseLib::IO::writeStringToFile(xml.writeToString(), fname);
30 }
31 else if (extension == "gli" || extension == "GLI")
32 {
33 FileIO::Legacy::writeGLIFileV4(fname, geo_name, geo_objs);
34 }
35 else
36 {
37 ERR("Writing of geometry failed, since it was not possible to determine"
38 " the required format from file extension.");
39 }
40}
void writeGLIFileV4(const std::string &fname, const std::string &geo_name, const GeoLib::GEOObjects &geo)

References ERR(), BaseLib::IO::XMLInterface::export_name, BaseLib::getFileExtension(), FileIO::Legacy::writeGLIFileV4(), BaseLib::IO::writeStringToFile(), and BaseLib::IO::Writer::writeToString().

Referenced by main(), and writeBCsAndGeometry().

Variable Documentation

◆ link_vars

const std::array<std::string, 6> FileIO::link_vars
Initial value:
= {"flow rate",
"flow depth",
"flow velocity",
"flow volume",
"fraction conduit/non-conduit",
"concentration of pollutant"}

Variables that always exist for links. There might be more.

Definition at line 57 of file SWMMInterface.cpp.

57 {"flow rate",
58 "flow depth",
59 "flow velocity",
60 "flow volume",
61 "fraction conduit/non-conduit",
62 "concentration of pollutant"};

Referenced by FileIO::SwmmInterface::getArrayName().

◆ n_obj_params

std::array<std::size_t, 4> const FileIO::n_obj_params = {8, 6, 5, 15}

Number of base variables for the four object types (subcatchments/nodes/links/system).

Definition at line 84 of file SWMMInterface.cpp.

84{8, 6, 5, 15};

Referenced by FileIO::SwmmInterface::getArrayAtTimeStep(), FileIO::SwmmInterface::getArrayForObject(), FileIO::SwmmInterface::getArrayName(), and FileIO::SwmmInterface::getNumberOfParameters().

◆ node_vars

const std::array<std::string, 7> FileIO::node_vars
Initial value:
= {"water depth",
"hydraulic head",
"volume of stored water",
"lateral inflow",
"total inflow",
"flow lost to flooding",
"concentration of pollutant"}

Variables that always exist for nodes. There might be more.

Definition at line 48 of file SWMMInterface.cpp.

48 {"water depth",
49 "hydraulic head",
50 "volume of stored water",
51 "lateral inflow",
52 "total inflow",
53 "flow lost to flooding",
54 "concentration of pollutant"};

Referenced by FileIO::SwmmInterface::getArrayName().

◆ subcatchment_vars

const std::array<std::string, 9> FileIO::subcatchment_vars
Initial value:
= {
"rainfall",
"snow depth",
"evaporation loss",
"infiltration losses",
"runoff rate",
"groundwater outflow",
"groundwater head",
"moisture content",
"concentration of pollutant"}

Variables that always exist for subcatchments. There might be more.

Definition at line 36 of file SWMMInterface.cpp.

36 {
37 "rainfall",
38 "snow depth",
39 "evaporation loss",
40 "infiltration losses",
41 "runoff rate",
42 "groundwater outflow",
43 "groundwater head",
44 "moisture content",
45 "concentration of pollutant"};

Referenced by FileIO::SwmmInterface::getArrayName().

◆ system_vars

const std::array<std::string, 15> FileIO::system_vars
Initial value:
= {
"air temperature",
"rainfall",
"snow depth",
"evaporation + infiltration loss",
"runoff flow",
"dry weather inflow",
"groundwater inflow",
"RDII inflow",
"direct inflow",
"total lateral inflow",
"flow lost to flooding",
"flow leaving through outfalls",
"volume of stored water",
"actual evaporation rate",
"potential evaporation rate"}

All variables that exist for the system.

Definition at line 65 of file SWMMInterface.cpp.

65 {
66 "air temperature",
67 "rainfall",
68 "snow depth",
69 "evaporation + infiltration loss",
70 "runoff flow",
71 "dry weather inflow",
72 "groundwater inflow",
73 "RDII inflow",
74 "direct inflow",
75 "total lateral inflow",
76 "flow lost to flooding",
77 "flow leaving through outfalls",
78 "volume of stored water",
79 "actual evaporation rate",
80 "potential evaporation rate"};

Referenced by FileIO::SwmmInterface::getArrayName().